Ejemplo 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;
 }
Ejemplo n.º 2
0
 function generateThumbnail($originalImagePathFromRoot)
 {
     $imageGalleryRelative = $this->getGalleryRelativeURLFromPath($originalImagePathFromRoot);
     $filename = pathinfoFilename($imageGalleryRelative);
     $fileExtension = pathinfoExtension($imageGalleryRelative);
     $directory = pathinfoDirname($imageGalleryRelative);
     if ($directory === ".") {
         $directory = "";
     }
     $directory = normalizePath($directory);
     $targetCachedFileName = $this->photosPathFromRoot . 'cache' . DIRECTORY_SEPARATOR . $directory . $filename . '_' . $this->settings['thumbnail_size'] . '.' . $fileExtension;
     $createCachedFile = $this->fileSystemHelper->generateCacheDirectory($directory);
     //Load the original image
     switch ($fileExtension) {
         case 'jpg':
         case 'jpeg':
             $image = imagecreatefromjpeg($originalImagePathFromRoot);
             $format = "jpeg";
             break;
         case 'png':
             $image = imagecreatefrompng($originalImagePathFromRoot);
             $format = "png";
             break;
     }
     //Resize it
     $width = imagesx($image);
     $height = imagesy($image);
     $new_size = $this->resizedSize($width, $height);
     $newImage = ImageCreateTrueColor($new_size[0], $new_size[1]);
     imagecopyresampled($newImage, $image, 0, 0, 0, 0, $new_size[0], $new_size[1], $width, $height);
     $this->cacheImage($newImage, $targetCachedFileName, $format);
     return true;
 }