コード例 #1
0
 /**
  * Load themes from theme dir
  *
  * @param string $themeDir Dir with themes
  *
  * @return array
  */
 public function loadThemes($themeDir)
 {
     $themes = array();
     if (!is_dir($themeDir)) {
         return $themes;
     }
     $dirs = Finder::findDirectories("*")->in($themeDir);
     foreach ($dirs as $dir) {
         $themes[$dir->getFilename()] = ucfirst($dir->getFilename());
     }
     return $themes;
 }
コード例 #2
0
ファイル: FileManager.php プロジェクト: ixtrum/file-manager
 /**
  * Get directory content
  *
  * @param string $dir   Directory
  * @param string $mask  Mask
  * @param string $order Order
  *
  * @return array
  */
 private function getContent($dir, $mask, $order)
 {
     $path = $this->getAbsolutePath($dir);
     // Default filter mask
     if (empty($mask)) {
         $mask = "*";
     }
     if ($this->system->parameters["cache"] && $mask === "*") {
         $cache = $this->system->caching->getItem(array("content", $path));
         if ($cache) {
             return $cache;
         }
     }
     $content = array();
     foreach (FileSystem\Finder::findDirectories($mask)->in($path)->orderBy($order) as $item) {
         $entity = new Entities\Directory();
         $entity->actualDir = $dir;
         $entity->name = $item->getFilename();
         $entity->path = $dir . "{$entity->name}/";
         if ($dir === FileSystem::getRootname()) {
             $entity->path = "/{$entity->name}/";
         }
         $entity->modified = $item->getMTime();
         $content["directories"][] = $entity;
     }
     foreach (FileSystem\Finder::findFiles($mask)->in($path)->orderBy($order) as $item) {
         $entity = new Entities\File();
         $entity->actualDir = $dir;
         $entity->name = $item->getFilename();
         $entity->modified = $item->getMTime();
         $entity->size = $this->system->filesystem->getSize($item->getPathName());
         $entity->extension = strtolower(pathinfo($item->getFilename(), PATHINFO_EXTENSION));
         $entity->thumb = false;
         if ($this->system->parameters["thumbs"]) {
             $entity->thumb = in_array($entity->extension, $this->system->thumbs->supported);
         }
         $content["files"][] = $entity;
     }
     if ($this->system->parameters["cache"]) {
         $this->system->caching->saveItem(array("content", $path), $content);
     }
     return $content;
 }
コード例 #3
0
ファイル: FileSystem.php プロジェクト: ixtrum/file-manager
 /**
  * Get file/directory size
  *
  * @param string $path Path to file/dir
  *
  * @return string
  */
 public function getSize($path)
 {
     if (is_dir($path)) {
         $size = 0;
         $files = Finder::findFiles("*")->from($path);
         foreach ($files as $file) {
             $size += $this->getSize($file->getPathName());
         }
         return $size;
     }
     $fileSize = new FileSystem\FileSize($path);
     return $fileSize->getSize();
 }
コード例 #4
0
ファイル: Configurator.php プロジェクト: ixtrum/file-manager
 /**
  * Get available languages
  *
  * @todo Get lanugage title too
  *
  * @return array
  */
 private function getLanguages($langDir)
 {
     $langs = array($this->defaults["lang"] => $this->defaults["lang"]);
     foreach (Finder::findFiles("*.json")->in($langDir) as $file) {
         $langs[$file->getBasename(".json")] = $file->getBasename(".json");
     }
     return $langs;
 }
コード例 #5
0
 /**
  * Get info about files
  *
  * @param string  $dir     Dir
  * @param array   $files   Files
  * @param boolean $iterate Iterate? (optional)
  *
  * @return array
  */
 private function getFilesInfo($dir, $files, $iterate = true)
 {
     $path = $this->getAbsolutePath($dir);
     $info = array("size" => 0, "dirCount" => 0, "filesCount" => 0);
     foreach ($files as $file) {
         $filePath = $path . DIRECTORY_SEPARATOR . $file;
         if (!is_dir($filePath)) {
             $info['size'] += $this->system->filesystem->getSize($filePath);
             $info['filesCount']++;
         } elseif ($iterate) {
             $info['dirCount']++;
             $items = Finder::find('*')->from($filePath);
             foreach ($items as $item) {
                 if ($item->isDir()) {
                     $info['dirCount']++;
                 } else {
                     $info['size'] += $this->system->filesystem->getSize($item->getPathName());
                     $info['filesCount']++;
                 }
             }
         }
     }
     return $info;
 }
コード例 #6
0
ファイル: Thumbs.php プロジェクト: ixtrum/file-manager
 /**
  * Delete all thumbs from directory recursively
  *
  * @param string $dir Directory path
  *
  * @throws \Exception
  */
 public function deleteDirThumbs($dir)
 {
     if (!is_dir($dir)) {
         throw new \Exception("Directory '{$dir}' not found!");
     }
     $mask = $this->supported;
     foreach ($mask as $key => $val) {
         $mask[$key] = "*.{$val}";
     }
     $files = Finder::findFiles($mask)->from($dir);
     foreach ($files as $file) {
         $thumbPath = $this->getThumbPath($file->getPathname());
         if (file_exists($thumbPath)) {
             unlink($thumbPath);
         }
     }
 }