@@ -21,1004 +21,1004 @@ |
||
21 | 21 | class ModuleLoader |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Define the default main module |
|
26 | - */ |
|
27 | - const DEFAULT_MAIN_MODULE = 'content'; |
|
28 | - |
|
29 | - /** |
|
30 | - * Define the default pid |
|
31 | - */ |
|
32 | - const DEFAULT_PID = 0; |
|
33 | - |
|
34 | - /** |
|
35 | - * The type of data being listed (which corresponds to a table name in TCA) |
|
36 | - * |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - protected $dataType; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - protected $defaultPid; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var bool |
|
48 | - */ |
|
49 | - protected $isPidIgnored = false; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var bool |
|
53 | - */ |
|
54 | - protected $showPageTree = false; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var bool |
|
58 | - */ |
|
59 | - protected $isShown = true; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var string |
|
63 | - */ |
|
64 | - protected $access; |
|
65 | - |
|
66 | - /** |
|
67 | - * @var string |
|
68 | - */ |
|
69 | - protected $mainModule; |
|
70 | - |
|
71 | - /** |
|
72 | - * @var string |
|
73 | - */ |
|
74 | - protected $position = ''; |
|
75 | - |
|
76 | - /** |
|
77 | - * @var string |
|
78 | - */ |
|
79 | - protected $icon; |
|
80 | - |
|
81 | - /** |
|
82 | - * @var string |
|
83 | - */ |
|
84 | - protected $moduleLanguageFile; |
|
85 | - |
|
86 | - /** |
|
87 | - * The module key such as m1, m2. |
|
88 | - * |
|
89 | - * @var string |
|
90 | - */ |
|
91 | - protected $moduleKey = 'm1'; |
|
92 | - |
|
93 | - /** |
|
94 | - * @var string[] |
|
95 | - */ |
|
96 | - protected $additionalJavaScriptFiles = []; |
|
97 | - |
|
98 | - /** |
|
99 | - * @var string[] |
|
100 | - */ |
|
101 | - protected $additionalStyleSheetFiles = []; |
|
102 | - |
|
103 | - /** |
|
104 | - * @var array |
|
105 | - */ |
|
106 | - protected $components = []; |
|
107 | - |
|
108 | - /** |
|
109 | - * @param string $dataType |
|
110 | - */ |
|
111 | - public function __construct($dataType = null) |
|
112 | - { |
|
113 | - $this->dataType = $dataType; |
|
114 | - |
|
115 | - // Initialize components |
|
116 | - $this->components = [ |
|
117 | - ModulePosition::DOC_HEADER => [ |
|
118 | - ModulePosition::TOP => [ |
|
119 | - ModulePosition::LEFT => [], |
|
120 | - ModulePosition::RIGHT => [ |
|
121 | - \Fab\Vidi\View\Button\ToolButton::class, |
|
122 | - ], |
|
123 | - ], |
|
124 | - ModulePosition::BOTTOM => [ |
|
125 | - ModulePosition::LEFT => [ |
|
126 | - \Fab\Vidi\View\Button\NewButton::class, |
|
127 | - \Fab\Vidi\ViewHelpers\Link\BackViewHelper::class, |
|
128 | - ], |
|
129 | - ModulePosition::RIGHT => [], |
|
130 | - ], |
|
131 | - ], |
|
132 | - ModulePosition::GRID => [ |
|
133 | - ModulePosition::TOP => [ |
|
134 | - \Fab\Vidi\View\Check\RelationsCheck::class, |
|
135 | - #\Fab\Vidi\View\Tab\DataTypeTab::class, |
|
136 | - ], |
|
137 | - ModulePosition::BUTTONS => [ |
|
138 | - \Fab\Vidi\View\Button\EditButton::class, |
|
139 | - \Fab\Vidi\View\Button\DeleteButton::class, |
|
140 | - ], |
|
141 | - ModulePosition::BOTTOM => [], |
|
142 | - ], |
|
143 | - ModulePosition::MENU_MASS_ACTION => [ |
|
144 | - \Fab\Vidi\View\MenuItem\ExportXlsMenuItem::class, |
|
145 | - \Fab\Vidi\View\MenuItem\ExportXmlMenuItem::class, |
|
146 | - \Fab\Vidi\View\MenuItem\ExportCsvMenuItem::class, |
|
147 | - \Fab\Vidi\View\MenuItem\DividerMenuItem::class, |
|
148 | - \Fab\Vidi\View\MenuItem\MassDeleteMenuItem::class, |
|
149 | - #\Fab\Vidi\View\MenuItem\MassEditMenuItem::class, |
|
150 | - ], |
|
151 | - ]; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Tell whether a module is already registered. |
|
156 | - * |
|
157 | - * @param string $dataType |
|
158 | - * @return bool |
|
159 | - */ |
|
160 | - public function isRegistered($dataType): bool |
|
161 | - { |
|
162 | - $internalModuleSignature = $this->getInternalModuleSignature($dataType); |
|
163 | - return !empty($GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature]); |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * @return array |
|
168 | - */ |
|
169 | - protected function getExistingInternalConfiguration(): array |
|
170 | - { |
|
171 | - $internalModuleSignature = $this->getInternalModuleSignature(); |
|
172 | - return $GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature] ?? []; |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * @return array |
|
177 | - */ |
|
178 | - protected function getExistingMainConfiguration(): array |
|
179 | - { |
|
180 | - $moduleSignature = $this->computeMainModule() . '_' . $this->getInternalModuleSignature(); |
|
181 | - return $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature] ?? []; |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * @return string |
|
186 | - */ |
|
187 | - protected function computeMainModule(): string |
|
188 | - { |
|
189 | - $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
190 | - |
|
191 | - if ($this->mainModule !== null) { |
|
192 | - $mainModule = $this->mainModule; |
|
193 | - } elseif (!empty($existingConfiguration['mainModule'])) { // existing configuration may override. |
|
194 | - $mainModule = $existingConfiguration['mainModule']; |
|
195 | - } else { |
|
196 | - $mainModule = self::DEFAULT_MAIN_MODULE; //default value. |
|
197 | - } |
|
198 | - return $mainModule; |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * @return string |
|
203 | - */ |
|
204 | - protected function computeDefaultPid(): string |
|
205 | - { |
|
206 | - $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
207 | - |
|
208 | - if ($this->defaultPid !== null) { |
|
209 | - $defaultPid = $this->defaultPid; |
|
210 | - } elseif (!empty($existingConfiguration['defaultPid'])) { // existing configuration may override. |
|
211 | - $defaultPid = $existingConfiguration['defaultPid']; |
|
212 | - } else { |
|
213 | - $defaultPid = self::DEFAULT_PID; //default value. |
|
214 | - } |
|
215 | - return $defaultPid; |
|
216 | - } |
|
217 | - |
|
218 | - /** |
|
219 | - * @return array |
|
220 | - */ |
|
221 | - protected function computeAdditionalJavaScriptFiles(): array |
|
222 | - { |
|
223 | - $additionalJavaScriptFiles = $this->additionalJavaScriptFiles; |
|
224 | - |
|
225 | - // Possible merge of existing javascript files. |
|
226 | - $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
227 | - if (!empty($existingConfiguration['additionalJavaScriptFiles'])) { |
|
228 | - $additionalJavaScriptFiles = array_merge($additionalJavaScriptFiles, $existingConfiguration['additionalJavaScriptFiles']); |
|
229 | - } |
|
230 | - |
|
231 | - return $additionalJavaScriptFiles; |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * @return array |
|
236 | - */ |
|
237 | - protected function computeAdditionalStyleSheetFiles(): array |
|
238 | - { |
|
239 | - $additionalStyleSheetFiles = $this->additionalStyleSheetFiles; |
|
240 | - |
|
241 | - // Possible merge of existing style sheets. |
|
242 | - $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
243 | - if (!empty($existingConfiguration['additionalStyleSheetFiles'])) { |
|
244 | - $additionalStyleSheetFiles = array_merge($additionalStyleSheetFiles, $existingConfiguration['additionalStyleSheetFiles']); |
|
245 | - } |
|
246 | - |
|
247 | - return $additionalStyleSheetFiles; |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * @return array |
|
252 | - */ |
|
253 | - protected function computeComponents(): array |
|
254 | - { |
|
255 | - // We override the config in any case. See if we need more than that. |
|
256 | - return $this->components; |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Register the module in two places: core + vidi internal. |
|
261 | - * |
|
262 | - * @return $this |
|
263 | - */ |
|
264 | - public function register(): self |
|
265 | - { |
|
266 | - // Internal Vidi module registration. |
|
267 | - $configuration = []; |
|
268 | - $configuration['dataType'] = $this->dataType; |
|
269 | - $configuration['mainModule'] = $this->computeMainModule(); |
|
270 | - $configuration['defaultPid'] = $this->computeDefaultPid(); |
|
271 | - $configuration['additionalJavaScriptFiles'] = $this->computeAdditionalJavaScriptFiles(); |
|
272 | - $configuration['additionalStyleSheetFiles'] = $this->computeAdditionalStyleSheetFiles(); |
|
273 | - $configuration['components'] = $this->computeComponents(); |
|
274 | - $configuration['isPidIgnored'] = $this->isPidIgnored; |
|
275 | - |
|
276 | - $internalModuleSignature = $this->getInternalModuleSignature(); |
|
277 | - $GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature] = $configuration; |
|
278 | - |
|
279 | - // Core module registration. |
|
280 | - // Register and displays module in the BE only if told, default is "true". |
|
281 | - if ($this->isShown) { |
|
282 | - |
|
283 | - $moduleConfiguration = []; |
|
284 | - #$moduleConfiguration['routeTarget'] = \Fab\Vidi\Controller\ContentController::class . '::mainAction', // what to do here? |
|
285 | - $moduleConfiguration['access'] = $this->getAccess(); |
|
286 | - $moduleConfiguration['labels'] = $this->getModuleLanguageFile(); |
|
287 | - $icon = $this->getIcon(); |
|
288 | - if ($icon) { |
|
289 | - $moduleConfiguration['icon'] = $icon; |
|
290 | - } |
|
291 | - |
|
292 | - if ($this->showPageTree) { |
|
293 | - $moduleConfiguration['navigationComponentId'] = 'TYPO3/CMS/Backend/PageTree/PageTreeElement'; |
|
294 | - $moduleConfiguration['inheritNavigationComponentFromMainModule'] = true; |
|
295 | - } else { |
|
296 | - $moduleConfiguration['inheritNavigationComponentFromMainModule'] = true; |
|
297 | - } |
|
298 | - |
|
299 | - ExtensionUtility::registerModule( |
|
300 | - 'Fab.vidi', |
|
301 | - $this->computeMainModule(), |
|
302 | - $this->dataType . '_' . $this->moduleKey, |
|
303 | - $this->position, |
|
304 | - [ |
|
305 | - \Fab\Vidi\Controller\ContentController::class => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard', |
|
306 | - \Fab\Vidi\Controller\ToolController::class => 'welcome, work', |
|
307 | - \Fab\Vidi\Controller\FacetController::class => 'autoSuggest, autoSuggests', |
|
308 | - \Fab\Vidi\Controller\SelectionController::class => 'edit, update, create, delete, list, show', |
|
309 | - \Fab\Vidi\Controller\UserPreferencesController::class => 'save', |
|
310 | - \Fab\Vidi\Controller\ClipboardController::class => 'save, flush, show', |
|
311 | - ], |
|
312 | - $moduleConfiguration |
|
313 | - ); |
|
314 | - } |
|
315 | - return $this; |
|
316 | - } |
|
317 | - |
|
318 | - /** |
|
319 | - * Return the module code for a BE module. |
|
320 | - * |
|
321 | - * @return string |
|
322 | - */ |
|
323 | - public function getSignature(): string |
|
324 | - { |
|
325 | - $signature = GeneralUtility::_GP(Parameter::MODULE); |
|
326 | - $trimmedSignature = trim($signature, '/'); |
|
327 | - return str_replace(['/', 'module_'], ['_', ''], $trimmedSignature); |
|
328 | - } |
|
329 | - |
|
330 | - /** |
|
331 | - * Returns the current pid. |
|
332 | - * |
|
333 | - * @return int |
|
334 | - */ |
|
335 | - public function getCurrentPid(): int |
|
336 | - { |
|
337 | - return GeneralUtility::_GET(Parameter::PID) > 0 ? (int)GeneralUtility::_GET(Parameter::PID) : 0; |
|
338 | - } |
|
339 | - |
|
340 | - /** |
|
341 | - * Return the module URL. |
|
342 | - * |
|
343 | - * @param array $additionalParameters |
|
344 | - * @return string |
|
345 | - */ |
|
346 | - public function getModuleUrl(array $additionalParameters = []): string |
|
347 | - { |
|
348 | - $moduleCode = $this->getSignature(); |
|
349 | - |
|
350 | - // And don't forget the pid! |
|
351 | - if (GeneralUtility::_GET(Parameter::PID)) { |
|
352 | - $additionalParameters[Parameter::PID] = GeneralUtility::_GET(Parameter::PID); |
|
353 | - } |
|
354 | - |
|
355 | - return BackendUtility::getModuleUrl($moduleCode, $additionalParameters); |
|
356 | - } |
|
357 | - |
|
358 | - /** |
|
359 | - * Return the parameter prefix for a BE module. |
|
360 | - * |
|
361 | - * @return string |
|
362 | - */ |
|
363 | - public function getParameterPrefix(): string |
|
364 | - { |
|
365 | - return 'tx_vidi_' . strtolower($this->getSignature()); |
|
366 | - } |
|
367 | - |
|
368 | - /** |
|
369 | - * Return a configuration key or the entire module configuration array if not key is given. |
|
370 | - * |
|
371 | - * @param string $key |
|
372 | - * @return mixed |
|
373 | - */ |
|
374 | - public function getModuleConfiguration($key = '') |
|
375 | - { |
|
376 | - |
|
377 | - $vidiModuleCode = $this->getSignature(); |
|
378 | - |
|
379 | - // Module code must exist |
|
380 | - if (empty($GLOBALS['TBE_MODULES_EXT']['vidi'][$vidiModuleCode])) { |
|
381 | - $message = sprintf('Invalid or not existing module code "%s"', $vidiModuleCode); |
|
382 | - throw new InvalidKeyInArrayException($message, 1375092053); |
|
383 | - } |
|
384 | - |
|
385 | - $result = $GLOBALS['TBE_MODULES_EXT']['vidi'][$vidiModuleCode]; |
|
386 | - |
|
387 | - if (!empty($key)) { |
|
388 | - if (isset($result[$key])) { |
|
389 | - $result = $result[$key]; |
|
390 | - } else { |
|
391 | - // key must exist |
|
392 | - $message = sprintf('Invalid key configuration "%s"', $key); |
|
393 | - throw new InvalidKeyInArrayException($message, 1375092054); |
|
394 | - } |
|
395 | - } |
|
396 | - return $result; |
|
397 | - } |
|
398 | - |
|
399 | - /** |
|
400 | - * @param string $icon |
|
401 | - * @return $this |
|
402 | - */ |
|
403 | - public function setIcon($icon): self |
|
404 | - { |
|
405 | - $this->icon = $icon; |
|
406 | - return $this; |
|
407 | - } |
|
408 | - |
|
409 | - /** |
|
410 | - * @return string |
|
411 | - */ |
|
412 | - protected function getIcon(): string |
|
413 | - { |
|
414 | - $moduleConfiguration = $this->getExistingMainConfiguration(); |
|
415 | - |
|
416 | - |
|
417 | - if ($this->icon) { |
|
418 | - $icon = $this->icon; |
|
419 | - } elseif ($moduleConfiguration['icon']) { // existing configuration may override. |
|
420 | - $icon = $moduleConfiguration['icon']; |
|
421 | - } else { |
|
422 | - $icon = ''; //default value. |
|
423 | - } |
|
424 | - |
|
425 | - return $icon; |
|
426 | - } |
|
427 | - |
|
428 | - /** |
|
429 | - * @param string $mainModule |
|
430 | - * @return $this |
|
431 | - */ |
|
432 | - public function setMainModule($mainModule): self |
|
433 | - { |
|
434 | - $this->mainModule = $mainModule; |
|
435 | - return $this; |
|
436 | - } |
|
437 | - |
|
438 | - /** |
|
439 | - * @return string |
|
440 | - */ |
|
441 | - public function getMainModule(): string |
|
442 | - { |
|
443 | - if ($this->mainModule === null) { |
|
444 | - $this->mainModule = $this->getModuleConfiguration('mainModule'); |
|
445 | - } |
|
446 | - return $this->mainModule; |
|
447 | - } |
|
448 | - |
|
449 | - /** |
|
450 | - * @param string $moduleLanguageFile |
|
451 | - * @return $this |
|
452 | - */ |
|
453 | - public function setModuleLanguageFile($moduleLanguageFile): self |
|
454 | - { |
|
455 | - $this->moduleLanguageFile = $moduleLanguageFile; |
|
456 | - return $this; |
|
457 | - } |
|
458 | - |
|
459 | - /** |
|
460 | - * @param string $component |
|
461 | - * @return $this |
|
462 | - */ |
|
463 | - public function removeComponentFromDocHeader(string $component): self |
|
464 | - { |
|
465 | - foreach ($this->components[ModulePosition::DOC_HEADER] as $verticalPosition => $docHeaders) { |
|
466 | - foreach ($docHeaders as $horizontalPosition => $docHeader) { |
|
467 | - |
|
468 | - $index = array_search($component, $docHeader, true); |
|
469 | - if ($index !== false) { |
|
470 | - // $verticalPosition: top or bottom |
|
471 | - // $horizontalPosition: left or right |
|
472 | - unset($this->components[ModulePosition::DOC_HEADER][$verticalPosition][$horizontalPosition][$index]); |
|
473 | - } |
|
474 | - } |
|
475 | - } |
|
476 | - return $this; |
|
477 | - } |
|
478 | - |
|
479 | - /** |
|
480 | - * @param bool $isPidIgnored |
|
481 | - * @return $this |
|
482 | - */ |
|
483 | - public function ignorePid(bool $isPidIgnored): self |
|
484 | - { |
|
485 | - $this->isPidIgnored = $isPidIgnored; |
|
486 | - return $this; |
|
487 | - } |
|
488 | - |
|
489 | - /** |
|
490 | - * @return bool |
|
491 | - */ |
|
492 | - public function isPidIgnored(): bool |
|
493 | - { |
|
494 | - return $this->getModuleConfiguration('isPidIgnored'); |
|
495 | - } |
|
496 | - |
|
497 | - /** |
|
498 | - * @param string $component |
|
499 | - * @return bool |
|
500 | - */ |
|
501 | - public function hasComponentInDocHeader(string $component): bool |
|
502 | - { |
|
503 | - foreach ($this->getModuleConfiguration('components')[ModulePosition::DOC_HEADER] as $verticalPosition => $docHeaders) { |
|
504 | - foreach ($docHeaders as $horizontalPosition => $docHeader) { |
|
505 | - |
|
506 | - $index = array_search($component, $docHeader, true); |
|
507 | - if ($index !== false) { |
|
508 | - return true; |
|
509 | - } |
|
510 | - } |
|
511 | - } |
|
512 | - return false; |
|
513 | - } |
|
514 | - |
|
515 | - /** |
|
516 | - * @return string |
|
517 | - */ |
|
518 | - protected function getModuleLanguageFile(): string |
|
519 | - { |
|
520 | - $moduleConfiguration = $this->getExistingMainConfiguration(); |
|
521 | - |
|
522 | - if ($this->moduleLanguageFile) { |
|
523 | - $moduleLanguageFile = $this->moduleLanguageFile; |
|
524 | - } elseif ($moduleConfiguration['labels']) { // existing configuration may override. |
|
525 | - $moduleLanguageFile = $moduleConfiguration['labels']; |
|
526 | - } else { |
|
527 | - $moduleLanguageFile = ''; //default value. |
|
528 | - } |
|
529 | - |
|
530 | - return $moduleLanguageFile; |
|
531 | - } |
|
532 | - |
|
533 | - /** |
|
534 | - * @param string $position |
|
535 | - * @return $this |
|
536 | - */ |
|
537 | - public function setPosition($position): self |
|
538 | - { |
|
539 | - $this->position = $position; |
|
540 | - return $this; |
|
541 | - } |
|
542 | - |
|
543 | - /** |
|
544 | - * @return string |
|
545 | - */ |
|
546 | - public function getPosition(): string |
|
547 | - { |
|
548 | - return $this->position; |
|
549 | - } |
|
550 | - |
|
551 | - /** |
|
552 | - * @param array $files |
|
553 | - * @return $this |
|
554 | - */ |
|
555 | - public function addJavaScriptFiles(array $files): self |
|
556 | - { |
|
557 | - foreach ($files as $file) { |
|
558 | - $this->additionalJavaScriptFiles[] = $file; |
|
559 | - } |
|
560 | - return $this; |
|
561 | - } |
|
562 | - |
|
563 | - /** |
|
564 | - * @param string $fileNameAndPath |
|
565 | - * @return $this |
|
566 | - */ |
|
567 | - public function addJavaScriptFile($fileNameAndPath): self |
|
568 | - { |
|
569 | - $this->additionalJavaScriptFiles[] = $fileNameAndPath; |
|
570 | - return $this; |
|
571 | - } |
|
572 | - |
|
573 | - /** |
|
574 | - * @param array $files |
|
575 | - * @return $this |
|
576 | - */ |
|
577 | - public function addStyleSheetFiles(array $files): self |
|
578 | - { |
|
579 | - foreach ($files as $file) { |
|
580 | - $this->additionalStyleSheetFiles[] = $file; |
|
581 | - } |
|
582 | - return $this; |
|
583 | - } |
|
584 | - |
|
585 | - /** |
|
586 | - * @param string $fileNameAndPath |
|
587 | - * @return $this |
|
588 | - */ |
|
589 | - public function addStyleSheetFile($fileNameAndPath): self |
|
590 | - { |
|
591 | - $this->additionalStyleSheetFiles[] = $fileNameAndPath; |
|
592 | - return $this; |
|
593 | - } |
|
594 | - |
|
595 | - /** |
|
596 | - * @return string |
|
597 | - */ |
|
598 | - public function getDataType(): string |
|
599 | - { |
|
600 | - if ($this->dataType === null) { |
|
601 | - $this->dataType = $this->getModuleConfiguration('dataType'); |
|
602 | - } |
|
603 | - return $this->dataType; |
|
604 | - } |
|
605 | - |
|
606 | - /** |
|
607 | - * @return array |
|
608 | - */ |
|
609 | - public function getDataTypes(): array |
|
610 | - { |
|
611 | - $dataTypes = []; |
|
612 | - foreach ($GLOBALS['TBE_MODULES_EXT']['vidi'] as $module) { |
|
613 | - $dataTypes[] = $module['dataType']; |
|
614 | - } |
|
615 | - return $dataTypes; |
|
616 | - } |
|
617 | - |
|
618 | - /** |
|
619 | - * @param string $dataType |
|
620 | - * @return $this |
|
621 | - */ |
|
622 | - public function setDataType($dataType): self |
|
623 | - { |
|
624 | - $this->dataType = $dataType; |
|
625 | - return $this; |
|
626 | - } |
|
627 | - |
|
628 | - /** |
|
629 | - * @return int |
|
630 | - */ |
|
631 | - public function getDefaultPid(): int |
|
632 | - { |
|
633 | - if (empty($this->defaultPid)) { |
|
634 | - $this->defaultPid = $this->getModuleConfiguration('defaultPid'); |
|
635 | - } |
|
636 | - return (int)$this->defaultPid; |
|
637 | - } |
|
638 | - |
|
639 | - /** |
|
640 | - * @param string $defaultPid |
|
641 | - * @return $this |
|
642 | - */ |
|
643 | - public function setDefaultPid($defaultPid): self |
|
644 | - { |
|
645 | - $this->defaultPid = $defaultPid; |
|
646 | - return $this; |
|
647 | - } |
|
648 | - |
|
649 | - /** |
|
650 | - * @param bool $isPageTreeShown |
|
651 | - * @return $this |
|
652 | - */ |
|
653 | - public function showPageTree($isPageTreeShown): self |
|
654 | - { |
|
655 | - $this->showPageTree = $isPageTreeShown; |
|
656 | - return $this; |
|
657 | - } |
|
658 | - |
|
659 | - /** |
|
660 | - * @param string $isShown |
|
661 | - * @return $this |
|
662 | - */ |
|
663 | - public function isShown($isShown): self |
|
664 | - { |
|
665 | - $this->isShown = $isShown; |
|
666 | - return $this; |
|
667 | - } |
|
668 | - |
|
669 | - /** |
|
670 | - * @return $array |
|
671 | - */ |
|
672 | - public function getDocHeaderTopLeftComponents() |
|
673 | - { |
|
674 | - $configuration = $this->getModuleConfiguration(); |
|
675 | - return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT]; |
|
676 | - } |
|
677 | - |
|
678 | - /** |
|
679 | - * @param array $components |
|
680 | - * @return $this |
|
681 | - */ |
|
682 | - public function setDocHeaderTopLeftComponents(array $components): self |
|
683 | - { |
|
684 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT] = $components; |
|
685 | - return $this; |
|
686 | - } |
|
687 | - |
|
688 | - /** |
|
689 | - * @param string|array $components |
|
690 | - * @return $this |
|
691 | - */ |
|
692 | - public function addDocHeaderTopLeftComponents($components): self |
|
693 | - { |
|
694 | - if (is_string($components)) { |
|
695 | - $components = [$components]; |
|
696 | - } |
|
697 | - $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT]; |
|
698 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT] = array_merge($currentComponents, $components); |
|
699 | - return $this; |
|
700 | - } |
|
701 | - |
|
702 | - /** |
|
703 | - * @return $array |
|
704 | - */ |
|
705 | - public function getDocHeaderTopRightComponents() |
|
706 | - { |
|
707 | - $configuration = $this->getModuleConfiguration(); |
|
708 | - return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT]; |
|
709 | - } |
|
710 | - |
|
711 | - /** |
|
712 | - * @param array $components |
|
713 | - * @return $this |
|
714 | - */ |
|
715 | - public function setDocHeaderTopRightComponents(array $components): self |
|
716 | - { |
|
717 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT] = $components; |
|
718 | - return $this; |
|
719 | - } |
|
720 | - |
|
721 | - /** |
|
722 | - * @param string|array $components |
|
723 | - * @return $this |
|
724 | - */ |
|
725 | - public function addDocHeaderTopRightComponents($components): self |
|
726 | - { |
|
727 | - if (is_string($components)) { |
|
728 | - $components = [$components]; |
|
729 | - } |
|
730 | - $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT]; |
|
731 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT] = array_merge($currentComponents, $components); |
|
732 | - return $this; |
|
733 | - } |
|
734 | - |
|
735 | - /** |
|
736 | - * @return $array |
|
737 | - */ |
|
738 | - public function getDocHeaderBottomLeftComponents() |
|
739 | - { |
|
740 | - $configuration = $this->getModuleConfiguration(); |
|
741 | - return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT]; |
|
742 | - } |
|
743 | - |
|
744 | - /** |
|
745 | - * @param array $components |
|
746 | - * @return $this |
|
747 | - */ |
|
748 | - public function setDocHeaderBottomLeftComponents(array $components): self |
|
749 | - { |
|
750 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT] = $components; |
|
751 | - return $this; |
|
752 | - } |
|
753 | - |
|
754 | - /** |
|
755 | - * @param string|array $components |
|
756 | - * @return $this |
|
757 | - */ |
|
758 | - public function addDocHeaderBottomLeftComponents($components): self |
|
759 | - { |
|
760 | - if (is_string($components)) { |
|
761 | - $components = [$components]; |
|
762 | - } |
|
763 | - $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT]; |
|
764 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT] = array_merge($currentComponents, $components); |
|
765 | - return $this; |
|
766 | - } |
|
767 | - |
|
768 | - /** |
|
769 | - * @return $array |
|
770 | - */ |
|
771 | - public function getDocHeaderBottomRightComponents() |
|
772 | - { |
|
773 | - $configuration = $this->getModuleConfiguration(); |
|
774 | - return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT]; |
|
775 | - } |
|
776 | - |
|
777 | - /** |
|
778 | - * @param array $components |
|
779 | - * @return $this |
|
780 | - */ |
|
781 | - public function setDocHeaderBottomRightComponents(array $components): self |
|
782 | - { |
|
783 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT] = $components; |
|
784 | - return $this; |
|
785 | - } |
|
786 | - |
|
787 | - /** |
|
788 | - * @param string|array $components |
|
789 | - * @return $this |
|
790 | - */ |
|
791 | - public function addDocHeaderBottomRightComponents($components): self |
|
792 | - { |
|
793 | - if (is_string($components)) { |
|
794 | - $components = [$components]; |
|
795 | - } |
|
796 | - $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT]; |
|
797 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT] = array_merge($currentComponents, $components); |
|
798 | - return $this; |
|
799 | - } |
|
800 | - |
|
801 | - /** |
|
802 | - * @return $array |
|
803 | - */ |
|
804 | - public function getGridTopComponents() |
|
805 | - { |
|
806 | - $configuration = $this->getModuleConfiguration(); |
|
807 | - return $configuration['components'][ModulePosition::GRID][ModulePosition::TOP]; |
|
808 | - } |
|
809 | - |
|
810 | - /** |
|
811 | - * @param array $components |
|
812 | - * @return $this |
|
813 | - */ |
|
814 | - public function setGridTopComponents(array $components): self |
|
815 | - { |
|
816 | - $this->components[ModulePosition::GRID][ModulePosition::TOP] = $components; |
|
817 | - return $this; |
|
818 | - } |
|
819 | - |
|
820 | - /** |
|
821 | - * @param string|array $components |
|
822 | - * @return $this |
|
823 | - */ |
|
824 | - public function addGridTopComponents($components): self |
|
825 | - { |
|
826 | - if (is_string($components)) { |
|
827 | - $components = [$components]; |
|
828 | - } |
|
829 | - $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::TOP]; |
|
830 | - $this->components[ModulePosition::GRID][ModulePosition::TOP] = array_merge($currentComponents, $components); |
|
831 | - return $this; |
|
832 | - } |
|
833 | - |
|
834 | - /** |
|
835 | - * @return mixed $array |
|
836 | - */ |
|
837 | - public function getGridBottomComponents() |
|
838 | - { |
|
839 | - $configuration = $this->getModuleConfiguration(); |
|
840 | - return $configuration['components'][ModulePosition::GRID][ModulePosition::BOTTOM]; |
|
841 | - } |
|
842 | - |
|
843 | - /** |
|
844 | - * @param array $components |
|
845 | - * @return $this |
|
846 | - */ |
|
847 | - public function setGridBottomComponents(array $components): self |
|
848 | - { |
|
849 | - $this->components[ModulePosition::GRID][ModulePosition::BOTTOM] = $components; |
|
850 | - return $this; |
|
851 | - } |
|
852 | - |
|
853 | - /** |
|
854 | - * @param string|array $components |
|
855 | - * @return $this |
|
856 | - */ |
|
857 | - public function addGridBottomComponents($components): self |
|
858 | - { |
|
859 | - if (is_string($components)) { |
|
860 | - $components = [$components]; |
|
861 | - } |
|
862 | - $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::BOTTOM]; |
|
863 | - $this->components[ModulePosition::GRID][ModulePosition::BOTTOM] = array_merge($currentComponents, $components); |
|
864 | - return $this; |
|
865 | - } |
|
866 | - |
|
867 | - /** |
|
868 | - * @return $array |
|
869 | - */ |
|
870 | - public function getGridButtonsComponents() |
|
871 | - { |
|
872 | - $configuration = $this->getModuleConfiguration(); |
|
873 | - return $configuration['components'][ModulePosition::GRID][ModulePosition::BUTTONS]; |
|
874 | - } |
|
875 | - |
|
876 | - /** |
|
877 | - * @param array $components |
|
878 | - * @return $this |
|
879 | - */ |
|
880 | - public function setGridButtonsComponents(array $components): self |
|
881 | - { |
|
882 | - $this->components[ModulePosition::GRID][ModulePosition::BUTTONS] = $components; |
|
883 | - return $this; |
|
884 | - } |
|
885 | - |
|
886 | - /** |
|
887 | - * @param string|array $components |
|
888 | - * @return $this |
|
889 | - */ |
|
890 | - public function addGridButtonsComponents($components): self |
|
891 | - { |
|
892 | - if (is_string($components)) { |
|
893 | - $components = [$components]; |
|
894 | - } |
|
895 | - $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::BUTTONS]; |
|
896 | - $this->components[ModulePosition::GRID][ModulePosition::BUTTONS] = array_merge($components, $currentComponents); |
|
897 | - return $this; |
|
898 | - } |
|
899 | - |
|
900 | - /** |
|
901 | - * @return $array |
|
902 | - */ |
|
903 | - public function getMenuMassActionComponents() |
|
904 | - { |
|
905 | - $configuration = $this->getModuleConfiguration(); |
|
906 | - return $configuration['components'][ModulePosition::MENU_MASS_ACTION]; |
|
907 | - } |
|
908 | - |
|
909 | - /** |
|
910 | - * @param array $components |
|
911 | - * @return $this |
|
912 | - */ |
|
913 | - public function setMenuMassActionComponents(array $components): self |
|
914 | - { |
|
915 | - $this->components[ModulePosition::MENU_MASS_ACTION] = $components; |
|
916 | - return $this; |
|
917 | - } |
|
918 | - |
|
919 | - /** |
|
920 | - * @param string|array $components |
|
921 | - * @return $this |
|
922 | - */ |
|
923 | - public function addMenuMassActionComponents($components): self |
|
924 | - { |
|
925 | - if (is_string($components)) { |
|
926 | - $components = [$components]; |
|
927 | - } |
|
928 | - $currentComponents = $this->components[ModulePosition::MENU_MASS_ACTION]; |
|
929 | - $this->components[ModulePosition::MENU_MASS_ACTION] = array_merge($components, $currentComponents); |
|
930 | - return $this; |
|
931 | - } |
|
932 | - |
|
933 | - /** |
|
934 | - * @return string |
|
935 | - */ |
|
936 | - protected function getAccess(): string |
|
937 | - { |
|
938 | - $moduleConfiguration = $this->getExistingMainConfiguration(); |
|
939 | - |
|
940 | - if ($this->access !== null) { |
|
941 | - $access = $this->access; |
|
942 | - } elseif (!empty($moduleConfiguration['access'])) { // existing configuration may override. |
|
943 | - $access = $moduleConfiguration['access']; |
|
944 | - } else { |
|
945 | - $access = Access::USER; //default value. |
|
946 | - } |
|
947 | - return $access; |
|
948 | - } |
|
949 | - |
|
950 | - /** |
|
951 | - * @param string $access |
|
952 | - * @return $this |
|
953 | - */ |
|
954 | - public function setAccess($access): self |
|
955 | - { |
|
956 | - $this->access = $access; |
|
957 | - return $this; |
|
958 | - } |
|
959 | - |
|
960 | - /** |
|
961 | - * @return \string[] |
|
962 | - */ |
|
963 | - public function getAdditionalJavaScriptFiles(): array |
|
964 | - { |
|
965 | - if (empty($this->additionalJavaScriptFiles)) { |
|
966 | - $this->additionalJavaScriptFiles = $this->getModuleConfiguration('additionalJavaScriptFiles'); |
|
967 | - } |
|
968 | - return $this->additionalJavaScriptFiles; |
|
969 | - } |
|
970 | - |
|
971 | - /** |
|
972 | - * @return \string[] |
|
973 | - */ |
|
974 | - public function getAdditionalStyleSheetFiles(): array |
|
975 | - { |
|
976 | - if (empty($this->additionalStyleSheetFiles)) { |
|
977 | - $this->additionalStyleSheetFiles = $this->getModuleConfiguration('additionalStyleSheetFiles'); |
|
978 | - } |
|
979 | - return $this->additionalStyleSheetFiles; |
|
980 | - } |
|
981 | - |
|
982 | - /** |
|
983 | - * @return array |
|
984 | - */ |
|
985 | - public function getComponents(): array |
|
986 | - { |
|
987 | - return $this->components; |
|
988 | - } |
|
989 | - |
|
990 | - /** |
|
991 | - * @param string $pluginName |
|
992 | - * @return bool |
|
993 | - */ |
|
994 | - public function hasPlugin($pluginName = ''): bool |
|
995 | - { |
|
996 | - $parameterPrefix = $this->getParameterPrefix(); |
|
997 | - $parameters = GeneralUtility::_GET($parameterPrefix); |
|
998 | - |
|
999 | - $hasPlugin = !empty($parameters['plugins']) && is_array($parameters['plugins']); |
|
1000 | - if ($hasPlugin && $pluginName) { |
|
1001 | - $hasPlugin = in_array($pluginName, $parameters['plugins']); |
|
1002 | - } |
|
1003 | - return $hasPlugin; |
|
1004 | - } |
|
1005 | - |
|
1006 | - /** |
|
1007 | - * Compute the internal module code |
|
1008 | - * |
|
1009 | - * @param null|string $dataType |
|
1010 | - * @return string |
|
1011 | - */ |
|
1012 | - protected function getInternalModuleSignature($dataType = null): string |
|
1013 | - { |
|
1014 | - // Else we forge the module signature |
|
1015 | - if ($dataType === null) { |
|
1016 | - $dataType = $this->dataType; |
|
1017 | - } |
|
1018 | - $subModuleName = $dataType . '_' . $this->moduleKey; |
|
1019 | - |
|
1020 | - $mainModule = $this->mainModule ?: self::DEFAULT_MAIN_MODULE; |
|
1021 | - return $mainModule . '_Vidi' . GeneralUtility::underscoredToUpperCamelCase($subModuleName); |
|
1022 | - } |
|
24 | + /** |
|
25 | + * Define the default main module |
|
26 | + */ |
|
27 | + const DEFAULT_MAIN_MODULE = 'content'; |
|
28 | + |
|
29 | + /** |
|
30 | + * Define the default pid |
|
31 | + */ |
|
32 | + const DEFAULT_PID = 0; |
|
33 | + |
|
34 | + /** |
|
35 | + * The type of data being listed (which corresponds to a table name in TCA) |
|
36 | + * |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + protected $dataType; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + protected $defaultPid; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var bool |
|
48 | + */ |
|
49 | + protected $isPidIgnored = false; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var bool |
|
53 | + */ |
|
54 | + protected $showPageTree = false; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var bool |
|
58 | + */ |
|
59 | + protected $isShown = true; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var string |
|
63 | + */ |
|
64 | + protected $access; |
|
65 | + |
|
66 | + /** |
|
67 | + * @var string |
|
68 | + */ |
|
69 | + protected $mainModule; |
|
70 | + |
|
71 | + /** |
|
72 | + * @var string |
|
73 | + */ |
|
74 | + protected $position = ''; |
|
75 | + |
|
76 | + /** |
|
77 | + * @var string |
|
78 | + */ |
|
79 | + protected $icon; |
|
80 | + |
|
81 | + /** |
|
82 | + * @var string |
|
83 | + */ |
|
84 | + protected $moduleLanguageFile; |
|
85 | + |
|
86 | + /** |
|
87 | + * The module key such as m1, m2. |
|
88 | + * |
|
89 | + * @var string |
|
90 | + */ |
|
91 | + protected $moduleKey = 'm1'; |
|
92 | + |
|
93 | + /** |
|
94 | + * @var string[] |
|
95 | + */ |
|
96 | + protected $additionalJavaScriptFiles = []; |
|
97 | + |
|
98 | + /** |
|
99 | + * @var string[] |
|
100 | + */ |
|
101 | + protected $additionalStyleSheetFiles = []; |
|
102 | + |
|
103 | + /** |
|
104 | + * @var array |
|
105 | + */ |
|
106 | + protected $components = []; |
|
107 | + |
|
108 | + /** |
|
109 | + * @param string $dataType |
|
110 | + */ |
|
111 | + public function __construct($dataType = null) |
|
112 | + { |
|
113 | + $this->dataType = $dataType; |
|
114 | + |
|
115 | + // Initialize components |
|
116 | + $this->components = [ |
|
117 | + ModulePosition::DOC_HEADER => [ |
|
118 | + ModulePosition::TOP => [ |
|
119 | + ModulePosition::LEFT => [], |
|
120 | + ModulePosition::RIGHT => [ |
|
121 | + \Fab\Vidi\View\Button\ToolButton::class, |
|
122 | + ], |
|
123 | + ], |
|
124 | + ModulePosition::BOTTOM => [ |
|
125 | + ModulePosition::LEFT => [ |
|
126 | + \Fab\Vidi\View\Button\NewButton::class, |
|
127 | + \Fab\Vidi\ViewHelpers\Link\BackViewHelper::class, |
|
128 | + ], |
|
129 | + ModulePosition::RIGHT => [], |
|
130 | + ], |
|
131 | + ], |
|
132 | + ModulePosition::GRID => [ |
|
133 | + ModulePosition::TOP => [ |
|
134 | + \Fab\Vidi\View\Check\RelationsCheck::class, |
|
135 | + #\Fab\Vidi\View\Tab\DataTypeTab::class, |
|
136 | + ], |
|
137 | + ModulePosition::BUTTONS => [ |
|
138 | + \Fab\Vidi\View\Button\EditButton::class, |
|
139 | + \Fab\Vidi\View\Button\DeleteButton::class, |
|
140 | + ], |
|
141 | + ModulePosition::BOTTOM => [], |
|
142 | + ], |
|
143 | + ModulePosition::MENU_MASS_ACTION => [ |
|
144 | + \Fab\Vidi\View\MenuItem\ExportXlsMenuItem::class, |
|
145 | + \Fab\Vidi\View\MenuItem\ExportXmlMenuItem::class, |
|
146 | + \Fab\Vidi\View\MenuItem\ExportCsvMenuItem::class, |
|
147 | + \Fab\Vidi\View\MenuItem\DividerMenuItem::class, |
|
148 | + \Fab\Vidi\View\MenuItem\MassDeleteMenuItem::class, |
|
149 | + #\Fab\Vidi\View\MenuItem\MassEditMenuItem::class, |
|
150 | + ], |
|
151 | + ]; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Tell whether a module is already registered. |
|
156 | + * |
|
157 | + * @param string $dataType |
|
158 | + * @return bool |
|
159 | + */ |
|
160 | + public function isRegistered($dataType): bool |
|
161 | + { |
|
162 | + $internalModuleSignature = $this->getInternalModuleSignature($dataType); |
|
163 | + return !empty($GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature]); |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * @return array |
|
168 | + */ |
|
169 | + protected function getExistingInternalConfiguration(): array |
|
170 | + { |
|
171 | + $internalModuleSignature = $this->getInternalModuleSignature(); |
|
172 | + return $GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature] ?? []; |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * @return array |
|
177 | + */ |
|
178 | + protected function getExistingMainConfiguration(): array |
|
179 | + { |
|
180 | + $moduleSignature = $this->computeMainModule() . '_' . $this->getInternalModuleSignature(); |
|
181 | + return $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature] ?? []; |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * @return string |
|
186 | + */ |
|
187 | + protected function computeMainModule(): string |
|
188 | + { |
|
189 | + $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
190 | + |
|
191 | + if ($this->mainModule !== null) { |
|
192 | + $mainModule = $this->mainModule; |
|
193 | + } elseif (!empty($existingConfiguration['mainModule'])) { // existing configuration may override. |
|
194 | + $mainModule = $existingConfiguration['mainModule']; |
|
195 | + } else { |
|
196 | + $mainModule = self::DEFAULT_MAIN_MODULE; //default value. |
|
197 | + } |
|
198 | + return $mainModule; |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * @return string |
|
203 | + */ |
|
204 | + protected function computeDefaultPid(): string |
|
205 | + { |
|
206 | + $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
207 | + |
|
208 | + if ($this->defaultPid !== null) { |
|
209 | + $defaultPid = $this->defaultPid; |
|
210 | + } elseif (!empty($existingConfiguration['defaultPid'])) { // existing configuration may override. |
|
211 | + $defaultPid = $existingConfiguration['defaultPid']; |
|
212 | + } else { |
|
213 | + $defaultPid = self::DEFAULT_PID; //default value. |
|
214 | + } |
|
215 | + return $defaultPid; |
|
216 | + } |
|
217 | + |
|
218 | + /** |
|
219 | + * @return array |
|
220 | + */ |
|
221 | + protected function computeAdditionalJavaScriptFiles(): array |
|
222 | + { |
|
223 | + $additionalJavaScriptFiles = $this->additionalJavaScriptFiles; |
|
224 | + |
|
225 | + // Possible merge of existing javascript files. |
|
226 | + $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
227 | + if (!empty($existingConfiguration['additionalJavaScriptFiles'])) { |
|
228 | + $additionalJavaScriptFiles = array_merge($additionalJavaScriptFiles, $existingConfiguration['additionalJavaScriptFiles']); |
|
229 | + } |
|
230 | + |
|
231 | + return $additionalJavaScriptFiles; |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * @return array |
|
236 | + */ |
|
237 | + protected function computeAdditionalStyleSheetFiles(): array |
|
238 | + { |
|
239 | + $additionalStyleSheetFiles = $this->additionalStyleSheetFiles; |
|
240 | + |
|
241 | + // Possible merge of existing style sheets. |
|
242 | + $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
243 | + if (!empty($existingConfiguration['additionalStyleSheetFiles'])) { |
|
244 | + $additionalStyleSheetFiles = array_merge($additionalStyleSheetFiles, $existingConfiguration['additionalStyleSheetFiles']); |
|
245 | + } |
|
246 | + |
|
247 | + return $additionalStyleSheetFiles; |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * @return array |
|
252 | + */ |
|
253 | + protected function computeComponents(): array |
|
254 | + { |
|
255 | + // We override the config in any case. See if we need more than that. |
|
256 | + return $this->components; |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Register the module in two places: core + vidi internal. |
|
261 | + * |
|
262 | + * @return $this |
|
263 | + */ |
|
264 | + public function register(): self |
|
265 | + { |
|
266 | + // Internal Vidi module registration. |
|
267 | + $configuration = []; |
|
268 | + $configuration['dataType'] = $this->dataType; |
|
269 | + $configuration['mainModule'] = $this->computeMainModule(); |
|
270 | + $configuration['defaultPid'] = $this->computeDefaultPid(); |
|
271 | + $configuration['additionalJavaScriptFiles'] = $this->computeAdditionalJavaScriptFiles(); |
|
272 | + $configuration['additionalStyleSheetFiles'] = $this->computeAdditionalStyleSheetFiles(); |
|
273 | + $configuration['components'] = $this->computeComponents(); |
|
274 | + $configuration['isPidIgnored'] = $this->isPidIgnored; |
|
275 | + |
|
276 | + $internalModuleSignature = $this->getInternalModuleSignature(); |
|
277 | + $GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature] = $configuration; |
|
278 | + |
|
279 | + // Core module registration. |
|
280 | + // Register and displays module in the BE only if told, default is "true". |
|
281 | + if ($this->isShown) { |
|
282 | + |
|
283 | + $moduleConfiguration = []; |
|
284 | + #$moduleConfiguration['routeTarget'] = \Fab\Vidi\Controller\ContentController::class . '::mainAction', // what to do here? |
|
285 | + $moduleConfiguration['access'] = $this->getAccess(); |
|
286 | + $moduleConfiguration['labels'] = $this->getModuleLanguageFile(); |
|
287 | + $icon = $this->getIcon(); |
|
288 | + if ($icon) { |
|
289 | + $moduleConfiguration['icon'] = $icon; |
|
290 | + } |
|
291 | + |
|
292 | + if ($this->showPageTree) { |
|
293 | + $moduleConfiguration['navigationComponentId'] = 'TYPO3/CMS/Backend/PageTree/PageTreeElement'; |
|
294 | + $moduleConfiguration['inheritNavigationComponentFromMainModule'] = true; |
|
295 | + } else { |
|
296 | + $moduleConfiguration['inheritNavigationComponentFromMainModule'] = true; |
|
297 | + } |
|
298 | + |
|
299 | + ExtensionUtility::registerModule( |
|
300 | + 'Fab.vidi', |
|
301 | + $this->computeMainModule(), |
|
302 | + $this->dataType . '_' . $this->moduleKey, |
|
303 | + $this->position, |
|
304 | + [ |
|
305 | + \Fab\Vidi\Controller\ContentController::class => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard', |
|
306 | + \Fab\Vidi\Controller\ToolController::class => 'welcome, work', |
|
307 | + \Fab\Vidi\Controller\FacetController::class => 'autoSuggest, autoSuggests', |
|
308 | + \Fab\Vidi\Controller\SelectionController::class => 'edit, update, create, delete, list, show', |
|
309 | + \Fab\Vidi\Controller\UserPreferencesController::class => 'save', |
|
310 | + \Fab\Vidi\Controller\ClipboardController::class => 'save, flush, show', |
|
311 | + ], |
|
312 | + $moduleConfiguration |
|
313 | + ); |
|
314 | + } |
|
315 | + return $this; |
|
316 | + } |
|
317 | + |
|
318 | + /** |
|
319 | + * Return the module code for a BE module. |
|
320 | + * |
|
321 | + * @return string |
|
322 | + */ |
|
323 | + public function getSignature(): string |
|
324 | + { |
|
325 | + $signature = GeneralUtility::_GP(Parameter::MODULE); |
|
326 | + $trimmedSignature = trim($signature, '/'); |
|
327 | + return str_replace(['/', 'module_'], ['_', ''], $trimmedSignature); |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * Returns the current pid. |
|
332 | + * |
|
333 | + * @return int |
|
334 | + */ |
|
335 | + public function getCurrentPid(): int |
|
336 | + { |
|
337 | + return GeneralUtility::_GET(Parameter::PID) > 0 ? (int)GeneralUtility::_GET(Parameter::PID) : 0; |
|
338 | + } |
|
339 | + |
|
340 | + /** |
|
341 | + * Return the module URL. |
|
342 | + * |
|
343 | + * @param array $additionalParameters |
|
344 | + * @return string |
|
345 | + */ |
|
346 | + public function getModuleUrl(array $additionalParameters = []): string |
|
347 | + { |
|
348 | + $moduleCode = $this->getSignature(); |
|
349 | + |
|
350 | + // And don't forget the pid! |
|
351 | + if (GeneralUtility::_GET(Parameter::PID)) { |
|
352 | + $additionalParameters[Parameter::PID] = GeneralUtility::_GET(Parameter::PID); |
|
353 | + } |
|
354 | + |
|
355 | + return BackendUtility::getModuleUrl($moduleCode, $additionalParameters); |
|
356 | + } |
|
357 | + |
|
358 | + /** |
|
359 | + * Return the parameter prefix for a BE module. |
|
360 | + * |
|
361 | + * @return string |
|
362 | + */ |
|
363 | + public function getParameterPrefix(): string |
|
364 | + { |
|
365 | + return 'tx_vidi_' . strtolower($this->getSignature()); |
|
366 | + } |
|
367 | + |
|
368 | + /** |
|
369 | + * Return a configuration key or the entire module configuration array if not key is given. |
|
370 | + * |
|
371 | + * @param string $key |
|
372 | + * @return mixed |
|
373 | + */ |
|
374 | + public function getModuleConfiguration($key = '') |
|
375 | + { |
|
376 | + |
|
377 | + $vidiModuleCode = $this->getSignature(); |
|
378 | + |
|
379 | + // Module code must exist |
|
380 | + if (empty($GLOBALS['TBE_MODULES_EXT']['vidi'][$vidiModuleCode])) { |
|
381 | + $message = sprintf('Invalid or not existing module code "%s"', $vidiModuleCode); |
|
382 | + throw new InvalidKeyInArrayException($message, 1375092053); |
|
383 | + } |
|
384 | + |
|
385 | + $result = $GLOBALS['TBE_MODULES_EXT']['vidi'][$vidiModuleCode]; |
|
386 | + |
|
387 | + if (!empty($key)) { |
|
388 | + if (isset($result[$key])) { |
|
389 | + $result = $result[$key]; |
|
390 | + } else { |
|
391 | + // key must exist |
|
392 | + $message = sprintf('Invalid key configuration "%s"', $key); |
|
393 | + throw new InvalidKeyInArrayException($message, 1375092054); |
|
394 | + } |
|
395 | + } |
|
396 | + return $result; |
|
397 | + } |
|
398 | + |
|
399 | + /** |
|
400 | + * @param string $icon |
|
401 | + * @return $this |
|
402 | + */ |
|
403 | + public function setIcon($icon): self |
|
404 | + { |
|
405 | + $this->icon = $icon; |
|
406 | + return $this; |
|
407 | + } |
|
408 | + |
|
409 | + /** |
|
410 | + * @return string |
|
411 | + */ |
|
412 | + protected function getIcon(): string |
|
413 | + { |
|
414 | + $moduleConfiguration = $this->getExistingMainConfiguration(); |
|
415 | + |
|
416 | + |
|
417 | + if ($this->icon) { |
|
418 | + $icon = $this->icon; |
|
419 | + } elseif ($moduleConfiguration['icon']) { // existing configuration may override. |
|
420 | + $icon = $moduleConfiguration['icon']; |
|
421 | + } else { |
|
422 | + $icon = ''; //default value. |
|
423 | + } |
|
424 | + |
|
425 | + return $icon; |
|
426 | + } |
|
427 | + |
|
428 | + /** |
|
429 | + * @param string $mainModule |
|
430 | + * @return $this |
|
431 | + */ |
|
432 | + public function setMainModule($mainModule): self |
|
433 | + { |
|
434 | + $this->mainModule = $mainModule; |
|
435 | + return $this; |
|
436 | + } |
|
437 | + |
|
438 | + /** |
|
439 | + * @return string |
|
440 | + */ |
|
441 | + public function getMainModule(): string |
|
442 | + { |
|
443 | + if ($this->mainModule === null) { |
|
444 | + $this->mainModule = $this->getModuleConfiguration('mainModule'); |
|
445 | + } |
|
446 | + return $this->mainModule; |
|
447 | + } |
|
448 | + |
|
449 | + /** |
|
450 | + * @param string $moduleLanguageFile |
|
451 | + * @return $this |
|
452 | + */ |
|
453 | + public function setModuleLanguageFile($moduleLanguageFile): self |
|
454 | + { |
|
455 | + $this->moduleLanguageFile = $moduleLanguageFile; |
|
456 | + return $this; |
|
457 | + } |
|
458 | + |
|
459 | + /** |
|
460 | + * @param string $component |
|
461 | + * @return $this |
|
462 | + */ |
|
463 | + public function removeComponentFromDocHeader(string $component): self |
|
464 | + { |
|
465 | + foreach ($this->components[ModulePosition::DOC_HEADER] as $verticalPosition => $docHeaders) { |
|
466 | + foreach ($docHeaders as $horizontalPosition => $docHeader) { |
|
467 | + |
|
468 | + $index = array_search($component, $docHeader, true); |
|
469 | + if ($index !== false) { |
|
470 | + // $verticalPosition: top or bottom |
|
471 | + // $horizontalPosition: left or right |
|
472 | + unset($this->components[ModulePosition::DOC_HEADER][$verticalPosition][$horizontalPosition][$index]); |
|
473 | + } |
|
474 | + } |
|
475 | + } |
|
476 | + return $this; |
|
477 | + } |
|
478 | + |
|
479 | + /** |
|
480 | + * @param bool $isPidIgnored |
|
481 | + * @return $this |
|
482 | + */ |
|
483 | + public function ignorePid(bool $isPidIgnored): self |
|
484 | + { |
|
485 | + $this->isPidIgnored = $isPidIgnored; |
|
486 | + return $this; |
|
487 | + } |
|
488 | + |
|
489 | + /** |
|
490 | + * @return bool |
|
491 | + */ |
|
492 | + public function isPidIgnored(): bool |
|
493 | + { |
|
494 | + return $this->getModuleConfiguration('isPidIgnored'); |
|
495 | + } |
|
496 | + |
|
497 | + /** |
|
498 | + * @param string $component |
|
499 | + * @return bool |
|
500 | + */ |
|
501 | + public function hasComponentInDocHeader(string $component): bool |
|
502 | + { |
|
503 | + foreach ($this->getModuleConfiguration('components')[ModulePosition::DOC_HEADER] as $verticalPosition => $docHeaders) { |
|
504 | + foreach ($docHeaders as $horizontalPosition => $docHeader) { |
|
505 | + |
|
506 | + $index = array_search($component, $docHeader, true); |
|
507 | + if ($index !== false) { |
|
508 | + return true; |
|
509 | + } |
|
510 | + } |
|
511 | + } |
|
512 | + return false; |
|
513 | + } |
|
514 | + |
|
515 | + /** |
|
516 | + * @return string |
|
517 | + */ |
|
518 | + protected function getModuleLanguageFile(): string |
|
519 | + { |
|
520 | + $moduleConfiguration = $this->getExistingMainConfiguration(); |
|
521 | + |
|
522 | + if ($this->moduleLanguageFile) { |
|
523 | + $moduleLanguageFile = $this->moduleLanguageFile; |
|
524 | + } elseif ($moduleConfiguration['labels']) { // existing configuration may override. |
|
525 | + $moduleLanguageFile = $moduleConfiguration['labels']; |
|
526 | + } else { |
|
527 | + $moduleLanguageFile = ''; //default value. |
|
528 | + } |
|
529 | + |
|
530 | + return $moduleLanguageFile; |
|
531 | + } |
|
532 | + |
|
533 | + /** |
|
534 | + * @param string $position |
|
535 | + * @return $this |
|
536 | + */ |
|
537 | + public function setPosition($position): self |
|
538 | + { |
|
539 | + $this->position = $position; |
|
540 | + return $this; |
|
541 | + } |
|
542 | + |
|
543 | + /** |
|
544 | + * @return string |
|
545 | + */ |
|
546 | + public function getPosition(): string |
|
547 | + { |
|
548 | + return $this->position; |
|
549 | + } |
|
550 | + |
|
551 | + /** |
|
552 | + * @param array $files |
|
553 | + * @return $this |
|
554 | + */ |
|
555 | + public function addJavaScriptFiles(array $files): self |
|
556 | + { |
|
557 | + foreach ($files as $file) { |
|
558 | + $this->additionalJavaScriptFiles[] = $file; |
|
559 | + } |
|
560 | + return $this; |
|
561 | + } |
|
562 | + |
|
563 | + /** |
|
564 | + * @param string $fileNameAndPath |
|
565 | + * @return $this |
|
566 | + */ |
|
567 | + public function addJavaScriptFile($fileNameAndPath): self |
|
568 | + { |
|
569 | + $this->additionalJavaScriptFiles[] = $fileNameAndPath; |
|
570 | + return $this; |
|
571 | + } |
|
572 | + |
|
573 | + /** |
|
574 | + * @param array $files |
|
575 | + * @return $this |
|
576 | + */ |
|
577 | + public function addStyleSheetFiles(array $files): self |
|
578 | + { |
|
579 | + foreach ($files as $file) { |
|
580 | + $this->additionalStyleSheetFiles[] = $file; |
|
581 | + } |
|
582 | + return $this; |
|
583 | + } |
|
584 | + |
|
585 | + /** |
|
586 | + * @param string $fileNameAndPath |
|
587 | + * @return $this |
|
588 | + */ |
|
589 | + public function addStyleSheetFile($fileNameAndPath): self |
|
590 | + { |
|
591 | + $this->additionalStyleSheetFiles[] = $fileNameAndPath; |
|
592 | + return $this; |
|
593 | + } |
|
594 | + |
|
595 | + /** |
|
596 | + * @return string |
|
597 | + */ |
|
598 | + public function getDataType(): string |
|
599 | + { |
|
600 | + if ($this->dataType === null) { |
|
601 | + $this->dataType = $this->getModuleConfiguration('dataType'); |
|
602 | + } |
|
603 | + return $this->dataType; |
|
604 | + } |
|
605 | + |
|
606 | + /** |
|
607 | + * @return array |
|
608 | + */ |
|
609 | + public function getDataTypes(): array |
|
610 | + { |
|
611 | + $dataTypes = []; |
|
612 | + foreach ($GLOBALS['TBE_MODULES_EXT']['vidi'] as $module) { |
|
613 | + $dataTypes[] = $module['dataType']; |
|
614 | + } |
|
615 | + return $dataTypes; |
|
616 | + } |
|
617 | + |
|
618 | + /** |
|
619 | + * @param string $dataType |
|
620 | + * @return $this |
|
621 | + */ |
|
622 | + public function setDataType($dataType): self |
|
623 | + { |
|
624 | + $this->dataType = $dataType; |
|
625 | + return $this; |
|
626 | + } |
|
627 | + |
|
628 | + /** |
|
629 | + * @return int |
|
630 | + */ |
|
631 | + public function getDefaultPid(): int |
|
632 | + { |
|
633 | + if (empty($this->defaultPid)) { |
|
634 | + $this->defaultPid = $this->getModuleConfiguration('defaultPid'); |
|
635 | + } |
|
636 | + return (int)$this->defaultPid; |
|
637 | + } |
|
638 | + |
|
639 | + /** |
|
640 | + * @param string $defaultPid |
|
641 | + * @return $this |
|
642 | + */ |
|
643 | + public function setDefaultPid($defaultPid): self |
|
644 | + { |
|
645 | + $this->defaultPid = $defaultPid; |
|
646 | + return $this; |
|
647 | + } |
|
648 | + |
|
649 | + /** |
|
650 | + * @param bool $isPageTreeShown |
|
651 | + * @return $this |
|
652 | + */ |
|
653 | + public function showPageTree($isPageTreeShown): self |
|
654 | + { |
|
655 | + $this->showPageTree = $isPageTreeShown; |
|
656 | + return $this; |
|
657 | + } |
|
658 | + |
|
659 | + /** |
|
660 | + * @param string $isShown |
|
661 | + * @return $this |
|
662 | + */ |
|
663 | + public function isShown($isShown): self |
|
664 | + { |
|
665 | + $this->isShown = $isShown; |
|
666 | + return $this; |
|
667 | + } |
|
668 | + |
|
669 | + /** |
|
670 | + * @return $array |
|
671 | + */ |
|
672 | + public function getDocHeaderTopLeftComponents() |
|
673 | + { |
|
674 | + $configuration = $this->getModuleConfiguration(); |
|
675 | + return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT]; |
|
676 | + } |
|
677 | + |
|
678 | + /** |
|
679 | + * @param array $components |
|
680 | + * @return $this |
|
681 | + */ |
|
682 | + public function setDocHeaderTopLeftComponents(array $components): self |
|
683 | + { |
|
684 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT] = $components; |
|
685 | + return $this; |
|
686 | + } |
|
687 | + |
|
688 | + /** |
|
689 | + * @param string|array $components |
|
690 | + * @return $this |
|
691 | + */ |
|
692 | + public function addDocHeaderTopLeftComponents($components): self |
|
693 | + { |
|
694 | + if (is_string($components)) { |
|
695 | + $components = [$components]; |
|
696 | + } |
|
697 | + $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT]; |
|
698 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT] = array_merge($currentComponents, $components); |
|
699 | + return $this; |
|
700 | + } |
|
701 | + |
|
702 | + /** |
|
703 | + * @return $array |
|
704 | + */ |
|
705 | + public function getDocHeaderTopRightComponents() |
|
706 | + { |
|
707 | + $configuration = $this->getModuleConfiguration(); |
|
708 | + return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT]; |
|
709 | + } |
|
710 | + |
|
711 | + /** |
|
712 | + * @param array $components |
|
713 | + * @return $this |
|
714 | + */ |
|
715 | + public function setDocHeaderTopRightComponents(array $components): self |
|
716 | + { |
|
717 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT] = $components; |
|
718 | + return $this; |
|
719 | + } |
|
720 | + |
|
721 | + /** |
|
722 | + * @param string|array $components |
|
723 | + * @return $this |
|
724 | + */ |
|
725 | + public function addDocHeaderTopRightComponents($components): self |
|
726 | + { |
|
727 | + if (is_string($components)) { |
|
728 | + $components = [$components]; |
|
729 | + } |
|
730 | + $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT]; |
|
731 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT] = array_merge($currentComponents, $components); |
|
732 | + return $this; |
|
733 | + } |
|
734 | + |
|
735 | + /** |
|
736 | + * @return $array |
|
737 | + */ |
|
738 | + public function getDocHeaderBottomLeftComponents() |
|
739 | + { |
|
740 | + $configuration = $this->getModuleConfiguration(); |
|
741 | + return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT]; |
|
742 | + } |
|
743 | + |
|
744 | + /** |
|
745 | + * @param array $components |
|
746 | + * @return $this |
|
747 | + */ |
|
748 | + public function setDocHeaderBottomLeftComponents(array $components): self |
|
749 | + { |
|
750 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT] = $components; |
|
751 | + return $this; |
|
752 | + } |
|
753 | + |
|
754 | + /** |
|
755 | + * @param string|array $components |
|
756 | + * @return $this |
|
757 | + */ |
|
758 | + public function addDocHeaderBottomLeftComponents($components): self |
|
759 | + { |
|
760 | + if (is_string($components)) { |
|
761 | + $components = [$components]; |
|
762 | + } |
|
763 | + $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT]; |
|
764 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT] = array_merge($currentComponents, $components); |
|
765 | + return $this; |
|
766 | + } |
|
767 | + |
|
768 | + /** |
|
769 | + * @return $array |
|
770 | + */ |
|
771 | + public function getDocHeaderBottomRightComponents() |
|
772 | + { |
|
773 | + $configuration = $this->getModuleConfiguration(); |
|
774 | + return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT]; |
|
775 | + } |
|
776 | + |
|
777 | + /** |
|
778 | + * @param array $components |
|
779 | + * @return $this |
|
780 | + */ |
|
781 | + public function setDocHeaderBottomRightComponents(array $components): self |
|
782 | + { |
|
783 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT] = $components; |
|
784 | + return $this; |
|
785 | + } |
|
786 | + |
|
787 | + /** |
|
788 | + * @param string|array $components |
|
789 | + * @return $this |
|
790 | + */ |
|
791 | + public function addDocHeaderBottomRightComponents($components): self |
|
792 | + { |
|
793 | + if (is_string($components)) { |
|
794 | + $components = [$components]; |
|
795 | + } |
|
796 | + $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT]; |
|
797 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT] = array_merge($currentComponents, $components); |
|
798 | + return $this; |
|
799 | + } |
|
800 | + |
|
801 | + /** |
|
802 | + * @return $array |
|
803 | + */ |
|
804 | + public function getGridTopComponents() |
|
805 | + { |
|
806 | + $configuration = $this->getModuleConfiguration(); |
|
807 | + return $configuration['components'][ModulePosition::GRID][ModulePosition::TOP]; |
|
808 | + } |
|
809 | + |
|
810 | + /** |
|
811 | + * @param array $components |
|
812 | + * @return $this |
|
813 | + */ |
|
814 | + public function setGridTopComponents(array $components): self |
|
815 | + { |
|
816 | + $this->components[ModulePosition::GRID][ModulePosition::TOP] = $components; |
|
817 | + return $this; |
|
818 | + } |
|
819 | + |
|
820 | + /** |
|
821 | + * @param string|array $components |
|
822 | + * @return $this |
|
823 | + */ |
|
824 | + public function addGridTopComponents($components): self |
|
825 | + { |
|
826 | + if (is_string($components)) { |
|
827 | + $components = [$components]; |
|
828 | + } |
|
829 | + $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::TOP]; |
|
830 | + $this->components[ModulePosition::GRID][ModulePosition::TOP] = array_merge($currentComponents, $components); |
|
831 | + return $this; |
|
832 | + } |
|
833 | + |
|
834 | + /** |
|
835 | + * @return mixed $array |
|
836 | + */ |
|
837 | + public function getGridBottomComponents() |
|
838 | + { |
|
839 | + $configuration = $this->getModuleConfiguration(); |
|
840 | + return $configuration['components'][ModulePosition::GRID][ModulePosition::BOTTOM]; |
|
841 | + } |
|
842 | + |
|
843 | + /** |
|
844 | + * @param array $components |
|
845 | + * @return $this |
|
846 | + */ |
|
847 | + public function setGridBottomComponents(array $components): self |
|
848 | + { |
|
849 | + $this->components[ModulePosition::GRID][ModulePosition::BOTTOM] = $components; |
|
850 | + return $this; |
|
851 | + } |
|
852 | + |
|
853 | + /** |
|
854 | + * @param string|array $components |
|
855 | + * @return $this |
|
856 | + */ |
|
857 | + public function addGridBottomComponents($components): self |
|
858 | + { |
|
859 | + if (is_string($components)) { |
|
860 | + $components = [$components]; |
|
861 | + } |
|
862 | + $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::BOTTOM]; |
|
863 | + $this->components[ModulePosition::GRID][ModulePosition::BOTTOM] = array_merge($currentComponents, $components); |
|
864 | + return $this; |
|
865 | + } |
|
866 | + |
|
867 | + /** |
|
868 | + * @return $array |
|
869 | + */ |
|
870 | + public function getGridButtonsComponents() |
|
871 | + { |
|
872 | + $configuration = $this->getModuleConfiguration(); |
|
873 | + return $configuration['components'][ModulePosition::GRID][ModulePosition::BUTTONS]; |
|
874 | + } |
|
875 | + |
|
876 | + /** |
|
877 | + * @param array $components |
|
878 | + * @return $this |
|
879 | + */ |
|
880 | + public function setGridButtonsComponents(array $components): self |
|
881 | + { |
|
882 | + $this->components[ModulePosition::GRID][ModulePosition::BUTTONS] = $components; |
|
883 | + return $this; |
|
884 | + } |
|
885 | + |
|
886 | + /** |
|
887 | + * @param string|array $components |
|
888 | + * @return $this |
|
889 | + */ |
|
890 | + public function addGridButtonsComponents($components): self |
|
891 | + { |
|
892 | + if (is_string($components)) { |
|
893 | + $components = [$components]; |
|
894 | + } |
|
895 | + $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::BUTTONS]; |
|
896 | + $this->components[ModulePosition::GRID][ModulePosition::BUTTONS] = array_merge($components, $currentComponents); |
|
897 | + return $this; |
|
898 | + } |
|
899 | + |
|
900 | + /** |
|
901 | + * @return $array |
|
902 | + */ |
|
903 | + public function getMenuMassActionComponents() |
|
904 | + { |
|
905 | + $configuration = $this->getModuleConfiguration(); |
|
906 | + return $configuration['components'][ModulePosition::MENU_MASS_ACTION]; |
|
907 | + } |
|
908 | + |
|
909 | + /** |
|
910 | + * @param array $components |
|
911 | + * @return $this |
|
912 | + */ |
|
913 | + public function setMenuMassActionComponents(array $components): self |
|
914 | + { |
|
915 | + $this->components[ModulePosition::MENU_MASS_ACTION] = $components; |
|
916 | + return $this; |
|
917 | + } |
|
918 | + |
|
919 | + /** |
|
920 | + * @param string|array $components |
|
921 | + * @return $this |
|
922 | + */ |
|
923 | + public function addMenuMassActionComponents($components): self |
|
924 | + { |
|
925 | + if (is_string($components)) { |
|
926 | + $components = [$components]; |
|
927 | + } |
|
928 | + $currentComponents = $this->components[ModulePosition::MENU_MASS_ACTION]; |
|
929 | + $this->components[ModulePosition::MENU_MASS_ACTION] = array_merge($components, $currentComponents); |
|
930 | + return $this; |
|
931 | + } |
|
932 | + |
|
933 | + /** |
|
934 | + * @return string |
|
935 | + */ |
|
936 | + protected function getAccess(): string |
|
937 | + { |
|
938 | + $moduleConfiguration = $this->getExistingMainConfiguration(); |
|
939 | + |
|
940 | + if ($this->access !== null) { |
|
941 | + $access = $this->access; |
|
942 | + } elseif (!empty($moduleConfiguration['access'])) { // existing configuration may override. |
|
943 | + $access = $moduleConfiguration['access']; |
|
944 | + } else { |
|
945 | + $access = Access::USER; //default value. |
|
946 | + } |
|
947 | + return $access; |
|
948 | + } |
|
949 | + |
|
950 | + /** |
|
951 | + * @param string $access |
|
952 | + * @return $this |
|
953 | + */ |
|
954 | + public function setAccess($access): self |
|
955 | + { |
|
956 | + $this->access = $access; |
|
957 | + return $this; |
|
958 | + } |
|
959 | + |
|
960 | + /** |
|
961 | + * @return \string[] |
|
962 | + */ |
|
963 | + public function getAdditionalJavaScriptFiles(): array |
|
964 | + { |
|
965 | + if (empty($this->additionalJavaScriptFiles)) { |
|
966 | + $this->additionalJavaScriptFiles = $this->getModuleConfiguration('additionalJavaScriptFiles'); |
|
967 | + } |
|
968 | + return $this->additionalJavaScriptFiles; |
|
969 | + } |
|
970 | + |
|
971 | + /** |
|
972 | + * @return \string[] |
|
973 | + */ |
|
974 | + public function getAdditionalStyleSheetFiles(): array |
|
975 | + { |
|
976 | + if (empty($this->additionalStyleSheetFiles)) { |
|
977 | + $this->additionalStyleSheetFiles = $this->getModuleConfiguration('additionalStyleSheetFiles'); |
|
978 | + } |
|
979 | + return $this->additionalStyleSheetFiles; |
|
980 | + } |
|
981 | + |
|
982 | + /** |
|
983 | + * @return array |
|
984 | + */ |
|
985 | + public function getComponents(): array |
|
986 | + { |
|
987 | + return $this->components; |
|
988 | + } |
|
989 | + |
|
990 | + /** |
|
991 | + * @param string $pluginName |
|
992 | + * @return bool |
|
993 | + */ |
|
994 | + public function hasPlugin($pluginName = ''): bool |
|
995 | + { |
|
996 | + $parameterPrefix = $this->getParameterPrefix(); |
|
997 | + $parameters = GeneralUtility::_GET($parameterPrefix); |
|
998 | + |
|
999 | + $hasPlugin = !empty($parameters['plugins']) && is_array($parameters['plugins']); |
|
1000 | + if ($hasPlugin && $pluginName) { |
|
1001 | + $hasPlugin = in_array($pluginName, $parameters['plugins']); |
|
1002 | + } |
|
1003 | + return $hasPlugin; |
|
1004 | + } |
|
1005 | + |
|
1006 | + /** |
|
1007 | + * Compute the internal module code |
|
1008 | + * |
|
1009 | + * @param null|string $dataType |
|
1010 | + * @return string |
|
1011 | + */ |
|
1012 | + protected function getInternalModuleSignature($dataType = null): string |
|
1013 | + { |
|
1014 | + // Else we forge the module signature |
|
1015 | + if ($dataType === null) { |
|
1016 | + $dataType = $this->dataType; |
|
1017 | + } |
|
1018 | + $subModuleName = $dataType . '_' . $this->moduleKey; |
|
1019 | + |
|
1020 | + $mainModule = $this->mainModule ?: self::DEFAULT_MAIN_MODULE; |
|
1021 | + return $mainModule . '_Vidi' . GeneralUtility::underscoredToUpperCamelCase($subModuleName); |
|
1022 | + } |
|
1023 | 1023 | |
1024 | 1024 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function getExistingMainConfiguration(): array |
179 | 179 | { |
180 | - $moduleSignature = $this->computeMainModule() . '_' . $this->getInternalModuleSignature(); |
|
180 | + $moduleSignature = $this->computeMainModule().'_'.$this->getInternalModuleSignature(); |
|
181 | 181 | return $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature] ?? []; |
182 | 182 | } |
183 | 183 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | ExtensionUtility::registerModule( |
300 | 300 | 'Fab.vidi', |
301 | 301 | $this->computeMainModule(), |
302 | - $this->dataType . '_' . $this->moduleKey, |
|
302 | + $this->dataType.'_'.$this->moduleKey, |
|
303 | 303 | $this->position, |
304 | 304 | [ |
305 | 305 | \Fab\Vidi\Controller\ContentController::class => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard', |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public function getParameterPrefix(): string |
364 | 364 | { |
365 | - return 'tx_vidi_' . strtolower($this->getSignature()); |
|
365 | + return 'tx_vidi_'.strtolower($this->getSignature()); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -1015,10 +1015,10 @@ discard block |
||
1015 | 1015 | if ($dataType === null) { |
1016 | 1016 | $dataType = $this->dataType; |
1017 | 1017 | } |
1018 | - $subModuleName = $dataType . '_' . $this->moduleKey; |
|
1018 | + $subModuleName = $dataType.'_'.$this->moduleKey; |
|
1019 | 1019 | |
1020 | 1020 | $mainModule = $this->mainModule ?: self::DEFAULT_MAIN_MODULE; |
1021 | - return $mainModule . '_Vidi' . GeneralUtility::underscoredToUpperCamelCase($subModuleName); |
|
1021 | + return $mainModule.'_Vidi'.GeneralUtility::underscoredToUpperCamelCase($subModuleName); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | } |