@@ -19,38 +19,38 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class FilePickerMenuItem extends AbstractComponentView |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * Renders a "file picker" menu item to be placed in the grid menu of Media. |
|
| 24 | - * |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function render() |
|
| 28 | - { |
|
| 29 | - $result = ''; |
|
| 30 | - if ($this->getModuleLoader()->hasPlugin('filePicker')) { |
|
| 31 | - $result = sprintf( |
|
| 32 | - '<li><a href="%s" class="mass-file-picker" data-argument="assets">%s Insert files</a>', |
|
| 33 | - $this->getMassDeleteUri(), |
|
| 34 | - $this->getIconFactory()->getIcon('extensions-media-image-export', Icon::SIZE_SMALL) |
|
| 35 | - ); |
|
| 36 | - } |
|
| 37 | - return $result; |
|
| 38 | - } |
|
| 22 | + /** |
|
| 23 | + * Renders a "file picker" menu item to be placed in the grid menu of Media. |
|
| 24 | + * |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function render() |
|
| 28 | + { |
|
| 29 | + $result = ''; |
|
| 30 | + if ($this->getModuleLoader()->hasPlugin('filePicker')) { |
|
| 31 | + $result = sprintf( |
|
| 32 | + '<li><a href="%s" class="mass-file-picker" data-argument="assets">%s Insert files</a>', |
|
| 33 | + $this->getMassDeleteUri(), |
|
| 34 | + $this->getIconFactory()->getIcon('extensions-media-image-export', Icon::SIZE_SMALL) |
|
| 35 | + ); |
|
| 36 | + } |
|
| 37 | + return $result; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Render a mass delete URI. |
|
| 42 | - * |
|
| 43 | - * @return string |
|
| 44 | - */ |
|
| 45 | - protected function getMassDeleteUri() |
|
| 46 | - { |
|
| 47 | - $urlParameters = array( |
|
| 48 | - MediaModule::getParameterPrefix() => array( |
|
| 49 | - 'controller' => 'Asset', |
|
| 50 | - 'action' => '', |
|
| 51 | - 'format' => 'json', |
|
| 52 | - ), |
|
| 53 | - ); |
|
| 54 | - return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
| 55 | - } |
|
| 40 | + /** |
|
| 41 | + * Render a mass delete URI. |
|
| 42 | + * |
|
| 43 | + * @return string |
|
| 44 | + */ |
|
| 45 | + protected function getMassDeleteUri() |
|
| 46 | + { |
|
| 47 | + $urlParameters = array( |
|
| 48 | + MediaModule::getParameterPrefix() => array( |
|
| 49 | + 'controller' => 'Asset', |
|
| 50 | + 'action' => '', |
|
| 51 | + 'format' => 'json', |
|
| 52 | + ), |
|
| 53 | + ); |
|
| 54 | + return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -20,42 +20,42 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class ProcessedFileController extends ActionController |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * Initializes the controller before invoking an action method. |
|
| 25 | - */ |
|
| 26 | - public function initializeAction() |
|
| 27 | - { |
|
| 28 | - // Configure property mapping to retrieve the file object. |
|
| 29 | - if ($this->arguments->hasArgument('file')) { |
|
| 30 | - /** @var FileConverter $typeConverter */ |
|
| 31 | - $typeConverter = GeneralUtility::makeInstance(FileConverter::class); |
|
| 23 | + /** |
|
| 24 | + * Initializes the controller before invoking an action method. |
|
| 25 | + */ |
|
| 26 | + public function initializeAction() |
|
| 27 | + { |
|
| 28 | + // Configure property mapping to retrieve the file object. |
|
| 29 | + if ($this->arguments->hasArgument('file')) { |
|
| 30 | + /** @var FileConverter $typeConverter */ |
|
| 31 | + $typeConverter = GeneralUtility::makeInstance(FileConverter::class); |
|
| 32 | 32 | |
| 33 | - $propertyMappingConfiguration = $this->arguments->getArgument('file')->getPropertyMappingConfiguration(); |
|
| 34 | - $propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
| 35 | - } |
|
| 36 | - } |
|
| 33 | + $propertyMappingConfiguration = $this->arguments->getArgument('file')->getPropertyMappingConfiguration(); |
|
| 34 | + $propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Create a processed file according to some configuration. |
|
| 40 | - * |
|
| 41 | - * @param File $file |
|
| 42 | - * @param array $processingConfiguration |
|
| 43 | - * @return string |
|
| 44 | - */ |
|
| 45 | - public function createAction(File $file, array $processingConfiguration = []): ResponseInterface |
|
| 46 | - { |
|
| 47 | - $processedFile = $file->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $processingConfiguration); |
|
| 38 | + /** |
|
| 39 | + * Create a processed file according to some configuration. |
|
| 40 | + * |
|
| 41 | + * @param File $file |
|
| 42 | + * @param array $processingConfiguration |
|
| 43 | + * @return string |
|
| 44 | + */ |
|
| 45 | + public function createAction(File $file, array $processingConfiguration = []): ResponseInterface |
|
| 46 | + { |
|
| 47 | + $processedFile = $file->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $processingConfiguration); |
|
| 48 | 48 | |
| 49 | - $response = array( |
|
| 50 | - 'success' => true, |
|
| 51 | - 'original' => $file->getUid(), |
|
| 52 | - 'title' => $file->getProperty('title') ? $file->getProperty('title') : $file->getName(), |
|
| 53 | - 'publicUrl' => $processedFile->getPublicUrl(), |
|
| 54 | - 'width' => $processedFile->getProperty('width'), |
|
| 55 | - 'height' => $processedFile->getProperty('height'), |
|
| 56 | - ); |
|
| 49 | + $response = array( |
|
| 50 | + 'success' => true, |
|
| 51 | + 'original' => $file->getUid(), |
|
| 52 | + 'title' => $file->getProperty('title') ? $file->getProperty('title') : $file->getName(), |
|
| 53 | + 'publicUrl' => $processedFile->getPublicUrl(), |
|
| 54 | + 'width' => $processedFile->getProperty('width'), |
|
| 55 | + 'height' => $processedFile->getProperty('height'), |
|
| 56 | + ); |
|
| 57 | 57 | |
| 58 | - header("Content-Type: text/json"); |
|
| 59 | - return $this->htmlResponse(htmlspecialchars(json_encode($response), ENT_NOQUOTES)); |
|
| 60 | - } |
|
| 58 | + header("Content-Type: text/json"); |
|
| 59 | + return $this->htmlResponse(htmlspecialchars(json_encode($response), ENT_NOQUOTES)); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -22,36 +22,36 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class ImageEditorController extends ActionController |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * Initializes the controller before invoking an action method. |
|
| 27 | - */ |
|
| 28 | - public function initializeAction() |
|
| 29 | - { |
|
| 30 | - /** @var PageRenderer $pageRenderer */ |
|
| 31 | - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
| 32 | - $pageRenderer->addInlineLanguageLabelFile('EXT:media/Resources/Private/Language/locallang.xlf'); |
|
| 25 | + /** |
|
| 26 | + * Initializes the controller before invoking an action method. |
|
| 27 | + */ |
|
| 28 | + public function initializeAction() |
|
| 29 | + { |
|
| 30 | + /** @var PageRenderer $pageRenderer */ |
|
| 31 | + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
| 32 | + $pageRenderer->addInlineLanguageLabelFile('EXT:media/Resources/Private/Language/locallang.xlf'); |
|
| 33 | 33 | |
| 34 | - // Configure property mapping to retrieve the file object. |
|
| 35 | - if ($this->arguments->hasArgument('file')) { |
|
| 36 | - /** @var FileConverter $typeConverter */ |
|
| 37 | - $typeConverter = GeneralUtility::makeInstance(FileConverter::class); |
|
| 34 | + // Configure property mapping to retrieve the file object. |
|
| 35 | + if ($this->arguments->hasArgument('file')) { |
|
| 36 | + /** @var FileConverter $typeConverter */ |
|
| 37 | + $typeConverter = GeneralUtility::makeInstance(FileConverter::class); |
|
| 38 | 38 | |
| 39 | - $propertyMappingConfiguration = $this->arguments->getArgument('file')->getPropertyMappingConfiguration(); |
|
| 40 | - $propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
| 41 | - } |
|
| 42 | - } |
|
| 39 | + $propertyMappingConfiguration = $this->arguments->getArgument('file')->getPropertyMappingConfiguration(); |
|
| 40 | + $propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Handle GUI for inserting an image in the RTE. |
|
| 46 | - * |
|
| 47 | - * @param File $file |
|
| 48 | - * @return void |
|
| 49 | - */ |
|
| 50 | - public function showAction(File $file): ResponseInterface |
|
| 51 | - { |
|
| 52 | - $this->view->assign('file', $file); |
|
| 53 | - $moduleSignature = MediaModule::getSignature(); |
|
| 54 | - $this->view->assign('moduleUrl', BackendUtility::getModuleUrl($moduleSignature)); |
|
| 55 | - return $this->htmlResponse(); |
|
| 56 | - } |
|
| 44 | + /** |
|
| 45 | + * Handle GUI for inserting an image in the RTE. |
|
| 46 | + * |
|
| 47 | + * @param File $file |
|
| 48 | + * @return void |
|
| 49 | + */ |
|
| 50 | + public function showAction(File $file): ResponseInterface |
|
| 51 | + { |
|
| 52 | + $this->view->assign('file', $file); |
|
| 53 | + $moduleSignature = MediaModule::getSignature(); |
|
| 54 | + $this->view->assign('moduleUrl', BackendUtility::getModuleUrl($moduleSignature)); |
|
| 55 | + return $this->htmlResponse(); |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -19,30 +19,30 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class LinkCreatorController extends ActionController |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * Initializes the controller before invoking an action method. |
|
| 24 | - */ |
|
| 25 | - public function initializeAction() |
|
| 26 | - { |
|
| 27 | - // Configure property mapping to retrieve the file object. |
|
| 28 | - if ($this->arguments->hasArgument('file')) { |
|
| 29 | - /** @var FileConverter $typeConverter */ |
|
| 30 | - $typeConverter = GeneralUtility::makeInstance(FileConverter::class); |
|
| 22 | + /** |
|
| 23 | + * Initializes the controller before invoking an action method. |
|
| 24 | + */ |
|
| 25 | + public function initializeAction() |
|
| 26 | + { |
|
| 27 | + // Configure property mapping to retrieve the file object. |
|
| 28 | + if ($this->arguments->hasArgument('file')) { |
|
| 29 | + /** @var FileConverter $typeConverter */ |
|
| 30 | + $typeConverter = GeneralUtility::makeInstance(FileConverter::class); |
|
| 31 | 31 | |
| 32 | - $propertyMappingConfiguration = $this->arguments->getArgument('file')->getPropertyMappingConfiguration(); |
|
| 33 | - $propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
| 34 | - } |
|
| 35 | - } |
|
| 32 | + $propertyMappingConfiguration = $this->arguments->getArgument('file')->getPropertyMappingConfiguration(); |
|
| 33 | + $propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Handle GUI for creating a link in the RTE. |
|
| 39 | - * |
|
| 40 | - * @param File $file |
|
| 41 | - * @return void |
|
| 42 | - */ |
|
| 43 | - public function showAction(File $file): ResponseInterface |
|
| 44 | - { |
|
| 45 | - $this->view->assign('file', $file); |
|
| 46 | - return $this->htmlResponse(); |
|
| 47 | - } |
|
| 37 | + /** |
|
| 38 | + * Handle GUI for creating a link in the RTE. |
|
| 39 | + * |
|
| 40 | + * @param File $file |
|
| 41 | + * @return void |
|
| 42 | + */ |
|
| 43 | + public function showAction(File $file): ResponseInterface |
|
| 44 | + { |
|
| 45 | + $this->view->assign('file', $file); |
|
| 46 | + return $this->htmlResponse(); |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -27,327 +27,327 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class MediaModule implements SingletonInterface |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * @var string |
|
| 32 | - */ |
|
| 33 | - public const SIGNATURE = 'user_MediaM1'; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - public const PARAMETER_PREFIX = 'tx_media_user_mediam1'; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var ResourceStorage |
|
| 42 | - */ |
|
| 43 | - protected $currentStorage; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @return string |
|
| 47 | - */ |
|
| 48 | - public static function getSignature() |
|
| 49 | - { |
|
| 50 | - return self::SIGNATURE; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @return string |
|
| 55 | - */ |
|
| 56 | - public static function getParameterPrefix() |
|
| 57 | - { |
|
| 58 | - return self::PARAMETER_PREFIX; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Return all storage allowed for the Backend User. |
|
| 63 | - * |
|
| 64 | - * @throws \RuntimeException |
|
| 65 | - * @return ResourceStorage[] |
|
| 66 | - */ |
|
| 67 | - public function getAllowedStorages() |
|
| 68 | - { |
|
| 69 | - $storages = $this->getBackendUser()->getFileStorages(); |
|
| 70 | - if (empty($storages)) { |
|
| 71 | - throw new \RuntimeException('No storage is accessible for the current BE User. Forgotten to define a mount point for this BE User?', 1380801970); |
|
| 72 | - } |
|
| 73 | - return $storages; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Returns the current file storage in use. |
|
| 78 | - * |
|
| 79 | - * @return ResourceStorage |
|
| 80 | - */ |
|
| 81 | - public function getCurrentStorage() |
|
| 82 | - { |
|
| 83 | - if (is_null($this->currentStorage)) { |
|
| 84 | - $storageIdentifier = $this->getStorageIdentifierFromSessionOrArguments(); |
|
| 85 | - |
|
| 86 | - if ($storageIdentifier > 0) { |
|
| 87 | - $currentStorage = $this->getResourceFactory()->getStorageObject($storageIdentifier); |
|
| 88 | - } else { |
|
| 89 | - // We differentiate the cases whether the User is admin or not. |
|
| 90 | - if ($this->getBackendUser()->isAdmin()) { |
|
| 91 | - $currentStorage = $this->getResourceFactory()->getDefaultStorage(); |
|
| 92 | - |
|
| 93 | - // Not default storage has been flagged in "sys_file_storage". |
|
| 94 | - // Fallback approach: take the first storage as the current. |
|
| 95 | - if (!$currentStorage) { |
|
| 96 | - /** @var $storageRepository StorageRepository */ |
|
| 97 | - $storageRepository = GeneralUtility::makeInstance(StorageRepository::class); |
|
| 98 | - |
|
| 99 | - $storages = $storageRepository->findAll(); |
|
| 100 | - $currentStorage = current($storages); |
|
| 101 | - } |
|
| 102 | - } else { |
|
| 103 | - $fileMounts = $this->getBackendUser()->getFileMountRecords(); |
|
| 104 | - $firstFileMount = current($fileMounts); |
|
| 105 | - $currentStorage = $this->getResourceFactory()->getStorageObject($firstFileMount['base']); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - $this->currentStorage = $currentStorage; |
|
| 110 | - } |
|
| 111 | - return $this->currentStorage; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Retrieve a possible storage identifier from the session or from the arguments. |
|
| 116 | - * |
|
| 117 | - * @return int |
|
| 118 | - */ |
|
| 119 | - protected function getStorageIdentifierFromSessionOrArguments() |
|
| 120 | - { |
|
| 121 | - // Default value |
|
| 122 | - $storageIdentifier = 0; |
|
| 123 | - |
|
| 124 | - // Get last selected storage from User settings |
|
| 125 | - if (SessionUtility::getInstance()->get('lastSelectedStorage') > 0) { |
|
| 126 | - $storageIdentifier = SessionUtility::getInstance()->get('lastSelectedStorage'); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - $argumentPrefix = $this->getModuleLoader()->getParameterPrefix(); |
|
| 130 | - $arguments = GeneralUtility::_GET($argumentPrefix); |
|
| 131 | - |
|
| 132 | - // Override selected storage from the session if GET argument "storage" is detected. |
|
| 133 | - if (!empty($arguments['storage']) && (int)$arguments['storage'] > 0) { |
|
| 134 | - $storageIdentifier = (int)$arguments['storage']; |
|
| 135 | - |
|
| 136 | - // Save state |
|
| 137 | - SessionUtility::getInstance()->set('lastSelectedStorage', $storageIdentifier); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - return (int)$storageIdentifier; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Return the combined parameter from the URL. |
|
| 145 | - * |
|
| 146 | - * @return string |
|
| 147 | - */ |
|
| 148 | - public function getCombinedIdentifier() |
|
| 149 | - { |
|
| 150 | - // Fetch possible combined identifier. |
|
| 151 | - $combinedIdentifier = GeneralUtility::_GET('id'); |
|
| 152 | - |
|
| 153 | - if ($combinedIdentifier) { |
|
| 154 | - // Fix a bug at the Core level: the "id" parameter is encoded again when translating file. |
|
| 155 | - // Add a loop to decode maximum 999 time! |
|
| 156 | - $semaphore = 0; |
|
| 157 | - $semaphoreLimit = 999; |
|
| 158 | - while (!$this->isWellDecoded($combinedIdentifier) && $semaphore < $semaphoreLimit) { |
|
| 159 | - $combinedIdentifier = urldecode($combinedIdentifier); |
|
| 160 | - $semaphore++; |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - return $combinedIdentifier; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * @param $combinedIdentifier |
|
| 169 | - * @return bool |
|
| 170 | - */ |
|
| 171 | - protected function isWellDecoded($combinedIdentifier) |
|
| 172 | - { |
|
| 173 | - return preg_match('/.*:.*/', $combinedIdentifier); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * @return Folder |
|
| 178 | - */ |
|
| 179 | - public function getFirstAvailableFolder() |
|
| 180 | - { |
|
| 181 | - // Take the first object of the first storage. |
|
| 182 | - $storages = $this->getBackendUser()->getFileStorages(); |
|
| 183 | - $storage = reset($storages); |
|
| 184 | - if ($storage) { |
|
| 185 | - $folder = $storage->getRootLevelFolder(); |
|
| 186 | - } else { |
|
| 187 | - throw new \RuntimeException('Could not find any folder to be displayed.', 1444665954); |
|
| 188 | - } |
|
| 189 | - return $folder; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * @return Folder |
|
| 194 | - */ |
|
| 195 | - public function getCurrentFolder() |
|
| 196 | - { |
|
| 197 | - $combinedIdentifier = $this->getCombinedIdentifier(); |
|
| 198 | - |
|
| 199 | - if ($combinedIdentifier) { |
|
| 200 | - $folder = $this->getFolderForCombinedIdentifier($combinedIdentifier); |
|
| 201 | - } else { |
|
| 202 | - $folder = $this->getFirstAvailableFolder(); |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - return $folder; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * @param string $combinedIdentifier |
|
| 210 | - * @return Folder |
|
| 211 | - */ |
|
| 212 | - public function getFolderForCombinedIdentifier($combinedIdentifier) |
|
| 213 | - { |
|
| 214 | - // Code taken from FileListController.php |
|
| 215 | - $storage = $this->getResourceFactory()->getStorageObjectFromCombinedIdentifier($combinedIdentifier); |
|
| 216 | - $identifier = substr($combinedIdentifier, strpos($combinedIdentifier, ':') + 1); |
|
| 217 | - if (!$storage->hasFolder($identifier)) { |
|
| 218 | - $identifier = $storage->getFolderIdentifierFromFileIdentifier($identifier); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - // Retrieve the folder object. |
|
| 222 | - $folder = $this->getResourceFactory()->getFolderObjectFromCombinedIdentifier($storage->getUid() . ':' . $identifier); |
|
| 223 | - |
|
| 224 | - // Disallow the rendering of the processing folder (e.g. could be called manually) |
|
| 225 | - // and all folders without any defined storage |
|
| 226 | - if ($folder && ($folder->getStorage()->getUid() == 0 || trim($folder->getStorage()->getProcessingFolder()->getIdentifier(), '/') === trim($folder->getIdentifier(), '/'))) { |
|
| 227 | - $storage = $this->getResourceFactory()->getStorageObjectFromCombinedIdentifier($combinedIdentifier); |
|
| 228 | - $folder = $storage->getRootLevelFolder(); |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - return $folder; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * Tell whether the Folder Tree is display or not. |
|
| 236 | - * |
|
| 237 | - * @return bool |
|
| 238 | - */ |
|
| 239 | - public function hasFolderTree() |
|
| 240 | - { |
|
| 241 | - $configuration = $this->getModuleConfiguration(); |
|
| 242 | - return (bool)$configuration['has_folder_tree']; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * Tell whether the sub-folders must be included when browsing. |
|
| 247 | - * |
|
| 248 | - * @return bool |
|
| 249 | - */ |
|
| 250 | - public function hasRecursiveSelection() |
|
| 251 | - { |
|
| 252 | - $parameterPrefix = $this->getModuleLoader()->getParameterPrefix(); |
|
| 253 | - $parameters = GeneralUtility::_GET($parameterPrefix); |
|
| 254 | - |
|
| 255 | - $hasRecursiveSelection = true; |
|
| 256 | - if (isset($parameters['hasRecursiveSelection'])) { |
|
| 257 | - $hasRecursiveSelection = (bool)$parameters['hasRecursiveSelection']; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - return $hasRecursiveSelection; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - /** |
|
| 264 | - * Return the target folder for the uploaded file. |
|
| 265 | - * |
|
| 266 | - * @param UploadedFileInterface $uploadedFile |
|
| 267 | - * @param ResourceStorage $storage |
|
| 268 | - * @return Folder |
|
| 269 | - */ |
|
| 270 | - public function getTargetFolderForUploadedFile(UploadedFileInterface $uploadedFile, ResourceStorage $storage) |
|
| 271 | - { |
|
| 272 | - // default is the root level |
|
| 273 | - $folder = $storage->getRootLevelFolder(); // get the root folder by default |
|
| 274 | - |
|
| 275 | - // Get a possible mount point coming from the storage record. |
|
| 276 | - $storageRecord = $storage->getStorageRecord(); |
|
| 277 | - $mountPointIdentifier = $storageRecord['mount_point_file_type_' . $uploadedFile->getType()]; |
|
| 278 | - if ($mountPointIdentifier > 0) { |
|
| 279 | - // We don't have a Mount Point repository in FAL, so query the database directly. |
|
| 280 | - $record = $this->getDataService()->getRecord('sys_filemounts', ['uid' => $mountPointIdentifier]); |
|
| 281 | - |
|
| 282 | - if (!empty($record['path'])) { |
|
| 283 | - $folder = $storage->getFolder($record['path']); |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - return $folder; |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * Return a new target folder when moving file from one storage to another. |
|
| 291 | - * |
|
| 292 | - * @param ResourceStorage $storage |
|
| 293 | - * @param File $file |
|
| 294 | - * @return Folder |
|
| 295 | - */ |
|
| 296 | - public function getDefaultFolderInStorage(ResourceStorage $storage, File $file) |
|
| 297 | - { |
|
| 298 | - // default is the root level |
|
| 299 | - $folder = $storage->getRootLevelFolder(); |
|
| 300 | - |
|
| 301 | - // Retrieve storage record and a possible configured mount point. |
|
| 302 | - $storageRecord = $storage->getStorageRecord(); |
|
| 303 | - $mountPointIdentifier = $storageRecord['mount_point_file_type_' . $file->getType()]; |
|
| 304 | - |
|
| 305 | - if ($mountPointIdentifier > 0) { |
|
| 306 | - // We don't have a Mount Point repository in FAL, so query the database directly. |
|
| 307 | - $record = $this->getDataService()->getRecord('sys_filemounts', ['uid' => $mountPointIdentifier]); |
|
| 308 | - if (!empty($record['path'])) { |
|
| 309 | - $folder = $storage->getFolder($record['path']); |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - return $folder; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * @return array |
|
| 317 | - */ |
|
| 318 | - protected function getModuleConfiguration() |
|
| 319 | - { |
|
| 320 | - return GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('media'); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - /** |
|
| 324 | - * @return object|DataService |
|
| 325 | - */ |
|
| 326 | - protected function getDataService(): DataService |
|
| 327 | - { |
|
| 328 | - return GeneralUtility::makeInstance(DataService::class); |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - /** |
|
| 332 | - * Returns an instance of the current Backend User. |
|
| 333 | - * |
|
| 334 | - * @return BackendUserAuthentication |
|
| 335 | - */ |
|
| 336 | - protected function getBackendUser() |
|
| 337 | - { |
|
| 338 | - return $GLOBALS['BE_USER']; |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * @return ModuleLoader|object |
|
| 343 | - */ |
|
| 344 | - protected function getModuleLoader() |
|
| 345 | - { |
|
| 346 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - protected function getResourceFactory(): ResourceFactory |
|
| 350 | - { |
|
| 351 | - return GeneralUtility::makeInstance(ResourceFactory::class); |
|
| 352 | - } |
|
| 30 | + /** |
|
| 31 | + * @var string |
|
| 32 | + */ |
|
| 33 | + public const SIGNATURE = 'user_MediaM1'; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + public const PARAMETER_PREFIX = 'tx_media_user_mediam1'; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var ResourceStorage |
|
| 42 | + */ |
|
| 43 | + protected $currentStorage; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @return string |
|
| 47 | + */ |
|
| 48 | + public static function getSignature() |
|
| 49 | + { |
|
| 50 | + return self::SIGNATURE; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @return string |
|
| 55 | + */ |
|
| 56 | + public static function getParameterPrefix() |
|
| 57 | + { |
|
| 58 | + return self::PARAMETER_PREFIX; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Return all storage allowed for the Backend User. |
|
| 63 | + * |
|
| 64 | + * @throws \RuntimeException |
|
| 65 | + * @return ResourceStorage[] |
|
| 66 | + */ |
|
| 67 | + public function getAllowedStorages() |
|
| 68 | + { |
|
| 69 | + $storages = $this->getBackendUser()->getFileStorages(); |
|
| 70 | + if (empty($storages)) { |
|
| 71 | + throw new \RuntimeException('No storage is accessible for the current BE User. Forgotten to define a mount point for this BE User?', 1380801970); |
|
| 72 | + } |
|
| 73 | + return $storages; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Returns the current file storage in use. |
|
| 78 | + * |
|
| 79 | + * @return ResourceStorage |
|
| 80 | + */ |
|
| 81 | + public function getCurrentStorage() |
|
| 82 | + { |
|
| 83 | + if (is_null($this->currentStorage)) { |
|
| 84 | + $storageIdentifier = $this->getStorageIdentifierFromSessionOrArguments(); |
|
| 85 | + |
|
| 86 | + if ($storageIdentifier > 0) { |
|
| 87 | + $currentStorage = $this->getResourceFactory()->getStorageObject($storageIdentifier); |
|
| 88 | + } else { |
|
| 89 | + // We differentiate the cases whether the User is admin or not. |
|
| 90 | + if ($this->getBackendUser()->isAdmin()) { |
|
| 91 | + $currentStorage = $this->getResourceFactory()->getDefaultStorage(); |
|
| 92 | + |
|
| 93 | + // Not default storage has been flagged in "sys_file_storage". |
|
| 94 | + // Fallback approach: take the first storage as the current. |
|
| 95 | + if (!$currentStorage) { |
|
| 96 | + /** @var $storageRepository StorageRepository */ |
|
| 97 | + $storageRepository = GeneralUtility::makeInstance(StorageRepository::class); |
|
| 98 | + |
|
| 99 | + $storages = $storageRepository->findAll(); |
|
| 100 | + $currentStorage = current($storages); |
|
| 101 | + } |
|
| 102 | + } else { |
|
| 103 | + $fileMounts = $this->getBackendUser()->getFileMountRecords(); |
|
| 104 | + $firstFileMount = current($fileMounts); |
|
| 105 | + $currentStorage = $this->getResourceFactory()->getStorageObject($firstFileMount['base']); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + $this->currentStorage = $currentStorage; |
|
| 110 | + } |
|
| 111 | + return $this->currentStorage; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Retrieve a possible storage identifier from the session or from the arguments. |
|
| 116 | + * |
|
| 117 | + * @return int |
|
| 118 | + */ |
|
| 119 | + protected function getStorageIdentifierFromSessionOrArguments() |
|
| 120 | + { |
|
| 121 | + // Default value |
|
| 122 | + $storageIdentifier = 0; |
|
| 123 | + |
|
| 124 | + // Get last selected storage from User settings |
|
| 125 | + if (SessionUtility::getInstance()->get('lastSelectedStorage') > 0) { |
|
| 126 | + $storageIdentifier = SessionUtility::getInstance()->get('lastSelectedStorage'); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + $argumentPrefix = $this->getModuleLoader()->getParameterPrefix(); |
|
| 130 | + $arguments = GeneralUtility::_GET($argumentPrefix); |
|
| 131 | + |
|
| 132 | + // Override selected storage from the session if GET argument "storage" is detected. |
|
| 133 | + if (!empty($arguments['storage']) && (int)$arguments['storage'] > 0) { |
|
| 134 | + $storageIdentifier = (int)$arguments['storage']; |
|
| 135 | + |
|
| 136 | + // Save state |
|
| 137 | + SessionUtility::getInstance()->set('lastSelectedStorage', $storageIdentifier); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + return (int)$storageIdentifier; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Return the combined parameter from the URL. |
|
| 145 | + * |
|
| 146 | + * @return string |
|
| 147 | + */ |
|
| 148 | + public function getCombinedIdentifier() |
|
| 149 | + { |
|
| 150 | + // Fetch possible combined identifier. |
|
| 151 | + $combinedIdentifier = GeneralUtility::_GET('id'); |
|
| 152 | + |
|
| 153 | + if ($combinedIdentifier) { |
|
| 154 | + // Fix a bug at the Core level: the "id" parameter is encoded again when translating file. |
|
| 155 | + // Add a loop to decode maximum 999 time! |
|
| 156 | + $semaphore = 0; |
|
| 157 | + $semaphoreLimit = 999; |
|
| 158 | + while (!$this->isWellDecoded($combinedIdentifier) && $semaphore < $semaphoreLimit) { |
|
| 159 | + $combinedIdentifier = urldecode($combinedIdentifier); |
|
| 160 | + $semaphore++; |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + return $combinedIdentifier; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * @param $combinedIdentifier |
|
| 169 | + * @return bool |
|
| 170 | + */ |
|
| 171 | + protected function isWellDecoded($combinedIdentifier) |
|
| 172 | + { |
|
| 173 | + return preg_match('/.*:.*/', $combinedIdentifier); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * @return Folder |
|
| 178 | + */ |
|
| 179 | + public function getFirstAvailableFolder() |
|
| 180 | + { |
|
| 181 | + // Take the first object of the first storage. |
|
| 182 | + $storages = $this->getBackendUser()->getFileStorages(); |
|
| 183 | + $storage = reset($storages); |
|
| 184 | + if ($storage) { |
|
| 185 | + $folder = $storage->getRootLevelFolder(); |
|
| 186 | + } else { |
|
| 187 | + throw new \RuntimeException('Could not find any folder to be displayed.', 1444665954); |
|
| 188 | + } |
|
| 189 | + return $folder; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * @return Folder |
|
| 194 | + */ |
|
| 195 | + public function getCurrentFolder() |
|
| 196 | + { |
|
| 197 | + $combinedIdentifier = $this->getCombinedIdentifier(); |
|
| 198 | + |
|
| 199 | + if ($combinedIdentifier) { |
|
| 200 | + $folder = $this->getFolderForCombinedIdentifier($combinedIdentifier); |
|
| 201 | + } else { |
|
| 202 | + $folder = $this->getFirstAvailableFolder(); |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + return $folder; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * @param string $combinedIdentifier |
|
| 210 | + * @return Folder |
|
| 211 | + */ |
|
| 212 | + public function getFolderForCombinedIdentifier($combinedIdentifier) |
|
| 213 | + { |
|
| 214 | + // Code taken from FileListController.php |
|
| 215 | + $storage = $this->getResourceFactory()->getStorageObjectFromCombinedIdentifier($combinedIdentifier); |
|
| 216 | + $identifier = substr($combinedIdentifier, strpos($combinedIdentifier, ':') + 1); |
|
| 217 | + if (!$storage->hasFolder($identifier)) { |
|
| 218 | + $identifier = $storage->getFolderIdentifierFromFileIdentifier($identifier); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + // Retrieve the folder object. |
|
| 222 | + $folder = $this->getResourceFactory()->getFolderObjectFromCombinedIdentifier($storage->getUid() . ':' . $identifier); |
|
| 223 | + |
|
| 224 | + // Disallow the rendering of the processing folder (e.g. could be called manually) |
|
| 225 | + // and all folders without any defined storage |
|
| 226 | + if ($folder && ($folder->getStorage()->getUid() == 0 || trim($folder->getStorage()->getProcessingFolder()->getIdentifier(), '/') === trim($folder->getIdentifier(), '/'))) { |
|
| 227 | + $storage = $this->getResourceFactory()->getStorageObjectFromCombinedIdentifier($combinedIdentifier); |
|
| 228 | + $folder = $storage->getRootLevelFolder(); |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + return $folder; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * Tell whether the Folder Tree is display or not. |
|
| 236 | + * |
|
| 237 | + * @return bool |
|
| 238 | + */ |
|
| 239 | + public function hasFolderTree() |
|
| 240 | + { |
|
| 241 | + $configuration = $this->getModuleConfiguration(); |
|
| 242 | + return (bool)$configuration['has_folder_tree']; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * Tell whether the sub-folders must be included when browsing. |
|
| 247 | + * |
|
| 248 | + * @return bool |
|
| 249 | + */ |
|
| 250 | + public function hasRecursiveSelection() |
|
| 251 | + { |
|
| 252 | + $parameterPrefix = $this->getModuleLoader()->getParameterPrefix(); |
|
| 253 | + $parameters = GeneralUtility::_GET($parameterPrefix); |
|
| 254 | + |
|
| 255 | + $hasRecursiveSelection = true; |
|
| 256 | + if (isset($parameters['hasRecursiveSelection'])) { |
|
| 257 | + $hasRecursiveSelection = (bool)$parameters['hasRecursiveSelection']; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + return $hasRecursiveSelection; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * Return the target folder for the uploaded file. |
|
| 265 | + * |
|
| 266 | + * @param UploadedFileInterface $uploadedFile |
|
| 267 | + * @param ResourceStorage $storage |
|
| 268 | + * @return Folder |
|
| 269 | + */ |
|
| 270 | + public function getTargetFolderForUploadedFile(UploadedFileInterface $uploadedFile, ResourceStorage $storage) |
|
| 271 | + { |
|
| 272 | + // default is the root level |
|
| 273 | + $folder = $storage->getRootLevelFolder(); // get the root folder by default |
|
| 274 | + |
|
| 275 | + // Get a possible mount point coming from the storage record. |
|
| 276 | + $storageRecord = $storage->getStorageRecord(); |
|
| 277 | + $mountPointIdentifier = $storageRecord['mount_point_file_type_' . $uploadedFile->getType()]; |
|
| 278 | + if ($mountPointIdentifier > 0) { |
|
| 279 | + // We don't have a Mount Point repository in FAL, so query the database directly. |
|
| 280 | + $record = $this->getDataService()->getRecord('sys_filemounts', ['uid' => $mountPointIdentifier]); |
|
| 281 | + |
|
| 282 | + if (!empty($record['path'])) { |
|
| 283 | + $folder = $storage->getFolder($record['path']); |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + return $folder; |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Return a new target folder when moving file from one storage to another. |
|
| 291 | + * |
|
| 292 | + * @param ResourceStorage $storage |
|
| 293 | + * @param File $file |
|
| 294 | + * @return Folder |
|
| 295 | + */ |
|
| 296 | + public function getDefaultFolderInStorage(ResourceStorage $storage, File $file) |
|
| 297 | + { |
|
| 298 | + // default is the root level |
|
| 299 | + $folder = $storage->getRootLevelFolder(); |
|
| 300 | + |
|
| 301 | + // Retrieve storage record and a possible configured mount point. |
|
| 302 | + $storageRecord = $storage->getStorageRecord(); |
|
| 303 | + $mountPointIdentifier = $storageRecord['mount_point_file_type_' . $file->getType()]; |
|
| 304 | + |
|
| 305 | + if ($mountPointIdentifier > 0) { |
|
| 306 | + // We don't have a Mount Point repository in FAL, so query the database directly. |
|
| 307 | + $record = $this->getDataService()->getRecord('sys_filemounts', ['uid' => $mountPointIdentifier]); |
|
| 308 | + if (!empty($record['path'])) { |
|
| 309 | + $folder = $storage->getFolder($record['path']); |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + return $folder; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * @return array |
|
| 317 | + */ |
|
| 318 | + protected function getModuleConfiguration() |
|
| 319 | + { |
|
| 320 | + return GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('media'); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + /** |
|
| 324 | + * @return object|DataService |
|
| 325 | + */ |
|
| 326 | + protected function getDataService(): DataService |
|
| 327 | + { |
|
| 328 | + return GeneralUtility::makeInstance(DataService::class); |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + /** |
|
| 332 | + * Returns an instance of the current Backend User. |
|
| 333 | + * |
|
| 334 | + * @return BackendUserAuthentication |
|
| 335 | + */ |
|
| 336 | + protected function getBackendUser() |
|
| 337 | + { |
|
| 338 | + return $GLOBALS['BE_USER']; |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * @return ModuleLoader|object |
|
| 343 | + */ |
|
| 344 | + protected function getModuleLoader() |
|
| 345 | + { |
|
| 346 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + protected function getResourceFactory(): ResourceFactory |
|
| 350 | + { |
|
| 351 | + return GeneralUtility::makeInstance(ResourceFactory::class); |
|
| 352 | + } |
|
| 353 | 353 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // Retrieve the folder object. |
| 222 | - $folder = $this->getResourceFactory()->getFolderObjectFromCombinedIdentifier($storage->getUid() . ':' . $identifier); |
|
| 222 | + $folder = $this->getResourceFactory()->getFolderObjectFromCombinedIdentifier($storage->getUid().':'.$identifier); |
|
| 223 | 223 | |
| 224 | 224 | // Disallow the rendering of the processing folder (e.g. could be called manually) |
| 225 | 225 | // and all folders without any defined storage |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | // Get a possible mount point coming from the storage record. |
| 276 | 276 | $storageRecord = $storage->getStorageRecord(); |
| 277 | - $mountPointIdentifier = $storageRecord['mount_point_file_type_' . $uploadedFile->getType()]; |
|
| 277 | + $mountPointIdentifier = $storageRecord['mount_point_file_type_'.$uploadedFile->getType()]; |
|
| 278 | 278 | if ($mountPointIdentifier > 0) { |
| 279 | 279 | // We don't have a Mount Point repository in FAL, so query the database directly. |
| 280 | 280 | $record = $this->getDataService()->getRecord('sys_filemounts', ['uid' => $mountPointIdentifier]); |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | // Retrieve storage record and a possible configured mount point. |
| 302 | 302 | $storageRecord = $storage->getStorageRecord(); |
| 303 | - $mountPointIdentifier = $storageRecord['mount_point_file_type_' . $file->getType()]; |
|
| 303 | + $mountPointIdentifier = $storageRecord['mount_point_file_type_'.$file->getType()]; |
|
| 304 | 304 | |
| 305 | 305 | if ($mountPointIdentifier > 0) { |
| 306 | 306 | // We don't have a Mount Point repository in FAL, so query the database directly. |
@@ -16,33 +16,33 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class VidiModule |
| 18 | 18 | { |
| 19 | - public const SIGNATURE = 'file_VidiSysFileM1'; |
|
| 20 | - public const PARAMETER_PREFIX = 'tx_vidi_file_vidisysfilem1'; |
|
| 21 | - |
|
| 22 | - public const SIGNATURE_FOLDER_TREE_OMITTED = 'content_VidiSysFileM1'; |
|
| 23 | - public const PARAMETER_PREFIX_FOLDER_TREE_OMITTED = 'tx_vidi_content_vidisysfilem1'; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @return string |
|
| 27 | - */ |
|
| 28 | - public static function getSignature() |
|
| 29 | - { |
|
| 30 | - return self::getMediaModule()->hasFolderTree() ? self::SIGNATURE : self::SIGNATURE_FOLDER_TREE_OMITTED; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @return string |
|
| 35 | - */ |
|
| 36 | - public static function getParameterPrefix() |
|
| 37 | - { |
|
| 38 | - return self::getMediaModule()->hasFolderTree() ? self::PARAMETER_PREFIX : self::PARAMETER_PREFIX_FOLDER_TREE_OMITTED; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @return MediaModule|object |
|
| 43 | - */ |
|
| 44 | - protected static function getMediaModule() |
|
| 45 | - { |
|
| 46 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
| 47 | - } |
|
| 19 | + public const SIGNATURE = 'file_VidiSysFileM1'; |
|
| 20 | + public const PARAMETER_PREFIX = 'tx_vidi_file_vidisysfilem1'; |
|
| 21 | + |
|
| 22 | + public const SIGNATURE_FOLDER_TREE_OMITTED = 'content_VidiSysFileM1'; |
|
| 23 | + public const PARAMETER_PREFIX_FOLDER_TREE_OMITTED = 'tx_vidi_content_vidisysfilem1'; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @return string |
|
| 27 | + */ |
|
| 28 | + public static function getSignature() |
|
| 29 | + { |
|
| 30 | + return self::getMediaModule()->hasFolderTree() ? self::SIGNATURE : self::SIGNATURE_FOLDER_TREE_OMITTED; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @return string |
|
| 35 | + */ |
|
| 36 | + public static function getParameterPrefix() |
|
| 37 | + { |
|
| 38 | + return self::getMediaModule()->hasFolderTree() ? self::PARAMETER_PREFIX : self::PARAMETER_PREFIX_FOLDER_TREE_OMITTED; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @return MediaModule|object |
|
| 43 | + */ |
|
| 44 | + protected static function getMediaModule() |
|
| 45 | + { |
|
| 46 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -16,39 +16,39 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Dimension |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @var int |
|
| 21 | - */ |
|
| 22 | - protected $width = 0; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var int |
|
| 26 | - */ |
|
| 27 | - protected $height = 0; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @param string $dimension |
|
| 31 | - */ |
|
| 32 | - public function __construct($dimension) |
|
| 33 | - { |
|
| 34 | - $dimensions = GeneralUtility::trimExplode('x', $dimension); |
|
| 35 | - $this->width = empty($dimensions[0]) ? 0 : $dimensions[0]; |
|
| 36 | - $this->height = empty($dimensions[1]) ? 0 : $dimensions[1]; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @return mixed |
|
| 41 | - */ |
|
| 42 | - public function getWidth() |
|
| 43 | - { |
|
| 44 | - return $this->width; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @return int |
|
| 49 | - */ |
|
| 50 | - public function getHeight() |
|
| 51 | - { |
|
| 52 | - return $this->height; |
|
| 53 | - } |
|
| 19 | + /** |
|
| 20 | + * @var int |
|
| 21 | + */ |
|
| 22 | + protected $width = 0; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var int |
|
| 26 | + */ |
|
| 27 | + protected $height = 0; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @param string $dimension |
|
| 31 | + */ |
|
| 32 | + public function __construct($dimension) |
|
| 33 | + { |
|
| 34 | + $dimensions = GeneralUtility::trimExplode('x', $dimension); |
|
| 35 | + $this->width = empty($dimensions[0]) ? 0 : $dimensions[0]; |
|
| 36 | + $this->height = empty($dimensions[1]) ? 0 : $dimensions[1]; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @return mixed |
|
| 41 | + */ |
|
| 42 | + public function getWidth() |
|
| 43 | + { |
|
| 44 | + return $this->width; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @return int |
|
| 49 | + */ |
|
| 50 | + public function getHeight() |
|
| 51 | + { |
|
| 52 | + return $this->height; |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -16,53 +16,53 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class FormUtility implements SingletonInterface |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Returns a class instance. |
|
| 21 | - * |
|
| 22 | - * @return \Fab\Media\FileUpload\FormUtility|object |
|
| 23 | - */ |
|
| 24 | - public static function getInstance() |
|
| 25 | - { |
|
| 26 | - return GeneralUtility::makeInstance(\Fab\Media\FileUpload\FormUtility::class); |
|
| 27 | - } |
|
| 19 | + /** |
|
| 20 | + * Returns a class instance. |
|
| 21 | + * |
|
| 22 | + * @return \Fab\Media\FileUpload\FormUtility|object |
|
| 23 | + */ |
|
| 24 | + public static function getInstance() |
|
| 25 | + { |
|
| 26 | + return GeneralUtility::makeInstance(\Fab\Media\FileUpload\FormUtility::class); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Tells whether the content type is valid. |
|
| 31 | - * |
|
| 32 | - * @return bool |
|
| 33 | - */ |
|
| 34 | - public function hasValidContentType() |
|
| 35 | - { |
|
| 36 | - return isset($GLOBALS['_SERVER']['CONTENT_TYPE']); |
|
| 37 | - } |
|
| 29 | + /** |
|
| 30 | + * Tells whether the content type is valid. |
|
| 31 | + * |
|
| 32 | + * @return bool |
|
| 33 | + */ |
|
| 34 | + public function hasValidContentType() |
|
| 35 | + { |
|
| 36 | + return isset($GLOBALS['_SERVER']['CONTENT_TYPE']); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Tells whether the form is multiparted, e.g "multipart/form-data" |
|
| 41 | - * |
|
| 42 | - * @return bool |
|
| 43 | - */ |
|
| 44 | - public function isMultiparted() |
|
| 45 | - { |
|
| 46 | - return strpos(strtolower($GLOBALS['_SERVER']['CONTENT_TYPE']), 'multipart/form-data') === 0; |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * Tells whether the form is multiparted, e.g "multipart/form-data" |
|
| 41 | + * |
|
| 42 | + * @return bool |
|
| 43 | + */ |
|
| 44 | + public function isMultiparted() |
|
| 45 | + { |
|
| 46 | + return strpos(strtolower($GLOBALS['_SERVER']['CONTENT_TYPE']), 'multipart/form-data') === 0; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Tells whether the form is URL encoded, e.g "application/x-www-form-urlencoded; charset=UTF-8" |
|
| 51 | - * |
|
| 52 | - * @return bool |
|
| 53 | - */ |
|
| 54 | - public function isUrlEncoded() |
|
| 55 | - { |
|
| 56 | - return strpos(strtolower($GLOBALS['_SERVER']['CONTENT_TYPE']), 'application/x-www-form-urlencoded') === 0; |
|
| 57 | - } |
|
| 49 | + /** |
|
| 50 | + * Tells whether the form is URL encoded, e.g "application/x-www-form-urlencoded; charset=UTF-8" |
|
| 51 | + * |
|
| 52 | + * @return bool |
|
| 53 | + */ |
|
| 54 | + public function isUrlEncoded() |
|
| 55 | + { |
|
| 56 | + return strpos(strtolower($GLOBALS['_SERVER']['CONTENT_TYPE']), 'application/x-www-form-urlencoded') === 0; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Tells whether the form is octet streamed, e.g "application/x-www-form-urlencoded; charset=UTF-8" |
|
| 61 | - * |
|
| 62 | - * @return bool |
|
| 63 | - */ |
|
| 64 | - public function isOctetStreamed() |
|
| 65 | - { |
|
| 66 | - return strpos(strtolower($GLOBALS['_SERVER']['CONTENT_TYPE']), 'application/octet-stream') === 0; |
|
| 67 | - } |
|
| 59 | + /** |
|
| 60 | + * Tells whether the form is octet streamed, e.g "application/x-www-form-urlencoded; charset=UTF-8" |
|
| 61 | + * |
|
| 62 | + * @return bool |
|
| 63 | + */ |
|
| 64 | + public function isOctetStreamed() |
|
| 65 | + { |
|
| 66 | + return strpos(strtolower($GLOBALS['_SERVER']['CONTENT_TYPE']), 'application/octet-stream') === 0; |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -14,11 +14,11 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | interface ImageOptimizerInterface |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Optimize the given uploaded image |
|
| 19 | - * |
|
| 20 | - * @param UploadedFileInterface $uploadedFile |
|
| 21 | - * @return UploadedFileInterface |
|
| 22 | - */ |
|
| 23 | - public function optimize($uploadedFile); |
|
| 17 | + /** |
|
| 18 | + * Optimize the given uploaded image |
|
| 19 | + * |
|
| 20 | + * @param UploadedFileInterface $uploadedFile |
|
| 21 | + * @return UploadedFileInterface |
|
| 22 | + */ |
|
| 23 | + public function optimize($uploadedFile); |
|
| 24 | 24 | } |