Esempio n. 1
0
 /**
  * (non-PHPdoc)
  * @see lib/model/ISyncableFile#generateFilePathArr()
  */
 public function generateFilePathArr($sub_type, $version = null)
 {
     static::validateFileSyncSubType($sub_type);
     if ($sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_DATA) {
         $data = $this->getData();
         if ($this->getType() == entryType::MIX && (!$this->getData() || !strpos($this->getData(), 'xml'))) {
             $data .= ".xml";
         }
         $res = myContentStorage::getGeneralEntityPath("entry/data", $this->getIntId(), $this->getId(), $data, $version);
         //			$res = myContentStorage::getGeneralEntityPath("entry/data", $this->getIntId(), $this->getId(), $this->getData(), $version);
     } elseif ($sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_DATA_EDIT) {
         $res = myContentStorage::getFileNameEdit(myContentStorage::getGeneralEntityPath("entry/data", $this->getIntId(), $this->getId(), $this->getData(), $version));
     } elseif ($sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_THUMB) {
         $res = myContentStorage::getGeneralEntityPath("entry/bigthumbnail", $this->getIntId(), $this->getId(), $this->getThumbnail(), $version);
     } elseif ($sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_ARCHIVE) {
         $res = null;
         $data_path = myContentStorage::getGeneralEntityPath("entry/data", $this->getIntId(), $this->getId(), $this->getData(), $version);
         // assume the suffix is not the same as the one on the data
         $archive_path = dirname(str_replace("content/entry/", "archive/", $data_path)) . "/" . $this->getId();
         if ($this->getArchiveExtension()) {
             $res = $archive_path . "." . $this->getArchiveExtension();
         } else {
             $archive_pattern = $archive_path . ".*";
             $arc_files = glob(myContentStorage::getFSContentRootPath() . $archive_pattern);
             foreach ($arc_files as $full_path_name) {
                 // return the first file found
                 $res = $full_path_name;
                 break;
             }
             if (!$res) {
                 $res = $archive_pattern;
             }
         }
     } elseif ($sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_DOWNLOAD) {
         // in this case the $version  is used as the format
         $basename = kFile::getFileNameNoExtension($this->getData());
         $path = myContentStorage::getGeneralEntityPath("entry/download", $this->getIntId(), $this->getId(), $basename);
         $download_path = $path . ".{$version}";
         $res = $download_path;
     } else {
         $path = "entry/data";
         switch ($sub_type) {
             case self::FILE_SYNC_ENTRY_SUB_TYPE_ISM:
                 $basename = $this->generateBaseFileName(0, $this->getIsmVersion());
                 $basename .= '.ism';
                 break;
             case self::FILE_SYNC_ENTRY_SUB_TYPE_ISMC:
                 $basename = $this->generateBaseFileName(0, $this->getIsmVersion());
                 $basename .= '.ismc';
                 break;
             case self::FILE_SYNC_ENTRY_SUB_TYPE_CONVERSION_LOG:
                 $basename = $this->generateBaseFileName(0, $this->getIsmVersion());
                 $basename .= '.log';
                 break;
         }
         $res = myContentStorage::getGeneralEntityPath($path, $this->getIntId(), $this->getId(), $basename);
     }
     return array(myContentStorage::getFSContentRootPath(), $res);
 }
Esempio n. 2
0
 /**
 	will return the edit file name if exists, else the original one
 */
 public static function getBestFileFlavor($file_name)
 {
     $edit_file_name = myContentStorage::getFileNameEdit($file_name);
     if (file_exists($edit_file_name) && filesize($edit_file_name) > 0) {
         return $edit_file_name;
     }
     return $file_name;
 }