本文整理汇总了PHP中FabrikWorker::fabrikReadDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikWorker::fabrikReadDirectory方法的具体用法?PHP FabrikWorker::fabrikReadDirectory怎么用?PHP FabrikWorker::fabrikReadDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikWorker
的用法示例。
在下文中一共展示了FabrikWorker::fabrikReadDirectory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fabrikReadDirectory
/**
* Utility function to read the files in a directory
* @param string The file system path
* @param string A filter for the names
* @param boolean Recurse search into sub-directories
* @param boolean True if to prepend the full path to the file name
* @param array folder names not to recurse into
* @param boolean return a list of folders only (true)
* @return array of file/folder names
*/
public function fabrikReadDirectory($path, $filter = '.', $recurse = false, $fullpath = false, $aFolderFilter = array(), $foldersOnly = false)
{
$arr = array();
if (!@is_dir($path)) {
return $arr;
}
$handle = opendir($path);
while ($file = readdir($handle)) {
$dir = JPath::clean($path . '/' . $file);
$isDir = is_dir($dir);
if ($file != "." && $file != "..") {
if (preg_match("/{$filter}/", $file)) {
if ($isDir && $foldersOnly || !$foldersOnly) {
if ($fullpath) {
$arr[] = trim(JPath::clean($path . '/' . $file));
} else {
$arr[] = trim($file);
}
}
}
$goDown = true;
if ($recurse && $isDir) {
foreach ($aFolderFilter as $sFolderFilter) {
if (strstr($dir, $sFolderFilter)) {
$goDown = false;
}
}
if ($goDown) {
$arr2 = FabrikWorker::fabrikReadDirectory($dir, $filter, $recurse, $fullpath, $aFolderFilter, $foldersOnly);
$arrDiff = array_diff($arr, $arr2);
$arr = array_merge($arrDiff);
}
}
}
}
closedir($handle);
asort($arr);
return $arr;
}