Completed
Push — master ( b0b1c6...4fec92 )
by Fabien
54:17
created
Classes/Security/FilePermissionsAspect.php 2 patches
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -27,202 +27,202 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Classes/Hook/DataHandlerHook.php 1 patch
Indentation   +306 added lines, -306 removed lines patch added patch discarded remove patch
@@ -25,310 +25,310 @@
 block discarded – undo
25 25
  */
26 26
 class DataHandlerHook
27 27
 {
28
-    /**
29
-     * Store indexed file before the Data Handler start "working".
30
-     *
31
-     * @var array
32
-     */
33
-    protected $beforeDataHandlerProcessFileIdentifiers = [];
34
-
35
-    /**
36
-     * Store indexed file after the Data Handler has done its job.
37
-     *
38
-     * @var array
39
-     */
40
-    protected $afterDataHandlerProcessFileIdentifiers = [];
41
-
42
-    /**
43
-     * Internal key for the Cache Manager.
44
-     *
45
-     * @var string
46
-     */
47
-    protected $registerKey = 'media-hook-elementsToKeepTrack';
48
-
49
-    /**
50
-     * First procedures to launch before all operations in DataHandler.
51
-     *
52
-     * Feed variable $this->beforeDataHandlerProcessFileIdentifiers
53
-     *
54
-     * @param DataHandler $caller TCEMain Object
55
-     * @return void
56
-     */
57
-    public function processDatamap_beforeStart(DataHandler $caller)
58
-    {
59
-        // Use a register to keep track of files.
60
-        // It is required according to TCEMain behaviour which register "elements to be deleted".
61
-        // Those element must not be forgotten.
62
-        $this->initializeFileRegister();
63
-        $this->registerFilesToKeepTrack();
64
-
65
-        foreach ($caller->datamap as $tableName => $configuration) {
66
-            $id = key($configuration);
67
-            if (!MathUtility::canBeInterpretedAsInteger($id)) {
68
-                continue;
69
-            }
70
-
71
-            /** @var $refIndexObj \TYPO3\CMS\Core\Database\ReferenceIndex */
72
-            $refIndexObj = GeneralUtility::makeInstance(ReferenceIndex::class);
73
-            if (BackendUtility::isTableWorkspaceEnabled($tableName)) {
74
-                $refIndexObj->setWorkspaceId($caller->BE_USER->workspace);
75
-            }
76
-            $indexes = $refIndexObj->updateRefIndexTable($tableName, $id);
77
-
78
-            // Make sure $index is an array.
79
-            if (!is_array($indexes)) {
80
-                $indexes = [];
81
-            }
82
-
83
-            try {
84
-                $fileIdentifiers = $this->lookForFiles($indexes);
85
-                $this->addBeforeDataHandlerProcessFileIdentifiers($fileIdentifiers);
86
-            } catch (\Exception $e) {
87
-                // do nothing
88
-            }
89
-        }
90
-    }
91
-
92
-    /**
93
-     * Last procedures to launch after all operations in DataHandler.
94
-     *
95
-     * Process field "number_of_references" which may require updates.
96
-     *
97
-     * @param DataHandler $caller TCEMain Object
98
-     * @return void
99
-     */
100
-    public function processDatamap_afterAllOperations(DataHandler $caller)
101
-    {
102
-        // First collect files which have been involved.
103
-        foreach ($caller->datamap as $tableName => $configuration) {
104
-            $id = key($configuration);
105
-
106
-            /** @var $refIndexObj \TYPO3\CMS\Core\Database\ReferenceIndex */
107
-            $refIndexObj = GeneralUtility::makeInstance(ReferenceIndex::class);
108
-            if (BackendUtility::isTableWorkspaceEnabled($tableName)) {
109
-                $refIndexObj->setWorkspaceId($caller->BE_USER->workspace);
110
-            }
111
-            $indexes = $refIndexObj->updateRefIndexTable($tableName, $id);
112
-
113
-            // Make sure $index is an array.
114
-            if (!is_array($indexes)) {
115
-                $indexes = [];
116
-            }
117
-
118
-            $fileIdentifiers = $this->lookForFiles($indexes);
119
-            $this->addAfterDataHandlerProcessFileIdentifiers($fileIdentifiers);
120
-        }
121
-
122
-        // After collecting files, update the column "number_of_references".
123
-        foreach ($this->getFileToProcess() as $fileIdentifier) {
124
-            try {
125
-                $file = $this->getResourceFactory()->getFileObject($fileIdentifier);
126
-                $numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file);
127
-
128
-                $values = array(
129
-                    'number_of_references' => $numberOfReferences
130
-                );
131
-                $this->getDataService()->update('sys_file', $values, ['uid' => $file->getUid()]);
132
-            } catch (FileDoesNotExistException $fileDoesNotExistException) {
133
-                // Do nothing here. A file that does not exist needs no update.
134
-                // See https://github.com/fabarea/media/issues/159 for more information.
135
-            }
136
-        }
137
-    }
138
-
139
-    /**
140
-     * @return void
141
-     */
142
-    protected function initializeFileRegister()
143
-    {
144
-        $items = $this->getMemoryCache()->get($this->registerKey);
145
-        if (!is_array($items)) {
146
-            $this->getMemoryCache()->set($this->registerKey, []);
147
-        }
148
-    }
149
-
150
-    /**
151
-     * @return void
152
-     */
153
-    protected function registerFilesToKeepTrack()
154
-    {
155
-        $fileIdentifiers = [];
156
-        $elementsToBeDeleted = $this->getMemoryCache()->get('core-t3lib_TCEmain-elementsToBeDeleted');
157
-        if (is_array($elementsToBeDeleted)) {
158
-            foreach ($elementsToBeDeleted as $tableName => $element) {
159
-                if ($tableName === 'sys_file_reference') {
160
-                    $fileReferenceIdentifier = key($element);
161
-                    if ($element[$fileReferenceIdentifier] === true) {
162
-                        $fileIdentifier = $this->findFileByFileReference($fileReferenceIdentifier);
163
-                        $fileIdentifiers[] = $fileIdentifier;
164
-                    }
165
-                }
166
-            }
167
-        }
168
-
169
-        // Put back in the memory cache the value.
170
-        $items = $this->getMemoryCache()->get($this->registerKey);
171
-        $mergedItems = array_merge($items, $fileIdentifiers);
172
-        $this->getMemoryCache()->set($this->registerKey, $mergedItems);
173
-    }
174
-
175
-    /**
176
-     * @return array
177
-     */
178
-    protected function getRegisteredFiles()
179
-    {
180
-        $files = $this->getMemoryCache()->get($this->registerKey);
181
-        return $files;
182
-    }
183
-
184
-    /**
185
-     * Look for file which are within the reference index.
186
-     *
187
-     * @return array
188
-     */
189
-    protected function getFileToProcess()
190
-    {
191
-        $fileIdentifiers = array_merge(
192
-            $this->beforeDataHandlerProcessFileIdentifiers,
193
-            $this->afterDataHandlerProcessFileIdentifiers,
194
-            $this->getRegisteredFiles()
195
-        );
196
-        return array_unique($fileIdentifiers);
197
-    }
198
-
199
-    /**
200
-     * @param array $fileIdentifiers
201
-     * @return void
202
-     */
203
-    protected function addBeforeDataHandlerProcessFileIdentifiers(array $fileIdentifiers)
204
-    {
205
-        $this->beforeDataHandlerProcessFileIdentifiers = array_merge($this->beforeDataHandlerProcessFileIdentifiers, $fileIdentifiers);
206
-    }
207
-
208
-    /**
209
-     * @param array $fileIdentifiers
210
-     * @return void
211
-     */
212
-    protected function addAfterDataHandlerProcessFileIdentifiers(array $fileIdentifiers)
213
-    {
214
-        $this->afterDataHandlerProcessFileIdentifiers = array_merge($this->afterDataHandlerProcessFileIdentifiers, $fileIdentifiers);
215
-    }
216
-
217
-    /**
218
-     * Look for file which are within the reference index.
219
-     *
220
-     * @param array $indexes
221
-     * @return array
222
-     */
223
-    protected function lookForFiles(array $indexes)
224
-    {
225
-        $fileIdentifiers = [];
226
-        if (isset($indexes['relations'])) {
227
-            foreach ($indexes['relations'] as $index) {
228
-                if (is_array($index)) {
229
-                    if ($this->isSoftReferenceImage($index)) {
230
-                        $fileIdentifiers[] = $index['ref_uid'];
231
-                    } elseif ($this->isSoftReferenceLink($index)) {
232
-                        $fileIdentifiers[] = $index['ref_uid'];
233
-                    } elseif ($this->isFileReference($index)) {
234
-                        $fileIdentifiers[] = $this->findFileByFileReference($index['ref_uid']);
235
-                    }
236
-                }
237
-            }
238
-        }
239
-
240
-        return $fileIdentifiers;
241
-    }
242
-
243
-    /**
244
-     * @param array $index
245
-     * @return bool
246
-     */
247
-    public function isFileReference(array $index)
248
-    {
249
-        return $index['ref_table'] === 'sys_file_reference';
250
-    }
251
-
252
-    /**
253
-     * @param array $index
254
-     * @return bool
255
-     */
256
-    public function isSoftReferenceLink(array $index)
257
-    {
258
-        return $index['softref_key'] === 'typolink_tag' && $index['ref_table'] === 'sys_file';
259
-    }
260
-
261
-    /**
262
-     * @param array $index
263
-     * @return bool
264
-     */
265
-    public function isSoftReferenceImage(array $index)
266
-    {
267
-        return $index['softref_key'] === 'rtehtmlarea_images' && $index['ref_table'] === 'sys_file';
268
-    }
269
-
270
-    /**
271
-     * Retrieve the File identifier.
272
-     *
273
-     * @param $fileReferenceIdentifier
274
-     * @return int
275
-     * @throws \Exception
276
-     */
277
-    protected function findFileByFileReference($fileReferenceIdentifier)
278
-    {
279
-        $record = $this->getDataService()->getRecord(
280
-            'sys_file_reference',
281
-            [
282
-                'uid' => $fileReferenceIdentifier
283
-            ]
284
-        );
285
-
286
-        if (empty($record)) {
287
-            throw new \Exception('There is something broken with the File References. Consider updating the Reference Index.', 1408619796);
288
-        }
289
-
290
-        $fileIdentifier = $record['uid_local'];
291
-        return $fileIdentifier;
292
-    }
293
-
294
-    /**
295
-     * @return FileReferenceService|object
296
-     */
297
-    protected function getFileReferenceService()
298
-    {
299
-        return GeneralUtility::makeInstance(FileReferenceService::class);
300
-    }
301
-
302
-    /**
303
-     * Gets an instance of the memory cache.
304
-     *
305
-     * @return VariableFrontend
306
-     */
307
-    protected function getMemoryCache()
308
-    {
309
-        return $this->getCacheManager()->getCache('cache_runtime');
310
-    }
311
-
312
-    /**
313
-     * Create and returns an instance of the CacheManager
314
-     *
315
-     * @return CacheManager|object
316
-     */
317
-    protected function getCacheManager()
318
-    {
319
-        return GeneralUtility::makeInstance(CacheManager::class);
320
-    }
321
-
322
-    /**
323
-     * @return object|DataService
324
-     */
325
-    protected function getDataService(): DataService
326
-    {
327
-        return GeneralUtility::makeInstance(DataService::class);
328
-    }
329
-
330
-    protected function getResourceFactory(): ResourceFactory
331
-    {
332
-        return GeneralUtility::makeInstance(ResourceFactory::class);
333
-    }
28
+	/**
29
+	 * Store indexed file before the Data Handler start "working".
30
+	 *
31
+	 * @var array
32
+	 */
33
+	protected $beforeDataHandlerProcessFileIdentifiers = [];
34
+
35
+	/**
36
+	 * Store indexed file after the Data Handler has done its job.
37
+	 *
38
+	 * @var array
39
+	 */
40
+	protected $afterDataHandlerProcessFileIdentifiers = [];
41
+
42
+	/**
43
+	 * Internal key for the Cache Manager.
44
+	 *
45
+	 * @var string
46
+	 */
47
+	protected $registerKey = 'media-hook-elementsToKeepTrack';
48
+
49
+	/**
50
+	 * First procedures to launch before all operations in DataHandler.
51
+	 *
52
+	 * Feed variable $this->beforeDataHandlerProcessFileIdentifiers
53
+	 *
54
+	 * @param DataHandler $caller TCEMain Object
55
+	 * @return void
56
+	 */
57
+	public function processDatamap_beforeStart(DataHandler $caller)
58
+	{
59
+		// Use a register to keep track of files.
60
+		// It is required according to TCEMain behaviour which register "elements to be deleted".
61
+		// Those element must not be forgotten.
62
+		$this->initializeFileRegister();
63
+		$this->registerFilesToKeepTrack();
64
+
65
+		foreach ($caller->datamap as $tableName => $configuration) {
66
+			$id = key($configuration);
67
+			if (!MathUtility::canBeInterpretedAsInteger($id)) {
68
+				continue;
69
+			}
70
+
71
+			/** @var $refIndexObj \TYPO3\CMS\Core\Database\ReferenceIndex */
72
+			$refIndexObj = GeneralUtility::makeInstance(ReferenceIndex::class);
73
+			if (BackendUtility::isTableWorkspaceEnabled($tableName)) {
74
+				$refIndexObj->setWorkspaceId($caller->BE_USER->workspace);
75
+			}
76
+			$indexes = $refIndexObj->updateRefIndexTable($tableName, $id);
77
+
78
+			// Make sure $index is an array.
79
+			if (!is_array($indexes)) {
80
+				$indexes = [];
81
+			}
82
+
83
+			try {
84
+				$fileIdentifiers = $this->lookForFiles($indexes);
85
+				$this->addBeforeDataHandlerProcessFileIdentifiers($fileIdentifiers);
86
+			} catch (\Exception $e) {
87
+				// do nothing
88
+			}
89
+		}
90
+	}
91
+
92
+	/**
93
+	 * Last procedures to launch after all operations in DataHandler.
94
+	 *
95
+	 * Process field "number_of_references" which may require updates.
96
+	 *
97
+	 * @param DataHandler $caller TCEMain Object
98
+	 * @return void
99
+	 */
100
+	public function processDatamap_afterAllOperations(DataHandler $caller)
101
+	{
102
+		// First collect files which have been involved.
103
+		foreach ($caller->datamap as $tableName => $configuration) {
104
+			$id = key($configuration);
105
+
106
+			/** @var $refIndexObj \TYPO3\CMS\Core\Database\ReferenceIndex */
107
+			$refIndexObj = GeneralUtility::makeInstance(ReferenceIndex::class);
108
+			if (BackendUtility::isTableWorkspaceEnabled($tableName)) {
109
+				$refIndexObj->setWorkspaceId($caller->BE_USER->workspace);
110
+			}
111
+			$indexes = $refIndexObj->updateRefIndexTable($tableName, $id);
112
+
113
+			// Make sure $index is an array.
114
+			if (!is_array($indexes)) {
115
+				$indexes = [];
116
+			}
117
+
118
+			$fileIdentifiers = $this->lookForFiles($indexes);
119
+			$this->addAfterDataHandlerProcessFileIdentifiers($fileIdentifiers);
120
+		}
121
+
122
+		// After collecting files, update the column "number_of_references".
123
+		foreach ($this->getFileToProcess() as $fileIdentifier) {
124
+			try {
125
+				$file = $this->getResourceFactory()->getFileObject($fileIdentifier);
126
+				$numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file);
127
+
128
+				$values = array(
129
+					'number_of_references' => $numberOfReferences
130
+				);
131
+				$this->getDataService()->update('sys_file', $values, ['uid' => $file->getUid()]);
132
+			} catch (FileDoesNotExistException $fileDoesNotExistException) {
133
+				// Do nothing here. A file that does not exist needs no update.
134
+				// See https://github.com/fabarea/media/issues/159 for more information.
135
+			}
136
+		}
137
+	}
138
+
139
+	/**
140
+	 * @return void
141
+	 */
142
+	protected function initializeFileRegister()
143
+	{
144
+		$items = $this->getMemoryCache()->get($this->registerKey);
145
+		if (!is_array($items)) {
146
+			$this->getMemoryCache()->set($this->registerKey, []);
147
+		}
148
+	}
149
+
150
+	/**
151
+	 * @return void
152
+	 */
153
+	protected function registerFilesToKeepTrack()
154
+	{
155
+		$fileIdentifiers = [];
156
+		$elementsToBeDeleted = $this->getMemoryCache()->get('core-t3lib_TCEmain-elementsToBeDeleted');
157
+		if (is_array($elementsToBeDeleted)) {
158
+			foreach ($elementsToBeDeleted as $tableName => $element) {
159
+				if ($tableName === 'sys_file_reference') {
160
+					$fileReferenceIdentifier = key($element);
161
+					if ($element[$fileReferenceIdentifier] === true) {
162
+						$fileIdentifier = $this->findFileByFileReference($fileReferenceIdentifier);
163
+						$fileIdentifiers[] = $fileIdentifier;
164
+					}
165
+				}
166
+			}
167
+		}
168
+
169
+		// Put back in the memory cache the value.
170
+		$items = $this->getMemoryCache()->get($this->registerKey);
171
+		$mergedItems = array_merge($items, $fileIdentifiers);
172
+		$this->getMemoryCache()->set($this->registerKey, $mergedItems);
173
+	}
174
+
175
+	/**
176
+	 * @return array
177
+	 */
178
+	protected function getRegisteredFiles()
179
+	{
180
+		$files = $this->getMemoryCache()->get($this->registerKey);
181
+		return $files;
182
+	}
183
+
184
+	/**
185
+	 * Look for file which are within the reference index.
186
+	 *
187
+	 * @return array
188
+	 */
189
+	protected function getFileToProcess()
190
+	{
191
+		$fileIdentifiers = array_merge(
192
+			$this->beforeDataHandlerProcessFileIdentifiers,
193
+			$this->afterDataHandlerProcessFileIdentifiers,
194
+			$this->getRegisteredFiles()
195
+		);
196
+		return array_unique($fileIdentifiers);
197
+	}
198
+
199
+	/**
200
+	 * @param array $fileIdentifiers
201
+	 * @return void
202
+	 */
203
+	protected function addBeforeDataHandlerProcessFileIdentifiers(array $fileIdentifiers)
204
+	{
205
+		$this->beforeDataHandlerProcessFileIdentifiers = array_merge($this->beforeDataHandlerProcessFileIdentifiers, $fileIdentifiers);
206
+	}
207
+
208
+	/**
209
+	 * @param array $fileIdentifiers
210
+	 * @return void
211
+	 */
212
+	protected function addAfterDataHandlerProcessFileIdentifiers(array $fileIdentifiers)
213
+	{
214
+		$this->afterDataHandlerProcessFileIdentifiers = array_merge($this->afterDataHandlerProcessFileIdentifiers, $fileIdentifiers);
215
+	}
216
+
217
+	/**
218
+	 * Look for file which are within the reference index.
219
+	 *
220
+	 * @param array $indexes
221
+	 * @return array
222
+	 */
223
+	protected function lookForFiles(array $indexes)
224
+	{
225
+		$fileIdentifiers = [];
226
+		if (isset($indexes['relations'])) {
227
+			foreach ($indexes['relations'] as $index) {
228
+				if (is_array($index)) {
229
+					if ($this->isSoftReferenceImage($index)) {
230
+						$fileIdentifiers[] = $index['ref_uid'];
231
+					} elseif ($this->isSoftReferenceLink($index)) {
232
+						$fileIdentifiers[] = $index['ref_uid'];
233
+					} elseif ($this->isFileReference($index)) {
234
+						$fileIdentifiers[] = $this->findFileByFileReference($index['ref_uid']);
235
+					}
236
+				}
237
+			}
238
+		}
239
+
240
+		return $fileIdentifiers;
241
+	}
242
+
243
+	/**
244
+	 * @param array $index
245
+	 * @return bool
246
+	 */
247
+	public function isFileReference(array $index)
248
+	{
249
+		return $index['ref_table'] === 'sys_file_reference';
250
+	}
251
+
252
+	/**
253
+	 * @param array $index
254
+	 * @return bool
255
+	 */
256
+	public function isSoftReferenceLink(array $index)
257
+	{
258
+		return $index['softref_key'] === 'typolink_tag' && $index['ref_table'] === 'sys_file';
259
+	}
260
+
261
+	/**
262
+	 * @param array $index
263
+	 * @return bool
264
+	 */
265
+	public function isSoftReferenceImage(array $index)
266
+	{
267
+		return $index['softref_key'] === 'rtehtmlarea_images' && $index['ref_table'] === 'sys_file';
268
+	}
269
+
270
+	/**
271
+	 * Retrieve the File identifier.
272
+	 *
273
+	 * @param $fileReferenceIdentifier
274
+	 * @return int
275
+	 * @throws \Exception
276
+	 */
277
+	protected function findFileByFileReference($fileReferenceIdentifier)
278
+	{
279
+		$record = $this->getDataService()->getRecord(
280
+			'sys_file_reference',
281
+			[
282
+				'uid' => $fileReferenceIdentifier
283
+			]
284
+		);
285
+
286
+		if (empty($record)) {
287
+			throw new \Exception('There is something broken with the File References. Consider updating the Reference Index.', 1408619796);
288
+		}
289
+
290
+		$fileIdentifier = $record['uid_local'];
291
+		return $fileIdentifier;
292
+	}
293
+
294
+	/**
295
+	 * @return FileReferenceService|object
296
+	 */
297
+	protected function getFileReferenceService()
298
+	{
299
+		return GeneralUtility::makeInstance(FileReferenceService::class);
300
+	}
301
+
302
+	/**
303
+	 * Gets an instance of the memory cache.
304
+	 *
305
+	 * @return VariableFrontend
306
+	 */
307
+	protected function getMemoryCache()
308
+	{
309
+		return $this->getCacheManager()->getCache('cache_runtime');
310
+	}
311
+
312
+	/**
313
+	 * Create and returns an instance of the CacheManager
314
+	 *
315
+	 * @return CacheManager|object
316
+	 */
317
+	protected function getCacheManager()
318
+	{
319
+		return GeneralUtility::makeInstance(CacheManager::class);
320
+	}
321
+
322
+	/**
323
+	 * @return object|DataService
324
+	 */
325
+	protected function getDataService(): DataService
326
+	{
327
+		return GeneralUtility::makeInstance(DataService::class);
328
+	}
329
+
330
+	protected function getResourceFactory(): ResourceFactory
331
+	{
332
+		return GeneralUtility::makeInstance(ResourceFactory::class);
333
+	}
334 334
 }
