@@ -18,33 +18,33 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class MoveViewHelper extends AbstractViewHelper |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Render a move storage URI. |
|
| 23 | - * |
|
| 24 | - * @return string |
|
| 25 | - */ |
|
| 26 | - public function render() |
|
| 27 | - { |
|
| 28 | - $urlParameters = array( |
|
| 29 | - VidiModule::getParameterPrefix() => array( |
|
| 30 | - 'controller' => 'Content', |
|
| 31 | - 'action' => 'move', |
|
| 32 | - 'fieldNameAndPath' => $this->templateVariableContainer->get('fieldNameAndPath'), |
|
| 33 | - 'matches' => $this->templateVariableContainer->get('matches'), |
|
| 34 | - ), |
|
| 35 | - ); |
|
| 21 | + /** |
|
| 22 | + * Render a move storage URI. |
|
| 23 | + * |
|
| 24 | + * @return string |
|
| 25 | + */ |
|
| 26 | + public function render() |
|
| 27 | + { |
|
| 28 | + $urlParameters = array( |
|
| 29 | + VidiModule::getParameterPrefix() => array( |
|
| 30 | + 'controller' => 'Content', |
|
| 31 | + 'action' => 'move', |
|
| 32 | + 'fieldNameAndPath' => $this->templateVariableContainer->get('fieldNameAndPath'), |
|
| 33 | + 'matches' => $this->templateVariableContainer->get('matches'), |
|
| 34 | + ), |
|
| 35 | + ); |
|
| 36 | 36 | |
| 37 | - $moduleUrl = BackendUtility::getModuleUrl( |
|
| 38 | - VidiModule::getSignature(), |
|
| 39 | - $urlParameters |
|
| 40 | - ); |
|
| 37 | + $moduleUrl = BackendUtility::getModuleUrl( |
|
| 38 | + VidiModule::getSignature(), |
|
| 39 | + $urlParameters |
|
| 40 | + ); |
|
| 41 | 41 | |
| 42 | - // Work around a bug in BackendUtility::getModuleUrl if matches is empty getModuleUrl() will not return the parameter. |
|
| 43 | - $matches = $this->templateVariableContainer->get('matches'); |
|
| 44 | - if (empty($matches)) { |
|
| 45 | - $moduleUrl .= '&' . urlencode(VidiModule::getParameterPrefix() . '[matches]='); |
|
| 46 | - } |
|
| 42 | + // Work around a bug in BackendUtility::getModuleUrl if matches is empty getModuleUrl() will not return the parameter. |
|
| 43 | + $matches = $this->templateVariableContainer->get('matches'); |
|
| 44 | + if (empty($matches)) { |
|
| 45 | + $moduleUrl .= '&' . urlencode(VidiModule::getParameterPrefix() . '[matches]='); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - return $moduleUrl; |
|
| 49 | - } |
|
| 48 | + return $moduleUrl; |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -18,37 +18,37 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class FormResultCompiler extends \TYPO3\CMS\Backend\Form\FormResultCompiler |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * JavaScript bottom code |
|
| 23 | - * |
|
| 24 | - * @param string $formname The identification of the form on the page. |
|
| 25 | - * @return string A section with JavaScript - if $update is false, embedded in <script></script> |
|
| 26 | - */ |
|
| 27 | - protected function JSbottom() |
|
| 28 | - { |
|
| 29 | - $out = parent::JSbottom(); |
|
| 21 | + /** |
|
| 22 | + * JavaScript bottom code |
|
| 23 | + * |
|
| 24 | + * @param string $formname The identification of the form on the page. |
|
| 25 | + * @return string A section with JavaScript - if $update is false, embedded in <script></script> |
|
| 26 | + */ |
|
| 27 | + protected function JSbottom() |
|
| 28 | + { |
|
| 29 | + $out = parent::JSbottom(); |
|
| 30 | 30 | |
| 31 | - $tsConfig = $this->getBackendUser()->getTSConfig(); |
|
| 32 | - $enableMediaFilePicker = (bool)$tsConfig['options.vidi.enableMediaFilePicker']; |
|
| 33 | - if ($enableMediaFilePicker) { |
|
| 34 | - $pageRenderer = $this->getPageRenderer(); |
|
| 35 | - $pageRenderer->loadRequireJsModule('TYPO3/CMS/Media/MediaFormEngine', 'function(MediaFormEngine) { |
|
| 31 | + $tsConfig = $this->getBackendUser()->getTSConfig(); |
|
| 32 | + $enableMediaFilePicker = (bool)$tsConfig['options.vidi.enableMediaFilePicker']; |
|
| 33 | + if ($enableMediaFilePicker) { |
|
| 34 | + $pageRenderer = $this->getPageRenderer(); |
|
| 35 | + $pageRenderer->loadRequireJsModule('TYPO3/CMS/Media/MediaFormEngine', 'function(MediaFormEngine) { |
|
| 36 | 36 | MediaFormEngine.vidiModuleUrl = \'' . BackendUtility::getModuleUrl(VidiModule::getSignature()) . '\'; |
| 37 | 37 | MediaFormEngine.vidiModulePrefix = \'' . VidiModule::getParameterPrefix() . '\'; |
| 38 | 38 | MediaFormEngine.browserUrl = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')) . '; |
| 39 | 39 | }'); |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - return $out; |
|
| 43 | - } |
|
| 42 | + return $out; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Returns an instance of the current Backend User. |
|
| 47 | - * |
|
| 48 | - * @return BackendUserAuthentication |
|
| 49 | - */ |
|
| 50 | - protected function getBackendUser() |
|
| 51 | - { |
|
| 52 | - return $GLOBALS['BE_USER']; |
|
| 53 | - } |
|
| 45 | + /** |
|
| 46 | + * Returns an instance of the current Backend User. |
|
| 47 | + * |
|
| 48 | + * @return BackendUserAuthentication |
|
| 49 | + */ |
|
| 50 | + protected function getBackendUser() |
|
| 51 | + { |
|
| 52 | + return $GLOBALS['BE_USER']; |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -33,9 +33,9 @@ |
||
| 33 | 33 | if ($enableMediaFilePicker) { |
| 34 | 34 | $pageRenderer = $this->getPageRenderer(); |
| 35 | 35 | $pageRenderer->loadRequireJsModule('TYPO3/CMS/Media/MediaFormEngine', 'function(MediaFormEngine) { |
| 36 | - MediaFormEngine.vidiModuleUrl = \'' . BackendUtility::getModuleUrl(VidiModule::getSignature()) . '\'; |
|
| 37 | - MediaFormEngine.vidiModulePrefix = \'' . VidiModule::getParameterPrefix() . '\'; |
|
| 38 | - MediaFormEngine.browserUrl = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')) . '; |
|
| 36 | + MediaFormEngine.vidiModuleUrl = \'' . BackendUtility::getModuleUrl(VidiModule::getSignature()).'\'; |
|
| 37 | + MediaFormEngine.vidiModulePrefix = \'' . VidiModule::getParameterPrefix().'\'; |
|
| 38 | + MediaFormEngine.browserUrl = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')).'; |
|
| 39 | 39 | }'); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -20,36 +20,36 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class TceForms extends AbstractFormElement |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @return array |
|
| 25 | - */ |
|
| 26 | - public function render() |
|
| 27 | - { |
|
| 28 | - // Load StyleSheets in the Page Renderer |
|
| 29 | - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
| 30 | - $cssFile = ExtensionManagementUtility::extPath('media') . 'Resources/Public/StyleSheets/fineuploader.tce.css'; |
|
| 31 | - $pageRenderer->addCssFile($cssFile); |
|
| 32 | - |
|
| 33 | - // language labels for JavaScript files |
|
| 34 | - $pageRenderer->addInlineLanguageLabelFile(ExtensionManagementUtility::extPath('media') . 'Resources/Private/Language/locallang.xlf', 'media_file_upload'); |
|
| 35 | - |
|
| 36 | - // js files to be loaded |
|
| 37 | - $pageRenderer->addJsFile(ExtensionManagementUtility::extPath('core') . 'Resources/Public/JavaScript/Contrib/jquery/jquery.min.js'); |
|
| 38 | - $pageRenderer->addJsFile(ExtensionManagementUtility::extPath('media') . 'Resources/Public/JavaScript/Encoder.js'); |
|
| 39 | - $pageRenderer->addJsFile(ExtensionManagementUtility::extPath('media') . 'Resources/Public/Libraries/Fineuploader/jquery.fineuploader-5.0.9.min.js'); |
|
| 40 | - |
|
| 41 | - $result = $this->initializeResultArray(); |
|
| 42 | - |
|
| 43 | - $fileMetadataRecord = $this->data['databaseRow']; |
|
| 44 | - |
|
| 45 | - if ($fileMetadataRecord['file'] <= 0) { |
|
| 46 | - throw new \Exception('I could not find a valid file identifier', 1392926871); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** @var $fileUpload \Fab\Media\Form\FileUploadTceForms */ |
|
| 50 | - $fileUpload = GeneralUtility::makeInstance(FileUploadTceForms::class); |
|
| 51 | - $fileUpload->setValue($fileMetadataRecord['file'][0])->setPrefix(MediaModule::getParameterPrefix()); |
|
| 52 | - $result['html'] = $fileUpload->render(); |
|
| 53 | - return $result; |
|
| 54 | - } |
|
| 23 | + /** |
|
| 24 | + * @return array |
|
| 25 | + */ |
|
| 26 | + public function render() |
|
| 27 | + { |
|
| 28 | + // Load StyleSheets in the Page Renderer |
|
| 29 | + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
| 30 | + $cssFile = ExtensionManagementUtility::extPath('media') . 'Resources/Public/StyleSheets/fineuploader.tce.css'; |
|
| 31 | + $pageRenderer->addCssFile($cssFile); |
|
| 32 | + |
|
| 33 | + // language labels for JavaScript files |
|
| 34 | + $pageRenderer->addInlineLanguageLabelFile(ExtensionManagementUtility::extPath('media') . 'Resources/Private/Language/locallang.xlf', 'media_file_upload'); |
|
| 35 | + |
|
| 36 | + // js files to be loaded |
|
| 37 | + $pageRenderer->addJsFile(ExtensionManagementUtility::extPath('core') . 'Resources/Public/JavaScript/Contrib/jquery/jquery.min.js'); |
|
| 38 | + $pageRenderer->addJsFile(ExtensionManagementUtility::extPath('media') . 'Resources/Public/JavaScript/Encoder.js'); |
|
| 39 | + $pageRenderer->addJsFile(ExtensionManagementUtility::extPath('media') . 'Resources/Public/Libraries/Fineuploader/jquery.fineuploader-5.0.9.min.js'); |
|
| 40 | + |
|
| 41 | + $result = $this->initializeResultArray(); |
|
| 42 | + |
|
| 43 | + $fileMetadataRecord = $this->data['databaseRow']; |
|
| 44 | + |
|
| 45 | + if ($fileMetadataRecord['file'] <= 0) { |
|
| 46 | + throw new \Exception('I could not find a valid file identifier', 1392926871); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** @var $fileUpload \Fab\Media\Form\FileUploadTceForms */ |
|
| 50 | + $fileUpload = GeneralUtility::makeInstance(FileUploadTceForms::class); |
|
| 51 | + $fileUpload->setValue($fileMetadataRecord['file'][0])->setPrefix(MediaModule::getParameterPrefix()); |
|
| 52 | + $result['html'] = $fileUpload->render(); |
|
| 53 | + return $result; |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -18,27 +18,27 @@ |
||
| 18 | 18 | |
| 19 | 19 | class FileCacheWarmUpCommand extends Command |
| 20 | 20 | { |
| 21 | - protected SymfonyStyle $io; |
|
| 22 | - |
|
| 23 | - protected function initialize(InputInterface $input, OutputInterface $output) |
|
| 24 | - { |
|
| 25 | - $this->io = new SymfonyStyle($input, $output); |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Warm up the cache. Update some caching columns such as "number_of_references" to speed up the search. |
|
| 30 | - */ |
|
| 31 | - protected function execute(InputInterface $input, OutputInterface $output): int |
|
| 32 | - { |
|
| 33 | - $numberOfEntries = $this->getCacheService()->warmUp(); |
|
| 34 | - $message = sprintf('Done! Processed %s entries', $numberOfEntries); |
|
| 35 | - $this->io->info($message); |
|
| 36 | - |
|
| 37 | - return 0; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - protected function getCacheService(): CacheService |
|
| 41 | - { |
|
| 42 | - return GeneralUtility::makeInstance(CacheService::class); |
|
| 43 | - } |
|
| 21 | + protected SymfonyStyle $io; |
|
| 22 | + |
|
| 23 | + protected function initialize(InputInterface $input, OutputInterface $output) |
|
| 24 | + { |
|
| 25 | + $this->io = new SymfonyStyle($input, $output); |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Warm up the cache. Update some caching columns such as "number_of_references" to speed up the search. |
|
| 30 | + */ |
|
| 31 | + protected function execute(InputInterface $input, OutputInterface $output): int |
|
| 32 | + { |
|
| 33 | + $numberOfEntries = $this->getCacheService()->warmUp(); |
|
| 34 | + $message = sprintf('Done! Processed %s entries', $numberOfEntries); |
|
| 35 | + $this->io->info($message); |
|
| 36 | + |
|
| 37 | + return 0; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + protected function getCacheService(): CacheService |
|
| 41 | + { |
|
| 42 | + return GeneralUtility::makeInstance(CacheService::class); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -21,110 +21,110 @@ |
||
| 21 | 21 | |
| 22 | 22 | class ThumbnailCommand extends Command |
| 23 | 23 | { |
| 24 | - protected SymfonyStyle $io; |
|
| 25 | - |
|
| 26 | - protected function initialize(InputInterface $input, OutputInterface $output) |
|
| 27 | - { |
|
| 28 | - $this->io = new SymfonyStyle($input, $output); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - protected function configure() |
|
| 32 | - { |
|
| 33 | - $this |
|
| 34 | - ->addOption( |
|
| 35 | - 'limit', |
|
| 36 | - '', |
|
| 37 | - InputOption::VALUE_REQUIRED, |
|
| 38 | - 'where to stop in the batch processing.', |
|
| 39 | - 0 |
|
| 40 | - ) |
|
| 41 | - ->addOption( |
|
| 42 | - 'offset', |
|
| 43 | - '', |
|
| 44 | - InputOption::VALUE_REQUIRED, |
|
| 45 | - 'where to start in the batch processing.', |
|
| 46 | - 0 |
|
| 47 | - ) |
|
| 48 | - ->addOption( |
|
| 49 | - 'configuration', |
|
| 50 | - '', |
|
| 51 | - InputOption::VALUE_REQUIRED, |
|
| 52 | - 'override the default thumbnail configuration.', |
|
| 53 | - [] |
|
| 54 | - ); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Generate a bunch of thumbnails in advance to speed up the output of the Media BE module. |
|
| 59 | - */ |
|
| 60 | - protected function execute(InputInterface $input, OutputInterface $output): int |
|
| 61 | - { |
|
| 62 | - $limit = $input->getOption('limit'); |
|
| 63 | - $offset = $input->getOption('offset'); |
|
| 64 | - $configuration = $input->getOption('configuration'); |
|
| 65 | - $verbose = $input->getOption('verbose'); |
|
| 66 | - |
|
| 67 | - foreach ($this->getStorageRepository()->findAll() as $storage) { |
|
| 68 | - $this->io->info(sprintf('Processing files from storage %s (%s)', $storage->getName(), $storage->getUid())); |
|
| 69 | - |
|
| 70 | - if ($storage->isOnline()) { |
|
| 71 | - // For the CLI cause. |
|
| 72 | - $storage->setEvaluatePermissions(false); |
|
| 73 | - |
|
| 74 | - $thumbnailGenerator = $this->getThumbnailGenerator(); |
|
| 75 | - $thumbnailGenerator |
|
| 76 | - ->setStorage($storage) |
|
| 77 | - ->setConfiguration($configuration) |
|
| 78 | - ->generate($limit, $offset); |
|
| 79 | - |
|
| 80 | - if ($verbose) { |
|
| 81 | - $resultSet = $thumbnailGenerator->getResultSet(); |
|
| 82 | - foreach ($resultSet as $result) { |
|
| 83 | - $message = sprintf( |
|
| 84 | - '* File "%s": %s %s', |
|
| 85 | - $result['fileUid'], |
|
| 86 | - $result['fileIdentifier'], |
|
| 87 | - empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri'] |
|
| 88 | - ); |
|
| 89 | - $this->io->info($message); |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $message = sprintf( |
|
| 94 | - 'Done! New generated %s thumbnail(s) from %s traversed file(s) of a total of %s files.', |
|
| 95 | - $thumbnailGenerator->getNumberOfProcessedFiles(), |
|
| 96 | - $thumbnailGenerator->getNumberOfTraversedFiles(), |
|
| 97 | - $thumbnailGenerator->getTotalNumberOfFiles() |
|
| 98 | - ); |
|
| 99 | - $this->io->info($message); |
|
| 100 | - |
|
| 101 | - // Add warning message if missing files were found along the way. |
|
| 102 | - if ($thumbnailGenerator->getNumberOfMissingFiles() > 0) { |
|
| 103 | - $message = sprintf( |
|
| 104 | - 'ATTENTION! %s missing file(s) detected.', |
|
| 105 | - $thumbnailGenerator->getNumberOfMissingFiles() |
|
| 106 | - ); |
|
| 107 | - $this->io->warning($message); |
|
| 108 | - } |
|
| 109 | - } else { |
|
| 110 | - $this->io->info('Storage is offline!'); |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - return 0; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - protected function getDataService(): DataService |
|
| 117 | - { |
|
| 118 | - return GeneralUtility::makeInstance(DataService::class); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - protected function getThumbnailGenerator(): ThumbnailGenerator |
|
| 122 | - { |
|
| 123 | - return GeneralUtility::makeInstance(ThumbnailGenerator::class); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - protected function getStorageRepository(): StorageRepository |
|
| 127 | - { |
|
| 128 | - return GeneralUtility::makeInstance(StorageRepository::class); |
|
| 129 | - } |
|
| 24 | + protected SymfonyStyle $io; |
|
| 25 | + |
|
| 26 | + protected function initialize(InputInterface $input, OutputInterface $output) |
|
| 27 | + { |
|
| 28 | + $this->io = new SymfonyStyle($input, $output); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + protected function configure() |
|
| 32 | + { |
|
| 33 | + $this |
|
| 34 | + ->addOption( |
|
| 35 | + 'limit', |
|
| 36 | + '', |
|
| 37 | + InputOption::VALUE_REQUIRED, |
|
| 38 | + 'where to stop in the batch processing.', |
|
| 39 | + 0 |
|
| 40 | + ) |
|
| 41 | + ->addOption( |
|
| 42 | + 'offset', |
|
| 43 | + '', |
|
| 44 | + InputOption::VALUE_REQUIRED, |
|
| 45 | + 'where to start in the batch processing.', |
|
| 46 | + 0 |
|
| 47 | + ) |
|
| 48 | + ->addOption( |
|
| 49 | + 'configuration', |
|
| 50 | + '', |
|
| 51 | + InputOption::VALUE_REQUIRED, |
|
| 52 | + 'override the default thumbnail configuration.', |
|
| 53 | + [] |
|
| 54 | + ); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Generate a bunch of thumbnails in advance to speed up the output of the Media BE module. |
|
| 59 | + */ |
|
| 60 | + protected function execute(InputInterface $input, OutputInterface $output): int |
|
| 61 | + { |
|
| 62 | + $limit = $input->getOption('limit'); |
|
| 63 | + $offset = $input->getOption('offset'); |
|
| 64 | + $configuration = $input->getOption('configuration'); |
|
| 65 | + $verbose = $input->getOption('verbose'); |
|
| 66 | + |
|
| 67 | + foreach ($this->getStorageRepository()->findAll() as $storage) { |
|
| 68 | + $this->io->info(sprintf('Processing files from storage %s (%s)', $storage->getName(), $storage->getUid())); |
|
| 69 | + |
|
| 70 | + if ($storage->isOnline()) { |
|
| 71 | + // For the CLI cause. |
|
| 72 | + $storage->setEvaluatePermissions(false); |
|
| 73 | + |
|
| 74 | + $thumbnailGenerator = $this->getThumbnailGenerator(); |
|
| 75 | + $thumbnailGenerator |
|
| 76 | + ->setStorage($storage) |
|
| 77 | + ->setConfiguration($configuration) |
|
| 78 | + ->generate($limit, $offset); |
|
| 79 | + |
|
| 80 | + if ($verbose) { |
|
| 81 | + $resultSet = $thumbnailGenerator->getResultSet(); |
|
| 82 | + foreach ($resultSet as $result) { |
|
| 83 | + $message = sprintf( |
|
| 84 | + '* File "%s": %s %s', |
|
| 85 | + $result['fileUid'], |
|
| 86 | + $result['fileIdentifier'], |
|
| 87 | + empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri'] |
|
| 88 | + ); |
|
| 89 | + $this->io->info($message); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $message = sprintf( |
|
| 94 | + 'Done! New generated %s thumbnail(s) from %s traversed file(s) of a total of %s files.', |
|
| 95 | + $thumbnailGenerator->getNumberOfProcessedFiles(), |
|
| 96 | + $thumbnailGenerator->getNumberOfTraversedFiles(), |
|
| 97 | + $thumbnailGenerator->getTotalNumberOfFiles() |
|
| 98 | + ); |
|
| 99 | + $this->io->info($message); |
|
| 100 | + |
|
| 101 | + // Add warning message if missing files were found along the way. |
|
| 102 | + if ($thumbnailGenerator->getNumberOfMissingFiles() > 0) { |
|
| 103 | + $message = sprintf( |
|
| 104 | + 'ATTENTION! %s missing file(s) detected.', |
|
| 105 | + $thumbnailGenerator->getNumberOfMissingFiles() |
|
| 106 | + ); |
|
| 107 | + $this->io->warning($message); |
|
| 108 | + } |
|
| 109 | + } else { |
|
| 110 | + $this->io->info('Storage is offline!'); |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + return 0; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + protected function getDataService(): DataService |
|
| 117 | + { |
|
| 118 | + return GeneralUtility::makeInstance(DataService::class); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + protected function getThumbnailGenerator(): ThumbnailGenerator |
|
| 122 | + { |
|
| 123 | + return GeneralUtility::makeInstance(ThumbnailGenerator::class); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + protected function getStorageRepository(): StorageRepository |
|
| 127 | + { |
|
| 128 | + return GeneralUtility::makeInstance(StorageRepository::class); |
|
| 129 | + } |
|
| 130 | 130 | } |
@@ -84,7 +84,7 @@ |
||
| 84 | 84 | '* File "%s": %s %s', |
| 85 | 85 | $result['fileUid'], |
| 86 | 86 | $result['fileIdentifier'], |
| 87 | - empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri'] |
|
| 87 | + empty($result['thumbnailUri']) ? '' : ' -> '.$result['thumbnailUri'] |
|
| 88 | 88 | ); |
| 89 | 89 | $this->io->info($message); |
| 90 | 90 | } |
@@ -25,69 +25,69 @@ |
||
| 25 | 25 | |
| 26 | 26 | class FileCacheFlushProcessedFilesCommand extends Command |
| 27 | 27 | { |
| 28 | - protected SymfonyStyle $io; |
|
| 29 | - |
|
| 30 | - protected function initialize(InputInterface $input, OutputInterface $output) |
|
| 31 | - { |
|
| 32 | - $this->io = new SymfonyStyle($input, $output); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Flush all processed files to be used for debugging mainly. |
|
| 37 | - */ |
|
| 38 | - protected function execute(InputInterface $input, OutputInterface $output): int |
|
| 39 | - { |
|
| 40 | - foreach ($this->getStorageRepository()->findAll() as $storage) { |
|
| 41 | - // This only works for local driver |
|
| 42 | - if ($storage->getDriverType() === 'Local' && $storage->isOnline()) { |
|
| 43 | - $processedDirectoryPath = Environment::getPublicPath() . $this->getProcessingFolderPath($storage); |
|
| 44 | - $this->io->info(sprintf('Removing files from %s for storage "%s" (%s)', $processedDirectoryPath, $storage->getName(), $storage->getUid())); |
|
| 45 | - |
|
| 46 | - $this->clearProcessedFiles($storage->getUid()); |
|
| 47 | - |
|
| 48 | - GeneralUtility::rmdir($processedDirectoryPath, true); |
|
| 49 | - GeneralUtility::mkdir($processedDirectoryPath); // recreate the directory. |
|
| 50 | - |
|
| 51 | - $message = sprintf('Done! Removed all processed files from storage %s.', $storage->getUid()); |
|
| 52 | - $this->io->info($message); |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return 0; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - public function clearProcessedFiles(int $storageUid): int |
|
| 60 | - { |
|
| 61 | - $repository = GeneralUtility::makeInstance(ProcessedFileRepository::class); |
|
| 62 | - return $repository->removeAll($storageUid); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - protected function getProcessingFolderPath(ResourceStorage $storage): string |
|
| 66 | - { |
|
| 67 | - $storageConfiguration = $storage->getConfiguration(); |
|
| 68 | - $storageBasePath = rtrim($storageConfiguration['basePath'], '/'); |
|
| 69 | - return '/' . $storageBasePath . $storage->getProcessingFolder()->getIdentifier(); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - protected function getCacheService(): CacheService |
|
| 73 | - { |
|
| 74 | - return GeneralUtility::makeInstance(CacheService::class); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - protected function getStorageRepository(): StorageRepository |
|
| 78 | - { |
|
| 79 | - return GeneralUtility::makeInstance(StorageRepository::class); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - protected function getDataService(): DataService |
|
| 83 | - { |
|
| 84 | - return GeneralUtility::makeInstance(DataService::class); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - protected function getConnection(string $tableName): Connection |
|
| 88 | - { |
|
| 89 | - /** @var ConnectionPool $connectionPool */ |
|
| 90 | - $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
| 91 | - return $connectionPool->getConnectionForTable($tableName); |
|
| 92 | - } |
|
| 28 | + protected SymfonyStyle $io; |
|
| 29 | + |
|
| 30 | + protected function initialize(InputInterface $input, OutputInterface $output) |
|
| 31 | + { |
|
| 32 | + $this->io = new SymfonyStyle($input, $output); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Flush all processed files to be used for debugging mainly. |
|
| 37 | + */ |
|
| 38 | + protected function execute(InputInterface $input, OutputInterface $output): int |
|
| 39 | + { |
|
| 40 | + foreach ($this->getStorageRepository()->findAll() as $storage) { |
|
| 41 | + // This only works for local driver |
|
| 42 | + if ($storage->getDriverType() === 'Local' && $storage->isOnline()) { |
|
| 43 | + $processedDirectoryPath = Environment::getPublicPath() . $this->getProcessingFolderPath($storage); |
|
| 44 | + $this->io->info(sprintf('Removing files from %s for storage "%s" (%s)', $processedDirectoryPath, $storage->getName(), $storage->getUid())); |
|
| 45 | + |
|
| 46 | + $this->clearProcessedFiles($storage->getUid()); |
|
| 47 | + |
|
| 48 | + GeneralUtility::rmdir($processedDirectoryPath, true); |
|
| 49 | + GeneralUtility::mkdir($processedDirectoryPath); // recreate the directory. |
|
| 50 | + |
|
| 51 | + $message = sprintf('Done! Removed all processed files from storage %s.', $storage->getUid()); |
|
| 52 | + $this->io->info($message); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return 0; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + public function clearProcessedFiles(int $storageUid): int |
|
| 60 | + { |
|
| 61 | + $repository = GeneralUtility::makeInstance(ProcessedFileRepository::class); |
|
| 62 | + return $repository->removeAll($storageUid); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + protected function getProcessingFolderPath(ResourceStorage $storage): string |
|
| 66 | + { |
|
| 67 | + $storageConfiguration = $storage->getConfiguration(); |
|
| 68 | + $storageBasePath = rtrim($storageConfiguration['basePath'], '/'); |
|
| 69 | + return '/' . $storageBasePath . $storage->getProcessingFolder()->getIdentifier(); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + protected function getCacheService(): CacheService |
|
| 73 | + { |
|
| 74 | + return GeneralUtility::makeInstance(CacheService::class); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + protected function getStorageRepository(): StorageRepository |
|
| 78 | + { |
|
| 79 | + return GeneralUtility::makeInstance(StorageRepository::class); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + protected function getDataService(): DataService |
|
| 83 | + { |
|
| 84 | + return GeneralUtility::makeInstance(DataService::class); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + protected function getConnection(string $tableName): Connection |
|
| 88 | + { |
|
| 89 | + /** @var ConnectionPool $connectionPool */ |
|
| 90 | + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
| 91 | + return $connectionPool->getConnectionForTable($tableName); |
|
| 92 | + } |
|
| 93 | 93 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | foreach ($this->getStorageRepository()->findAll() as $storage) { |
| 41 | 41 | // This only works for local driver |
| 42 | 42 | if ($storage->getDriverType() === 'Local' && $storage->isOnline()) { |
| 43 | - $processedDirectoryPath = Environment::getPublicPath() . $this->getProcessingFolderPath($storage); |
|
| 43 | + $processedDirectoryPath = Environment::getPublicPath().$this->getProcessingFolderPath($storage); |
|
| 44 | 44 | $this->io->info(sprintf('Removing files from %s for storage "%s" (%s)', $processedDirectoryPath, $storage->getName(), $storage->getUid())); |
| 45 | 45 | |
| 46 | 46 | $this->clearProcessedFiles($storage->getUid()); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | $storageConfiguration = $storage->getConfiguration(); |
| 68 | 68 | $storageBasePath = rtrim($storageConfiguration['basePath'], '/'); |
| 69 | - return '/' . $storageBasePath . $storage->getProcessingFolder()->getIdentifier(); |
|
| 69 | + return '/'.$storageBasePath.$storage->getProcessingFolder()->getIdentifier(); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | protected function getCacheService(): CacheService |
@@ -19,36 +19,36 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class StorageValidator extends AbstractValidator |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * Check if $storageIdentifier is allowed. If it is not valid, throw an exception. |
|
| 24 | - * |
|
| 25 | - * @param int $combinedIdentifier |
|
| 26 | - * @return void |
|
| 27 | - */ |
|
| 28 | - public function isValid($combinedIdentifier) |
|
| 29 | - { |
|
| 30 | - $allowedStorageIdentifiers = []; |
|
| 31 | - foreach ($this->getMediaModule()->getAllowedStorages() as $allowedStorage) { |
|
| 32 | - $allowedStorageIdentifiers[] = $allowedStorage->getUid(); |
|
| 33 | - } |
|
| 22 | + /** |
|
| 23 | + * Check if $storageIdentifier is allowed. If it is not valid, throw an exception. |
|
| 24 | + * |
|
| 25 | + * @param int $combinedIdentifier |
|
| 26 | + * @return void |
|
| 27 | + */ |
|
| 28 | + public function isValid($combinedIdentifier) |
|
| 29 | + { |
|
| 30 | + $allowedStorageIdentifiers = []; |
|
| 31 | + foreach ($this->getMediaModule()->getAllowedStorages() as $allowedStorage) { |
|
| 32 | + $allowedStorageIdentifiers[] = $allowedStorage->getUid(); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - $storage = $this->getResourceFactory()->getStorageObjectFromCombinedIdentifier($combinedIdentifier); |
|
| 36 | - if (!in_array($storage->getUid(), $allowedStorageIdentifiers)) { |
|
| 37 | - $message = sprintf('Storage identifier "%s" is not allowed or is currently off-line.', $combinedIdentifier); |
|
| 38 | - $this->addError($message, 1380813503); |
|
| 39 | - } |
|
| 40 | - } |
|
| 35 | + $storage = $this->getResourceFactory()->getStorageObjectFromCombinedIdentifier($combinedIdentifier); |
|
| 36 | + if (!in_array($storage->getUid(), $allowedStorageIdentifiers)) { |
|
| 37 | + $message = sprintf('Storage identifier "%s" is not allowed or is currently off-line.', $combinedIdentifier); |
|
| 38 | + $this->addError($message, 1380813503); |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return MediaModule|object |
|
| 44 | - */ |
|
| 45 | - protected function getMediaModule() |
|
| 46 | - { |
|
| 47 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
| 48 | - } |
|
| 42 | + /** |
|
| 43 | + * @return MediaModule|object |
|
| 44 | + */ |
|
| 45 | + protected function getMediaModule() |
|
| 46 | + { |
|
| 47 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - protected function getResourceFactory(): ResourceFactory |
|
| 51 | - { |
|
| 52 | - return GeneralUtility::makeInstance(ResourceFactory::class); |
|
| 53 | - } |
|
| 50 | + protected function getResourceFactory(): ResourceFactory |
|
| 51 | + { |
|
| 52 | + return GeneralUtility::makeInstance(ResourceFactory::class); |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | class ConfigurationArrayConverter extends ArrayConverter |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Match configuration options (to parse actual options) |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - public const PATTERN_MATCH_CONFIGURATIONOPTIONS = '/ |
|
| 20 | + /** |
|
| 21 | + * Match configuration options (to parse actual options) |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + public const PATTERN_MATCH_CONFIGURATIONOPTIONS = '/ |
|
| 25 | 25 | \s* |
| 26 | 26 | (?P<optionName>[a-z0-9]+) |
| 27 | 27 | \s*=\s* |
@@ -32,84 +32,84 @@ discard block |
||
| 32 | 32 | ) |
| 33 | 33 | /ixS'; |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * We can only convert empty strings to array or array to array. |
|
| 37 | - * |
|
| 38 | - * @param mixed $source |
|
| 39 | - * @param string $targetType |
|
| 40 | - * @return boolean |
|
| 41 | - */ |
|
| 42 | - public function canConvertFrom($source, string $targetType): bool |
|
| 43 | - { |
|
| 44 | - return is_string($source) || is_array($source); |
|
| 45 | - } |
|
| 35 | + /** |
|
| 36 | + * We can only convert empty strings to array or array to array. |
|
| 37 | + * |
|
| 38 | + * @param mixed $source |
|
| 39 | + * @param string $targetType |
|
| 40 | + * @return boolean |
|
| 41 | + */ |
|
| 42 | + public function canConvertFrom($source, string $targetType): bool |
|
| 43 | + { |
|
| 44 | + return is_string($source) || is_array($source); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Convert from $source to $targetType, a noop if the source is an array. |
|
| 49 | - * If it is an empty string it will be converted to an empty array. |
|
| 50 | - * |
|
| 51 | - * @param string|array $source |
|
| 52 | - * @param string $targetType |
|
| 53 | - * @param array $convertedChildProperties |
|
| 54 | - * @param PropertyMappingConfigurationInterface $configuration |
|
| 55 | - * @return array |
|
| 56 | - * @api |
|
| 57 | - */ |
|
| 58 | - public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) |
|
| 59 | - { |
|
| 60 | - if (is_string($source)) { |
|
| 61 | - if ($source === '') { |
|
| 62 | - $target = []; |
|
| 63 | - } else { |
|
| 64 | - $target = $this->parseConfigurationOptions($source); |
|
| 65 | - } |
|
| 66 | - } |
|
| 47 | + /** |
|
| 48 | + * Convert from $source to $targetType, a noop if the source is an array. |
|
| 49 | + * If it is an empty string it will be converted to an empty array. |
|
| 50 | + * |
|
| 51 | + * @param string|array $source |
|
| 52 | + * @param string $targetType |
|
| 53 | + * @param array $convertedChildProperties |
|
| 54 | + * @param PropertyMappingConfigurationInterface $configuration |
|
| 55 | + * @return array |
|
| 56 | + * @api |
|
| 57 | + */ |
|
| 58 | + public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) |
|
| 59 | + { |
|
| 60 | + if (is_string($source)) { |
|
| 61 | + if ($source === '') { |
|
| 62 | + $target = []; |
|
| 63 | + } else { |
|
| 64 | + $target = $this->parseConfigurationOptions($source); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - if (is_array($source)) { |
|
| 69 | - $target = $source; |
|
| 70 | - } |
|
| 68 | + if (is_array($source)) { |
|
| 69 | + $target = $source; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - return $target; |
|
| 73 | - } |
|
| 72 | + return $target; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Parses $rawValidatorOptions not containing quoted option values. |
|
| 77 | - * $rawValidatorOptions will be an empty string afterwards (pass by ref!). |
|
| 78 | - * |
|
| 79 | - * @param string $rawValidatorOptions |
|
| 80 | - * @return array An array of optionName/optionValue pairs |
|
| 81 | - */ |
|
| 82 | - protected function parseConfigurationOptions($rawConfigurationOptions) |
|
| 83 | - { |
|
| 84 | - $configurationOptions = []; |
|
| 85 | - $parsedConfigurationOptions = []; |
|
| 86 | - preg_match_all(self::PATTERN_MATCH_CONFIGURATIONOPTIONS, $rawConfigurationOptions, $configurationOptions, PREG_SET_ORDER); |
|
| 87 | - foreach ($configurationOptions as $configurationOption) { |
|
| 88 | - $parsedConfigurationOptions[trim($configurationOption['optionName'])] = trim($configurationOption['optionValue']); |
|
| 89 | - } |
|
| 90 | - array_walk($parsedConfigurationOptions, array($this, 'unquoteString')); |
|
| 91 | - return $parsedConfigurationOptions; |
|
| 92 | - } |
|
| 75 | + /** |
|
| 76 | + * Parses $rawValidatorOptions not containing quoted option values. |
|
| 77 | + * $rawValidatorOptions will be an empty string afterwards (pass by ref!). |
|
| 78 | + * |
|
| 79 | + * @param string $rawValidatorOptions |
|
| 80 | + * @return array An array of optionName/optionValue pairs |
|
| 81 | + */ |
|
| 82 | + protected function parseConfigurationOptions($rawConfigurationOptions) |
|
| 83 | + { |
|
| 84 | + $configurationOptions = []; |
|
| 85 | + $parsedConfigurationOptions = []; |
|
| 86 | + preg_match_all(self::PATTERN_MATCH_CONFIGURATIONOPTIONS, $rawConfigurationOptions, $configurationOptions, PREG_SET_ORDER); |
|
| 87 | + foreach ($configurationOptions as $configurationOption) { |
|
| 88 | + $parsedConfigurationOptions[trim($configurationOption['optionName'])] = trim($configurationOption['optionValue']); |
|
| 89 | + } |
|
| 90 | + array_walk($parsedConfigurationOptions, array($this, 'unquoteString')); |
|
| 91 | + return $parsedConfigurationOptions; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Removes escapings from a given argument string and trims the outermost |
|
| 96 | - * quotes. |
|
| 97 | - * |
|
| 98 | - * This method is meant as a helper for regular expression results. |
|
| 99 | - * |
|
| 100 | - * @param string &$quotedValue Value to unquote |
|
| 101 | - * @return void |
|
| 102 | - */ |
|
| 103 | - protected function unquoteString(&$quotedValue) |
|
| 104 | - { |
|
| 105 | - switch ($quotedValue[0]) { |
|
| 106 | - case '"': |
|
| 107 | - $quotedValue = str_replace('\\"', '"', trim($quotedValue, '"')); |
|
| 108 | - break; |
|
| 109 | - case '\'': |
|
| 110 | - $quotedValue = str_replace('\\\'', '\'', trim($quotedValue, '\'')); |
|
| 111 | - break; |
|
| 112 | - } |
|
| 113 | - $quotedValue = str_replace('\\\\', '\\', $quotedValue); |
|
| 114 | - } |
|
| 94 | + /** |
|
| 95 | + * Removes escapings from a given argument string and trims the outermost |
|
| 96 | + * quotes. |
|
| 97 | + * |
|
| 98 | + * This method is meant as a helper for regular expression results. |
|
| 99 | + * |
|
| 100 | + * @param string &$quotedValue Value to unquote |
|
| 101 | + * @return void |
|
| 102 | + */ |
|
| 103 | + protected function unquoteString(&$quotedValue) |
|
| 104 | + { |
|
| 105 | + switch ($quotedValue[0]) { |
|
| 106 | + case '"': |
|
| 107 | + $quotedValue = str_replace('\\"', '"', trim($quotedValue, '"')); |
|
| 108 | + break; |
|
| 109 | + case '\'': |
|
| 110 | + $quotedValue = str_replace('\\\'', '\'', trim($quotedValue, '\'')); |
|
| 111 | + break; |
|
| 112 | + } |
|
| 113 | + $quotedValue = str_replace('\\\\', '\\', $quotedValue); |
|
| 114 | + } |
|
| 115 | 115 | } |
@@ -27,202 +27,202 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class FilePermissionsAspect |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * Post-process the matcher object to respect the file storages. |
|
| 32 | - * |
|
| 33 | - * @param Matcher $matcher |
|
| 34 | - * @param string $dataType |
|
| 35 | - * @return void |
|
| 36 | - * @throws \InvalidArgumentException |
|
| 37 | - */ |
|
| 38 | - public function addFilePermissionsForFileStorages(Matcher $matcher, $dataType) |
|
| 39 | - { |
|
| 40 | - if ($dataType === 'sys_file' && $this->isPermissionNecessary()) { |
|
| 41 | - if ($this->isFolderConsidered()) { |
|
| 42 | - $folder = $this->getMediaModule()->getCurrentFolder(); |
|
| 43 | - |
|
| 44 | - if ($this->getMediaModule()->hasRecursiveSelection()) { |
|
| 45 | - // Only add like condition if needed. |
|
| 46 | - if ($folder->getStorage()->getRootLevelFolder() !== $folder) { |
|
| 47 | - $matcher->like('identifier', $folder->getIdentifier() . '%', $automaticallyAddWildCard = false); |
|
| 48 | - } |
|
| 49 | - } else { |
|
| 50 | - // Browse only currently |
|
| 51 | - $files = $this->getFileUids($folder); |
|
| 52 | - $matcher->in('uid', $files); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - $matcher->equals('storage', $folder->getStorage()->getUid()); |
|
| 56 | - } else { |
|
| 57 | - $storage = $this->getMediaModule()->getCurrentStorage(); |
|
| 58 | - |
|
| 59 | - // Set the storage identifier only if the storage is on-line. |
|
| 60 | - $identifier = -1; |
|
| 61 | - if ($storage->isOnline()) { |
|
| 62 | - $identifier = $storage->getUid(); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - if ($this->getModuleLoader()->hasPlugin() && !$this->getCurrentBackendUser()->isAdmin()) { |
|
| 66 | - $fileMounts = $this->getCurrentBackendUser()->getFileMountRecords(); |
|
| 67 | - $collectedFiles = []; |
|
| 68 | - foreach ($fileMounts as $fileMount) { |
|
| 69 | - $combinedIdentifier = $fileMount['base'] . ':' . $fileMount['path']; |
|
| 70 | - $folder = $this->getResourceFactory()->getFolderObjectFromCombinedIdentifier($combinedIdentifier); |
|
| 71 | - |
|
| 72 | - $files = $this->getFileUids($folder); |
|
| 73 | - $collectedFiles = array_merge($collectedFiles, $files); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - $matcher->in('uid', $collectedFiles); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - $matcher->equals('storage', $identifier); |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @return bool |
|
| 86 | - */ |
|
| 87 | - protected function isPermissionNecessary() |
|
| 88 | - { |
|
| 89 | - $isNecessary = true; |
|
| 90 | - |
|
| 91 | - $parameters = GeneralUtility::_GET(VidiModule::getParameterPrefix()); |
|
| 92 | - |
|
| 93 | - if ($parameters['controller'] === 'Clipboard' && ($parameters['action'] === 'show' || $parameters['action'] === 'flush')) { |
|
| 94 | - $isNecessary = false; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if ($parameters['controller'] === 'Content' && ($parameters['action'] === 'copyClipboard' || $parameters['action'] === 'moveClipboard')) { |
|
| 98 | - $isNecessary = false; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $isNecessary; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @return bool |
|
| 106 | - */ |
|
| 107 | - protected function isFolderConsidered() |
|
| 108 | - { |
|
| 109 | - return $this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @param Folder $folder |
|
| 114 | - * @return array |
|
| 115 | - */ |
|
| 116 | - protected function getFileUids(Folder $folder) |
|
| 117 | - { |
|
| 118 | - $files = []; |
|
| 119 | - foreach ($folder->getFiles() as $file) { |
|
| 120 | - $files[] = $file->getUid(); |
|
| 121 | - } |
|
| 122 | - return $files; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Post-process the constraints object to respect the file mounts. |
|
| 127 | - * |
|
| 128 | - * @param Query $query |
|
| 129 | - * @param ConstraintInterface|null $constraints |
|
| 130 | - * @param ConstraintContainer $constraintContainer |
|
| 131 | - * @throws \InvalidArgumentException |
|
| 132 | - * @throws InvalidNumberOfConstraintsException |
|
| 133 | - */ |
|
| 134 | - public function addFilePermissionsForFileMounts(Query $query, $constraints, ConstraintContainer $constraintContainer) |
|
| 135 | - { |
|
| 136 | - if ($query->getType() === 'sys_file') { |
|
| 137 | - if (!$this->getCurrentBackendUser()->isAdmin()) { |
|
| 138 | - $this->respectFileMounts($query, $constraints, $constraintContainer); |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * @param Query $query |
|
| 145 | - * @param ConstraintInterface|null $constraints |
|
| 146 | - * @param ConstraintContainer $constraintContainer |
|
| 147 | - * @return array |
|
| 148 | - * @throws \InvalidArgumentException |
|
| 149 | - * @throws InvalidNumberOfConstraintsException |
|
| 150 | - */ |
|
| 151 | - protected function respectFileMounts(Query $query, $constraints, ConstraintContainer $constraintContainer) |
|
| 152 | - { |
|
| 153 | - $tableName = 'sys_filemounts'; |
|
| 154 | - |
|
| 155 | - // Get the file mount identifiers for the current Backend User. |
|
| 156 | - $fileMounts = GeneralUtility::trimExplode(',', $this->getCurrentBackendUser()->dataLists['filemount_list']); |
|
| 157 | - $fileMountUids = implode(',', array_filter($fileMounts)); |
|
| 158 | - |
|
| 159 | - // Fetch the records. |
|
| 160 | - $fileMountRecords = $this->getDataService()->getRecords( |
|
| 161 | - $tableName, |
|
| 162 | - [ |
|
| 163 | - 'uid' => $fileMountUids |
|
| 164 | - ] |
|
| 165 | - ); |
|
| 166 | - $constraintsRespectingFileMounts = []; |
|
| 167 | - foreach ((array)$fileMountRecords as $fileMountRecord) { |
|
| 168 | - if ($fileMountRecord['path']) { |
|
| 169 | - $constraintsRespectingFileMounts[] = $query->like( |
|
| 170 | - 'identifier', |
|
| 171 | - $fileMountRecord['path'] . '%' |
|
| 172 | - ); |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - $logicalOrForRespectingFileMounts = $query->logicalOr($constraintsRespectingFileMounts); |
|
| 177 | - |
|
| 178 | - if ($constraints) { |
|
| 179 | - $constraints = $query->logicalAnd([$constraints, $logicalOrForRespectingFileMounts]); |
|
| 180 | - } else { |
|
| 181 | - $constraints = $logicalOrForRespectingFileMounts; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - $constraintContainer->setConstraint($constraints); |
|
| 185 | - |
|
| 186 | - return [$query, $constraints, $constraintContainer]; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * @return BackendUserAuthentication |
|
| 191 | - */ |
|
| 192 | - protected function getCurrentBackendUser() |
|
| 193 | - { |
|
| 194 | - return $GLOBALS['BE_USER']; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * @return object|DataService |
|
| 199 | - */ |
|
| 200 | - protected function getDataService(): DataService |
|
| 201 | - { |
|
| 202 | - return GeneralUtility::makeInstance(DataService::class); |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * @return MediaModule|object |
|
| 207 | - * @throws \InvalidArgumentException |
|
| 208 | - */ |
|
| 209 | - protected function getMediaModule() |
|
| 210 | - { |
|
| 211 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * Get the Vidi Module Loader. |
|
| 216 | - * |
|
| 217 | - * @return object|ModuleLoader |
|
| 218 | - */ |
|
| 219 | - protected function getModuleLoader() |
|
| 220 | - { |
|
| 221 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - protected function getResourceFactory(): ResourceFactory |
|
| 225 | - { |
|
| 226 | - return GeneralUtility::makeInstance(ResourceFactory::class); |
|
| 227 | - } |
|
| 30 | + /** |
|
| 31 | + * Post-process the matcher object to respect the file storages. |
|
| 32 | + * |
|
| 33 | + * @param Matcher $matcher |
|
| 34 | + * @param string $dataType |
|
| 35 | + * @return void |
|
| 36 | + * @throws \InvalidArgumentException |
|
| 37 | + */ |
|
| 38 | + public function addFilePermissionsForFileStorages(Matcher $matcher, $dataType) |
|
| 39 | + { |
|
| 40 | + if ($dataType === 'sys_file' && $this->isPermissionNecessary()) { |
|
| 41 | + if ($this->isFolderConsidered()) { |
|
| 42 | + $folder = $this->getMediaModule()->getCurrentFolder(); |
|
| 43 | + |
|
| 44 | + if ($this->getMediaModule()->hasRecursiveSelection()) { |
|
| 45 | + // Only add like condition if needed. |
|
| 46 | + if ($folder->getStorage()->getRootLevelFolder() !== $folder) { |
|
| 47 | + $matcher->like('identifier', $folder->getIdentifier() . '%', $automaticallyAddWildCard = false); |
|
| 48 | + } |
|
| 49 | + } else { |
|
| 50 | + // Browse only currently |
|
| 51 | + $files = $this->getFileUids($folder); |
|
| 52 | + $matcher->in('uid', $files); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + $matcher->equals('storage', $folder->getStorage()->getUid()); |
|
| 56 | + } else { |
|
| 57 | + $storage = $this->getMediaModule()->getCurrentStorage(); |
|
| 58 | + |
|
| 59 | + // Set the storage identifier only if the storage is on-line. |
|
| 60 | + $identifier = -1; |
|
| 61 | + if ($storage->isOnline()) { |
|
| 62 | + $identifier = $storage->getUid(); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + if ($this->getModuleLoader()->hasPlugin() && !$this->getCurrentBackendUser()->isAdmin()) { |
|
| 66 | + $fileMounts = $this->getCurrentBackendUser()->getFileMountRecords(); |
|
| 67 | + $collectedFiles = []; |
|
| 68 | + foreach ($fileMounts as $fileMount) { |
|
| 69 | + $combinedIdentifier = $fileMount['base'] . ':' . $fileMount['path']; |
|
| 70 | + $folder = $this->getResourceFactory()->getFolderObjectFromCombinedIdentifier($combinedIdentifier); |
|
| 71 | + |
|
| 72 | + $files = $this->getFileUids($folder); |
|
| 73 | + $collectedFiles = array_merge($collectedFiles, $files); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + $matcher->in('uid', $collectedFiles); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + $matcher->equals('storage', $identifier); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @return bool |
|
| 86 | + */ |
|
| 87 | + protected function isPermissionNecessary() |
|
| 88 | + { |
|
| 89 | + $isNecessary = true; |
|
| 90 | + |
|
| 91 | + $parameters = GeneralUtility::_GET(VidiModule::getParameterPrefix()); |
|
| 92 | + |
|
| 93 | + if ($parameters['controller'] === 'Clipboard' && ($parameters['action'] === 'show' || $parameters['action'] === 'flush')) { |
|
| 94 | + $isNecessary = false; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if ($parameters['controller'] === 'Content' && ($parameters['action'] === 'copyClipboard' || $parameters['action'] === 'moveClipboard')) { |
|
| 98 | + $isNecessary = false; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + return $isNecessary; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @return bool |
|
| 106 | + */ |
|
| 107 | + protected function isFolderConsidered() |
|
| 108 | + { |
|
| 109 | + return $this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @param Folder $folder |
|
| 114 | + * @return array |
|
| 115 | + */ |
|
| 116 | + protected function getFileUids(Folder $folder) |
|
| 117 | + { |
|
| 118 | + $files = []; |
|
| 119 | + foreach ($folder->getFiles() as $file) { |
|
| 120 | + $files[] = $file->getUid(); |
|
| 121 | + } |
|
| 122 | + return $files; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Post-process the constraints object to respect the file mounts. |
|
| 127 | + * |
|
| 128 | + * @param Query $query |
|
| 129 | + * @param ConstraintInterface|null $constraints |
|
| 130 | + * @param ConstraintContainer $constraintContainer |
|
| 131 | + * @throws \InvalidArgumentException |
|
| 132 | + * @throws InvalidNumberOfConstraintsException |
|
| 133 | + */ |
|
| 134 | + public function addFilePermissionsForFileMounts(Query $query, $constraints, ConstraintContainer $constraintContainer) |
|
| 135 | + { |
|
| 136 | + if ($query->getType() === 'sys_file') { |
|
| 137 | + if (!$this->getCurrentBackendUser()->isAdmin()) { |
|
| 138 | + $this->respectFileMounts($query, $constraints, $constraintContainer); |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * @param Query $query |
|
| 145 | + * @param ConstraintInterface|null $constraints |
|
| 146 | + * @param ConstraintContainer $constraintContainer |
|
| 147 | + * @return array |
|
| 148 | + * @throws \InvalidArgumentException |
|
| 149 | + * @throws InvalidNumberOfConstraintsException |
|
| 150 | + */ |
|
| 151 | + protected function respectFileMounts(Query $query, $constraints, ConstraintContainer $constraintContainer) |
|
| 152 | + { |
|
| 153 | + $tableName = 'sys_filemounts'; |
|
| 154 | + |
|
| 155 | + // Get the file mount identifiers for the current Backend User. |
|
| 156 | + $fileMounts = GeneralUtility::trimExplode(',', $this->getCurrentBackendUser()->dataLists['filemount_list']); |
|
| 157 | + $fileMountUids = implode(',', array_filter($fileMounts)); |
|
| 158 | + |
|
| 159 | + // Fetch the records. |
|
| 160 | + $fileMountRecords = $this->getDataService()->getRecords( |
|
| 161 | + $tableName, |
|
| 162 | + [ |
|
| 163 | + 'uid' => $fileMountUids |
|
| 164 | + ] |
|
| 165 | + ); |
|
| 166 | + $constraintsRespectingFileMounts = []; |
|
| 167 | + foreach ((array)$fileMountRecords as $fileMountRecord) { |
|
| 168 | + if ($fileMountRecord['path']) { |
|
| 169 | + $constraintsRespectingFileMounts[] = $query->like( |
|
| 170 | + 'identifier', |
|
| 171 | + $fileMountRecord['path'] . '%' |
|
| 172 | + ); |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + $logicalOrForRespectingFileMounts = $query->logicalOr($constraintsRespectingFileMounts); |
|
| 177 | + |
|
| 178 | + if ($constraints) { |
|
| 179 | + $constraints = $query->logicalAnd([$constraints, $logicalOrForRespectingFileMounts]); |
|
| 180 | + } else { |
|
| 181 | + $constraints = $logicalOrForRespectingFileMounts; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + $constraintContainer->setConstraint($constraints); |
|
| 185 | + |
|
| 186 | + return [$query, $constraints, $constraintContainer]; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * @return BackendUserAuthentication |
|
| 191 | + */ |
|
| 192 | + protected function getCurrentBackendUser() |
|
| 193 | + { |
|
| 194 | + return $GLOBALS['BE_USER']; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * @return object|DataService |
|
| 199 | + */ |
|
| 200 | + protected function getDataService(): DataService |
|
| 201 | + { |
|
| 202 | + return GeneralUtility::makeInstance(DataService::class); |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * @return MediaModule|object |
|
| 207 | + * @throws \InvalidArgumentException |
|
| 208 | + */ |
|
| 209 | + protected function getMediaModule() |
|
| 210 | + { |
|
| 211 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * Get the Vidi Module Loader. |
|
| 216 | + * |
|
| 217 | + * @return object|ModuleLoader |
|
| 218 | + */ |
|
| 219 | + protected function getModuleLoader() |
|
| 220 | + { |
|
| 221 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + protected function getResourceFactory(): ResourceFactory |
|
| 225 | + { |
|
| 226 | + return GeneralUtility::makeInstance(ResourceFactory::class); |
|
| 227 | + } |
|
| 228 | 228 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | if ($this->getMediaModule()->hasRecursiveSelection()) { |
| 45 | 45 | // Only add like condition if needed. |
| 46 | 46 | if ($folder->getStorage()->getRootLevelFolder() !== $folder) { |
| 47 | - $matcher->like('identifier', $folder->getIdentifier() . '%', $automaticallyAddWildCard = false); |
|
| 47 | + $matcher->like('identifier', $folder->getIdentifier().'%', $automaticallyAddWildCard = false); |
|
| 48 | 48 | } |
| 49 | 49 | } else { |
| 50 | 50 | // Browse only currently |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $fileMounts = $this->getCurrentBackendUser()->getFileMountRecords(); |
| 67 | 67 | $collectedFiles = []; |
| 68 | 68 | foreach ($fileMounts as $fileMount) { |
| 69 | - $combinedIdentifier = $fileMount['base'] . ':' . $fileMount['path']; |
|
| 69 | + $combinedIdentifier = $fileMount['base'].':'.$fileMount['path']; |
|
| 70 | 70 | $folder = $this->getResourceFactory()->getFolderObjectFromCombinedIdentifier($combinedIdentifier); |
| 71 | 71 | |
| 72 | 72 | $files = $this->getFileUids($folder); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | if ($fileMountRecord['path']) { |
| 169 | 169 | $constraintsRespectingFileMounts[] = $query->like( |
| 170 | 170 | 'identifier', |
| 171 | - $fileMountRecord['path'] . '%' |
|
| 171 | + $fileMountRecord['path'].'%' |
|
| 172 | 172 | ); |
| 173 | 173 | } |
| 174 | 174 | } |