Varien_File_Object Class Reference

Inheritance diagram for Varien_File_Object:

IFactory

List of all members.

Public Member Functions

 __construct ($path)
 getFilesName (&$files)
 getFileName (&$files=null)
 getFilesPaths (&$paths)
 getFilePath (&$path=null)
 useFilter ($useFilter)
 getFilesObj (&$objs)
 getDirsName (&$dirs)
 getDirName ()
 setFilesFilter ($filter)
 addFilter ($filter)
 getExtension ()
 getName ()
 renderFilter ()
 toArray (&$arr)
 toXml (&$xml, $recursionLevel=0, $addOpenTag=true, $rootName='Struct')

Static Public Member Functions

static getExt ($fileName)

Protected Attributes

 $_filename
 $_path
 $_filter
 $_isCorrect = true
 $filtered


Detailed Description

Definition at line 6 of file Object.php.


Constructor & Destructor Documentation

__construct ( path  ) 

Constructor

Parameters:
string $path - path to directory
Returns:
none

Definition at line 19 of file Object.php.

00020     {
00021         parent::__construct($path);
00022         $this->_path=$path;
00023         $this->_filename=basename($path);
00024     }


Member Function Documentation

addFilter ( filter  ) 

set file filter

Parameters:
array $filter - array of filter
Returns:
none

Definition at line 139 of file Object.php.

00140     {
00141         $this->_filter = $filter;
00142     }

getDirName (  ) 

nothing

Parameters:
array &$dirs - array of dirs
Returns:
none

Definition at line 119 of file Object.php.

00120     {
00121         return Varien_Directory_Collection::lastDir($this->_path);
00122     }

getDirsName ( &$  dirs  ) 

nothing

Parameters:
array &$dirs - array of dirs
Returns:
none

Implements IFactory.

Definition at line 109 of file Object.php.

00110     {
00111         return Varien_Directory_Collection::getLastDir($this->_path);
00112     }

static getExt ( fileName  )  [static]

get extension of file

Parameters:
string $fileName - name of file
Returns:
string - extension of file

Definition at line 158 of file Object.php.

00159     {
00160         if($fileName === ''){
00161             $path_parts = pathinfo($this->_filename);
00162         } else {
00163             $path_parts = pathinfo($fileName);
00164         }
00165         if(isset($path_parts["extension"]))
00166             return $path_parts["extension"];
00167         else
00168             return '';          
00169     }

getExtension (  ) 

get extension of file

Returns:
string - extension of file

Definition at line 148 of file Object.php.

00149     {
00150         return self::getExt($this->_filename);
00151     }

getFileName ( &$  files = null  ) 

add file name to array

Parameters:
array &$files - array of files
Returns:
none

Definition at line 41 of file Object.php.

00042     {
00043         if($this->_isCorrect){
00044             if($files===null)
00045                 return $this->_filename;
00046             $files[] = $this->_filename;
00047         }
00048     }

getFilePath ( &$  path = null  ) 

add file path to array

Parameters:
array &$paths - array of paths
Returns:
none

Definition at line 67 of file Object.php.

00068     {
00069         if($this->_isCorrect){
00070             if($path===null)
00071                 return $this->_path;
00072             $paths[] = $this->_path;
00073         }
00074     }

getFilesName ( &$  files  ) 

add file name to array

Parameters:
array &$files - array of files
Returns:
none

Implements IFactory.

Definition at line 31 of file Object.php.

00032     {
00033         $this->getFileName(&$files);
00034     }

getFilesObj ( &$  objs  ) 

add file object to array

Parameters:
array &$objs - array of gile objects
Returns:
none

Implements IFactory.

Definition at line 97 of file Object.php.

00098     {
00099         if($this->_isCorrect){
00100             $objs[] = $this;
00101         }
00102     }

getFilesPaths ( &$  paths  ) 

add file path to array

Parameters:
array &$paths - array of paths
Returns:
none

Implements IFactory.

Definition at line 55 of file Object.php.

00056     {
00057         if($this->_isCorrect){
00058             $paths[] = (string)$this->_path;
00059         }
00060     }

getName (  ) 

get name of file

Returns:
string - name of file

Definition at line 175 of file Object.php.

00176     {
00177         return basename($this->_filename,'.'.$this->getExtension());
00178     }

renderFilter (  ) 

render filters

Returns:
none

Definition at line 184 of file Object.php.

00185     {
00186         #print_r($this->_filter);
00187         if(isset($this->_filter) && count($this->_filter)>0 && $this->filtered==false){
00188             $this->filtered = true;
00189             if(isset($this->_filter['extension'])){
00190                 $filter = $this->_filter['extension'];
00191                 if($filter!=null){
00192                     if(is_array($filter)){
00193                         if(!in_array($this->getExtension(),$filter)){
00194                             $this->_isCorrect = false;
00195                         }
00196                     } else {
00197                         if($this->getExtension()!=$filter){
00198                             $this->_isCorrect = false;
00199                         }
00200                     }
00201                 }
00202             }
00203             if(isset($this->_filter['name'])){
00204                 $filter = $this->_filter['name'];
00205                 if($filter!=null){
00206                     if(is_array($filter)){
00207                         if(!in_array($this->getName(),$filter)){
00208                             $this->_isCorrect = false;
00209                         }
00210                     } else {
00211                         if($this->getName()!=$filter){
00212                             $this->_isCorrect = false;
00213                         }
00214                     }
00215                 }
00216             }
00217             
00218             if(isset($this->_filter['regName'])){
00219                 $filter = $this->_filter['regName'];
00220                 
00221                 if($filter!=null){
00222                     foreach ($filter as $value) {
00223                         if(!preg_match($value,$this->getName())){
00224                             $this->_isCorrect = false;
00225                         }   
00226                     }
00227                     
00228                 }
00229             }
00230         }
00231     }

setFilesFilter ( filter  ) 

set file filter

Parameters:
array $filter - array of filter
Returns:
none

Definition at line 129 of file Object.php.

00130     {
00131         $this->addFilter($filter);
00132     }

toArray ( &$  arr  ) 

add to array file name

Parameters:
array &$arr -export array
Returns:
none

Implements IFactory.

Definition at line 238 of file Object.php.

00239     {
00240         if($this->_isCorrect){
00241             $arr['files_in_dirs'][] = $this->_filename;
00242         }
00243     }

toXml ( &$  xml,
recursionLevel = 0,
addOpenTag = true,
rootName = 'Struct' 
)

add to xml file name

Parameters:
array &$xml -export xml
int $recursionLevel - level of recursion
bool $addOpenTag - nothing
string $rootName - nothing
Returns:
none

Implements IFactory.

Definition at line 253 of file Object.php.

00254     {
00255         if($this->_isCorrect){
00256             $xml .=str_repeat("\t",$recursionLevel+2).'<fileName>'.$this->_filename.'</fileName>'."\n";
00257         }
00258     }

useFilter ( useFilter  ) 

use filter

Parameters:
bool $useFilter - use or not filter
Returns:
none

Implements IFactory.

Definition at line 81 of file Object.php.

00082     {
00083         if($useFilter){
00084             $this->renderFilter();
00085         } else {
00086             $this->_isCorrect = true;
00087             $this->filtered = false;
00088         }
00089         
00090     }


Member Data Documentation

$_filename [protected]

Definition at line 7 of file Object.php.

$_filter [protected]

Definition at line 9 of file Object.php.

$_isCorrect = true [protected]

Definition at line 10 of file Object.php.

$_path [protected]

Definition at line 8 of file Object.php.

$filtered [protected]

Definition at line 11 of file Object.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:25:02 2009 for Magento by  doxygen 1.5.8