Please login to merge, or discard this patch.
Classes/Hook/FileUploadHook.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -20,39 +20,39 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
ext_localconf.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -9,35 +9,35 @@
 block discarded – undo
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
 });
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
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');
Please login to merge, or discard this patch.
Configuration/TCA/Overrides/sys_file_metadata.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,36 +4,36 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
Configuration/TCA/Overrides/sys_file_reference.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@
 block discarded – undo
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.
Please login to merge, or discard this patch.
Configuration/TCA/Overrides/sys_file.php 2 patches
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -14,229 +14,229 @@
 block discarded – undo
14 14
 use Fab\Vidi\Grid\ButtonGroupRenderer;
15 15
 
16 16
 if (!defined('TYPO3')) {
17
-    die('Access denied.');
17
+	die('Access denied.');
18 18
 }
19 19
 
20 20
 $tca = [
21
-    'ctrl' => [
22
-        'default_sortby' => 'uid DESC',
23
-        // Beware that "metadata.categories" is quite expansive performance wise.
24
-        'searchFields' => 'uid, extension, name, metadata.title, metadata.description, metadata.categories',
25
-    ],
26
-    'columns' => [
27
-        'extension' => [
28
-            'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:sys_file.extension',
29
-            'config' => [
30
-                'type' => 'input',
31
-                'size' => 255,
32
-                'eval' => 'trim',
33
-            ],
34
-        ],
35
-        'number_of_references' => [
36
-            'config' => [
37
-                'type' => 'input',
38
-                'size' => 255,
39
-                'readOnly' => true,
40
-            ],
41
-        ],
42
-    ],
43
-    'vidi' => [
44
-        // For actions such as update, remove, copy, move, the DataHandler of the Core is configured to be used by default.
45
-        // It will work fine in most cases. However, there is the chance to set your own Data Handler if there are special needs (@see FileDataHandler in EXT:media)
46
-        // Another reasons, would be for speed. You will notice a performance cost when mass editing data using the Core DataHandler.
47
-        // Using your own DataHandler would make the mass processing much faster.
48
-        'data_handler' => [
49
-            // For all actions
50
-            '*' => 'Fab\Media\DataHandler\FileDataHandler'
51
-        ],
52
-    ],
53
-    'grid' => [
54
-        'excluded_fields' => 'number_of_references, missing',
55
-        'facets' => [
56
-            'metadata.title',
57
-            'metadata.categories',
58
-            'name',
59
-            StandardFacet::class => [
60
-                'name' => 'extension',
61
-                'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:sys_file.extension'
62
-            ],
63
-            'metadata.description',
64
-            'identifier',
65
-            StandardFacet::class => [
66
-                'name' => 'number_of_references',
67
-                'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:usage',
68
-                'suggestions' => ['0', '1', '2', '3', 'etc...'] // auto-suggestions
69
-            ],
21
+	'ctrl' => [
22
+		'default_sortby' => 'uid DESC',
23
+		// Beware that "metadata.categories" is quite expansive performance wise.
24
+		'searchFields' => 'uid, extension, name, metadata.title, metadata.description, metadata.categories',
25
+	],
26
+	'columns' => [
27
+		'extension' => [
28
+			'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:sys_file.extension',
29
+			'config' => [
30
+				'type' => 'input',
31
+				'size' => 255,
32
+				'eval' => 'trim',
33
+			],
34
+		],
35
+		'number_of_references' => [
36
+			'config' => [
37
+				'type' => 'input',
38
+				'size' => 255,
39
+				'readOnly' => true,
40
+			],
41
+		],
42
+	],
43
+	'vidi' => [
44
+		// For actions such as update, remove, copy, move, the DataHandler of the Core is configured to be used by default.
45
+		// It will work fine in most cases. However, there is the chance to set your own Data Handler if there are special needs (@see FileDataHandler in EXT:media)
46
+		// Another reasons, would be for speed. You will notice a performance cost when mass editing data using the Core DataHandler.
47
+		// Using your own DataHandler would make the mass processing much faster.
48
+		'data_handler' => [
49
+			// For all actions
50
+			'*' => 'Fab\Media\DataHandler\FileDataHandler'
51
+		],
52
+	],
53
+	'grid' => [
54
+		'excluded_fields' => 'number_of_references, missing',
55
+		'facets' => [
56
+			'metadata.title',
57
+			'metadata.categories',
58
+			'name',
59
+			StandardFacet::class => [
60
+				'name' => 'extension',
61
+				'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:sys_file.extension'
62
+			],
63
+			'metadata.description',
64
+			'identifier',
65
+			StandardFacet::class => [
66
+				'name' => 'number_of_references',
67
+				'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:usage',
68
+				'suggestions' => ['0', '1', '2', '3', 'etc...'] // auto-suggestions
69
+			],
70 70
 
71
-            StandardFacet::class => [
72
-                'name' => 'type',
73
-                'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type',
74
-                'suggestions' => [
75
-                    File::FILETYPE_TEXT => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_1',
76
-                    File::FILETYPE_IMAGE => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_2',
77
-                    File::FILETYPE_AUDIO => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_3',
78
-                    File::FILETYPE_VIDEO => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_4',
79
-                    File::FILETYPE_APPLICATION => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_5',
80
-                ]
81
-            ],
82
-            ActionPermissionFacet::class => [],
83
-            'uid',
84
-        ],
85
-        'columns' => [
86
-            '__checkbox' => [
87
-                'renderer' => CheckBoxRenderer::class,
88
-            ],
89
-            'uid' => [
90
-                'visible' => false,
91
-                'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:uid',
92
-                'width' => '5px',
93
-            ],
94
-            'identifier' => [
95
-                'visible' => false,
96
-            ],
97
-            'fileinfo' => [
98
-                'renderer' => PreviewRenderer::class,
99
-                'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:preview',
100
-                'wrap' => '<div class="center preview">|</div>',
101
-                'width' => '150px',
102
-                'sortable' => false,
103
-            ],
104
-            'metadata.title' => [
105
-                'renderer' => MetadataRenderer::class,
106
-                'rendererConfiguration' => [
107
-                    'property' => 'title',
108
-                ],
109
-                'width' => '400px',
110
-                'editable' => true,
111
-                'sortable' => true,
112
-            ],
113
-            'metadata.description' => [
114
-                'renderer' => MetadataRenderer::class,
115
-                'rendererConfiguration' => [
116
-                    'property' => 'description',
117
-                ],
118
-                'visible' => false,
119
-                'sortable' => false,
120
-            ],
121
-            'tstamp' => [
122
-                'visible' => false,
123
-                'format' => 'Fab\Vidi\Formatter\Date',
124
-                'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:sys_file.tstamp',
125
-            ],
126
-            'metadata.categories' => [
127
-                'renderers' => [
128
-                    RelationEditRenderer::class,
129
-                    CategoryRenderer::class,
130
-                ],
131
-                'editable' => true,
132
-                'visible' => true,
133
-                'sortable' => false,
134
-            ],
135
-            'usage' => [
136
-                'renderer' => 'Fab\Media\Grid\UsageRenderer',
137
-                'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:usage',
138
-                'visible' => true,
139
-                'sortable' => false,
140
-            ],
141
-            'metadata' => [
142
-                'label' => 'Metadata File Identifier',
143
-                'renderer' => MetadataRenderer::class,
144
-                'rendererConfiguration' => [
145
-                    'property' => 'uid',
146
-                ],
147
-                'visible' => false,
148
-                'sortable' => false,
149
-            ],
150
-            '__action_permission' => [
151
-                'renderer' => 'Fab\Media\Grid\ActionPermissionColumn',
152
-                'visible' => false,
153
-                'sortable' => false,
154
-                'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:permission',
155
-            ],
156
-        ]
157
-    ]
71
+			StandardFacet::class => [
72
+				'name' => 'type',
73
+				'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type',
74
+				'suggestions' => [
75
+					File::FILETYPE_TEXT => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_1',
76
+					File::FILETYPE_IMAGE => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_2',
77
+					File::FILETYPE_AUDIO => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_3',
78
+					File::FILETYPE_VIDEO => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_4',
79
+					File::FILETYPE_APPLICATION => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_5',
80
+				]
81
+			],
82
+			ActionPermissionFacet::class => [],
83
+			'uid',
84
+		],
85
+		'columns' => [
86
+			'__checkbox' => [
87
+				'renderer' => CheckBoxRenderer::class,
88
+			],
89
+			'uid' => [
90
+				'visible' => false,
91
+				'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:uid',
92
+				'width' => '5px',
93
+			],
94
+			'identifier' => [
95
+				'visible' => false,
96
+			],
97
+			'fileinfo' => [
98
+				'renderer' => PreviewRenderer::class,
99
+				'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:preview',
100
+				'wrap' => '<div class="center preview">|</div>',
101
+				'width' => '150px',
102
+				'sortable' => false,
103
+			],
104
+			'metadata.title' => [
105
+				'renderer' => MetadataRenderer::class,
106
+				'rendererConfiguration' => [
107
+					'property' => 'title',
108
+				],
109
+				'width' => '400px',
110
+				'editable' => true,
111
+				'sortable' => true,
112
+			],
113
+			'metadata.description' => [
114
+				'renderer' => MetadataRenderer::class,
115
+				'rendererConfiguration' => [
116
+					'property' => 'description',
117
+				],
118
+				'visible' => false,
119
+				'sortable' => false,
120
+			],
121
+			'tstamp' => [
122
+				'visible' => false,
123
+				'format' => 'Fab\Vidi\Formatter\Date',
124
+				'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:sys_file.tstamp',
125
+			],
126
+			'metadata.categories' => [
127
+				'renderers' => [
128
+					RelationEditRenderer::class,
129
+					CategoryRenderer::class,
130
+				],
131
+				'editable' => true,
132
+				'visible' => true,
133
+				'sortable' => false,
134
+			],
135
+			'usage' => [
136
+				'renderer' => 'Fab\Media\Grid\UsageRenderer',
137
+				'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:usage',
138
+				'visible' => true,
139
+				'sortable' => false,
140
+			],
141
+			'metadata' => [
142
+				'label' => 'Metadata File Identifier',
143
+				'renderer' => MetadataRenderer::class,
144
+				'rendererConfiguration' => [
145
+					'property' => 'uid',
146
+				],
147
+				'visible' => false,
148
+				'sortable' => false,
149
+			],
150
+			'__action_permission' => [
151
+				'renderer' => 'Fab\Media\Grid\ActionPermissionColumn',
152
+				'visible' => false,
153
+				'sortable' => false,
154
+				'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:permission',
155
+			],
156
+		]
157
+	]
158 158
 ];
