Пример #1
0
 /**
  * Get the path for a file version
  *
  * @param Version $file_version
  * @param ThumbnailVersion $thumbnail
  * @return null|string
  */
 public function getPath(Version $file_version, ThumbnailVersion $thumbnail)
 {
     /** @var File $file */
     $file = $file_version->getFile();
     $file_id = $file->getFileID();
     $storage_location = $file->getFileStorageLocationObject();
     $configuration = $storage_location->getConfigurationObject();
     $version_id = $file_version->getFileVersionID();
     $storage_location_id = $storage_location->getID();
     $thumbnail_handle = $thumbnail->getHandle();
     $path = $this->getStoredPath($file_id, $version_id, $storage_location_id, $thumbnail_handle);
     if ($path) {
         if ($configuration instanceof DeferredConfigurationInterface) {
             return $configuration->getPublicURLToFile($path);
         }
         return $path;
     } elseif ($path = $this->determinePath($file_version, $thumbnail, $storage_location, $configuration)) {
         $this->storePath($path, $file_id, $version_id, $storage_location_id, $thumbnail_handle);
         if ($configuration instanceof DeferredConfigurationInterface) {
             return $configuration->getPublicURLToFile($path);
         }
         return $path;
     }
 }
Пример #2
0
 /**
  * When given a thumbnail type versin object and a full path to a file on the server
  * the file is imported into the system as is as the thumbnail.
  * @param ThumbnailTypeVersion $version
  * @param $path
  */
 public function importThumbnail(\Concrete\Core\File\Image\Thumbnail\Type\Version $version, $path)
 {
     $thumbnailPath = $version->getFilePath($this);
     $filesystem = $this->getFile()->getFileStorageLocationObject()->getFileSystemObject();
     if ($filesystem->has($thumbnailPath)) {
         $filesystem->delete($thumbnailPath);
     }
     $filesystem->write($thumbnailPath, file_get_contents($path), array('visibility' => AdapterInterface::VISIBILITY_PUBLIC, 'mimetype' => 'image/jpeg'));
     if ($version->getHandle() == \Config::get('concrete.icons.file_manager_listing.handle')) {
         $this->fvHasListingThumbnail = true;
     }
     if ($version->getHandle() == \Config::get('concrete.icons.file_manager_detail.handle')) {
         $this->fvHasDetailThumbnail = true;
     }
     $this->save();
 }