@@ -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 | } |
@@ -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 | } |
@@ -27,152 +27,152 @@ |
||
27 | 27 | */ |
28 | 28 | class FilePermissionsAspect |
29 | 29 | { |
30 | - /** |
|
31 | - * Post-process the matcher object to respect the file storages. |
|
32 | - */ |
|
33 | - public function addFilePermissionsForFileStorages(Matcher $matcher, string $dataType): void |
|
34 | - { |
|
35 | - if ($dataType === 'sys_file' && $this->isPermissionNecessary()) { |
|
36 | - if ($this->isFolderConsidered()) { |
|
37 | - $folder = $this->getMediaModule()->getCurrentFolder(); |
|
38 | - |
|
39 | - if ($this->getMediaModule()->hasRecursiveSelection()) { |
|
40 | - // Only add like condition if needed. |
|
41 | - if ($folder->getStorage()->getRootLevelFolder() !== $folder) { |
|
42 | - $matcher->like('identifier', $folder->getIdentifier() . '%', $automaticallyAddWildCard = false); |
|
43 | - } |
|
44 | - } else { |
|
45 | - // Browse only currently |
|
46 | - $files = $this->getFileUids($folder); |
|
47 | - $matcher->in('uid', $files); |
|
48 | - } |
|
49 | - |
|
50 | - $matcher->equals('storage', $folder->getStorage()->getUid()); |
|
51 | - } else { |
|
52 | - $storage = $this->getMediaModule()->getCurrentStorage(); |
|
53 | - |
|
54 | - // Set the storage identifier only if the storage is on-line. |
|
55 | - $identifier = -1; |
|
56 | - if ($storage->isOnline()) { |
|
57 | - $identifier = $storage->getUid(); |
|
58 | - } |
|
59 | - |
|
60 | - if ($this->getModuleLoader()->hasPlugin() && !$this->getCurrentBackendUser()->isAdmin()) { |
|
61 | - $fileMounts = $this->getCurrentBackendUser()->getFileMountRecords(); |
|
62 | - $collectedFiles = []; |
|
63 | - foreach ($fileMounts as $fileMount) { |
|
64 | - $combinedIdentifier = $fileMount['base'] . ':' . $fileMount['path']; |
|
65 | - $folder = $this->getResourceFactory()->getFolderObjectFromCombinedIdentifier($combinedIdentifier); |
|
66 | - |
|
67 | - $files = $this->getFileUids($folder); |
|
68 | - $collectedFiles = array_merge($collectedFiles, $files); |
|
69 | - } |
|
70 | - |
|
71 | - $matcher->in('uid', $collectedFiles); |
|
72 | - } |
|
73 | - |
|
74 | - $matcher->equals('storage', $identifier); |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - protected function isPermissionNecessary(): bool |
|
80 | - { |
|
81 | - $isNecessary = true; |
|
82 | - |
|
83 | - $parameters = GeneralUtility::_GET(VidiModule::getParameterPrefix()); |
|
84 | - |
|
85 | - if ($parameters['controller'] === 'Clipboard' && ($parameters['action'] === 'show' || $parameters['action'] === 'flush')) { |
|
86 | - $isNecessary = false; |
|
87 | - } |
|
88 | - |
|
89 | - if ($parameters['controller'] === 'Content' && ($parameters['action'] === 'copyClipboard' || $parameters['action'] === 'moveClipboard')) { |
|
90 | - $isNecessary = false; |
|
91 | - } |
|
92 | - |
|
93 | - return $isNecessary; |
|
94 | - } |
|
95 | - |
|
96 | - protected function isFolderConsidered(): bool |
|
97 | - { |
|
98 | - return $this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin(); |
|
99 | - } |
|
100 | - |
|
101 | - protected function getFileUids(Folder $folder): array |
|
102 | - { |
|
103 | - $files = []; |
|
104 | - foreach ($folder->getFiles() as $file) { |
|
105 | - $files[] = $file->getUid(); |
|
106 | - } |
|
107 | - return $files; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Post-process the constraints object to respect the file mounts. |
|
112 | - * |
|
113 | - * @param ConstraintInterface|null $constraints |
|
114 | - */ |
|
115 | - public function addFilePermissionsForFileMounts(Query $query, $constraints, ConstraintContainer $constraintContainer): void |
|
116 | - { |
|
117 | - if ($query->getType() === 'sys_file') { |
|
118 | - if (!$this->getCurrentBackendUser()->isAdmin()) { |
|
119 | - $this->respectFileMounts($query, $constraints, $constraintContainer); |
|
120 | - } |
|
121 | - } |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @param ConstraintInterface|null $constraints |
|
126 | - */ |
|
127 | - protected function respectFileMounts(Query $query, $constraints, ConstraintContainer $constraintContainer): array |
|
128 | - { |
|
129 | - // Get the file mount identifiers for the current Backend User. |
|
130 | - $fileMountRecords = $this->getCurrentBackendUser()->getFileMountRecords(); |
|
131 | - $constraintsRespectingFileMounts = []; |
|
132 | - foreach ((array)$fileMountRecords as $fileMountRecord) { |
|
133 | - if ($fileMountRecord['path']) { |
|
134 | - $constraintsRespectingFileMounts[] = $query->like( |
|
135 | - 'identifier', |
|
136 | - $fileMountRecord['path'] . '%' |
|
137 | - ); |
|
138 | - } |
|
139 | - } |
|
140 | - |
|
141 | - $logicalOrForRespectingFileMounts = $query->logicalOr($constraintsRespectingFileMounts); |
|
142 | - |
|
143 | - if ($constraints) { |
|
144 | - $constraints = $query->logicalAnd([$constraints, $logicalOrForRespectingFileMounts]); |
|
145 | - } else { |
|
146 | - $constraints = $logicalOrForRespectingFileMounts; |
|
147 | - } |
|
148 | - |
|
149 | - $constraintContainer->setConstraint($constraints); |
|
150 | - |
|
151 | - return [$query, $constraints, $constraintContainer]; |
|
152 | - } |
|
153 | - |
|
154 | - protected function getCurrentBackendUser(): BackendUserAuthentication |
|
155 | - { |
|
156 | - return $GLOBALS['BE_USER']; |
|
157 | - } |
|
158 | - |
|
159 | - protected function getDataService(): DataService |
|
160 | - { |
|
161 | - return GeneralUtility::makeInstance(DataService::class); |
|
162 | - } |
|
163 | - |
|
164 | - protected function getMediaModule(): MediaModule |
|
165 | - { |
|
166 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
167 | - } |
|
168 | - |
|
169 | - protected function getModuleLoader(): ModuleLoader |
|
170 | - { |
|
171 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
172 | - } |
|
173 | - |
|
174 | - protected function getResourceFactory(): ResourceFactory |
|
175 | - { |
|
176 | - return GeneralUtility::makeInstance(ResourceFactory::class); |
|
177 | - } |
|
30 | + /** |
|
31 | + * Post-process the matcher object to respect the file storages. |
|
32 | + */ |
|
33 | + public function addFilePermissionsForFileStorages(Matcher $matcher, string $dataType): void |
|
34 | + { |
|
35 | + if ($dataType === 'sys_file' && $this->isPermissionNecessary()) { |
|
36 | + if ($this->isFolderConsidered()) { |
|
37 | + $folder = $this->getMediaModule()->getCurrentFolder(); |
|
38 | + |
|
39 | + if ($this->getMediaModule()->hasRecursiveSelection()) { |
|
40 | + // Only add like condition if needed. |
|
41 | + if ($folder->getStorage()->getRootLevelFolder() !== $folder) { |
|
42 | + $matcher->like('identifier', $folder->getIdentifier() . '%', $automaticallyAddWildCard = false); |
|
43 | + } |
|
44 | + } else { |
|
45 | + // Browse only currently |
|
46 | + $files = $this->getFileUids($folder); |
|
47 | + $matcher->in('uid', $files); |
|
48 | + } |
|
49 | + |
|
50 | + $matcher->equals('storage', $folder->getStorage()->getUid()); |
|
51 | + } else { |
|
52 | + $storage = $this->getMediaModule()->getCurrentStorage(); |
|
53 | + |
|
54 | + // Set the storage identifier only if the storage is on-line. |
|
55 | + $identifier = -1; |
|
56 | + if ($storage->isOnline()) { |
|
57 | + $identifier = $storage->getUid(); |
|
58 | + } |
|
59 | + |
|
60 | + if ($this->getModuleLoader()->hasPlugin() && !$this->getCurrentBackendUser()->isAdmin()) { |
|
61 | + $fileMounts = $this->getCurrentBackendUser()->getFileMountRecords(); |
|
62 | + $collectedFiles = []; |
|
63 | + foreach ($fileMounts as $fileMount) { |
|
64 | + $combinedIdentifier = $fileMount['base'] . ':' . $fileMount['path']; |
|
65 | + $folder = $this->getResourceFactory()->getFolderObjectFromCombinedIdentifier($combinedIdentifier); |
|
66 | + |
|
67 | + $files = $this->getFileUids($folder); |
|
68 | + $collectedFiles = array_merge($collectedFiles, $files); |
|
69 | + } |
|
70 | + |
|
71 | + $matcher->in('uid', $collectedFiles); |
|
72 | + } |
|
73 | + |
|
74 | + $matcher->equals('storage', $identifier); |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + protected function isPermissionNecessary(): bool |
|
80 | + { |
|
81 | + $isNecessary = true; |
|
82 | + |
|
83 | + $parameters = GeneralUtility::_GET(VidiModule::getParameterPrefix()); |
|
84 | + |
|
85 | + if ($parameters['controller'] === 'Clipboard' && ($parameters['action'] === 'show' || $parameters['action'] === 'flush')) { |
|
86 | + $isNecessary = false; |
|
87 | + } |
|
88 | + |
|
89 | + if ($parameters['controller'] === 'Content' && ($parameters['action'] === 'copyClipboard' || $parameters['action'] === 'moveClipboard')) { |
|
90 | + $isNecessary = false; |
|
91 | + } |
|
92 | + |
|
93 | + return $isNecessary; |
|
94 | + } |
|
95 | + |
|
96 | + protected function isFolderConsidered(): bool |
|
97 | + { |
|
98 | + return $this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin(); |
|
99 | + } |
|
100 | + |
|
101 | + protected function getFileUids(Folder $folder): array |
|
102 | + { |
|
103 | + $files = []; |
|
104 | + foreach ($folder->getFiles() as $file) { |
|
105 | + $files[] = $file->getUid(); |
|
106 | + } |
|
107 | + return $files; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Post-process the constraints object to respect the file mounts. |
|
112 | + * |
|
113 | + * @param ConstraintInterface|null $constraints |
|
114 | + */ |
|
115 | + public function addFilePermissionsForFileMounts(Query $query, $constraints, ConstraintContainer $constraintContainer): void |
|
116 | + { |
|
117 | + if ($query->getType() === 'sys_file') { |
|
118 | + if (!$this->getCurrentBackendUser()->isAdmin()) { |
|
119 | + $this->respectFileMounts($query, $constraints, $constraintContainer); |
|
120 | + } |
|
121 | + } |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @param ConstraintInterface|null $constraints |
|
126 | + */ |
|
127 | + protected function respectFileMounts(Query $query, $constraints, ConstraintContainer $constraintContainer): array |
|
128 | + { |
|
129 | + // Get the file mount identifiers for the current Backend User. |
|
130 | + $fileMountRecords = $this->getCurrentBackendUser()->getFileMountRecords(); |
|
131 | + $constraintsRespectingFileMounts = []; |
|
132 | + foreach ((array)$fileMountRecords as $fileMountRecord) { |
|
133 | + if ($fileMountRecord['path']) { |
|
134 | + $constraintsRespectingFileMounts[] = $query->like( |
|
135 | + 'identifier', |
|
136 | + $fileMountRecord['path'] . '%' |
|
137 | + ); |
|
138 | + } |
|
139 | + } |
|
140 | + |
|
141 | + $logicalOrForRespectingFileMounts = $query->logicalOr($constraintsRespectingFileMounts); |
|
142 | + |
|
143 | + if ($constraints) { |
|
144 | + $constraints = $query->logicalAnd([$constraints, $logicalOrForRespectingFileMounts]); |
|
145 | + } else { |
|
146 | + $constraints = $logicalOrForRespectingFileMounts; |
|
147 | + } |
|
148 | + |
|
149 | + $constraintContainer->setConstraint($constraints); |
|
150 | + |
|
151 | + return [$query, $constraints, $constraintContainer]; |
|
152 | + } |
|
153 | + |
|
154 | + protected function getCurrentBackendUser(): BackendUserAuthentication |
|
155 | + { |
|
156 | + return $GLOBALS['BE_USER']; |
|
157 | + } |
|
158 | + |
|
159 | + protected function getDataService(): DataService |
|
160 | + { |
|
161 | + return GeneralUtility::makeInstance(DataService::class); |
|
162 | + } |
|
163 | + |
|
164 | + protected function getMediaModule(): MediaModule |
|
165 | + { |
|
166 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
167 | + } |
|
168 | + |
|
169 | + protected function getModuleLoader(): ModuleLoader |
|
170 | + { |
|
171 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
172 | + } |
|
173 | + |
|
174 | + protected function getResourceFactory(): ResourceFactory |
|
175 | + { |
|
176 | + return GeneralUtility::makeInstance(ResourceFactory::class); |
|
177 | + } |
|
178 | 178 | } |
@@ -20,39 +20,39 @@ |
||
20 | 20 | */ |
21 | 21 | class FileUploadHook implements ExtendedFileUtilityProcessDataHookInterface |
22 | 22 | { |
23 | - /** |
|
24 | - * @param string $action The action |
|
25 | - * @param array $cmdArr The parameter sent to the action handler |
|
26 | - * @param array $result The results of all calls to the action handler |
|
27 | - * @param ExtendedFileUtility $pObj The parent object |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function processData_postProcessAction($action, array $cmdArr, array $result, ExtendedFileUtility $pObj) |
|
31 | - { |
|
32 | - if ($action === 'upload') { |
|
33 | - /** @var File[] $files */ |
|
34 | - $files = array_pop($result); |
|
35 | - if (!is_array($files)) { |
|
36 | - return; |
|
37 | - } |
|
23 | + /** |
|
24 | + * @param string $action The action |
|
25 | + * @param array $cmdArr The parameter sent to the action handler |
|
26 | + * @param array $result The results of all calls to the action handler |
|
27 | + * @param ExtendedFileUtility $pObj The parent object |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function processData_postProcessAction($action, array $cmdArr, array $result, ExtendedFileUtility $pObj) |
|
31 | + { |
|
32 | + if ($action === 'upload') { |
|
33 | + /** @var File[] $files */ |
|
34 | + $files = array_pop($result); |
|
35 | + if (!is_array($files)) { |
|
36 | + return; |
|
37 | + } |
|
38 | 38 | |
39 | - foreach ($files as $file) { |
|
40 | - // Run the indexer for extracting metadata. |
|
41 | - $this->getMediaIndexer($file->getStorage()) |
|
42 | - ->extractMetadata($file) |
|
43 | - ->applyDefaultCategories($file); |
|
44 | - } |
|
45 | - } |
|
46 | - } |
|
39 | + foreach ($files as $file) { |
|
40 | + // Run the indexer for extracting metadata. |
|
41 | + $this->getMediaIndexer($file->getStorage()) |
|
42 | + ->extractMetadata($file) |
|
43 | + ->applyDefaultCategories($file); |
|
44 | + } |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Get the instance of the Indexer service to update the metadata of the file. |
|
50 | - * |
|
51 | - * @param ResourceStorage $storage |
|
52 | - * @return MediaIndexer|object |
|
53 | - */ |
|
54 | - protected function getMediaIndexer($storage) |
|
55 | - { |
|
56 | - return GeneralUtility::makeInstance(MediaIndexer::class, $storage); |
|
57 | - } |
|
48 | + /** |
|
49 | + * Get the instance of the Indexer service to update the metadata of the file. |
|
50 | + * |
|
51 | + * @param ResourceStorage $storage |
|
52 | + * @return MediaIndexer|object |
|
53 | + */ |
|
54 | + protected function getMediaIndexer($storage) |
|
55 | + { |
|
56 | + return GeneralUtility::makeInstance(MediaIndexer::class, $storage); |
|
57 | + } |
|
58 | 58 | } |
@@ -9,35 +9,35 @@ |
||
9 | 9 | defined('TYPO3') or die(); |
10 | 10 | |
11 | 11 | call_user_func(function () { |
12 | - $configuration = GeneralUtility::makeInstance( |
|
13 | - ExtensionConfiguration::class |
|
14 | - )->get('media'); |
|
15 | - |
|
16 | - $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1547054767] = [ |
|
17 | - 'nodeName' => 'findUploader', |
|
18 | - 'priority' => 40, |
|
19 | - 'class' => TceForms::class, |
|
20 | - ]; |
|
21 | - |
|
22 | - $disableTitleMetadataExtractor = isset($configuration['disable_title_metadata_extractor']) ? $configuration['disable_title_metadata_extractor'] : false; |
|
23 | - if (!$disableTitleMetadataExtractor) { |
|
24 | - // Register basic metadata extractor. Will feed the file with a "title" when indexing, e.g. upload, through scheduler |
|
25 | - GeneralUtility::makeInstance(ExtractorRegistry::class)->registerExtractionService(TitleMetadataExtractor::class); |
|
26 | - } |
|
27 | - |
|
28 | - // Hook for traditional file upload, trigger metadata indexing as well. |
|
29 | - // Could be done at the Core level in the future... |
|
30 | - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_extfilefunc.php']['processData'][] = 'Fab\Media\Hook\FileUploadHook'; |
|
31 | - |
|
32 | - |
|
33 | - // Special process to fill column "usage" which indicates the total number of file reference including soft references. |
|
34 | - $GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'Fab\Media\Hook\DataHandlerHook'; |
|
35 | - |
|
36 | - $hasMediaFilePicker = isset($configuration['has_media_file_picker']) ? $configuration['has_media_file_picker'] : false; |
|
37 | - if ($hasMediaFilePicker) { |
|
38 | - // Override classes for the Object Manager. |
|
39 | - $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][FormResultCompiler::class] = array( |
|
40 | - 'className' => \Fab\Media\Override\Backend\Form\FormResultCompiler::class |
|
41 | - ); |
|
42 | - } |
|
12 | + $configuration = GeneralUtility::makeInstance( |
|
13 | + ExtensionConfiguration::class |
|
14 | + )->get('media'); |
|
15 | + |
|
16 | + $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1547054767] = [ |
|
17 | + 'nodeName' => 'findUploader', |
|
18 | + 'priority' => 40, |
|
19 | + 'class' => TceForms::class, |
|
20 | + ]; |
|
21 | + |
|
22 | + $disableTitleMetadataExtractor = isset($configuration['disable_title_metadata_extractor']) ? $configuration['disable_title_metadata_extractor'] : false; |
|
23 | + if (!$disableTitleMetadataExtractor) { |
|
24 | + // Register basic metadata extractor. Will feed the file with a "title" when indexing, e.g. upload, through scheduler |
|
25 | + GeneralUtility::makeInstance(ExtractorRegistry::class)->registerExtractionService(TitleMetadataExtractor::class); |
|
26 | + } |
|
27 | + |
|
28 | + // Hook for traditional file upload, trigger metadata indexing as well. |
|
29 | + // Could be done at the Core level in the future... |
|
30 | + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_extfilefunc.php']['processData'][] = 'Fab\Media\Hook\FileUploadHook'; |
|
31 | + |
|
32 | + |
|
33 | + // Special process to fill column "usage" which indicates the total number of file reference including soft references. |
|
34 | + $GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'Fab\Media\Hook\DataHandlerHook'; |
|
35 | + |
|
36 | + $hasMediaFilePicker = isset($configuration['has_media_file_picker']) ? $configuration['has_media_file_picker'] : false; |
|
37 | + if ($hasMediaFilePicker) { |
|
38 | + // Override classes for the Object Manager. |
|
39 | + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][FormResultCompiler::class] = array( |
|
40 | + 'className' => \Fab\Media\Override\Backend\Form\FormResultCompiler::class |
|
41 | + ); |
|
42 | + } |
|
43 | 43 | }); |
@@ -8,7 +8,7 @@ |
||
8 | 8 | use TYPO3\CMS\Backend\Form\FormResultCompiler; |
9 | 9 | defined('TYPO3') or die(); |
10 | 10 | |
11 | -call_user_func(function () { |
|
11 | +call_user_func(function() { |
|
12 | 12 | $configuration = GeneralUtility::makeInstance( |
13 | 13 | ExtensionConfiguration::class |
14 | 14 | )->get('media'); |
@@ -4,36 +4,36 @@ |
||
4 | 4 | use TYPO3\CMS\Core\Utility\ArrayUtility; |
5 | 5 | |
6 | 6 | if (!defined('TYPO3')) { |
7 | - die('Access denied.'); |
|
7 | + die('Access denied.'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | // We only want to have file relations if extension File advanced metadata is loaded. |
11 | 11 | if (ExtensionManagementUtility::isLoaded('filemetadata')) { |
12 | - $configuration = '--div--;LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:tab.relations, related_files'; |
|
13 | - ExtensionManagementUtility::addToAllTCAtypes('sys_file_metadata', $configuration); |
|
12 | + $configuration = '--div--;LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:tab.relations, related_files'; |
|
13 | + ExtensionManagementUtility::addToAllTCAtypes('sys_file_metadata', $configuration); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | $tca = [ |
17 | - 'ctrl' => [ |
|
18 | - 'default_sortby' => 'ORDER BY uid DESC', |
|
19 | - 'searchFields' => 'uid,extension,name', // sys_file_metadata.title,sys_file_metadata.keywords, |
|
20 | - ], |
|
21 | - 'columns' => [ |
|
22 | - 'fileinfo' => [ |
|
23 | - 'config' => [ |
|
24 | - 'type' => 'user', |
|
25 | - 'renderType' => 'findUploader', |
|
26 | - ], |
|
27 | - ], |
|
28 | - 'related_files' => [ |
|
29 | - 'displayCond' => 'FIELD:sys_language_uid:<=:0', |
|
30 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_metadata.relations', |
|
31 | - 'config' => ExtensionManagementUtility::getFileFieldTCAConfig( |
|
32 | - 'related_files', |
|
33 | - [], |
|
34 | - '' |
|
35 | - ), |
|
36 | - ], |
|
37 | - ], |
|
17 | + 'ctrl' => [ |
|
18 | + 'default_sortby' => 'ORDER BY uid DESC', |
|
19 | + 'searchFields' => 'uid,extension,name', // sys_file_metadata.title,sys_file_metadata.keywords, |
|
20 | + ], |
|
21 | + 'columns' => [ |
|
22 | + 'fileinfo' => [ |
|
23 | + 'config' => [ |
|
24 | + 'type' => 'user', |
|
25 | + 'renderType' => 'findUploader', |
|
26 | + ], |
|
27 | + ], |
|
28 | + 'related_files' => [ |
|
29 | + 'displayCond' => 'FIELD:sys_language_uid:<=:0', |
|
30 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang_db.xlf:sys_file_metadata.relations', |
|
31 | + 'config' => ExtensionManagementUtility::getFileFieldTCAConfig( |
|
32 | + 'related_files', |
|
33 | + [], |
|
34 | + '' |
|
35 | + ), |
|
36 | + ], |
|
37 | + ], |
|
38 | 38 | ]; |
39 | 39 | ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA']['sys_file_metadata'], $tca); |
@@ -3,13 +3,13 @@ |
||
3 | 3 | use TYPO3\CMS\Core\Utility\ArrayUtility; |
4 | 4 | |
5 | 5 | if (!defined('TYPO3')) { |
6 | - die('Access denied.'); |
|
6 | + die('Access denied.'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $tca = [ |
10 | - 'ctrl' => [ |
|
11 | - 'rootLevel' => -1, // Otherwise File Reference will not work between files. |
|
12 | - ], |
|
10 | + 'ctrl' => [ |
|
11 | + 'rootLevel' => -1, // Otherwise File Reference will not work between files. |
|
12 | + ], |
|
13 | 13 | ]; |
14 | 14 | |
15 | 15 | // Disable the File Upload in IRRE since it can not be configured the target storage. |