@@ -15,214 +15,214 @@ |
||
15 | 15 | use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; |
16 | 16 | |
17 | 17 | if (!defined('TYPO3')) { |
18 | - die('Access denied.'); |
|
18 | + die('Access denied.'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | $tca = [ |
22 | - 'ctrl' => [ |
|
23 | - 'default_sortby' => 'uid DESC', |
|
24 | - // Beware that "metadata.categories" is quite expansive performance wise. |
|
25 | - 'searchFields' => 'uid, extension, name, metadata.title, metadata.description, metadata.categories', |
|
26 | - ], |
|
27 | - 'columns' => [ |
|
28 | - 'extension' => [ |
|
29 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:sys_file.extension', |
|
30 | - 'config' => [ |
|
31 | - 'type' => 'input', |
|
32 | - 'size' => 255, |
|
33 | - 'eval' => 'trim', |
|
34 | - ], |
|
35 | - ], |
|
36 | - 'number_of_references' => [ |
|
37 | - 'config' => [ |
|
38 | - 'type' => 'input', |
|
39 | - 'size' => 255, |
|
40 | - 'readOnly' => true, |
|
41 | - ], |
|
42 | - ], |
|
43 | - ], |
|
44 | - 'vidi' => [ |
|
45 | - // For actions such as update, remove, copy, move, the DataHandler of the Core is configured to be used by default. |
|
46 | - // 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) |
|
47 | - // Another reasons, would be for speed. You will notice a performance cost when mass editing data using the Core DataHandler. |
|
48 | - // Using your own DataHandler would make the mass processing much faster. |
|
49 | - 'data_handler' => [ |
|
50 | - // For all actions |
|
51 | - '*' => 'Fab\Media\DataHandler\FileDataHandler' |
|
52 | - ], |
|
53 | - ], |
|
54 | - 'grid' => [ |
|
55 | - 'excluded_fields' => 'number_of_references, missing', |
|
56 | - 'facets' => [ |
|
57 | - 'metadata.title', |
|
58 | - 'metadata.categories', |
|
59 | - 'name', |
|
60 | - StandardFacet::class => [ |
|
61 | - 'name' => 'extension', |
|
62 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:sys_file.extension' |
|
63 | - ], |
|
64 | - 'metadata.description', |
|
65 | - 'identifier', |
|
66 | - NumberOfReferencesFacet::class => [], |
|
67 | - TypeFacet::class => [], |
|
68 | - ActionPermissionFacet::class => [], |
|
69 | - 'uid', |
|
70 | - ], |
|
71 | - 'columns' => [ |
|
72 | - '__checkbox' => [ |
|
73 | - 'renderer' => CheckBoxRenderer::class, |
|
74 | - ], |
|
75 | - 'uid' => [ |
|
76 | - 'visible' => false, |
|
77 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:uid', |
|
78 | - 'width' => '5px', |
|
79 | - ], |
|
80 | - 'identifier' => [ |
|
81 | - 'visible' => false, |
|
82 | - ], |
|
83 | - 'fileinfo' => [ |
|
84 | - 'renderer' => PreviewRenderer::class, |
|
85 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:preview', |
|
86 | - 'wrap' => '<div class="center preview">|</div>', |
|
87 | - 'width' => '150px', |
|
88 | - 'sortable' => false, |
|
89 | - ], |
|
90 | - 'metadata.title' => [ |
|
91 | - 'renderer' => MetadataRenderer::class, |
|
92 | - 'rendererConfiguration' => [ |
|
93 | - 'property' => 'title', |
|
94 | - ], |
|
95 | - 'width' => '400px', |
|
96 | - 'editable' => true, |
|
97 | - 'sortable' => true, |
|
98 | - ], |
|
99 | - 'metadata.description' => [ |
|
100 | - 'renderer' => MetadataRenderer::class, |
|
101 | - 'rendererConfiguration' => [ |
|
102 | - 'property' => 'description', |
|
103 | - ], |
|
104 | - 'visible' => false, |
|
105 | - 'sortable' => false, |
|
106 | - ], |
|
107 | - 'tstamp' => [ |
|
108 | - 'visible' => false, |
|
109 | - 'format' => 'Fab\Vidi\Formatter\Date', |
|
110 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:sys_file.tstamp', |
|
111 | - ], |
|
112 | - 'metadata.categories' => [ |
|
113 | - 'renderers' => [ |
|
114 | - RelationEditRenderer::class, |
|
115 | - CategoryRenderer::class, |
|
116 | - ], |
|
117 | - 'editable' => true, |
|
118 | - 'visible' => true, |
|
119 | - 'sortable' => false, |
|
120 | - ], |
|
121 | - 'usage' => [ |
|
122 | - 'renderer' => 'Fab\Media\Grid\UsageRenderer', |
|
123 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:usage', |
|
124 | - 'visible' => true, |
|
125 | - 'sortable' => false, |
|
126 | - ], |
|
127 | - 'metadata' => [ |
|
128 | - 'label' => 'Metadata File Identifier', |
|
129 | - 'renderer' => MetadataRenderer::class, |
|
130 | - 'rendererConfiguration' => [ |
|
131 | - 'property' => 'uid', |
|
132 | - ], |
|
133 | - 'visible' => false, |
|
134 | - 'sortable' => false, |
|
135 | - ], |
|
136 | - '__action_permission' => [ |
|
137 | - 'renderer' => 'Fab\Media\Grid\ActionPermissionColumn', |
|
138 | - 'visible' => false, |
|
139 | - 'sortable' => false, |
|
140 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:permission', |
|
141 | - ], |
|
142 | - ] |
|
143 | - ] |
|
22 | + 'ctrl' => [ |
|
23 | + 'default_sortby' => 'uid DESC', |
|
24 | + // Beware that "metadata.categories" is quite expansive performance wise. |
|
25 | + 'searchFields' => 'uid, extension, name, metadata.title, metadata.description, metadata.categories', |
|
26 | + ], |
|
27 | + 'columns' => [ |
|
28 | + 'extension' => [ |
|
29 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:sys_file.extension', |
|
30 | + 'config' => [ |
|
31 | + 'type' => 'input', |
|
32 | + 'size' => 255, |
|
33 | + 'eval' => 'trim', |
|
34 | + ], |
|
35 | + ], |
|
36 | + 'number_of_references' => [ |
|
37 | + 'config' => [ |
|
38 | + 'type' => 'input', |
|
39 | + 'size' => 255, |
|
40 | + 'readOnly' => true, |
|
41 | + ], |
|
42 | + ], |
|
43 | + ], |
|
44 | + 'vidi' => [ |
|
45 | + // For actions such as update, remove, copy, move, the DataHandler of the Core is configured to be used by default. |
|
46 | + // 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) |
|
47 | + // Another reasons, would be for speed. You will notice a performance cost when mass editing data using the Core DataHandler. |
|
48 | + // Using your own DataHandler would make the mass processing much faster. |
|
49 | + 'data_handler' => [ |
|
50 | + // For all actions |
|
51 | + '*' => 'Fab\Media\DataHandler\FileDataHandler' |
|
52 | + ], |
|
53 | + ], |
|
54 | + 'grid' => [ |
|
55 | + 'excluded_fields' => 'number_of_references, missing', |
|
56 | + 'facets' => [ |
|
57 | + 'metadata.title', |
|
58 | + 'metadata.categories', |
|
59 | + 'name', |
|
60 | + StandardFacet::class => [ |
|
61 | + 'name' => 'extension', |
|
62 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:sys_file.extension' |
|
63 | + ], |
|
64 | + 'metadata.description', |
|
65 | + 'identifier', |
|
66 | + NumberOfReferencesFacet::class => [], |
|
67 | + TypeFacet::class => [], |
|
68 | + ActionPermissionFacet::class => [], |
|
69 | + 'uid', |
|
70 | + ], |
|
71 | + 'columns' => [ |
|
72 | + '__checkbox' => [ |
|
73 | + 'renderer' => CheckBoxRenderer::class, |
|
74 | + ], |
|
75 | + 'uid' => [ |
|
76 | + 'visible' => false, |
|
77 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:uid', |
|
78 | + 'width' => '5px', |
|
79 | + ], |
|
80 | + 'identifier' => [ |
|
81 | + 'visible' => false, |
|
82 | + ], |
|
83 | + 'fileinfo' => [ |
|
84 | + 'renderer' => PreviewRenderer::class, |
|
85 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:preview', |
|
86 | + 'wrap' => '<div class="center preview">|</div>', |
|
87 | + 'width' => '150px', |
|
88 | + 'sortable' => false, |
|
89 | + ], |
|
90 | + 'metadata.title' => [ |
|
91 | + 'renderer' => MetadataRenderer::class, |
|
92 | + 'rendererConfiguration' => [ |
|
93 | + 'property' => 'title', |
|
94 | + ], |
|
95 | + 'width' => '400px', |
|
96 | + 'editable' => true, |
|
97 | + 'sortable' => true, |
|
98 | + ], |
|
99 | + 'metadata.description' => [ |
|
100 | + 'renderer' => MetadataRenderer::class, |
|
101 | + 'rendererConfiguration' => [ |
|
102 | + 'property' => 'description', |
|
103 | + ], |
|
104 | + 'visible' => false, |
|
105 | + 'sortable' => false, |
|
106 | + ], |
|
107 | + 'tstamp' => [ |
|
108 | + 'visible' => false, |
|
109 | + 'format' => 'Fab\Vidi\Formatter\Date', |
|
110 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:sys_file.tstamp', |
|
111 | + ], |
|
112 | + 'metadata.categories' => [ |
|
113 | + 'renderers' => [ |
|
114 | + RelationEditRenderer::class, |
|
115 | + CategoryRenderer::class, |
|
116 | + ], |
|
117 | + 'editable' => true, |
|
118 | + 'visible' => true, |
|
119 | + 'sortable' => false, |
|
120 | + ], |
|
121 | + 'usage' => [ |
|
122 | + 'renderer' => 'Fab\Media\Grid\UsageRenderer', |
|
123 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:usage', |
|
124 | + 'visible' => true, |
|
125 | + 'sortable' => false, |
|
126 | + ], |
|
127 | + 'metadata' => [ |
|
128 | + 'label' => 'Metadata File Identifier', |
|
129 | + 'renderer' => MetadataRenderer::class, |
|
130 | + 'rendererConfiguration' => [ |
|
131 | + 'property' => 'uid', |
|
132 | + ], |
|
133 | + 'visible' => false, |
|
134 | + 'sortable' => false, |
|
135 | + ], |
|
136 | + '__action_permission' => [ |
|
137 | + 'renderer' => 'Fab\Media\Grid\ActionPermissionColumn', |
|
138 | + 'visible' => false, |
|
139 | + 'sortable' => false, |
|
140 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:permission', |
|
141 | + ], |
|
142 | + ] |
|
143 | + ] |
|
144 | 144 | ]; |
145 | 145 | |
146 | 146 | // Add more info to the Grid if EXT:filemetadata is loaded. Notice that the extension is not required but suggested. |
147 | 147 | if (ExtensionManagementUtility::isLoaded('filemetadata')) { |
148 | - $additionalTca = [ |
|
149 | - 'ctrl' => [ |
|
150 | - 'searchFields' => $tca['ctrl']['searchFields'] . ', metadata.keywords', |
|
151 | - ], |
|
152 | - 'grid' => [ |
|
153 | - 'columns' => [ |
|
154 | - 'metadata.keywords' => [ |
|
155 | - 'renderer' => MetadataRenderer::class, |
|
156 | - 'configuration' => [ |
|
157 | - 'property' => 'keywords', |
|
158 | - ], |
|
159 | - 'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.keywords', |
|
160 | - 'visible' => false, |
|
161 | - 'sortable' => false, |
|
162 | - ], |
|
163 | - 'metadata.fe_groups' => [ |
|
164 | - 'renderers' => [ |
|
165 | - RelationEditRenderer::class, |
|
166 | - FrontendPermissionRenderer::class, |
|
167 | - ], |
|
168 | - 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:permissions_fe_groups', |
|
169 | - 'visible' => false, |
|
170 | - 'sortable' => false, |
|
171 | - ], |
|
172 | - 'metadata.status' => [ |
|
173 | - 'renderer' => MetadataRenderer::class, |
|
174 | - 'rendererConfiguration' => [ |
|
175 | - 'property' => 'status', |
|
176 | - ], |
|
177 | - 'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.status', |
|
178 | - 'visible' => false, |
|
179 | - 'width' => '5%', |
|
180 | - 'sortable' => false, |
|
181 | - ], |
|
182 | - # un-comment me to see the "visible" flag in the grid. |
|
183 | - #'visible' => array( |
|
184 | - # 'renderer' => 'Fab\Media\Grid\VisibilityRenderer', @todo will not work out of the box after 6.2 migration |
|
185 | - # 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:visibility_abbreviation', |
|
186 | - # 'width' => '3%', |
|
187 | - #), |
|
188 | - 'metadata.creator_tool' => [ |
|
189 | - 'renderer' => MetadataRenderer::class, |
|
190 | - 'rendererConfiguration' => [ |
|
191 | - 'property' => 'creator_tool', |
|
192 | - ], |
|
193 | - 'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.creator_tool', |
|
194 | - 'visible' => false, |
|
195 | - 'sortable' => false, |
|
196 | - ], |
|
197 | - 'metadata.content_creation_date' => [ |
|
198 | - 'renderer' => MetadataRenderer::class, |
|
199 | - 'rendererConfiguration' => [ |
|
200 | - 'property' => 'content_creation_date', |
|
201 | - ], |
|
202 | - 'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.content_creation_date', |
|
203 | - 'visible' => false, |
|
204 | - 'format' => 'datetime', |
|
205 | - 'sortable' => false, |
|
206 | - ], |
|
207 | - 'metadata.content_modification_date' => [ |
|
208 | - 'renderer' => MetadataRenderer::class, |
|
209 | - 'rendererConfiguration' => [ |
|
210 | - 'property' => 'content_modification_date', |
|
211 | - ], |
|
212 | - 'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.content_modification_date', |
|
213 | - 'visible' => false, |
|
214 | - 'format' => 'datetime', |
|
215 | - 'sortable' => false, |
|
216 | - ], |
|
217 | - ] |
|
218 | - ] |
|
219 | - ]; |
|
220 | - ArrayUtility::mergeRecursiveWithOverrule($tca, $additionalTca); |
|
148 | + $additionalTca = [ |
|
149 | + 'ctrl' => [ |
|
150 | + 'searchFields' => $tca['ctrl']['searchFields'] . ', metadata.keywords', |
|
151 | + ], |
|
152 | + 'grid' => [ |
|
153 | + 'columns' => [ |
|
154 | + 'metadata.keywords' => [ |
|
155 | + 'renderer' => MetadataRenderer::class, |
|
156 | + 'configuration' => [ |
|
157 | + 'property' => 'keywords', |
|
158 | + ], |
|
159 | + 'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.keywords', |
|
160 | + 'visible' => false, |
|
161 | + 'sortable' => false, |
|
162 | + ], |
|
163 | + 'metadata.fe_groups' => [ |
|
164 | + 'renderers' => [ |
|
165 | + RelationEditRenderer::class, |
|
166 | + FrontendPermissionRenderer::class, |
|
167 | + ], |
|
168 | + 'label' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:permissions_fe_groups', |
|
169 | + 'visible' => false, |
|
170 | + 'sortable' => false, |
|
171 | + ], |
|
172 | + 'metadata.status' => [ |
|
173 | + 'renderer' => MetadataRenderer::class, |
|
174 | + 'rendererConfiguration' => [ |
|
175 | + 'property' => 'status', |
|
176 | + ], |
|
177 | + 'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.status', |
|
178 | + 'visible' => false, |
|
179 | + 'width' => '5%', |
|
180 | + 'sortable' => false, |
|
181 | + ], |
|
182 | + # un-comment me to see the "visible" flag in the grid. |
|
183 | + #'visible' => array( |
|
184 | + # 'renderer' => 'Fab\Media\Grid\VisibilityRenderer', @todo will not work out of the box after 6.2 migration |
|
185 | + # 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:visibility_abbreviation', |
|
186 | + # 'width' => '3%', |
|
187 | + #), |
|
188 | + 'metadata.creator_tool' => [ |
|
189 | + 'renderer' => MetadataRenderer::class, |
|
190 | + 'rendererConfiguration' => [ |
|
191 | + 'property' => 'creator_tool', |
|
192 | + ], |
|
193 | + 'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.creator_tool', |
|
194 | + 'visible' => false, |
|
195 | + 'sortable' => false, |
|
196 | + ], |
|
197 | + 'metadata.content_creation_date' => [ |
|
198 | + 'renderer' => MetadataRenderer::class, |
|
199 | + 'rendererConfiguration' => [ |
|
200 | + 'property' => 'content_creation_date', |
|
201 | + ], |
|
202 | + 'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.content_creation_date', |
|
203 | + 'visible' => false, |
|
204 | + 'format' => 'datetime', |
|
205 | + 'sortable' => false, |
|
206 | + ], |
|
207 | + 'metadata.content_modification_date' => [ |
|
208 | + 'renderer' => MetadataRenderer::class, |
|
209 | + 'rendererConfiguration' => [ |
|
210 | + 'property' => 'content_modification_date', |
|
211 | + ], |
|
212 | + 'label' => 'LLL:EXT:filemetadata/Resources/Private/Language/locallang_tca.xlf:sys_file_metadata.content_modification_date', |
|
213 | + 'visible' => false, |
|
214 | + 'format' => 'datetime', |
|
215 | + 'sortable' => false, |
|
216 | + ], |
|
217 | + ] |
|
218 | + ] |
|
219 | + ]; |
|
220 | + ArrayUtility::mergeRecursiveWithOverrule($tca, $additionalTca); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | // Control buttons such as edit, delete, etc... must be set at the end in any case. |
224 | 224 | $tca['grid']['columns']['__buttons'] = [ |
225 | - 'renderer' => ButtonGroupRenderer::class, |
|
225 | + 'renderer' => ButtonGroupRenderer::class, |
|
226 | 226 | ]; |
227 | 227 | |
228 | 228 | ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA']['sys_file'], $tca); |
@@ -19,181 +19,181 @@ |
||
19 | 19 | |
20 | 20 | class ActionPermissionFacet implements FacetInterface |
21 | 21 | { |
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected string $name = '__action_permission'; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - protected string $label = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:permission'; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var array |
|
34 | - */ |
|
35 | - protected array $suggestions = array( |
|
36 | - 'r' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:facet.read_only', |
|
37 | - 'w' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:facet.write', |
|
38 | - ); |
|
39 | - |
|
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
43 | - protected string $dataType = 'sys_file'; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var bool |
|
47 | - */ |
|
48 | - protected bool $canModifyMatcher = false; |
|
49 | - |
|
50 | - public function getName(): string |
|
51 | - { |
|
52 | - return $this->name; |
|
53 | - } |
|
54 | - |
|
55 | - public function getLabel(): string |
|
56 | - { |
|
57 | - return $this->getLanguageService()->sL($this->label); |
|
58 | - } |
|
59 | - |
|
60 | - public function getSuggestions(): array |
|
61 | - { |
|
62 | - $suggestions = []; |
|
63 | - foreach ($this->suggestions as $key => $label) { |
|
64 | - $suggestions[] = array($key => $this->getLanguageService()->sL($label)); |
|
65 | - } |
|
66 | - |
|
67 | - return $suggestions; |
|
68 | - } |
|
69 | - |
|
70 | - public function hasSuggestions(): bool |
|
71 | - { |
|
72 | - return true; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @param string $dataType |
|
77 | - * @return $this |
|
78 | - */ |
|
79 | - public function setDataType($dataType): ActionPermissionFacet |
|
80 | - { |
|
81 | - $this->dataType = $dataType; |
|
82 | - return $this; |
|
83 | - } |
|
84 | - |
|
85 | - public function canModifyMatcher(): bool |
|
86 | - { |
|
87 | - return $this->canModifyMatcher; |
|
88 | - } |
|
89 | - |
|
90 | - public function modifyMatcher(Matcher $matcher, $value): Matcher |
|
91 | - { |
|
92 | - return $matcher; |
|
93 | - } |
|
94 | - |
|
95 | - public function modifyResultSet(AfterFindContentObjectsSignalArguments $signalArguments): array |
|
96 | - { |
|
97 | - if ($signalArguments->getDataType() === 'sys_file') { |
|
98 | - $queryParts = $this->getQueryParts(); |
|
99 | - |
|
100 | - if (!empty($queryParts)) { |
|
101 | - $permission = $this->getPermissionValue($queryParts); |
|
102 | - |
|
103 | - if ($permission) { |
|
104 | - // We are force to query the content repository again here without limit |
|
105 | - $matcher = $signalArguments->getMatcher(); |
|
106 | - $order = $signalArguments->getOrder(); |
|
107 | - $objects = ContentRepositoryFactory::getInstance($this->dataType)->findBy($matcher, $order); |
|
108 | - |
|
109 | - $filteredObjects = []; |
|
110 | - foreach ($objects as $object) { |
|
111 | - $file = $this->getFileConverter()->convert($object->getUid()); |
|
112 | - if ($permission === 'read' && !$file->checkActionPermission('write')) { |
|
113 | - $filteredObjects[] = $object; |
|
114 | - } elseif ($permission === 'write' && $file->checkActionPermission('write')) { |
|
115 | - $filteredObjects[] = $object; |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - // Only take part of the array according to offset and limit. |
|
120 | - $offset = $signalArguments->getOffset(); |
|
121 | - $limit = $signalArguments->getLimit(); |
|
122 | - $signalArguments->setContentObjects(array_slice($filteredObjects, $offset, $limit)); |
|
123 | - |
|
124 | - // Count number of records |
|
125 | - $signalArguments->setNumberOfObjects(count($filteredObjects)); |
|
126 | - $signalArguments->setHasBeenProcessed(true); |
|
127 | - } |
|
128 | - } |
|
129 | - } |
|
130 | - |
|
131 | - return array($signalArguments); |
|
132 | - } |
|
133 | - |
|
134 | - protected function getQueryParts(): array |
|
135 | - { |
|
136 | - // Transmit recursive selection parameter. |
|
137 | - $parameterPrefix = $this->getModuleLoader()->getParameterPrefix(); |
|
138 | - $parameters = GeneralUtility::_GP($parameterPrefix); |
|
139 | - |
|
140 | - $queryParts = []; |
|
141 | - if (!empty($parameters['searchTerm'])) { |
|
142 | - $query = rawurldecode($parameters['searchTerm']); |
|
143 | - $queryParts = json_decode($query, true); |
|
144 | - } |
|
145 | - |
|
146 | - return $queryParts; |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * Retrieve the search permission value. |
|
151 | - */ |
|
152 | - protected function getPermissionValue(array $queryParts): string |
|
153 | - { |
|
154 | - $permission = ''; |
|
155 | - |
|
156 | - // Check also amongst labels. |
|
157 | - $labelReadOnly = $this->getLanguageService()->sL($this->suggestions['r']); |
|
158 | - $labelWrite = $this->getLanguageService()->sL($this->suggestions['w']); |
|
159 | - |
|
160 | - foreach ($queryParts as $queryPart) { |
|
161 | - $facetName = key($queryPart); |
|
162 | - $value = $queryPart[$facetName]; |
|
163 | - if ($facetName === $this->name) { |
|
164 | - if ($value === 'r' || $value === $labelReadOnly) { |
|
165 | - $permission = 'read'; |
|
166 | - } elseif ($value === 'w' || $value === $labelWrite) { |
|
167 | - $permission = 'write'; |
|
168 | - } |
|
169 | - } |
|
170 | - } |
|
171 | - return $permission; |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * Magic method implementation for retrieving state. |
|
176 | - * |
|
177 | - * @param array $states |
|
178 | - * @return $this |
|
179 | - */ |
|
180 | - public static function __set_state($states) |
|
181 | - { |
|
182 | - return new ActionPermissionFacet(); |
|
183 | - } |
|
184 | - |
|
185 | - protected function getLanguageService(): LanguageService |
|
186 | - { |
|
187 | - return $GLOBALS['LANG']; |
|
188 | - } |
|
189 | - |
|
190 | - protected function getFileConverter(): ContentToFileConverter |
|
191 | - { |
|
192 | - return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
193 | - } |
|
194 | - |
|
195 | - protected function getModuleLoader(): ModuleLoader |
|
196 | - { |
|
197 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
198 | - } |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected string $name = '__action_permission'; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + protected string $label = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:permission'; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var array |
|
34 | + */ |
|
35 | + protected array $suggestions = array( |
|
36 | + 'r' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:facet.read_only', |
|
37 | + 'w' => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:facet.write', |
|
38 | + ); |
|
39 | + |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | + protected string $dataType = 'sys_file'; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var bool |
|
47 | + */ |
|
48 | + protected bool $canModifyMatcher = false; |
|
49 | + |
|
50 | + public function getName(): string |
|
51 | + { |
|
52 | + return $this->name; |
|
53 | + } |
|
54 | + |
|
55 | + public function getLabel(): string |
|
56 | + { |
|
57 | + return $this->getLanguageService()->sL($this->label); |
|
58 | + } |
|
59 | + |
|
60 | + public function getSuggestions(): array |
|
61 | + { |
|
62 | + $suggestions = []; |
|
63 | + foreach ($this->suggestions as $key => $label) { |
|
64 | + $suggestions[] = array($key => $this->getLanguageService()->sL($label)); |
|
65 | + } |
|
66 | + |
|
67 | + return $suggestions; |
|
68 | + } |
|
69 | + |
|
70 | + public function hasSuggestions(): bool |
|
71 | + { |
|
72 | + return true; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * @param string $dataType |
|
77 | + * @return $this |
|
78 | + */ |
|
79 | + public function setDataType($dataType): ActionPermissionFacet |
|
80 | + { |
|
81 | + $this->dataType = $dataType; |
|
82 | + return $this; |
|
83 | + } |
|
84 | + |
|
85 | + public function canModifyMatcher(): bool |
|
86 | + { |
|
87 | + return $this->canModifyMatcher; |
|
88 | + } |
|
89 | + |
|
90 | + public function modifyMatcher(Matcher $matcher, $value): Matcher |
|
91 | + { |
|
92 | + return $matcher; |
|
93 | + } |
|
94 | + |
|
95 | + public function modifyResultSet(AfterFindContentObjectsSignalArguments $signalArguments): array |
|
96 | + { |
|
97 | + if ($signalArguments->getDataType() === 'sys_file') { |
|
98 | + $queryParts = $this->getQueryParts(); |
|
99 | + |
|
100 | + if (!empty($queryParts)) { |
|
101 | + $permission = $this->getPermissionValue($queryParts); |
|
102 | + |
|
103 | + if ($permission) { |
|
104 | + // We are force to query the content repository again here without limit |
|
105 | + $matcher = $signalArguments->getMatcher(); |
|
106 | + $order = $signalArguments->getOrder(); |
|
107 | + $objects = ContentRepositoryFactory::getInstance($this->dataType)->findBy($matcher, $order); |
|
108 | + |
|
109 | + $filteredObjects = []; |
|
110 | + foreach ($objects as $object) { |
|
111 | + $file = $this->getFileConverter()->convert($object->getUid()); |
|
112 | + if ($permission === 'read' && !$file->checkActionPermission('write')) { |
|
113 | + $filteredObjects[] = $object; |
|
114 | + } elseif ($permission === 'write' && $file->checkActionPermission('write')) { |
|
115 | + $filteredObjects[] = $object; |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + // Only take part of the array according to offset and limit. |
|
120 | + $offset = $signalArguments->getOffset(); |
|
121 | + $limit = $signalArguments->getLimit(); |
|
122 | + $signalArguments->setContentObjects(array_slice($filteredObjects, $offset, $limit)); |
|
123 | + |
|
124 | + // Count number of records |
|
125 | + $signalArguments->setNumberOfObjects(count($filteredObjects)); |
|
126 | + $signalArguments->setHasBeenProcessed(true); |
|
127 | + } |
|
128 | + } |
|
129 | + } |
|
130 | + |
|
131 | + return array($signalArguments); |
|
132 | + } |
|
133 | + |
|
134 | + protected function getQueryParts(): array |
|
135 | + { |
|
136 | + // Transmit recursive selection parameter. |
|
137 | + $parameterPrefix = $this->getModuleLoader()->getParameterPrefix(); |
|
138 | + $parameters = GeneralUtility::_GP($parameterPrefix); |
|
139 | + |
|
140 | + $queryParts = []; |
|
141 | + if (!empty($parameters['searchTerm'])) { |
|
142 | + $query = rawurldecode($parameters['searchTerm']); |
|
143 | + $queryParts = json_decode($query, true); |
|
144 | + } |
|
145 | + |
|
146 | + return $queryParts; |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * Retrieve the search permission value. |
|
151 | + */ |
|
152 | + protected function getPermissionValue(array $queryParts): string |
|
153 | + { |
|
154 | + $permission = ''; |
|
155 | + |
|
156 | + // Check also amongst labels. |
|
157 | + $labelReadOnly = $this->getLanguageService()->sL($this->suggestions['r']); |
|
158 | + $labelWrite = $this->getLanguageService()->sL($this->suggestions['w']); |
|
159 | + |
|
160 | + foreach ($queryParts as $queryPart) { |
|
161 | + $facetName = key($queryPart); |
|
162 | + $value = $queryPart[$facetName]; |
|
163 | + if ($facetName === $this->name) { |
|
164 | + if ($value === 'r' || $value === $labelReadOnly) { |
|
165 | + $permission = 'read'; |
|
166 | + } elseif ($value === 'w' || $value === $labelWrite) { |
|
167 | + $permission = 'write'; |
|
168 | + } |
|
169 | + } |
|
170 | + } |
|
171 | + return $permission; |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * Magic method implementation for retrieving state. |
|
176 | + * |
|
177 | + * @param array $states |
|
178 | + * @return $this |
|
179 | + */ |
|
180 | + public static function __set_state($states) |
|
181 | + { |
|
182 | + return new ActionPermissionFacet(); |
|
183 | + } |
|
184 | + |
|
185 | + protected function getLanguageService(): LanguageService |
|
186 | + { |
|
187 | + return $GLOBALS['LANG']; |
|
188 | + } |
|
189 | + |
|
190 | + protected function getFileConverter(): ContentToFileConverter |
|
191 | + { |
|
192 | + return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
193 | + } |
|
194 | + |
|
195 | + protected function getModuleLoader(): ModuleLoader |
|
196 | + { |
|
197 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
198 | + } |
|
199 | 199 | } |
@@ -14,69 +14,69 @@ |
||
14 | 14 | |
15 | 15 | class NumberOfReferencesFacet implements FacetInterface |
16 | 16 | { |
17 | - protected string $name = 'number_of_references'; |
|
17 | + protected string $name = 'number_of_references'; |
|
18 | 18 | |
19 | - protected string $label = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:usage'; |
|
19 | + protected string $label = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:usage'; |
|
20 | 20 | |
21 | - protected array $suggestions = [ |
|
22 | - '0', '1', '2', '3', 'etc...' |
|
23 | - ]; |
|
24 | - protected string $dataType = 'sys_file'; |
|
21 | + protected array $suggestions = [ |
|
22 | + '0', '1', '2', '3', 'etc...' |
|
23 | + ]; |
|
24 | + protected string $dataType = 'sys_file'; |
|
25 | 25 | |
26 | - public function getName(): string |
|
27 | - { |
|
28 | - return $this->name; |
|
29 | - } |
|
26 | + public function getName(): string |
|
27 | + { |
|
28 | + return $this->name; |
|
29 | + } |
|
30 | 30 | |
31 | - public function getLabel(): string |
|
32 | - { |
|
33 | - return $this->getLanguageService()->sL($this->label); |
|
34 | - } |
|
31 | + public function getLabel(): string |
|
32 | + { |
|
33 | + return $this->getLanguageService()->sL($this->label); |
|
34 | + } |
|
35 | 35 | |
36 | - public function getSuggestions(): array |
|
37 | - { |
|
38 | - return $this->suggestions; |
|
39 | - } |
|
36 | + public function getSuggestions(): array |
|
37 | + { |
|
38 | + return $this->suggestions; |
|
39 | + } |
|
40 | 40 | |
41 | - public function hasSuggestions(): bool |
|
42 | - { |
|
43 | - return true; |
|
44 | - } |
|
41 | + public function hasSuggestions(): bool |
|
42 | + { |
|
43 | + return true; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param string $dataType |
|
48 | - * @return $this |
|
49 | - */ |
|
50 | - public function setDataType($dataType): NumberOfReferencesFacet |
|
51 | - { |
|
52 | - $this->dataType = $dataType; |
|
53 | - return $this; |
|
54 | - } |
|
46 | + /** |
|
47 | + * @param string $dataType |
|
48 | + * @return $this |
|
49 | + */ |
|
50 | + public function setDataType($dataType): NumberOfReferencesFacet |
|
51 | + { |
|
52 | + $this->dataType = $dataType; |
|
53 | + return $this; |
|
54 | + } |
|
55 | 55 | |
56 | - public function canModifyMatcher(): bool |
|
57 | - { |
|
58 | - return false; |
|
59 | - } |
|
56 | + public function canModifyMatcher(): bool |
|
57 | + { |
|
58 | + return false; |
|
59 | + } |
|
60 | 60 | |
61 | - public function modifyMatcher(Matcher $matcher, $value): Matcher |
|
62 | - { |
|
63 | - return $matcher; |
|
64 | - } |
|
61 | + public function modifyMatcher(Matcher $matcher, $value): Matcher |
|
62 | + { |
|
63 | + return $matcher; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Magic method implementation for retrieving state. |
|
68 | - * |
|
69 | - * @param array $states |
|
70 | - * @return $this |
|
71 | - */ |
|
72 | - public static function __set_state($states) |
|
73 | - { |
|
74 | - return new NumberOfReferencesFacet(); |
|
75 | - } |
|
66 | + /** |
|
67 | + * Magic method implementation for retrieving state. |
|
68 | + * |
|
69 | + * @param array $states |
|
70 | + * @return $this |
|
71 | + */ |
|
72 | + public static function __set_state($states) |
|
73 | + { |
|
74 | + return new NumberOfReferencesFacet(); |
|
75 | + } |
|
76 | 76 | |
77 | - protected function getLanguageService(): LanguageService |
|
78 | - { |
|
79 | - return $GLOBALS['LANG']; |
|
80 | - } |
|
77 | + protected function getLanguageService(): LanguageService |
|
78 | + { |
|
79 | + return $GLOBALS['LANG']; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | } |
@@ -15,79 +15,79 @@ |
||
15 | 15 | |
16 | 16 | class TypeFacet implements FacetInterface |
17 | 17 | { |
18 | - protected string $name = 'type'; |
|
19 | - |
|
20 | - protected string $label = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type'; |
|
21 | - |
|
22 | - protected array $suggestions = [ |
|
23 | - File::FILETYPE_TEXT => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_1', |
|
24 | - File::FILETYPE_IMAGE => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_2', |
|
25 | - File::FILETYPE_AUDIO => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_3', |
|
26 | - File::FILETYPE_VIDEO => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_4', |
|
27 | - File::FILETYPE_APPLICATION => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_5', |
|
28 | - ]; |
|
29 | - |
|
30 | - protected string $dataType = ''; |
|
31 | - |
|
32 | - public function getName(): string |
|
33 | - { |
|
34 | - return $this->name; |
|
35 | - } |
|
36 | - |
|
37 | - public function getLabel(): string |
|
38 | - { |
|
39 | - return $this->getLanguageService()->sL($this->label); |
|
40 | - } |
|
41 | - |
|
42 | - public function getSuggestions(): array |
|
43 | - { |
|
44 | - $suggestions = []; |
|
45 | - foreach ($this->suggestions as $key => $label) { |
|
46 | - $suggestions[] = array($key => $this->getLanguageService()->sL($label)); |
|
47 | - } |
|
48 | - |
|
49 | - return $suggestions; |
|
50 | - } |
|
51 | - |
|
52 | - public function hasSuggestions(): bool |
|
53 | - { |
|
54 | - return true; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param string $dataType |
|
59 | - * @return $this |
|
60 | - */ |
|
61 | - public function setDataType($dataType): TypeFacet |
|
62 | - { |
|
63 | - $this->dataType = $dataType; |
|
64 | - return $this; |
|
65 | - } |
|
66 | - |
|
67 | - public function canModifyMatcher(): bool |
|
68 | - { |
|
69 | - return false; |
|
70 | - } |
|
71 | - |
|
72 | - public function modifyMatcher(Matcher $matcher, $value): Matcher |
|
73 | - { |
|
74 | - return $matcher; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Magic method implementation for retrieving state. |
|
79 | - * |
|
80 | - * @param array $states |
|
81 | - * @return $this |
|
82 | - */ |
|
83 | - public static function __set_state($states) |
|
84 | - { |
|
85 | - return new TypeFacet(); |
|
86 | - } |
|
87 | - |
|
88 | - protected function getLanguageService(): LanguageService |
|
89 | - { |
|
90 | - return $GLOBALS['LANG']; |
|
91 | - } |
|
18 | + protected string $name = 'type'; |
|
19 | + |
|
20 | + protected string $label = 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type'; |
|
21 | + |
|
22 | + protected array $suggestions = [ |
|
23 | + File::FILETYPE_TEXT => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_1', |
|
24 | + File::FILETYPE_IMAGE => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_2', |
|
25 | + File::FILETYPE_AUDIO => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_3', |
|
26 | + File::FILETYPE_VIDEO => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_4', |
|
27 | + File::FILETYPE_APPLICATION => 'LLL:EXT:media/Resources/Private/Language/locallang.xlf:type_5', |
|
28 | + ]; |
|
29 | + |
|
30 | + protected string $dataType = ''; |
|
31 | + |
|
32 | + public function getName(): string |
|
33 | + { |
|
34 | + return $this->name; |
|
35 | + } |
|
36 | + |
|
37 | + public function getLabel(): string |
|
38 | + { |
|
39 | + return $this->getLanguageService()->sL($this->label); |
|
40 | + } |
|
41 | + |
|
42 | + public function getSuggestions(): array |
|
43 | + { |
|
44 | + $suggestions = []; |
|
45 | + foreach ($this->suggestions as $key => $label) { |
|
46 | + $suggestions[] = array($key => $this->getLanguageService()->sL($label)); |
|
47 | + } |
|
48 | + |
|
49 | + return $suggestions; |
|
50 | + } |
|
51 | + |
|
52 | + public function hasSuggestions(): bool |
|
53 | + { |
|
54 | + return true; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param string $dataType |
|
59 | + * @return $this |
|
60 | + */ |
|
61 | + public function setDataType($dataType): TypeFacet |
|
62 | + { |
|
63 | + $this->dataType = $dataType; |
|
64 | + return $this; |
|
65 | + } |
|
66 | + |
|
67 | + public function canModifyMatcher(): bool |
|
68 | + { |
|
69 | + return false; |
|
70 | + } |
|
71 | + |
|
72 | + public function modifyMatcher(Matcher $matcher, $value): Matcher |
|
73 | + { |
|
74 | + return $matcher; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Magic method implementation for retrieving state. |
|
79 | + * |
|
80 | + * @param array $states |
|
81 | + * @return $this |
|
82 | + */ |
|
83 | + public static function __set_state($states) |
|
84 | + { |
|
85 | + return new TypeFacet(); |
|
86 | + } |
|
87 | + |
|
88 | + protected function getLanguageService(): LanguageService |
|
89 | + { |
|
90 | + return $GLOBALS['LANG']; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | } |