예제 #1
0
파일: MetaFile.php 프로젝트: vectrex/vxphp
 /**
  * creates a metafile instance
  * requires either id or path stored in db
  *
  * @param string $path of metafile
  * @param integer $id of metafile
  */
 private function __construct($path = NULL, $id = NULL, $dbEntry = NULL)
 {
     if (isset($path)) {
         $this->data = $this->getDbEntryByPath($path);
     } else {
         if (isset($id)) {
             $this->data = $this->getDbEntryById($id);
         } else {
             if (isset($dbEntry)) {
                 $this->data = $dbEntry;
             }
         }
     }
     $this->id = $this->data['filesID'];
     $this->filesystemFile = FilesystemFile::getInstance(Application::getInstance()->extendToAbsoluteAssetsPath($this->data['FullPath']));
     $this->metaFolder = MetaFolder::getInstance($this->filesystemFile->getFolder()->getPath());
     // when record features an obscured_filename, the FilesystemFile is bound to this obscured filename, while the metafile always references the non-obscured filename
     $this->isObscured = $this->data['File'] !== $this->filesystemFile->getFilename();
 }
예제 #2
0
 /**
  * returns all FilesystemFile instances in folder
  * when $extension is specified, only files with extension are returned
  *
  * @param $extension
  * @return array of FilesystemFile instances
  */
 public function getFiles($extension = NULL)
 {
     $result = [];
     $glob = $this->path . '*';
     if (!is_null($extension)) {
         $glob .= ".{$extension}";
     }
     foreach (array_filter(glob($glob), 'is_file') as $f) {
         $result[] = FilesystemFile::getInstance($f, $this);
     }
     return $result;
 }