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;
 }
Exemplo n.º 2
0
 private function loadVars()
 {
     //Directories
     $dir = array();
     $this->vars['current_directory'] = '';
     //We listen to query strings to deduce the folder the user is going for
     // forinstance: nickwalker.us/photos?hello  would mean they want to look into the folder /photos/hello
     $this->vars['current_directory'] = normalizePath($_SERVER['QUERY_STRING']);
     $this->vars['gallery_url'] = dirname($_SERVER['REQUEST_URI']);
     $this->vars['current_folder_name'] = $this->getDirectoryName($this->vars['current_directory']);
     $this->vars['description'] = FileSystemHelper::getFolderDescription($this->photosPathFromRoot . $this->vars['current_directory']);
     // Populates $this->vars['file_list'] and $this->vars['folder_list']
     $this->loadDirectoryInformation($this->photosPathFromRoot . $this->vars['current_directory']);
     //var_dump($this->vars);
 }