159 159
 
160 160
 // Add more info to the Grid if EXT:filemetadata is loaded. Notice that the extension is not required but suggested.
161 161
 if (ExtensionManagementUtility::isLoaded('filemetadata')) {
162
-    $additionalTca = [
163
-        'ctrl' => [
164
-            'searchFields' => $tca['ctrl']['searchFields'] . ', metadata.keywords',
165
-        ],
166
-        'grid' => [
167
-            'columns' => [
168
-                'metadata.keywords' => [
169
-                    'renderer' => MetadataRenderer::class,
170
-                    'configuration' => [
171
-                        'property' => 'keywords',
172
-                    ],
173
-                    'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.keywords',
174
-                    'visible' => false,
175
-                    'sortable' => false,
176
-                ],
177
-                'metadata.fe_groups' => [
178
-                    'renderers' => [
179
-                        RelationEditRenderer::class,
180
-                        FrontendPermissionRenderer::class,
181
-                    ],
182
-                    'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:permissions_fe_groups',
183
-                    'visible' => false,
184
-                    'sortable' => false,
185
-                ],
186
-                'metadata.status' => [
187
-                    'renderer' => MetadataRenderer::class,
188
-                    'rendererConfiguration' => [
189
-                        'property' => 'status',
190
-                    ],
191
-                    'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.status',
192
-                    'visible' => false,
193
-                    'width' => '5%',
194
-                    'sortable' => false,
195
-                ],
196
-                # un-comment me to see the "visible" flag in the grid.
197
-                #'visible' => array(
198
-                #	'renderer' => 'Fab\Media\Grid\VisibilityRenderer', @todo will not work out of the box after 6.2 migration
199
-                #	'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:visibility_abbreviation',
200
-                #	'width' => '3%',
201
-                #),
202
-                'metadata.creator_tool' => [
203
-                    'renderer' => MetadataRenderer::class,
204
-                    'rendererConfiguration' => [
205
-                        'property' => 'creator_tool',
206
-                    ],
207
-                    'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.creator_tool',
208
-                    'visible' => false,
209
-                    'sortable' => false,
210
-                ],
211
-                'metadata.content_creation_date' => [
212
-                    'renderer' => MetadataRenderer::class,
213
-                    'rendererConfiguration' => [
214
-                        'property' => 'content_creation_date',
215
-                    ],
216
-                    'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.content_creation_date',
217
-                    'visible' => false,
218
-                    'format' => 'datetime',
219
-                    'sortable' => false,
220
-                ],
221
-                'metadata.content_modification_date' => [
222
-                    'renderer' => MetadataRenderer::class,
223
-                    'rendererConfiguration' => [
224
-                        'property' => 'content_modification_date',
225
-                    ],
226
-                    'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.content_modification_date',
227
-                    'visible' => false,
228
-                    'format' => 'datetime',
229
-                    'sortable' => false,
230
-                ],
231
-            ]
232
-        ]
233
-    ];
234
-    ArrayUtility::mergeRecursiveWithOverrule($tca, $additionalTca);
162
+	$additionalTca = [
163
+		'ctrl' => [
164
+			'searchFields' => $tca['ctrl']['searchFields'] . ', metadata.keywords',
165
+		],
166
+		'grid' => [
167
+			'columns' => [
168
+				'metadata.keywords' => [
169
+					'renderer' => MetadataRenderer::class,
170
+					'configuration' => [
171
+						'property' => 'keywords',
172
+					],
173
+					'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.keywords',
174
+					'visible' => false,
175
+					'sortable' => false,
176
+				],
177
+				'metadata.fe_groups' => [
178
+					'renderers' => [
179
+						RelationEditRenderer::class,
180
+						FrontendPermissionRenderer::class,
181
+					],
182
+					'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:permissions_fe_groups',
183
+					'visible' => false,
184
+					'sortable' => false,
185
+				],
186
+				'metadata.status' => [
187
+					'renderer' => MetadataRenderer::class,
188
+					'rendererConfiguration' => [
189
+						'property' => 'status',
190
+					],
191
+					'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.status',
192
+					'visible' => false,
193
+					'width' => '5%',
194
+					'sortable' => false,
195
+				],
196
+				# un-comment me to see the "visible" flag in the grid.
197
+				#'visible' => array(
198
+				#	'renderer' => 'Fab\Media\Grid\VisibilityRenderer', @todo will not work out of the box after 6.2 migration
199
+				#	'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:visibility_abbreviation',
200
+				#	'width' => '3%',
201
+				#),
202
+				'metadata.creator_tool' => [
203
+					'renderer' => MetadataRenderer::class,
204
+					'rendererConfiguration' => [
205
+						'property' => 'creator_tool',
206
+					],
207
+					'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.creator_tool',
208
+					'visible' => false,
209
+					'sortable' => false,
210
+				],
211
+				'metadata.content_creation_date' => [
212
+					'renderer' => MetadataRenderer::class,
213
+					'rendererConfiguration' => [
214
+						'property' => 'content_creation_date',
215
+					],
216
+					'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.content_creation_date',
217
+					'visible' => false,
218
+					'format' => 'datetime',
219
+					'sortable' => false,
220
+				],
221
+				'metadata.content_modification_date' => [
222
+					'renderer' => MetadataRenderer::class,
223
+					'rendererConfiguration' => [
224
+						'property' => 'content_modification_date',
225
+					],
226
+					'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.content_modification_date',
227
+					'visible' => false,
228
+					'format' => 'datetime',
229
+					'sortable' => false,
230
+				],
231
+			]
232
+		]
233
+	];
234
+	ArrayUtility::mergeRecursiveWithOverrule($tca, $additionalTca);
235 235
 }
236 236
 
237 237
 // Control buttons such as edit, delete, etc... must be set at the end in any case.
238 238
 $tca['grid']['columns']['__buttons'] = [
239
-    'renderer' => ButtonGroupRenderer::class,
239
+	'renderer' => ButtonGroupRenderer::class,
240 240
 ];
241 241
 
242 242
 ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA']['sys_file'], $tca);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@
 block discarded – undo
161 161
 if (ExtensionManagementUtility::isLoaded('filemetadata')) {
162 162
     $additionalTca = [
163 163
         'ctrl' => [
164
-            'searchFields' => $tca['ctrl']['searchFields'] . ', metadata.keywords',
164
+            'searchFields' => $tca['ctrl']['searchFields'].', metadata.keywords',
165 165
         ],
166 166
         'grid' => [
167 167
             'columns' => [
Please login to merge, or discard this patch.
ext_tables.php 2 patches
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
 defined('TYPO3') or die();
52 52
 
53 53
 call_user_func(function () {
54
-    $configuration = GeneralUtility::makeInstance(
55
-        ExtensionConfiguration::class
56
-    )->get('media');
54
+	$configuration = GeneralUtility::makeInstance(
55
+		ExtensionConfiguration::class
56
+	)->get('media');
57 57
 
58
-    // Default User TSConfig to be added in any case.
59
-    ExtensionManagementUtility::addUserTSConfig('
58
+	// Default User TSConfig to be added in any case.
59
+	ExtensionManagementUtility::addUserTSConfig('
60 60
 
61 61
 		# Enable or disabled the Media File Picker in the BE
62 62
 		options.vidi.enableMediaFilePicker = 1
@@ -66,145 +66,145 @@  discard block
 block discarded – undo
66 66
 
67 67
 	');
68 68
 
69
-    $moduleFileLanguage = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf';
70
-    if ($configuration['hide_file_list'] == 1) {
71
-        $moduleFileLanguage = 'LLL:EXT:media/Resources/Private/Language/locallang_filelist.xlf';
69
+	$moduleFileLanguage = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf';
70
+	if ($configuration['hide_file_list'] == 1) {
71
+		$moduleFileLanguage = 'LLL:EXT:media/Resources/Private/Language/locallang_filelist.xlf';
72 72
 
73
-        // Default User TSConfig to be added in any case.
74
-        ExtensionManagementUtility::addUserTSConfig('
73
+		// Default User TSConfig to be added in any case.
74
+		ExtensionManagementUtility::addUserTSConfig('
75 75
 
76 76
 			# Hide default File List
77 77
 			options.hideModules.file := addToList(FilelistList)
78 78
 		');
79
-    }
80
-
81
-    ExtensionUtility::registerModule(
82
-        'Media',
83
-        'user', // Make media module a submodule of 'user'
84
-        'm1',
85
-        'bottom', // Position
86
-        [
87
-            AssetController::class => 'create, update, download, editStorage',
88
-            ImageEditorController::class => 'show',
89
-            LinkCreatorController::class => 'show',
90
-            ProcessedFileController::class => 'create',
91
-        ],
92
-        [
93
-            'access' => 'user,group',
94
-            'icon' => 'EXT:media/Resources/Public/Icons/Extension.svg',
95
-            'labels' => 'LLL:EXT:media/Resources/Private/Language/locallang_module.xlf',
96
-        ]
97
-    );
98
-
99
-    $defaultMainModule = (bool)$configuration['has_folder_tree'] ? 'file' : 'content';
100
-
101
-    /** @var ModuleLoader $moduleLoader */
102
-    $moduleLoader = GeneralUtility::makeInstance(
103
-        ModuleLoader::class,
104
-        'sys_file'
105
-    );
106
-    $moduleLoader->setIcon('EXT:media/Resources/Public/Icons/Extension.svg')
107
-        ->setModuleLanguageFile($moduleFileLanguage)
108
-        ->setMainModule($defaultMainModule)
109
-        ->addJavaScriptFiles([
110
-            'EXT:media/Resources/Public/Libraries/Fineuploader/jquery.fineuploader-5.0.9.min.js',
111
-        ])
112
-        ->addStyleSheetFiles([
113
-            'EXT:media/Resources/Public/StyleSheets/media.css',
114
-            'EXT:media/Resources/Public/StyleSheets/fineuploader.css',
115
-        ])
116
-        ->setDocHeaderTopLeftComponents(
117
-            [
118
-                StorageMenu::class,
119
-                RecursiveCheckbox::class,]
120
-        )
121
-        ->setDocHeaderBottomLeftComponents([
122
-            ClipboardButton::class,
123
-            NewFolder::class,
124
-            UploadButton::class,
125
-        ])
126
-        ->setGridTopComponents([
127
-            InlineJavaScript::class,
128
-            ConfigurationWarning::class,
129
-            SelectedFolderInfo::class,
130
-        ])
131
-        ->setGridBottomComponents([
132
-            LinkCreatorPlugin::class,
133
-            ImageEditorPlugin::class,
134
-            FilePickerPlugin::class,
135
-        ])
136
-        ->setGridButtonsComponents([
137
-            LinkCreatorButton::class,
138
-            ImageEditorButton::class,
139
-            FilePickerButton::class,
140
-            EditButton::class,
141
-            DownloadButton::class,
142
-            DeleteButton::class,
143
-        ])
144
-        ->setMenuMassActionComponents([
145
-            ExportXlsMenuItem::class,
146
-            ExportXmlMenuItem::class,
147
-            ExportCsvMenuItem::class,
148
-            DividerMenuItem::class,
149
-
150
-            // Media custom View Helper
151
-            ClipboardMenuItem::class,
152
-            FilePickerMenuItem::class,
153
-            ChangeStorageMenuItem::class,
154
-            MassDeleteMenuItem::class,
155
-        ])
156
-        ->register();
157
-
158
-
159
-    /** @var $signalSlotDispatcher \TYPO3\CMS\Extbase\SignalSlot\Dispatcher */
160
-    $signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class);
161
-
162
-    # Register some tool for Media.
163
-    ToolRegistry::getInstance()->register('sys_file', ThumbnailGeneratorTool::class);
164
-    ToolRegistry::getInstance()->register('sys_file', CacheWarmUpTool::class);
165
-    ToolRegistry::getInstance()->register('sys_file', MissingFilesFinderTool::class);
166
-    ToolRegistry::getInstance()->register('sys_file', DuplicateRecordsFinderTool::class);
167
-    ToolRegistry::getInstance()->register('sys_file', DuplicateFilesFinderTool::class);
168
-
169
-    // Connect some signals with slots.
170
-    $signalSlotDispatcher->connect(
171
-        'Fab\Vidi\Controller\Backend\ContentController', // Small exception in naming here as the class was previously located in "Controller\Backend".
172
-        'postProcessMatcherObject',
173
-        FilePermissionsAspect::class,
174
-        'addFilePermissionsForFileStorages'
175
-    );
176
-
177
-    $signalSlotDispatcher->connect(
178
-        ContentRepository::class,
179
-        'postProcessConstraintsObject',
180
-        FilePermissionsAspect::class,
181
-        'addFilePermissionsForFileMounts'
182
-    );
183
-
184
-    $signalSlotDispatcher->connect(
185
-        ContentService::class,
186
-        'afterFindContentObjects',
187
-        ActionPermissionFacet::class,
188
-        'modifyResultSet'
189
-    );
190
-
191
-    // Add new sprite icon.
192
-    $icons = [
193
-        'image-edit' => 'EXT:media/Resources/Public/Icons/image_edit.png',
194
-        'image-link' => 'EXT:media/Resources/Public/Icons/image_link.png',
195
-        'image-export' => 'EXT:media/Resources/Public/Icons/image_export.png',
196
-        'storage-change' => 'EXT:media/Resources/Public/Icons/folder_go.png',
197
-    ];
198
-    /** @var IconRegistry $iconRegistry */
199
-    $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
200
-    foreach ($icons as $key => $icon) {
201
-        $iconRegistry->registerIcon(
202
-            'extensions-media-' . $key,
203
-            BitmapIconProvider::class,
204
-            [
205
-                'source' => $icon
206
-            ]
207
-        );
208
-    }
209
-    unset($iconRegistry);
79
+	}
80
+
81
+	ExtensionUtility::registerModule(
82
+		'Media',
83
+		'user', // Make media module a submodule of 'user'
84
+		'm1',
85
+		'bottom', // Position
86
+		[
87
+			AssetController::class => 'create, update, download, editStorage',
88
+			ImageEditorController::class => 'show',
89
+			LinkCreatorController::class => 'show',
90
+			ProcessedFileController::class => 'create',
91
+		],
92
+		[
93
+			'access' => 'user,group',
94
+			'icon' => 'EXT:media/Resources/Public/Icons/Extension.svg',
95
+			'labels' => 'LLL:EXT:media/Resources/Private/Language/locallang_module.xlf',
96
+		]
97
+	);
98
+
99
+	$defaultMainModule = (bool)$configuration['has_folder_tree'] ? 'file' : 'content';
100
+
101
+	/** @var ModuleLoader $moduleLoader */
102
+	$moduleLoader = GeneralUtility::makeInstance(
103
+		ModuleLoader::class,
104
+		'sys_file'
105
+	);
106
+	$moduleLoader->setIcon('EXT:media/Resources/Public/Icons/Extension.svg')
107
+		->setModuleLanguageFile($moduleFileLanguage)
108
+		->setMainModule($defaultMainModule)
109
+		->addJavaScriptFiles([
110
+			'EXT:media/Resources/Public/Libraries/Fineuploader/jquery.fineuploader-5.0.9.min.js',
111
+		])
112
+		->addStyleSheetFiles([
113
+			'EXT:media/Resources/Public/StyleSheets/media.css',
114
+			'EXT:media/Resources/Public/StyleSheets/fineuploader.css',
115
+		])
116
+		->setDocHeaderTopLeftComponents(
117
+			[
118
+				StorageMenu::class,
119
+				RecursiveCheckbox::class,]
120
+		)
121
+		->setDocHeaderBottomLeftComponents([
122
+			ClipboardButton::class,
123
+			NewFolder::class,
124
+			UploadButton::class,
125
+		])
126
+		->setGridTopComponents([
127
+			InlineJavaScript::class,
128
+			ConfigurationWarning::class,
129
+			SelectedFolderInfo::class,
130
+		])
131
+		->setGridBottomComponents([
132
+			LinkCreatorPlugin::class,
133
+			ImageEditorPlugin::class,
134
+			FilePickerPlugin::class,
135
+		])
136
+		->setGridButtonsComponents([
137
+			LinkCreatorButton::class,
138
+			ImageEditorButton::class,
139
+			FilePickerButton::class,
140
+			EditButton::class,
141
+			DownloadButton::class,
142
+			DeleteButton::class,
143
+		])
144
+		->setMenuMassActionComponents([
145
+			ExportXlsMenuItem::class,
146
+			ExportXmlMenuItem::class,
147
+			ExportCsvMenuItem::class,
148
+			DividerMenuItem::class,
149
+
150
+			// Media custom View Helper
151
+			ClipboardMenuItem::class,
152
+			FilePickerMenuItem::class,
153
+			ChangeStorageMenuItem::class,
154
+			MassDeleteMenuItem::class,
155
+		])
156
+		->register();
157
+
158
+
159
+	/** @var $signalSlotDispatcher \TYPO3\CMS\Extbase\SignalSlot\Dispatcher */
160
+	$signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class);
161
+
162
+	# Register some tool for Media.
163
+	ToolRegistry::getInstance()->register('sys_file', ThumbnailGeneratorTool::class);
164
+	ToolRegistry::getInstance()->register('sys_file', CacheWarmUpTool::class);
165
+	ToolRegistry::getInstance()->register('sys_file', MissingFilesFinderTool::class);
166
+	ToolRegistry::getInstance()->register('sys_file', DuplicateRecordsFinderTool::class);
167
+	ToolRegistry::getInstance()->register('sys_file', DuplicateFilesFinderTool::class);
168
+
169
+	// Connect some signals with slots.
170
+	$signalSlotDispatcher->connect(
171
+		'Fab\Vidi\Controller\Backend\ContentController', // Small exception in naming here as the class was previously located in "Controller\Backend".
172
+		'postProcessMatcherObject',
173
+		FilePermissionsAspect::class,
174
+		'addFilePermissionsForFileStorages'
175
+	);
176
+
177
+	$signalSlotDispatcher->connect(
178
+		ContentRepository::class,
179
+		'postProcessConstraintsObject',
180
+		FilePermissionsAspect::class,
181
+		'addFilePermissionsForFileMounts'
182
+	);
183
+
184
+	$signalSlotDispatcher->connect(
185
+		ContentService::class,
186
+		'afterFindContentObjects',
187
+		ActionPermissionFacet::class,
188
+		'modifyResultSet'
189
+	);
190
+
191
+	// Add new sprite icon.
192
+	$icons = [
193
+		'image-edit' => 'EXT:media/Resources/Public/Icons/image_edit.png',
194
+		'image-link' => 'EXT:media/Resources/Public/Icons/image_link.png',
195
+		'image-export' => 'EXT:media/Resources/Public/Icons/image_export.png',
196
+		'storage-change' => 'EXT:media/Resources/Public/Icons/folder_go.png',
197
+	];
198
+	/** @var IconRegistry $iconRegistry */
199
+	$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
200
+	foreach ($icons as $key => $icon) {
201
+		$iconRegistry->registerIcon(
202
+			'extensions-media-' . $key,
203
+			BitmapIconProvider::class,
204
+			[
205
+				'source' => $icon
206
+			]
207
+		);
208
+	}
209
+	unset($iconRegistry);
210 210
 });
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 defined('TYPO3') or die();
52 52
 
53
-call_user_func(function () {
53
+call_user_func(function() {
54 54
     $configuration = GeneralUtility::makeInstance(
55 55
         ExtensionConfiguration::class
56 56
     )->get('media');
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         ->setDocHeaderTopLeftComponents(
117 117
             [
118 118
                 StorageMenu::class,
119
-                RecursiveCheckbox::class,]
119
+                RecursiveCheckbox::class, ]
120 120
         )
121 121
         ->setDocHeaderBottomLeftComponents([
122 122
             ClipboardButton::class,
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
200 200
     foreach ($icons as $key => $icon) {
201 201
         $iconRegistry->registerIcon(
202
-            'extensions-media-' . $key,
202
+            'extensions-media-'.$key,
203 203
             BitmapIconProvider::class,
204 204
             [
205 205
                 'source' => $icon
Please login to merge, or discard this patch.
ext_emconf.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $EM_CONF[$_EXTKEY] = [
4
-    'title' => 'Media management',
5
-    'description' => 'Media management system for TYPO3 CMS.',
6
-    'category' => 'module',
7
-    'author' => 'Fabien Udriot',
8
-    'author_email' => '[email protected]',
9
-    'state' => 'stable',
10
-    'version' => '6.1.0-dev',
11
-    'autoload' => [
12
-        'psr-4' => ['Fab\\Media\\' => 'Classes']
13
-    ],
14
-    'constraints' =>
15
-        [
16
-            'depends' =>
17
-                [
18
-                    'typo3' => '11.5.0-11.5.99',
19
-                    'vidi' => '5.0.0-0.0.0',
20
-                ],
21
-            'conflicts' =>
22
-                [
23
-                ],
24
-            'suggests' =>
25
-                [
26
-                    'metadata' => '',
27
-                    'filemetadata' => '',
28
-                ],
29
-        ]
4
+	'title' => 'Media management',
5
+	'description' => 'Media management system for TYPO3 CMS.',
6
+	'category' => 'module',
7
+	'author' => 'Fabien Udriot',
8
+	'author_email' => '[email protected]',
9
+	'state' => 'stable',
10
+	'version' => '6.1.0-dev',
11
+	'autoload' => [
12
+		'psr-4' => ['Fab\\Media\\' => 'Classes']
13
+	],
14
+	'constraints' =>
15
+		[
16
+			'depends' =>
17
+				[
18
+					'typo3' => '11.5.0-11.5.99',
19
+					'vidi' => '5.0.0-0.0.0',
20
+				],
21
+			'conflicts' =>
22
+				[
23
+				],
24
+			'suggests' =>
25
+				[
26
+					'metadata' => '',
27
+					'filemetadata' => '',
28
+				],
29
+		]
30 30
 ];
Please login to merge, or discard this patch.