コード例 #1
0
 /**
  * Short description of method getVersionedFile
  *
  * @access public
  * @author Cédric Alfonsi, <*****@*****.**>
  * @param  string rowId
  * @param  string columnId
  * @param  string data
  * @return core_kernel_classes_Resource
  */
 public function getVersionedFile($rowId, $columnId, $data = null)
 {
     $returnValue = null;
     if (empty($data)) {
         throw new Exception('data can not be empty');
     }
     if (!empty($data) && common_Utils::isUri($data)) {
         $data = new core_kernel_classes_Resource($data);
     }
     if (!core_kernel_versioning_File::isVersionedFile($data)) {
         throw new Exception('data has to be a valid versioned file uri');
     }
     $returnValue = $data;
     return $returnValue;
 }
コード例 #2
0
ファイル: class.File.php プロジェクト: nagyist/tao-core
 /**
  * Download a resource file content
  * @param {String} uri Uri of the resource file
  */
 public function downloadFile()
 {
     if ($this->hasRequestParameter('uri')) {
         $uri = tao_helpers_Uri::decode($this->getRequestParameter('uri'));
         $resource = new core_kernel_classes_Resource($uri);
         if (core_kernel_versioning_File::isVersionedFile($resource) || core_kernel_file_File::isFile($resource)) {
             $file = new core_kernel_file_File($uri);
             $fileName = $file->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_FILE_FILENAME));
             $content = $file->getFileContent();
             $size = strlen($content);
             $mimeType = tao_helpers_File::getMimeType($file->getAbsolutePath(), true);
             $this->setContentHeader($mimeType);
             header("Content-Length: {$size}");
             header("Content-Disposition: attachment; filename=\"{$fileName}\"");
             header("Expires: 0");
             header("Cache-Control: no-cache, must-revalidate");
             header("Pragma: no-cache");
             print $content;
             return;
         } else {
             throw new Exception('The resource (' . $uri . ') is not a valid file resource');
         }
     }
 }
コード例 #3
0
 /**
  * Deletes the content but does not unreference it
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  core_kernel_classes_Resource item
  * @return boolean
  */
 public function deleteItemContent(core_kernel_classes_Resource $item)
 {
     $returnValue = (bool) false;
     //delete the folder for all languages!
     foreach ($item->getUsedLanguages($this->itemContentProperty) as $lang) {
         $files = $item->getPropertyValuesByLg($this->itemContentProperty, $lang);
         foreach ($files->getIterator() as $file) {
             if ($file instanceof core_kernel_classes_Resource) {
                 $file = new core_kernel_file_File($file);
                 if (core_kernel_versioning_File::isVersionedFile($file)) {
                     $file = new core_kernel_versioning_File($file);
                 }
                 try {
                     $file->delete();
                 } catch (core_kernel_versioning_exception_FileUnversionedException $e) {
                     // file was not versioned after all, ignore in delte
                 }
             }
         }
     }
     $returnValue = true;
     return (bool) $returnValue;
 }