/** * Returns the contents of a directory and their exclusion status * @param $root string Start from this folder * @return array Directories and their status */ function getDirectory($root) { // If there's no root directory specified, use the site's root $root = is_null($root) ? JPATH_SITE : $root; // Initialize filter list $this->init(); // Initialize directories array $arDirs = array(); // Get subfolders jpimport('classes.engine.lister.default'); $FS = new JoomlapackListerAbstraction(); $allFilesAndDirs = $FS->getDirContents($root); if (!($allFilesAndDirs === false)) { foreach ($allFilesAndDirs as $fileName) { if (is_dir($fileName)) { $fileName = basename($fileName); if (JoomlapackAbstraction::TranslateWinPath($root) == JoomlapackAbstraction::TranslateWinPath(JPATH_SITE) && ($fileName == "." || $fileName == "..")) { } else { if ($this->_folderFilters == "") { $arDirs[$fileName] = false; } else { $arDirs[$fileName] = in_array(JoomlapackAbstraction::TranslateWinPath($root . DS . $fileName), $this->_folderFilters); } } } // if } // foreach } // if ksort($arDirs); return $arDirs; }
function echoHTML() { jpimport('classes.engine.lister.default'); $lister = new JoomlapackListerAbstraction(); echo "<h2>Default method</h2>"; $data = $lister->getDirContents('/'); $this->do_dump($data); echo "<h2>glob</h2>"; $data = $lister->_getDirContents_glob('/'); $this->do_dump($data); }
/** * Gets the contents of a directory and flags excluded files * * @param string $root The directory to scan * @return array An associative array of associative arrays (use the code, Luke!) */ function getDirectory($root) { // If there's no root directory specified, use the site's root $root = is_null($root) ? JPATH_SITE : $root; $isSiteRoot = JoomlapackAbstraction::TranslateWinPath($root) == JoomlapackAbstraction::TranslateWinPath(JPATH_SITE); // Initialize filter list $this->init(); // Initialize the two arrays to be returned $arDirs = array(); $arFiles = array(); // Get directory's contents jpimport('classes.engine.lister.default'); $FS = new JoomlapackListerAbstraction(); $allFilesAndDirs = $FS->getDirContents($root); if (!($allFilesAndDirs === false)) { foreach ($allFilesAndDirs as $fileName) { //$fileName = basename($fileName); if (is_dir($fileName)) { $fileName = basename($fileName); if ($isSiteRoot && ($fileName == '.' || $fileName == '..') || $fileName == '.') { // Don't include . and .. for site's root, or . for all dirs } else { if ($fileName != '.') { $arDirs[] = $fileName; } } } elseif (is_file($fileName)) { $fileName = basename($fileName); $excluded = is_array($this->_singleFileFilters) ? in_array(JoomlapackAbstraction::TranslateWinPath($root . DS . $fileName), $this->_singleFileFilters) : false; $arFiles[$fileName] = $excluded; } } } sort($arDirs); $ret['folders'] = $arDirs; unset($arDirs); $ret['files'] = $arFiles; unset($arFiles); return $ret; }
/** * Loads all installer definition files * @return array An array of the installer names and packages */ function loadAllDefinitions() { jpimport('classes.engine.lister.default'); $FS = new JoomlapackListerAbstraction(); $defs = array(); $fileList = $FS->getDirContents(JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . "installers" . DS, "*.xml"); foreach ($fileList as $file) { $baseName = basename($file); if ($this->loadDefinition($baseName)) { $newDef['name'] = $this->Name; $newDef['package'] = $this->Package; $newDef['meta'] = $baseName; $defs[] = $newDef; } } return $defs; }
/** * Populates a list of all backup files */ function _getBackupFileList() { jpimport('classes.engine.lister.default'); $configuration =& JoomlapackConfiguration::getInstance(); $FS = new JoomlapackListerAbstraction(); $allFilesAndFolders = array(); foreach ($this->filePatterns as $pattern) { $moreFiles = $FS->getDirContents($configuration->OutputDirectory, '*' . $pattern); $allFilesAndFolders = $this->_selectiveMergeArrays($allFilesAndFolders, $moreFiles); } if ($allFilesAndFolders === false) { $this->backupFiles = array(); } else { $this->backupFiles = array(); foreach ($allFilesAndFolders as $fileName) { if (is_file($fileName)) { $this->backupFiles[] = $fileName; } } } }