Static Public Attributes | |
static | $allowDirs = '/^[a-z0-9\.\-]+$/i' |
static | $allowFiles = '/^[a-z0-9\.\-\_]+\.(xml|ser)$/i' |
static | $disallowFiles = '/^package\.xml$/i' |
Protected Member Functions | |
_fetchPackages () | |
_collectRecursive ($dir, &$result, $dirsFirst=true) |
Definition at line 31 of file Collection.php.
_collectRecursive | ( | $ | dir, | |
&$ | result, | |||
$ | dirsFirst = true | |||
) | [protected] |
Get package files from directory recursively
string | $dir | |
array | &$result | |
bool | $dirsFirst |
Definition at line 65 of file Collection.php.
00066 { 00067 $_result = glob($dir . DS . '*'); 00068 00069 if (!is_array($_result)) { 00070 return; 00071 } 00072 00073 if (!$dirsFirst) { 00074 // collect all the stuff recursively 00075 foreach ($_result as $item) { 00076 if (is_dir($item) && preg_match(self::$allowDirs, basename($item))) { 00077 $this->_collectRecursive($item, $result, $dirsFirst); 00078 } 00079 elseif (is_file($item) 00080 && preg_match(self::$allowFiles, basename($item)) 00081 && !preg_match(self::$disallowFiles, basename($item))) { 00082 $result[] = $item; 00083 } 00084 } 00085 } 00086 else { 00087 // collect directories first 00088 $dirs = array(); 00089 $files = array(); 00090 foreach ($_result as $item) { 00091 if (is_dir($item) && preg_match(self::$allowDirs, basename($item))) { 00092 $dirs[] = $item; 00093 } 00094 elseif (is_file($item) 00095 && preg_match(self::$allowFiles, basename($item)) 00096 && !preg_match(self::$disallowFiles, basename($item))) { 00097 $files[] = $item; 00098 } 00099 } 00100 // search directories recursively 00101 foreach ($dirs as $item) { 00102 $this->_collectRecursive($item, $result, $dirsFirst); 00103 } 00104 // add files 00105 foreach ($files as $item) { 00106 $result[] = $item; 00107 } 00108 } 00109 }
_fetchPackages | ( | ) | [protected] |
Get all packages identifiers
Reimplemented from Mage_Adminhtml_Model_Extension_Collection_Abstract.
Definition at line 42 of file Collection.php.
00043 { 00044 $baseDir = Mage::getBaseDir('var') . DS . 'pear'; 00045 $files = array(); 00046 $this->_collectRecursive($baseDir, $files); 00047 $result = array(); 00048 foreach ($files as $file) { 00049 $file = preg_replace(array('/^' . preg_quote($baseDir . DS, '/') . '/', '/\.(xml|ser)$/'), '', $file); 00050 $result[] = array( 00051 'filename' => $file, 00052 'filename_id' => $file 00053 ); 00054 } 00055 return $result; 00056 }
$allowDirs = '/^[a-z0-9\.\-]+$/i' [static] |
Definition at line 33 of file Collection.php.
$allowFiles = '/^[a-z0-9\.\-\_]+\.(xml|ser)$/i' [static] |
Definition at line 34 of file Collection.php.
$disallowFiles = '/^package\.xml$/i' [static] |
Definition at line 35 of file Collection.php.