Source for file OCSP_DIRECTORY.phpclass

Documentation is available at OCSP_DIRECTORY.phpclass

  1. <?php
  2. /**
  3.   * openCSP class file OCSP_DIRECTORY
  4.   *
  5.   * @project Open CSP-Management
  6.   * @package common
  7.   *
  8.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  9.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.   *
  11.   * @since pk-09.06.2008
  12.   * @version $Id: OCSP_DIRECTORY.phpclass,v 1.4 2008/11/06 08:41:58 pitlinz Exp $
  13.   */
  14.  
  15. // ---------------------------------------------------------
  16. // requirements
  17. // ---------------------------------------------------------
  18.  
  19.     if (!function_exists('pcf_require_class'))
  20.     {
  21.         require_once dirname(__FILE__DIRECTORY_SEPARATOR "pcf.phpinc";
  22.     }
  23.     
  24.     if (!function_exists('pcf_checkDir'))
  25.     {
  26.         require_once dirname(__FILE__DIRECTORY_SEPARATOR "pcf_directory.phpinc";
  27.     }
  28.  
  29. /**
  30.   * openCSP class OCSP_DIRECTORY
  31.   *
  32.   * @project Open CSP-Management
  33.   * @package default
  34.   *
  35.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  36.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  37.   *
  38.   * @since pk-09.06.2008
  39.   * @version $Id: OCSP_DIRECTORY.phpclass,v 1.4 2008/11/06 08:41:58 pitlinz Exp $
  40.   */
  41. {
  42.     /*** class constants  --------------------------------------------- */
  43.  
  44.     /**
  45.      * @constant string CLASS_SRC_FILE
  46.      *
  47.      * @abstract
  48.      */
  49.     const CLASS_SRC_FILE = __FILE__;
  50.     
  51.     /*** class variables  --------------------------------------------- */
  52.     
  53.     /*** class methods ------------------------------------------------ */
  54.     
  55.     /**
  56.      * returns if $aDir is a directory
  57.      *
  58.      * @param string $aDir 
  59.      * @param boolean $allowLink 
  60.      * 
  61.      * @return boolean 
  62.      */
  63.     public static function isDir($aDir,$allowLink=True)
  64.     {
  65.         if (is_dir($aDir))
  66.         {
  67.             return True;
  68.         else if ($allowLink && is_link($aDir&& ($aDir=readlink($aDir))) {
  69.             return self::isDir($aDir,$allowLink);
  70.         else {
  71.             return False;
  72.         }        
  73.     }
  74.     
  75.     /**
  76.      * checks if a dir exits and creats it if $createDir
  77.      *
  78.      * @param string $aDir 
  79.      * @param boolean $createDir 
  80.      * @param octal $rMask 
  81.      * @param boolean $debug 
  82.      * 
  83.      * @return boolean 
  84.      */
  85.     public static function checkDir($aDir,$createDir=False,$rMask=0770,$debug=False)
  86.     {
  87.         return pcf_checkDir($aDir,$createDir,$rMask,$debug);
  88.     }
  89.     
  90.     /**
  91.      * checks if $aDir is a valid dirname fixes chars and /
  92.      * 
  93.      * if $isPath is not set $aDir is searched for $pathSep
  94.      *
  95.      * @param string $aDir 
  96.      * @param char $pathSep 
  97.      * @param int $isPath 
  98.      * @param boolean $debug 
  99.      * 
  100.      * @return string 
  101.      * 
  102.      */
  103.     public static function checkDirName($aDir,$pathSep=_OCSP_DIRSEP_,$isPath=-1,$debug=False)    
  104.     {
  105.         if ($debugechoDebugMethod(__FILE__,"static","OCSP_DIRECTORY::checkDirName");
  106.         
  107.         $str_dir trim($aDir);
  108.         if ($isPath == -1)
  109.         {
  110.             $bol_isPath (strstr($str_dir,$pathSepTrue :  False);
  111.         else {
  112.             $bol_isPath (intval($isPathTrue False);
  113.         }
  114.  
  115.         if ($bol_isPath)
  116.         {
  117.             $str_ret ((substr($str_dir,0,1)==$pathSep$pathSep "");
  118.             if ($arr_path explode($pathSep,$str_dir))
  119.             {
  120.                 foreach($arr_path as $str_dirName)
  121.                 {
  122.                     if (!empty($str_dirName))
  123.                     {
  124.                         $str_ret .= self::checkDirName($str_dirName,$pathSep,0,$debug$pathSep
  125.                     }
  126.                 }
  127.                 return $str_ret;
  128.             }
  129.             return False;
  130.         else {
  131.             
  132.             $str_dir str_replace("Ä","Ae",$str_dir);
  133.             $str_dir str_replace("ä","ae",$str_dir);
  134.             $str_dir str_replace("Ö","Oe",$str_dir);
  135.             $str_dir str_replace("ö","oe",$str_dir);
  136.             $str_dir str_replace("Ü","Ue",$str_dir);
  137.             $str_dir str_replace("ü","ue",$str_dir);
  138.             $str_dir str_replace("ß","ss",$str_dir);
  139.             $str_dir str_replace("€","EURO",$str_dir);
  140.         
  141.             return preg_replace('/[^a-z0-9_\-\.]/i''_'$str_dir);            
  142.         }
  143.         
  144.         
  145.     }
  146.     
  147.     /**
  148.       * returns an array with files of a specified type in a directory
  149.         *
  150.       * possible types:
  151.       * - F   = FILE
  152.       * - D   = DIRECTORY
  153.       * . !D  = WITHOUT DIRECTORIES (pk-04-08-18)
  154.       * - L   = LINK
  155.       * - A   = ALL
  156.       *
  157.       * Combination of types are also allowed
  158.       * FL returns files and links
  159.       *
  160.       * @param string $dirName (the directory)
  161.       * @param string $type (file type(s))
  162.       * @param boolean $debug 
  163.       * @param array $blackList 
  164.       *
  165.       * @return array 
  166.       */
  167.     public static function getDirList($dirName,$type="F",$debug=FALSE,$blackList=array())
  168.     {
  169.         return pcf_getDirList($dirName,$type,$debug,$blackList);        
  170.     }
  171.     
  172.     
  173.     
  174.     /*** compostion --------------------------------------------------- */
  175.     
  176.     /*** attributes  -------------------------------------------------- */
  177.     
  178.     /*** factory / construct  ----------------------------------------- */
  179.     
  180.     /*** getter / setter ---------------------------------------------- */
  181.     
  182.     
  183. }
  184.  
  185. ?>

Documentation generated on Thu, 08 Jan 2009 17:45:36 +0100 by phpDocumentor 1.4.0a2