Exemplo n.º 1
0
 function getDirectoryData($pathFromRoot)
 {
     $fileBlacklist = file_get_contents($this->packagePathFromRoot . 'file_blacklist.txt');
     $fileBlacklist = explode(",", $fileBlacklist);
     $folderBlacklist = file_get_contents($this->packagePathFromRoot . 'folder_blacklist.txt');
     $folderBlacklist = explode(",", $folderBlacklist);
     $fileTypes = file_get_contents($this->packagePathFromRoot . 'file_types.txt');
     $fileTypes = explode(",", $fileTypes);
     $output = array();
     $directories = array();
     $files = array();
     if ($dh = opendir($pathFromRoot)) {
         while (($item = readdir($dh)) !== false) {
             if (is_dir($pathFromRoot . $item) && !FileSystemHelper::isInList($item, $folderBlacklist)) {
                 $directories[] = array('path' => normalizePath($pathFromRoot . $item), 'name' => $item, 'description' => FileSystemHelper::getFolderDescription(normalizePath($pathFromRoot . $item)));
                 sort($directories);
             } else {
                 if (is_file($pathFromRoot . $item) && !FileSystemHelper::isInList($item, $fileBlacklist) && FileSystemHelper::isInList(pathinfoExtension($item), $fileTypes)) {
                     $files[] = array('path' => $pathFromRoot . $item, 'name' => $item, 'data' => array('width' => getimagesizeWidth($pathFromRoot . $item), 'height' => getimagesizeHeight($pathFromRoot . $item)), 'description' => FileSystemHelper::getImageDescription($pathFromRoot . $item));
                     sort($files);
                 }
             }
         }
         closedir($dh);
     }
     $output['file'] = $files;
     $output['dir'] = $directories;
     return $output;
 }