/** * @param bool|\Concrete\Core\Entity\File\StorageLocation\StorageLocation $location */ public function includeOptionsForm($location = false) { $configuration = $this->getConfigurationObject(); if ($location instanceof \Concrete\Core\Entity\File\StorageLocation\StorageLocation) { $configuration = $location->getConfigurationObject(); } \View::element(DIRNAME_FILE_STORAGE_LOCATION_TYPES . '/' . $this->getHandle(), array('type' => $this, 'location' => $location, 'configuration' => $configuration), $this->getPackageHandle()); }
public function setFileStorageLocation(\Concrete\Core\Entity\File\StorageLocation\StorageLocation $newLocation) { $fh = Loader::helper('concrete/file'); $currentLocation = $this->getFileStorageLocationObject(); if ($newLocation->getID() == $currentLocation->getID()) { return false; } $currentFilesystem = $currentLocation->getFileSystemObject(); $newFileSystem = $newLocation->getFileSystemObject(); $list = $this->getVersionList(); try { foreach ($list as $fv) { $contents = $fv->getFileContents(); $newFileSystem->put($fh->prefix($fv->getPrefix(), $fv->getFilename()), $contents); $currentFilesystem->delete($fh->prefix($fv->getPrefix(), $fv->getFilename())); } } catch (\Exception $e) { throw new \Exception($e->getMessage()); } $this->setStorageLocation($newLocation); $this->save(); }
/** * Determine the path for a file version thumbnail based on the storage location * * @param \Concrete\Core\Entity\File\Version $file_version * @param \Concrete\Core\File\Image\Thumbnail\Type\Version $thumbnail * @param \Concrete\Core\Entity\File\StorageLocation\StorageLocation $storage * @param \Concrete\Core\File\StorageLocation\Configuration\ConfigurationInterface $configuration * @return string */ protected function determinePath(Version $file_version, ThumbnailVersion $thumbnail, \Concrete\Core\Entity\File\StorageLocation\StorageLocation $storage, ConfigurationInterface $configuration) { $fss = $storage->getFileSystemObject(); $path = $thumbnail->getFilePath($file_version); if ($fss->has($path)) { if ($configuration instanceof DeferredConfigurationInterface) { return $path; } return $configuration->getPublicURLToFile($path); } return $this->getDefaultPath($file_version, $thumbnail, $storage, $configuration); }