@@ -12,7 +12,6 @@ |
||
| 12 | 12 | use TYPO3\CMS\Core\Utility\GeneralUtility; |
| 13 | 13 | use TYPO3\CMS\Extbase\Utility\ExtensionUtility; |
| 14 | 14 | use Fab\Vidi\Exception\InvalidKeyInArrayException; |
| 15 | -use Fab\Vidi\Service\BackendUserPreferenceService; |
|
| 16 | 15 | |
| 17 | 16 | /** |
| 18 | 17 | * Service class used in other extensions to register a vidi based backend module. |
@@ -20,998 +20,998 @@ |
||
| 20 | 20 | class ModuleLoader |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Define the default main module |
|
| 25 | - */ |
|
| 26 | - const DEFAULT_MAIN_MODULE = 'content'; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Define the default pid |
|
| 30 | - */ |
|
| 31 | - const DEFAULT_PID = 0; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * The type of data being listed (which corresponds to a table name in TCA) |
|
| 35 | - * |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - protected $dataType; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var string |
|
| 42 | - */ |
|
| 43 | - protected $defaultPid; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @var bool |
|
| 47 | - */ |
|
| 48 | - protected $showPageTree = false; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @var bool |
|
| 52 | - */ |
|
| 53 | - protected $isShown = true; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @var string |
|
| 57 | - */ |
|
| 58 | - protected $access; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @var string |
|
| 62 | - */ |
|
| 63 | - protected $mainModule; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @var string |
|
| 67 | - */ |
|
| 68 | - protected $position = ''; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @var string |
|
| 72 | - */ |
|
| 73 | - protected $icon; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @var string |
|
| 77 | - */ |
|
| 78 | - protected $moduleLanguageFile; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * The module key such as m1, m2. |
|
| 82 | - * |
|
| 83 | - * @var string |
|
| 84 | - */ |
|
| 85 | - protected $moduleKey = 'm1'; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @var string[] |
|
| 89 | - */ |
|
| 90 | - protected $additionalJavaScriptFiles = []; |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @var string[] |
|
| 94 | - */ |
|
| 95 | - protected $additionalStyleSheetFiles = []; |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * @var array |
|
| 99 | - */ |
|
| 100 | - protected $components = []; |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @param string $dataType |
|
| 104 | - */ |
|
| 105 | - public function __construct($dataType = null) |
|
| 106 | - { |
|
| 107 | - $this->dataType = $dataType; |
|
| 108 | - |
|
| 109 | - // Initialize components |
|
| 110 | - $this->components = [ |
|
| 111 | - ModulePosition::DOC_HEADER => [ |
|
| 112 | - ModulePosition::TOP => [ |
|
| 113 | - ModulePosition::LEFT => [], |
|
| 114 | - ModulePosition::RIGHT => [ |
|
| 115 | - \Fab\Vidi\View\Button\ToolButton::class, |
|
| 116 | - ], |
|
| 117 | - ], |
|
| 118 | - ModulePosition::BOTTOM => [ |
|
| 119 | - ModulePosition::LEFT => [ |
|
| 120 | - \Fab\Vidi\View\Button\NewButton::class, |
|
| 121 | - \Fab\Vidi\ViewHelpers\Link\BackViewHelper::class, |
|
| 122 | - ], |
|
| 123 | - ModulePosition::RIGHT => [], |
|
| 124 | - ], |
|
| 125 | - ], |
|
| 126 | - ModulePosition::GRID => [ |
|
| 127 | - ModulePosition::TOP => [ |
|
| 128 | - \Fab\Vidi\View\Check\PidCheck::class, |
|
| 129 | - \Fab\Vidi\View\Check\RelationsCheck::class, |
|
| 130 | - #\Fab\Vidi\View\Tab\DataTypeTab::class, |
|
| 131 | - ], |
|
| 132 | - ModulePosition::BUTTONS => [ |
|
| 133 | - \Fab\Vidi\View\Button\EditButton::class, |
|
| 134 | - \Fab\Vidi\View\Button\DeleteButton::class, |
|
| 135 | - ], |
|
| 136 | - ModulePosition::BOTTOM => [], |
|
| 137 | - ], |
|
| 138 | - ModulePosition::MENU_MASS_ACTION => [ |
|
| 139 | - \Fab\Vidi\View\MenuItem\ExportXlsMenuItem::class, |
|
| 140 | - \Fab\Vidi\View\MenuItem\ExportXmlMenuItem::class, |
|
| 141 | - \Fab\Vidi\View\MenuItem\ExportCsvMenuItem::class, |
|
| 142 | - \Fab\Vidi\View\MenuItem\DividerMenuItem::class, |
|
| 143 | - \Fab\Vidi\View\MenuItem\MassDeleteMenuItem::class, |
|
| 144 | - #\Fab\Vidi\View\MenuItem\MassEditMenuItem::class, |
|
| 145 | - ], |
|
| 146 | - ]; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Tell whether a module is already registered. |
|
| 151 | - * |
|
| 152 | - * @param string $dataType |
|
| 153 | - * @return bool |
|
| 154 | - */ |
|
| 155 | - public function isRegistered($dataType): bool |
|
| 156 | - { |
|
| 157 | - $internalModuleSignature = $this->getInternalModuleSignature($dataType); |
|
| 158 | - return !empty($GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature]); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * @return array |
|
| 163 | - */ |
|
| 164 | - protected function getExistingInternalConfiguration(): array |
|
| 165 | - { |
|
| 166 | - $internalModuleSignature = $this->getInternalModuleSignature(); |
|
| 167 | - return is_array($GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature]) |
|
| 168 | - ? $GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature] |
|
| 169 | - : []; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * @return array |
|
| 174 | - */ |
|
| 175 | - protected function getExistingMainConfiguration(): array |
|
| 176 | - { |
|
| 177 | - $possibleConfiguration = $GLOBALS['TBE_MODULES']['_configuration'][$this->computeMainModule() . '_' . $this->getInternalModuleSignature()]; |
|
| 178 | - return is_array($possibleConfiguration) ? $possibleConfiguration : []; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * @return string |
|
| 183 | - */ |
|
| 184 | - protected function computeMainModule(): string |
|
| 185 | - { |
|
| 186 | - $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
| 187 | - |
|
| 188 | - if ($this->mainModule !== null) { |
|
| 189 | - $mainModule = $this->mainModule; |
|
| 190 | - } elseif ($existingConfiguration['mainModule']) { // existing configuration may override. |
|
| 191 | - $mainModule = $existingConfiguration['mainModule']; |
|
| 192 | - } else { |
|
| 193 | - $mainModule = self::DEFAULT_MAIN_MODULE; //default value. |
|
| 194 | - } |
|
| 195 | - return $mainModule; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * @return string |
|
| 200 | - */ |
|
| 201 | - protected function computeDefaultPid(): string |
|
| 202 | - { |
|
| 203 | - $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
| 204 | - |
|
| 205 | - if ($this->defaultPid !== null) { |
|
| 206 | - $defaultPid = $this->defaultPid; |
|
| 207 | - } elseif ($existingConfiguration['defaultPid']) { // existing configuration may override. |
|
| 208 | - $defaultPid = $existingConfiguration['defaultPid']; |
|
| 209 | - } else { |
|
| 210 | - $defaultPid = self::DEFAULT_PID; //default value. |
|
| 211 | - } |
|
| 212 | - return $defaultPid; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * @return array |
|
| 217 | - */ |
|
| 218 | - protected function computeAdditionalJavaScriptFiles(): array |
|
| 219 | - { |
|
| 220 | - $additionalJavaScriptFiles = $this->additionalJavaScriptFiles; |
|
| 221 | - |
|
| 222 | - // Possible merge of existing javascript files. |
|
| 223 | - $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
| 224 | - if ($existingConfiguration['additionalJavaScriptFiles']) { |
|
| 225 | - $additionalJavaScriptFiles = array_merge($additionalJavaScriptFiles, $existingConfiguration['additionalJavaScriptFiles']); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - return $additionalJavaScriptFiles; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * @return array |
|
| 233 | - */ |
|
| 234 | - protected function computeAdditionalStyleSheetFiles(): array |
|
| 235 | - { |
|
| 236 | - $additionalStyleSheetFiles = $this->additionalStyleSheetFiles; |
|
| 237 | - |
|
| 238 | - // Possible merge of existing style sheets. |
|
| 239 | - $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
| 240 | - if ($existingConfiguration['additionalStyleSheetFiles']) { |
|
| 241 | - $additionalStyleSheetFiles = array_merge($additionalStyleSheetFiles, $existingConfiguration['additionalStyleSheetFiles']); |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - return $additionalStyleSheetFiles; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * @return array |
|
| 249 | - */ |
|
| 250 | - protected function computeComponents(): array |
|
| 251 | - { |
|
| 252 | - // We override the config in any case. See if we need more than that. |
|
| 253 | - return $this->components; |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * Register the module in two places: core + vidi internal. |
|
| 258 | - * |
|
| 259 | - * @return void |
|
| 260 | - * @throws \InvalidArgumentException |
|
| 261 | - */ |
|
| 262 | - public function register(): void |
|
| 263 | - { |
|
| 264 | - // Internal Vidi module registration. |
|
| 265 | - $configuration = []; |
|
| 266 | - $configuration['dataType'] = $this->dataType; |
|
| 267 | - $configuration['mainModule'] = $this->computeMainModule(); |
|
| 268 | - $configuration['defaultPid'] = $this->computeDefaultPid(); |
|
| 269 | - $configuration['additionalJavaScriptFiles'] = $this->computeAdditionalJavaScriptFiles(); |
|
| 270 | - $configuration['additionalStyleSheetFiles'] = $this->computeAdditionalStyleSheetFiles(); |
|
| 271 | - $configuration['components'] = $this->computeComponents(); |
|
| 272 | - |
|
| 273 | - $internalModuleSignature = $this->getInternalModuleSignature(); |
|
| 274 | - $GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature] = $configuration; |
|
| 275 | - |
|
| 276 | - // Core module registration. |
|
| 277 | - // Register and displays module in the BE only if told, default is "true". |
|
| 278 | - if ($this->isShown) { |
|
| 279 | - |
|
| 280 | - $moduleConfiguration = []; |
|
| 281 | - #$moduleConfiguration['routeTarget'] = \Fab\Vidi\Controller\ContentController::class . '::mainAction', // what to do here? |
|
| 282 | - $moduleConfiguration['access'] = $this->getAccess(); |
|
| 283 | - $moduleConfiguration['labels'] = $this->getModuleLanguageFile(); |
|
| 284 | - $icon = $this->getIcon(); |
|
| 285 | - if ($icon) { |
|
| 286 | - $moduleConfiguration['icon'] = $icon; |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - if ($this->showPageTree) { |
|
| 290 | - $moduleConfiguration['navigationComponentId'] = 'TYPO3/CMS/Backend/PageTree/PageTreeElement'; |
|
| 291 | - $moduleConfiguration['inheritNavigationComponentFromMainModule'] = true; |
|
| 292 | - } else { |
|
| 293 | - $moduleConfiguration['inheritNavigationComponentFromMainModule'] = true; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - ExtensionUtility::registerModule( |
|
| 297 | - 'Fab.vidi', |
|
| 298 | - $this->computeMainModule(), |
|
| 299 | - $this->dataType . '_' . $this->moduleKey, |
|
| 300 | - $this->position, |
|
| 301 | - [ |
|
| 302 | - 'Content' => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard', |
|
| 303 | - 'Tool' => 'welcome, work', |
|
| 304 | - 'Facet' => 'autoSuggest, autoSuggests', |
|
| 305 | - 'Selection' => 'edit, update, create, delete, list, show', |
|
| 306 | - 'UserPreferences' => 'save', |
|
| 307 | - 'Clipboard' => 'save, flush, show', |
|
| 308 | - ], |
|
| 309 | - $moduleConfiguration |
|
| 310 | - ); |
|
| 311 | - } |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - /** |
|
| 315 | - * Return the module code for a BE module. |
|
| 316 | - * |
|
| 317 | - * @return string |
|
| 318 | - */ |
|
| 319 | - public function getSignature(): string |
|
| 320 | - { |
|
| 321 | - $signature = GeneralUtility::_GP(Parameter::MODULE); |
|
| 322 | - $trimmedSignature = trim($signature, '/'); |
|
| 323 | - return str_replace('/', '_', $trimmedSignature); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * Returns the current pid. |
|
| 328 | - * |
|
| 329 | - * @return bool |
|
| 330 | - */ |
|
| 331 | - public function getCurrentPid(): bool |
|
| 332 | - { |
|
| 333 | - return GeneralUtility::_GET(Parameter::PID) > 0 ? (int)GeneralUtility::_GET(Parameter::PID) : 0; |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * Return the module URL. |
|
| 338 | - * |
|
| 339 | - * @param array $additionalParameters |
|
| 340 | - * @return string |
|
| 341 | - */ |
|
| 342 | - public function getModuleUrl(array $additionalParameters = []): string |
|
| 343 | - { |
|
| 344 | - $moduleCode = $this->getSignature(); |
|
| 345 | - |
|
| 346 | - // And don't forget the pid! |
|
| 347 | - if (GeneralUtility::_GET(Parameter::PID)) { |
|
| 348 | - $additionalParameters[Parameter::PID] = GeneralUtility::_GET(Parameter::PID); |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - return BackendUtility::getModuleUrl($moduleCode, $additionalParameters); |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - /** |
|
| 355 | - * Return the parameter prefix for a BE module. |
|
| 356 | - * |
|
| 357 | - * @return string |
|
| 358 | - */ |
|
| 359 | - public function getParameterPrefix(): string |
|
| 360 | - { |
|
| 361 | - return 'tx_vidi_' . strtolower($this->getSignature()); |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * Return a configuration key or the entire module configuration array if not key is given. |
|
| 366 | - * |
|
| 367 | - * @param string $key |
|
| 368 | - * @throws InvalidKeyInArrayException |
|
| 369 | - * @return mixed |
|
| 370 | - */ |
|
| 371 | - public function getModuleConfiguration($key = '') |
|
| 372 | - { |
|
| 373 | - |
|
| 374 | - $vidiModuleCode = $this->getSignature(); |
|
| 375 | - |
|
| 376 | - // Module code must exist |
|
| 377 | - if (empty($GLOBALS['TBE_MODULES_EXT']['vidi'][$vidiModuleCode])) { |
|
| 378 | - $message = sprintf('Invalid or not existing module code "%s"', $vidiModuleCode); |
|
| 379 | - throw new InvalidKeyInArrayException($message, 1375092053); |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - $result = $GLOBALS['TBE_MODULES_EXT']['vidi'][$vidiModuleCode]; |
|
| 383 | - |
|
| 384 | - if (!empty($key)) { |
|
| 385 | - if (isset($result[$key])) { |
|
| 386 | - $result = $result[$key]; |
|
| 387 | - } else { |
|
| 388 | - // key must exist |
|
| 389 | - $message = sprintf('Invalid key configuration "%s"', $key); |
|
| 390 | - throw new InvalidKeyInArrayException($message, 1375092054); |
|
| 391 | - } |
|
| 392 | - } |
|
| 393 | - return $result; |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * @param string $icon |
|
| 398 | - * @return $this |
|
| 399 | - */ |
|
| 400 | - public function setIcon($icon): self |
|
| 401 | - { |
|
| 402 | - $this->icon = $icon; |
|
| 403 | - return $this; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - /** |
|
| 407 | - * @return string |
|
| 408 | - */ |
|
| 409 | - protected function getIcon(): string |
|
| 410 | - { |
|
| 411 | - $moduleConfiguration = $this->getExistingMainConfiguration(); |
|
| 412 | - |
|
| 413 | - |
|
| 414 | - if ($this->icon) { |
|
| 415 | - $icon = $this->icon; |
|
| 416 | - } elseif ($moduleConfiguration['icon']) { // existing configuration may override. |
|
| 417 | - $icon = $moduleConfiguration['icon']; |
|
| 418 | - } else { |
|
| 419 | - $icon = ''; //default value. |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - return $icon; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * @param string $mainModule |
|
| 427 | - * @return $this |
|
| 428 | - */ |
|
| 429 | - public function setMainModule($mainModule): self |
|
| 430 | - { |
|
| 431 | - $this->mainModule = $mainModule; |
|
| 432 | - return $this; |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - /** |
|
| 436 | - * @return string |
|
| 437 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 438 | - */ |
|
| 439 | - public function getMainModule(): string |
|
| 440 | - { |
|
| 441 | - if ($this->mainModule === null) { |
|
| 442 | - $this->mainModule = $this->getModuleConfiguration('mainModule'); |
|
| 443 | - } |
|
| 444 | - return $this->mainModule; |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - /** |
|
| 448 | - * @param string $moduleLanguageFile |
|
| 449 | - * @return $this |
|
| 450 | - */ |
|
| 451 | - public function setModuleLanguageFile($moduleLanguageFile): self |
|
| 452 | - { |
|
| 453 | - $this->moduleLanguageFile = $moduleLanguageFile; |
|
| 454 | - return $this; |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - /** |
|
| 458 | - * @param string $component |
|
| 459 | - * @return $this |
|
| 460 | - */ |
|
| 461 | - public function removeComponentFromDocHeader(string $component): self |
|
| 462 | - { |
|
| 463 | - foreach ($this->components[ModulePosition::DOC_HEADER] as $verticalPosition => $docHeaders) { |
|
| 464 | - foreach ($docHeaders as $horizontalPosition => $docHeader) { |
|
| 465 | - |
|
| 466 | - $index = array_search($component, $docHeader, true); |
|
| 467 | - if ($index !== false) { |
|
| 468 | - // $verticalPosition: top or bottom |
|
| 469 | - // $horizontalPosition: left or right |
|
| 470 | - unset($this->components[ModulePosition::DOC_HEADER][$verticalPosition][$horizontalPosition][$index]); |
|
| 471 | - } |
|
| 472 | - } |
|
| 473 | - } |
|
| 474 | - return $this; |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - /** |
|
| 478 | - * @param string $component |
|
| 479 | - * @return bool |
|
| 480 | - */ |
|
| 481 | - public function hasComponentInDocHeader(string $component): bool |
|
| 482 | - { |
|
| 483 | - foreach ($this->getModuleConfiguration('components')[ModulePosition::DOC_HEADER] as $verticalPosition => $docHeaders) { |
|
| 484 | - foreach ($docHeaders as $horizontalPosition => $docHeader) { |
|
| 485 | - |
|
| 486 | - $index = array_search($component, $docHeader, true); |
|
| 487 | - if ($index !== false) { |
|
| 488 | - return true; |
|
| 489 | - } |
|
| 490 | - } |
|
| 491 | - } |
|
| 492 | - return false; |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - /** |
|
| 496 | - * @return string |
|
| 497 | - */ |
|
| 498 | - protected function getModuleLanguageFile(): string |
|
| 499 | - { |
|
| 500 | - $moduleConfiguration = $this->getExistingMainConfiguration(); |
|
| 501 | - |
|
| 502 | - if ($this->moduleLanguageFile) { |
|
| 503 | - $moduleLanguageFile = $this->moduleLanguageFile; |
|
| 504 | - } elseif ($moduleConfiguration['labels']) { // existing configuration may override. |
|
| 505 | - $moduleLanguageFile = $moduleConfiguration['labels']; |
|
| 506 | - } |
|
| 507 | - else { |
|
| 508 | - $moduleLanguageFile = ''; //default value. |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - return $moduleLanguageFile; |
|
| 512 | - } |
|
| 513 | - |
|
| 514 | - /** |
|
| 515 | - * @param string $position |
|
| 516 | - * @return $this |
|
| 517 | - */ |
|
| 518 | - public function setPosition($position): self |
|
| 519 | - { |
|
| 520 | - $this->position = $position; |
|
| 521 | - return $this; |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - /** |
|
| 525 | - * @return string |
|
| 526 | - */ |
|
| 527 | - public function getPosition(): string |
|
| 528 | - { |
|
| 529 | - return $this->position; |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - /** |
|
| 533 | - * @param array $files |
|
| 534 | - * @return $this |
|
| 535 | - */ |
|
| 536 | - public function addJavaScriptFiles(array $files): self |
|
| 537 | - { |
|
| 538 | - foreach ($files as $file) { |
|
| 539 | - $this->additionalJavaScriptFiles[] = $file; |
|
| 540 | - } |
|
| 541 | - return $this; |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - /** |
|
| 545 | - * @param string $fileNameAndPath |
|
| 546 | - * @return $this |
|
| 547 | - */ |
|
| 548 | - public function addJavaScriptFile($fileNameAndPath): self |
|
| 549 | - { |
|
| 550 | - $this->additionalJavaScriptFiles[] = $fileNameAndPath; |
|
| 551 | - return $this; |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - /** |
|
| 555 | - * @param array $files |
|
| 556 | - * @return $this |
|
| 557 | - */ |
|
| 558 | - public function addStyleSheetFiles(array $files): self |
|
| 559 | - { |
|
| 560 | - foreach ($files as $file) { |
|
| 561 | - $this->additionalStyleSheetFiles[] = $file; |
|
| 562 | - } |
|
| 563 | - return $this; |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - /** |
|
| 567 | - * @param string $fileNameAndPath |
|
| 568 | - * @return $this |
|
| 569 | - */ |
|
| 570 | - public function addStyleSheetFile($fileNameAndPath): self |
|
| 571 | - { |
|
| 572 | - $this->additionalStyleSheetFiles[] = $fileNameAndPath; |
|
| 573 | - return $this; |
|
| 574 | - } |
|
| 575 | - |
|
| 576 | - /** |
|
| 577 | - * @return string |
|
| 578 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 579 | - */ |
|
| 580 | - public function getDataType(): string |
|
| 581 | - { |
|
| 582 | - if ($this->dataType === null) { |
|
| 583 | - $this->dataType = $this->getModuleConfiguration('dataType'); |
|
| 584 | - } |
|
| 585 | - return $this->dataType; |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * @return array |
|
| 590 | - */ |
|
| 591 | - public function getDataTypes(): array |
|
| 592 | - { |
|
| 593 | - $dataTypes = []; |
|
| 594 | - foreach ($GLOBALS['TBE_MODULES_EXT']['vidi'] as $module) { |
|
| 595 | - $dataTypes[] = $module['dataType']; |
|
| 596 | - } |
|
| 597 | - return $dataTypes; |
|
| 598 | - } |
|
| 599 | - |
|
| 600 | - /** |
|
| 601 | - * @param string $dataType |
|
| 602 | - * @return $this |
|
| 603 | - */ |
|
| 604 | - public function setDataType($dataType): self |
|
| 605 | - { |
|
| 606 | - $this->dataType = $dataType; |
|
| 607 | - return $this; |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - /** |
|
| 611 | - * @return string |
|
| 612 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 613 | - */ |
|
| 614 | - public function getDefaultPid(): string |
|
| 615 | - { |
|
| 616 | - if (empty($this->defaultPid)) { |
|
| 617 | - $this->defaultPid = $this->getModuleConfiguration('defaultPid'); |
|
| 618 | - } |
|
| 619 | - return $this->defaultPid; |
|
| 620 | - } |
|
| 621 | - |
|
| 622 | - /** |
|
| 623 | - * @param string $defaultPid |
|
| 624 | - * @return $this |
|
| 625 | - */ |
|
| 626 | - public function setDefaultPid($defaultPid): self |
|
| 627 | - { |
|
| 628 | - $this->defaultPid = $defaultPid; |
|
| 629 | - return $this; |
|
| 630 | - } |
|
| 631 | - |
|
| 632 | - /** |
|
| 633 | - * @param bool $isPageTreeShown |
|
| 634 | - * @return $this |
|
| 635 | - */ |
|
| 636 | - public function showPageTree($isPageTreeShown): self |
|
| 637 | - { |
|
| 638 | - $this->showPageTree = $isPageTreeShown; |
|
| 639 | - return $this; |
|
| 640 | - } |
|
| 641 | - |
|
| 642 | - /** |
|
| 643 | - * @param string $isShown |
|
| 644 | - * @return $this |
|
| 645 | - */ |
|
| 646 | - public function isShown($isShown): self |
|
| 647 | - { |
|
| 648 | - $this->isShown = $isShown; |
|
| 649 | - return $this; |
|
| 650 | - } |
|
| 651 | - |
|
| 652 | - /** |
|
| 653 | - * @return $array |
|
| 654 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 655 | - */ |
|
| 656 | - public function getDocHeaderTopLeftComponents() |
|
| 657 | - { |
|
| 658 | - $configuration = $this->getModuleConfiguration(); |
|
| 659 | - return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT]; |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - /** |
|
| 663 | - * @param array $components |
|
| 664 | - * @return $this |
|
| 665 | - */ |
|
| 666 | - public function setDocHeaderTopLeftComponents(array $components): self |
|
| 667 | - { |
|
| 668 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT] = $components; |
|
| 669 | - return $this; |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - /** |
|
| 673 | - * @param string|array $components |
|
| 674 | - * @return $this |
|
| 675 | - */ |
|
| 676 | - public function addDocHeaderTopLeftComponents($components): self |
|
| 677 | - { |
|
| 678 | - if (is_string($components)) { |
|
| 679 | - $components = [$components]; |
|
| 680 | - } |
|
| 681 | - $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT]; |
|
| 682 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT] = array_merge($currentComponents, $components); |
|
| 683 | - return $this; |
|
| 684 | - } |
|
| 685 | - |
|
| 686 | - /** |
|
| 687 | - * @return $array |
|
| 688 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 689 | - */ |
|
| 690 | - public function getDocHeaderTopRightComponents() |
|
| 691 | - { |
|
| 692 | - $configuration = $this->getModuleConfiguration(); |
|
| 693 | - return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT]; |
|
| 694 | - } |
|
| 695 | - |
|
| 696 | - /** |
|
| 697 | - * @param array $components |
|
| 698 | - * @return $this |
|
| 699 | - */ |
|
| 700 | - public function setDocHeaderTopRightComponents(array $components): self |
|
| 701 | - { |
|
| 702 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT] = $components; |
|
| 703 | - return $this; |
|
| 704 | - } |
|
| 705 | - |
|
| 706 | - /** |
|
| 707 | - * @param string|array $components |
|
| 708 | - * @return $this |
|
| 709 | - */ |
|
| 710 | - public function addDocHeaderTopRightComponents($components): self |
|
| 711 | - { |
|
| 712 | - if (is_string($components)) { |
|
| 713 | - $components = [$components]; |
|
| 714 | - } |
|
| 715 | - $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT]; |
|
| 716 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT] = array_merge($currentComponents, $components); |
|
| 717 | - return $this; |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - /** |
|
| 721 | - * @return $array |
|
| 722 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 723 | - */ |
|
| 724 | - public function getDocHeaderBottomLeftComponents() |
|
| 725 | - { |
|
| 726 | - $configuration = $this->getModuleConfiguration(); |
|
| 727 | - return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT]; |
|
| 728 | - } |
|
| 729 | - |
|
| 730 | - /** |
|
| 731 | - * @param array $components |
|
| 732 | - * @return $this |
|
| 733 | - */ |
|
| 734 | - public function setDocHeaderBottomLeftComponents(array $components): self |
|
| 735 | - { |
|
| 736 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT] = $components; |
|
| 737 | - return $this; |
|
| 738 | - } |
|
| 739 | - |
|
| 740 | - /** |
|
| 741 | - * @param string|array $components |
|
| 742 | - * @return $this |
|
| 743 | - */ |
|
| 744 | - public function addDocHeaderBottomLeftComponents($components): self |
|
| 745 | - { |
|
| 746 | - if (is_string($components)) { |
|
| 747 | - $components = [$components]; |
|
| 748 | - } |
|
| 749 | - $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT]; |
|
| 750 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT] = array_merge($currentComponents, $components); |
|
| 751 | - return $this; |
|
| 752 | - } |
|
| 753 | - |
|
| 754 | - /** |
|
| 755 | - * @return $array |
|
| 756 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 757 | - */ |
|
| 758 | - public function getDocHeaderBottomRightComponents() |
|
| 759 | - { |
|
| 760 | - $configuration = $this->getModuleConfiguration(); |
|
| 761 | - return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT]; |
|
| 762 | - } |
|
| 763 | - |
|
| 764 | - /** |
|
| 765 | - * @param array $components |
|
| 766 | - * @return $this |
|
| 767 | - */ |
|
| 768 | - public function setDocHeaderBottomRightComponents(array $components): self |
|
| 769 | - { |
|
| 770 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT] = $components; |
|
| 771 | - return $this; |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - /** |
|
| 775 | - * @param string|array $components |
|
| 776 | - * @return $this |
|
| 777 | - */ |
|
| 778 | - public function addDocHeaderBottomRightComponents($components): self |
|
| 779 | - { |
|
| 780 | - if (is_string($components)) { |
|
| 781 | - $components = [$components]; |
|
| 782 | - } |
|
| 783 | - $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT]; |
|
| 784 | - $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT] = array_merge($currentComponents, $components); |
|
| 785 | - return $this; |
|
| 786 | - } |
|
| 787 | - |
|
| 788 | - /** |
|
| 789 | - * @return $array |
|
| 790 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 791 | - */ |
|
| 792 | - public function getGridTopComponents() |
|
| 793 | - { |
|
| 794 | - $configuration = $this->getModuleConfiguration(); |
|
| 795 | - return $configuration['components'][ModulePosition::GRID][ModulePosition::TOP]; |
|
| 796 | - } |
|
| 797 | - |
|
| 798 | - /** |
|
| 799 | - * @param array $components |
|
| 800 | - * @return $this |
|
| 801 | - */ |
|
| 802 | - public function setGridTopComponents(array $components): self |
|
| 803 | - { |
|
| 804 | - $this->components[ModulePosition::GRID][ModulePosition::TOP] = $components; |
|
| 805 | - return $this; |
|
| 806 | - } |
|
| 807 | - |
|
| 808 | - /** |
|
| 809 | - * @param string|array $components |
|
| 810 | - * @return $this |
|
| 811 | - */ |
|
| 812 | - public function addGridTopComponents($components): self |
|
| 813 | - { |
|
| 814 | - if (is_string($components)) { |
|
| 815 | - $components = [$components]; |
|
| 816 | - } |
|
| 817 | - $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::TOP]; |
|
| 818 | - $this->components[ModulePosition::GRID][ModulePosition::TOP] = array_merge($currentComponents, $components); |
|
| 819 | - return $this; |
|
| 820 | - } |
|
| 821 | - |
|
| 822 | - /** |
|
| 823 | - * @return $array |
|
| 824 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 825 | - */ |
|
| 826 | - public function getGridBottomComponents() |
|
| 827 | - { |
|
| 828 | - $configuration = $this->getModuleConfiguration(); |
|
| 829 | - return $configuration['components'][ModulePosition::GRID][ModulePosition::BOTTOM]; |
|
| 830 | - } |
|
| 831 | - |
|
| 832 | - /** |
|
| 833 | - * @param array $components |
|
| 834 | - * @return $this |
|
| 835 | - */ |
|
| 836 | - public function setGridBottomComponents(array $components): self |
|
| 837 | - { |
|
| 838 | - $this->components[ModulePosition::GRID][ModulePosition::BOTTOM] = $components; |
|
| 839 | - return $this; |
|
| 840 | - } |
|
| 841 | - |
|
| 842 | - /** |
|
| 843 | - * @param string|array $components |
|
| 844 | - * @return $this |
|
| 845 | - */ |
|
| 846 | - public function addGridBottomComponents($components): self |
|
| 847 | - { |
|
| 848 | - if (is_string($components)) { |
|
| 849 | - $components = [$components]; |
|
| 850 | - } |
|
| 851 | - $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::BOTTOM]; |
|
| 852 | - $this->components[ModulePosition::GRID][ModulePosition::BOTTOM] = array_merge($currentComponents, $components); |
|
| 853 | - return $this; |
|
| 854 | - } |
|
| 855 | - |
|
| 856 | - /** |
|
| 857 | - * @return $array |
|
| 858 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 859 | - */ |
|
| 860 | - public function getGridButtonsComponents() |
|
| 861 | - { |
|
| 862 | - $configuration = $this->getModuleConfiguration(); |
|
| 863 | - return $configuration['components'][ModulePosition::GRID][ModulePosition::BUTTONS]; |
|
| 864 | - } |
|
| 865 | - |
|
| 866 | - /** |
|
| 867 | - * @param array $components |
|
| 868 | - * @return $this |
|
| 869 | - */ |
|
| 870 | - public function setGridButtonsComponents(array $components): self |
|
| 871 | - { |
|
| 872 | - $this->components[ModulePosition::GRID][ModulePosition::BUTTONS] = $components; |
|
| 873 | - return $this; |
|
| 874 | - } |
|
| 875 | - |
|
| 876 | - /** |
|
| 877 | - * @param string|array $components |
|
| 878 | - * @return $this |
|
| 879 | - */ |
|
| 880 | - public function addGridButtonsComponents($components): self |
|
| 881 | - { |
|
| 882 | - if (is_string($components)) { |
|
| 883 | - $components = [$components]; |
|
| 884 | - } |
|
| 885 | - $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::BUTTONS]; |
|
| 886 | - $this->components[ModulePosition::GRID][ModulePosition::BUTTONS] = array_merge($components, $currentComponents); |
|
| 887 | - return $this; |
|
| 888 | - } |
|
| 889 | - |
|
| 890 | - /** |
|
| 891 | - * @return $array |
|
| 892 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 893 | - */ |
|
| 894 | - public function getMenuMassActionComponents() |
|
| 895 | - { |
|
| 896 | - $configuration = $this->getModuleConfiguration(); |
|
| 897 | - return $configuration['components'][ModulePosition::MENU_MASS_ACTION]; |
|
| 898 | - } |
|
| 899 | - |
|
| 900 | - /** |
|
| 901 | - * @param array $components |
|
| 902 | - * @return $this |
|
| 903 | - */ |
|
| 904 | - public function setMenuMassActionComponents(array $components): self |
|
| 905 | - { |
|
| 906 | - $this->components[ModulePosition::MENU_MASS_ACTION] = $components; |
|
| 907 | - return $this; |
|
| 908 | - } |
|
| 909 | - |
|
| 910 | - /** |
|
| 911 | - * @param string|array $components |
|
| 912 | - * @return $this |
|
| 913 | - */ |
|
| 914 | - public function addMenuMassActionComponents($components): self |
|
| 915 | - { |
|
| 916 | - if (is_string($components)) { |
|
| 917 | - $components = [$components]; |
|
| 918 | - } |
|
| 919 | - $currentComponents = $this->components[ModulePosition::MENU_MASS_ACTION]; |
|
| 920 | - $this->components[ModulePosition::MENU_MASS_ACTION] = array_merge($components, $currentComponents); |
|
| 921 | - return $this; |
|
| 922 | - } |
|
| 923 | - |
|
| 924 | - /** |
|
| 925 | - * @return string |
|
| 926 | - */ |
|
| 927 | - protected function getAccess(): string |
|
| 928 | - { |
|
| 929 | - $moduleConfiguration = $this->getExistingMainConfiguration(); |
|
| 930 | - |
|
| 931 | - if ($this->access !== null) { |
|
| 932 | - $access = $this->access; |
|
| 933 | - } elseif ($moduleConfiguration['access']) { // existing configuration may override. |
|
| 934 | - $access = $moduleConfiguration['access']; |
|
| 935 | - } else { |
|
| 936 | - $access = Access::USER; //default value. |
|
| 937 | - } |
|
| 938 | - return $access; |
|
| 939 | - } |
|
| 940 | - |
|
| 941 | - /** |
|
| 942 | - * @param string $access |
|
| 943 | - * @return $this |
|
| 944 | - */ |
|
| 945 | - public function setAccess($access): self |
|
| 946 | - { |
|
| 947 | - $this->access = $access; |
|
| 948 | - return $this; |
|
| 949 | - } |
|
| 950 | - |
|
| 951 | - /** |
|
| 952 | - * @return \string[] |
|
| 953 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 954 | - */ |
|
| 955 | - public function getAdditionalJavaScriptFiles(): array |
|
| 956 | - { |
|
| 957 | - if (empty($this->additionalJavaScriptFiles)) { |
|
| 958 | - $this->additionalJavaScriptFiles = $this->getModuleConfiguration('additionalJavaScriptFiles'); |
|
| 959 | - } |
|
| 960 | - return $this->additionalJavaScriptFiles; |
|
| 961 | - } |
|
| 962 | - |
|
| 963 | - /** |
|
| 964 | - * @return \string[] |
|
| 965 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 966 | - */ |
|
| 967 | - public function getAdditionalStyleSheetFiles(): array |
|
| 968 | - { |
|
| 969 | - if (empty($this->additionalStyleSheetFiles)) { |
|
| 970 | - $this->additionalStyleSheetFiles = $this->getModuleConfiguration('additionalStyleSheetFiles'); |
|
| 971 | - } |
|
| 972 | - return $this->additionalStyleSheetFiles; |
|
| 973 | - } |
|
| 974 | - |
|
| 975 | - /** |
|
| 976 | - * @return array |
|
| 977 | - */ |
|
| 978 | - public function getComponents(): array |
|
| 979 | - { |
|
| 980 | - return $this->components; |
|
| 981 | - } |
|
| 982 | - |
|
| 983 | - /** |
|
| 984 | - * @param string $pluginName |
|
| 985 | - * @return bool |
|
| 986 | - */ |
|
| 987 | - public function hasPlugin($pluginName = ''): bool |
|
| 988 | - { |
|
| 989 | - $parameterPrefix = $this->getParameterPrefix(); |
|
| 990 | - $parameters = GeneralUtility::_GET($parameterPrefix); |
|
| 991 | - |
|
| 992 | - $hasPlugin = !empty($parameters['plugins']) && is_array($parameters['plugins']); |
|
| 993 | - if ($hasPlugin && $pluginName) { |
|
| 994 | - $hasPlugin = in_array($pluginName, $parameters['plugins']); |
|
| 995 | - } |
|
| 996 | - return $hasPlugin; |
|
| 997 | - } |
|
| 998 | - |
|
| 999 | - /** |
|
| 1000 | - * Compute the internal module code |
|
| 1001 | - * |
|
| 1002 | - * @param null|string $dataType |
|
| 1003 | - * @return string |
|
| 1004 | - */ |
|
| 1005 | - protected function getInternalModuleSignature($dataType = null): string |
|
| 1006 | - { |
|
| 1007 | - // Else we forge the module signature |
|
| 1008 | - if ($dataType === null) { |
|
| 1009 | - $dataType = $this->dataType; |
|
| 1010 | - } |
|
| 1011 | - $subModuleName = $dataType . '_' . $this->moduleKey; |
|
| 1012 | - |
|
| 1013 | - $mainModule = $this->mainModule ? : self::DEFAULT_MAIN_MODULE; |
|
| 1014 | - return $mainModule . '_Vidi' . GeneralUtility::underscoredToUpperCamelCase($subModuleName); |
|
| 1015 | - } |
|
| 23 | + /** |
|
| 24 | + * Define the default main module |
|
| 25 | + */ |
|
| 26 | + const DEFAULT_MAIN_MODULE = 'content'; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Define the default pid |
|
| 30 | + */ |
|
| 31 | + const DEFAULT_PID = 0; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * The type of data being listed (which corresponds to a table name in TCA) |
|
| 35 | + * |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + protected $dataType; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var string |
|
| 42 | + */ |
|
| 43 | + protected $defaultPid; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @var bool |
|
| 47 | + */ |
|
| 48 | + protected $showPageTree = false; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @var bool |
|
| 52 | + */ |
|
| 53 | + protected $isShown = true; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @var string |
|
| 57 | + */ |
|
| 58 | + protected $access; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @var string |
|
| 62 | + */ |
|
| 63 | + protected $mainModule; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @var string |
|
| 67 | + */ |
|
| 68 | + protected $position = ''; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @var string |
|
| 72 | + */ |
|
| 73 | + protected $icon; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @var string |
|
| 77 | + */ |
|
| 78 | + protected $moduleLanguageFile; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * The module key such as m1, m2. |
|
| 82 | + * |
|
| 83 | + * @var string |
|
| 84 | + */ |
|
| 85 | + protected $moduleKey = 'm1'; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @var string[] |
|
| 89 | + */ |
|
| 90 | + protected $additionalJavaScriptFiles = []; |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @var string[] |
|
| 94 | + */ |
|
| 95 | + protected $additionalStyleSheetFiles = []; |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * @var array |
|
| 99 | + */ |
|
| 100 | + protected $components = []; |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @param string $dataType |
|
| 104 | + */ |
|
| 105 | + public function __construct($dataType = null) |
|
| 106 | + { |
|
| 107 | + $this->dataType = $dataType; |
|
| 108 | + |
|
| 109 | + // Initialize components |
|
| 110 | + $this->components = [ |
|
| 111 | + ModulePosition::DOC_HEADER => [ |
|
| 112 | + ModulePosition::TOP => [ |
|
| 113 | + ModulePosition::LEFT => [], |
|
| 114 | + ModulePosition::RIGHT => [ |
|
| 115 | + \Fab\Vidi\View\Button\ToolButton::class, |
|
| 116 | + ], |
|
| 117 | + ], |
|
| 118 | + ModulePosition::BOTTOM => [ |
|
| 119 | + ModulePosition::LEFT => [ |
|
| 120 | + \Fab\Vidi\View\Button\NewButton::class, |
|
| 121 | + \Fab\Vidi\ViewHelpers\Link\BackViewHelper::class, |
|
| 122 | + ], |
|
| 123 | + ModulePosition::RIGHT => [], |
|
| 124 | + ], |
|
| 125 | + ], |
|
| 126 | + ModulePosition::GRID => [ |
|
| 127 | + ModulePosition::TOP => [ |
|
| 128 | + \Fab\Vidi\View\Check\PidCheck::class, |
|
| 129 | + \Fab\Vidi\View\Check\RelationsCheck::class, |
|
| 130 | + #\Fab\Vidi\View\Tab\DataTypeTab::class, |
|
| 131 | + ], |
|
| 132 | + ModulePosition::BUTTONS => [ |
|
| 133 | + \Fab\Vidi\View\Button\EditButton::class, |
|
| 134 | + \Fab\Vidi\View\Button\DeleteButton::class, |
|
| 135 | + ], |
|
| 136 | + ModulePosition::BOTTOM => [], |
|
| 137 | + ], |
|
| 138 | + ModulePosition::MENU_MASS_ACTION => [ |
|
| 139 | + \Fab\Vidi\View\MenuItem\ExportXlsMenuItem::class, |
|
| 140 | + \Fab\Vidi\View\MenuItem\ExportXmlMenuItem::class, |
|
| 141 | + \Fab\Vidi\View\MenuItem\ExportCsvMenuItem::class, |
|
| 142 | + \Fab\Vidi\View\MenuItem\DividerMenuItem::class, |
|
| 143 | + \Fab\Vidi\View\MenuItem\MassDeleteMenuItem::class, |
|
| 144 | + #\Fab\Vidi\View\MenuItem\MassEditMenuItem::class, |
|
| 145 | + ], |
|
| 146 | + ]; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Tell whether a module is already registered. |
|
| 151 | + * |
|
| 152 | + * @param string $dataType |
|
| 153 | + * @return bool |
|
| 154 | + */ |
|
| 155 | + public function isRegistered($dataType): bool |
|
| 156 | + { |
|
| 157 | + $internalModuleSignature = $this->getInternalModuleSignature($dataType); |
|
| 158 | + return !empty($GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature]); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * @return array |
|
| 163 | + */ |
|
| 164 | + protected function getExistingInternalConfiguration(): array |
|
| 165 | + { |
|
| 166 | + $internalModuleSignature = $this->getInternalModuleSignature(); |
|
| 167 | + return is_array($GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature]) |
|
| 168 | + ? $GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature] |
|
| 169 | + : []; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * @return array |
|
| 174 | + */ |
|
| 175 | + protected function getExistingMainConfiguration(): array |
|
| 176 | + { |
|
| 177 | + $possibleConfiguration = $GLOBALS['TBE_MODULES']['_configuration'][$this->computeMainModule() . '_' . $this->getInternalModuleSignature()]; |
|
| 178 | + return is_array($possibleConfiguration) ? $possibleConfiguration : []; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * @return string |
|
| 183 | + */ |
|
| 184 | + protected function computeMainModule(): string |
|
| 185 | + { |
|
| 186 | + $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
| 187 | + |
|
| 188 | + if ($this->mainModule !== null) { |
|
| 189 | + $mainModule = $this->mainModule; |
|
| 190 | + } elseif ($existingConfiguration['mainModule']) { // existing configuration may override. |
|
| 191 | + $mainModule = $existingConfiguration['mainModule']; |
|
| 192 | + } else { |
|
| 193 | + $mainModule = self::DEFAULT_MAIN_MODULE; //default value. |
|
| 194 | + } |
|
| 195 | + return $mainModule; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * @return string |
|
| 200 | + */ |
|
| 201 | + protected function computeDefaultPid(): string |
|
| 202 | + { |
|
| 203 | + $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
| 204 | + |
|
| 205 | + if ($this->defaultPid !== null) { |
|
| 206 | + $defaultPid = $this->defaultPid; |
|
| 207 | + } elseif ($existingConfiguration['defaultPid']) { // existing configuration may override. |
|
| 208 | + $defaultPid = $existingConfiguration['defaultPid']; |
|
| 209 | + } else { |
|
| 210 | + $defaultPid = self::DEFAULT_PID; //default value. |
|
| 211 | + } |
|
| 212 | + return $defaultPid; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * @return array |
|
| 217 | + */ |
|
| 218 | + protected function computeAdditionalJavaScriptFiles(): array |
|
| 219 | + { |
|
| 220 | + $additionalJavaScriptFiles = $this->additionalJavaScriptFiles; |
|
| 221 | + |
|
| 222 | + // Possible merge of existing javascript files. |
|
| 223 | + $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
| 224 | + if ($existingConfiguration['additionalJavaScriptFiles']) { |
|
| 225 | + $additionalJavaScriptFiles = array_merge($additionalJavaScriptFiles, $existingConfiguration['additionalJavaScriptFiles']); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + return $additionalJavaScriptFiles; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * @return array |
|
| 233 | + */ |
|
| 234 | + protected function computeAdditionalStyleSheetFiles(): array |
|
| 235 | + { |
|
| 236 | + $additionalStyleSheetFiles = $this->additionalStyleSheetFiles; |
|
| 237 | + |
|
| 238 | + // Possible merge of existing style sheets. |
|
| 239 | + $existingConfiguration = $this->getExistingInternalConfiguration(); |
|
| 240 | + if ($existingConfiguration['additionalStyleSheetFiles']) { |
|
| 241 | + $additionalStyleSheetFiles = array_merge($additionalStyleSheetFiles, $existingConfiguration['additionalStyleSheetFiles']); |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + return $additionalStyleSheetFiles; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * @return array |
|
| 249 | + */ |
|
| 250 | + protected function computeComponents(): array |
|
| 251 | + { |
|
| 252 | + // We override the config in any case. See if we need more than that. |
|
| 253 | + return $this->components; |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * Register the module in two places: core + vidi internal. |
|
| 258 | + * |
|
| 259 | + * @return void |
|
| 260 | + * @throws \InvalidArgumentException |
|
| 261 | + */ |
|
| 262 | + public function register(): void |
|
| 263 | + { |
|
| 264 | + // Internal Vidi module registration. |
|
| 265 | + $configuration = []; |
|
| 266 | + $configuration['dataType'] = $this->dataType; |
|
| 267 | + $configuration['mainModule'] = $this->computeMainModule(); |
|
| 268 | + $configuration['defaultPid'] = $this->computeDefaultPid(); |
|
| 269 | + $configuration['additionalJavaScriptFiles'] = $this->computeAdditionalJavaScriptFiles(); |
|
| 270 | + $configuration['additionalStyleSheetFiles'] = $this->computeAdditionalStyleSheetFiles(); |
|
| 271 | + $configuration['components'] = $this->computeComponents(); |
|
| 272 | + |
|
| 273 | + $internalModuleSignature = $this->getInternalModuleSignature(); |
|
| 274 | + $GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature] = $configuration; |
|
| 275 | + |
|
| 276 | + // Core module registration. |
|
| 277 | + // Register and displays module in the BE only if told, default is "true". |
|
| 278 | + if ($this->isShown) { |
|
| 279 | + |
|
| 280 | + $moduleConfiguration = []; |
|
| 281 | + #$moduleConfiguration['routeTarget'] = \Fab\Vidi\Controller\ContentController::class . '::mainAction', // what to do here? |
|
| 282 | + $moduleConfiguration['access'] = $this->getAccess(); |
|
| 283 | + $moduleConfiguration['labels'] = $this->getModuleLanguageFile(); |
|
| 284 | + $icon = $this->getIcon(); |
|
| 285 | + if ($icon) { |
|
| 286 | + $moduleConfiguration['icon'] = $icon; |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + if ($this->showPageTree) { |
|
| 290 | + $moduleConfiguration['navigationComponentId'] = 'TYPO3/CMS/Backend/PageTree/PageTreeElement'; |
|
| 291 | + $moduleConfiguration['inheritNavigationComponentFromMainModule'] = true; |
|
| 292 | + } else { |
|
| 293 | + $moduleConfiguration['inheritNavigationComponentFromMainModule'] = true; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + ExtensionUtility::registerModule( |
|
| 297 | + 'Fab.vidi', |
|
| 298 | + $this->computeMainModule(), |
|
| 299 | + $this->dataType . '_' . $this->moduleKey, |
|
| 300 | + $this->position, |
|
| 301 | + [ |
|
| 302 | + 'Content' => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard', |
|
| 303 | + 'Tool' => 'welcome, work', |
|
| 304 | + 'Facet' => 'autoSuggest, autoSuggests', |
|
| 305 | + 'Selection' => 'edit, update, create, delete, list, show', |
|
| 306 | + 'UserPreferences' => 'save', |
|
| 307 | + 'Clipboard' => 'save, flush, show', |
|
| 308 | + ], |
|
| 309 | + $moduleConfiguration |
|
| 310 | + ); |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + /** |
|
| 315 | + * Return the module code for a BE module. |
|
| 316 | + * |
|
| 317 | + * @return string |
|
| 318 | + */ |
|
| 319 | + public function getSignature(): string |
|
| 320 | + { |
|
| 321 | + $signature = GeneralUtility::_GP(Parameter::MODULE); |
|
| 322 | + $trimmedSignature = trim($signature, '/'); |
|
| 323 | + return str_replace('/', '_', $trimmedSignature); |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * Returns the current pid. |
|
| 328 | + * |
|
| 329 | + * @return bool |
|
| 330 | + */ |
|
| 331 | + public function getCurrentPid(): bool |
|
| 332 | + { |
|
| 333 | + return GeneralUtility::_GET(Parameter::PID) > 0 ? (int)GeneralUtility::_GET(Parameter::PID) : 0; |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * Return the module URL. |
|
| 338 | + * |
|
| 339 | + * @param array $additionalParameters |
|
| 340 | + * @return string |
|
| 341 | + */ |
|
| 342 | + public function getModuleUrl(array $additionalParameters = []): string |
|
| 343 | + { |
|
| 344 | + $moduleCode = $this->getSignature(); |
|
| 345 | + |
|
| 346 | + // And don't forget the pid! |
|
| 347 | + if (GeneralUtility::_GET(Parameter::PID)) { |
|
| 348 | + $additionalParameters[Parameter::PID] = GeneralUtility::_GET(Parameter::PID); |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + return BackendUtility::getModuleUrl($moduleCode, $additionalParameters); |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + /** |
|
| 355 | + * Return the parameter prefix for a BE module. |
|
| 356 | + * |
|
| 357 | + * @return string |
|
| 358 | + */ |
|
| 359 | + public function getParameterPrefix(): string |
|
| 360 | + { |
|
| 361 | + return 'tx_vidi_' . strtolower($this->getSignature()); |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * Return a configuration key or the entire module configuration array if not key is given. |
|
| 366 | + * |
|
| 367 | + * @param string $key |
|
| 368 | + * @throws InvalidKeyInArrayException |
|
| 369 | + * @return mixed |
|
| 370 | + */ |
|
| 371 | + public function getModuleConfiguration($key = '') |
|
| 372 | + { |
|
| 373 | + |
|
| 374 | + $vidiModuleCode = $this->getSignature(); |
|
| 375 | + |
|
| 376 | + // Module code must exist |
|
| 377 | + if (empty($GLOBALS['TBE_MODULES_EXT']['vidi'][$vidiModuleCode])) { |
|
| 378 | + $message = sprintf('Invalid or not existing module code "%s"', $vidiModuleCode); |
|
| 379 | + throw new InvalidKeyInArrayException($message, 1375092053); |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + $result = $GLOBALS['TBE_MODULES_EXT']['vidi'][$vidiModuleCode]; |
|
| 383 | + |
|
| 384 | + if (!empty($key)) { |
|
| 385 | + if (isset($result[$key])) { |
|
| 386 | + $result = $result[$key]; |
|
| 387 | + } else { |
|
| 388 | + // key must exist |
|
| 389 | + $message = sprintf('Invalid key configuration "%s"', $key); |
|
| 390 | + throw new InvalidKeyInArrayException($message, 1375092054); |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | + return $result; |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * @param string $icon |
|
| 398 | + * @return $this |
|
| 399 | + */ |
|
| 400 | + public function setIcon($icon): self |
|
| 401 | + { |
|
| 402 | + $this->icon = $icon; |
|
| 403 | + return $this; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + /** |
|
| 407 | + * @return string |
|
| 408 | + */ |
|
| 409 | + protected function getIcon(): string |
|
| 410 | + { |
|
| 411 | + $moduleConfiguration = $this->getExistingMainConfiguration(); |
|
| 412 | + |
|
| 413 | + |
|
| 414 | + if ($this->icon) { |
|
| 415 | + $icon = $this->icon; |
|
| 416 | + } elseif ($moduleConfiguration['icon']) { // existing configuration may override. |
|
| 417 | + $icon = $moduleConfiguration['icon']; |
|
| 418 | + } else { |
|
| 419 | + $icon = ''; //default value. |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + return $icon; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * @param string $mainModule |
|
| 427 | + * @return $this |
|
| 428 | + */ |
|
| 429 | + public function setMainModule($mainModule): self |
|
| 430 | + { |
|
| 431 | + $this->mainModule = $mainModule; |
|
| 432 | + return $this; |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + /** |
|
| 436 | + * @return string |
|
| 437 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 438 | + */ |
|
| 439 | + public function getMainModule(): string |
|
| 440 | + { |
|
| 441 | + if ($this->mainModule === null) { |
|
| 442 | + $this->mainModule = $this->getModuleConfiguration('mainModule'); |
|
| 443 | + } |
|
| 444 | + return $this->mainModule; |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + /** |
|
| 448 | + * @param string $moduleLanguageFile |
|
| 449 | + * @return $this |
|
| 450 | + */ |
|
| 451 | + public function setModuleLanguageFile($moduleLanguageFile): self |
|
| 452 | + { |
|
| 453 | + $this->moduleLanguageFile = $moduleLanguageFile; |
|
| 454 | + return $this; |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + /** |
|
| 458 | + * @param string $component |
|
| 459 | + * @return $this |
|
| 460 | + */ |
|
| 461 | + public function removeComponentFromDocHeader(string $component): self |
|
| 462 | + { |
|
| 463 | + foreach ($this->components[ModulePosition::DOC_HEADER] as $verticalPosition => $docHeaders) { |
|
| 464 | + foreach ($docHeaders as $horizontalPosition => $docHeader) { |
|
| 465 | + |
|
| 466 | + $index = array_search($component, $docHeader, true); |
|
| 467 | + if ($index !== false) { |
|
| 468 | + // $verticalPosition: top or bottom |
|
| 469 | + // $horizontalPosition: left or right |
|
| 470 | + unset($this->components[ModulePosition::DOC_HEADER][$verticalPosition][$horizontalPosition][$index]); |
|
| 471 | + } |
|
| 472 | + } |
|
| 473 | + } |
|
| 474 | + return $this; |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + /** |
|
| 478 | + * @param string $component |
|
| 479 | + * @return bool |
|
| 480 | + */ |
|
| 481 | + public function hasComponentInDocHeader(string $component): bool |
|
| 482 | + { |
|
| 483 | + foreach ($this->getModuleConfiguration('components')[ModulePosition::DOC_HEADER] as $verticalPosition => $docHeaders) { |
|
| 484 | + foreach ($docHeaders as $horizontalPosition => $docHeader) { |
|
| 485 | + |
|
| 486 | + $index = array_search($component, $docHeader, true); |
|
| 487 | + if ($index !== false) { |
|
| 488 | + return true; |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | + } |
|
| 492 | + return false; |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + /** |
|
| 496 | + * @return string |
|
| 497 | + */ |
|
| 498 | + protected function getModuleLanguageFile(): string |
|
| 499 | + { |
|
| 500 | + $moduleConfiguration = $this->getExistingMainConfiguration(); |
|
| 501 | + |
|
| 502 | + if ($this->moduleLanguageFile) { |
|
| 503 | + $moduleLanguageFile = $this->moduleLanguageFile; |
|
| 504 | + } elseif ($moduleConfiguration['labels']) { // existing configuration may override. |
|
| 505 | + $moduleLanguageFile = $moduleConfiguration['labels']; |
|
| 506 | + } |
|
| 507 | + else { |
|
| 508 | + $moduleLanguageFile = ''; //default value. |
|
| 509 | + } |
|
| 510 | + |
|
| 511 | + return $moduleLanguageFile; |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + /** |
|
| 515 | + * @param string $position |
|
| 516 | + * @return $this |
|
| 517 | + */ |
|
| 518 | + public function setPosition($position): self |
|
| 519 | + { |
|
| 520 | + $this->position = $position; |
|
| 521 | + return $this; |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + /** |
|
| 525 | + * @return string |
|
| 526 | + */ |
|
| 527 | + public function getPosition(): string |
|
| 528 | + { |
|
| 529 | + return $this->position; |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + /** |
|
| 533 | + * @param array $files |
|
| 534 | + * @return $this |
|
| 535 | + */ |
|
| 536 | + public function addJavaScriptFiles(array $files): self |
|
| 537 | + { |
|
| 538 | + foreach ($files as $file) { |
|
| 539 | + $this->additionalJavaScriptFiles[] = $file; |
|
| 540 | + } |
|
| 541 | + return $this; |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + /** |
|
| 545 | + * @param string $fileNameAndPath |
|
| 546 | + * @return $this |
|
| 547 | + */ |
|
| 548 | + public function addJavaScriptFile($fileNameAndPath): self |
|
| 549 | + { |
|
| 550 | + $this->additionalJavaScriptFiles[] = $fileNameAndPath; |
|
| 551 | + return $this; |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + /** |
|
| 555 | + * @param array $files |
|
| 556 | + * @return $this |
|
| 557 | + */ |
|
| 558 | + public function addStyleSheetFiles(array $files): self |
|
| 559 | + { |
|
| 560 | + foreach ($files as $file) { |
|
| 561 | + $this->additionalStyleSheetFiles[] = $file; |
|
| 562 | + } |
|
| 563 | + return $this; |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + /** |
|
| 567 | + * @param string $fileNameAndPath |
|
| 568 | + * @return $this |
|
| 569 | + */ |
|
| 570 | + public function addStyleSheetFile($fileNameAndPath): self |
|
| 571 | + { |
|
| 572 | + $this->additionalStyleSheetFiles[] = $fileNameAndPath; |
|
| 573 | + return $this; |
|
| 574 | + } |
|
| 575 | + |
|
| 576 | + /** |
|
| 577 | + * @return string |
|
| 578 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 579 | + */ |
|
| 580 | + public function getDataType(): string |
|
| 581 | + { |
|
| 582 | + if ($this->dataType === null) { |
|
| 583 | + $this->dataType = $this->getModuleConfiguration('dataType'); |
|
| 584 | + } |
|
| 585 | + return $this->dataType; |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * @return array |
|
| 590 | + */ |
|
| 591 | + public function getDataTypes(): array |
|
| 592 | + { |
|
| 593 | + $dataTypes = []; |
|
| 594 | + foreach ($GLOBALS['TBE_MODULES_EXT']['vidi'] as $module) { |
|
| 595 | + $dataTypes[] = $module['dataType']; |
|
| 596 | + } |
|
| 597 | + return $dataTypes; |
|
| 598 | + } |
|
| 599 | + |
|
| 600 | + /** |
|
| 601 | + * @param string $dataType |
|
| 602 | + * @return $this |
|
| 603 | + */ |
|
| 604 | + public function setDataType($dataType): self |
|
| 605 | + { |
|
| 606 | + $this->dataType = $dataType; |
|
| 607 | + return $this; |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + /** |
|
| 611 | + * @return string |
|
| 612 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 613 | + */ |
|
| 614 | + public function getDefaultPid(): string |
|
| 615 | + { |
|
| 616 | + if (empty($this->defaultPid)) { |
|
| 617 | + $this->defaultPid = $this->getModuleConfiguration('defaultPid'); |
|
| 618 | + } |
|
| 619 | + return $this->defaultPid; |
|
| 620 | + } |
|
| 621 | + |
|
| 622 | + /** |
|
| 623 | + * @param string $defaultPid |
|
| 624 | + * @return $this |
|
| 625 | + */ |
|
| 626 | + public function setDefaultPid($defaultPid): self |
|
| 627 | + { |
|
| 628 | + $this->defaultPid = $defaultPid; |
|
| 629 | + return $this; |
|
| 630 | + } |
|
| 631 | + |
|
| 632 | + /** |
|
| 633 | + * @param bool $isPageTreeShown |
|
| 634 | + * @return $this |
|
| 635 | + */ |
|
| 636 | + public function showPageTree($isPageTreeShown): self |
|
| 637 | + { |
|
| 638 | + $this->showPageTree = $isPageTreeShown; |
|
| 639 | + return $this; |
|
| 640 | + } |
|
| 641 | + |
|
| 642 | + /** |
|
| 643 | + * @param string $isShown |
|
| 644 | + * @return $this |
|
| 645 | + */ |
|
| 646 | + public function isShown($isShown): self |
|
| 647 | + { |
|
| 648 | + $this->isShown = $isShown; |
|
| 649 | + return $this; |
|
| 650 | + } |
|
| 651 | + |
|
| 652 | + /** |
|
| 653 | + * @return $array |
|
| 654 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 655 | + */ |
|
| 656 | + public function getDocHeaderTopLeftComponents() |
|
| 657 | + { |
|
| 658 | + $configuration = $this->getModuleConfiguration(); |
|
| 659 | + return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT]; |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + /** |
|
| 663 | + * @param array $components |
|
| 664 | + * @return $this |
|
| 665 | + */ |
|
| 666 | + public function setDocHeaderTopLeftComponents(array $components): self |
|
| 667 | + { |
|
| 668 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT] = $components; |
|
| 669 | + return $this; |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + /** |
|
| 673 | + * @param string|array $components |
|
| 674 | + * @return $this |
|
| 675 | + */ |
|
| 676 | + public function addDocHeaderTopLeftComponents($components): self |
|
| 677 | + { |
|
| 678 | + if (is_string($components)) { |
|
| 679 | + $components = [$components]; |
|
| 680 | + } |
|
| 681 | + $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT]; |
|
| 682 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT] = array_merge($currentComponents, $components); |
|
| 683 | + return $this; |
|
| 684 | + } |
|
| 685 | + |
|
| 686 | + /** |
|
| 687 | + * @return $array |
|
| 688 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 689 | + */ |
|
| 690 | + public function getDocHeaderTopRightComponents() |
|
| 691 | + { |
|
| 692 | + $configuration = $this->getModuleConfiguration(); |
|
| 693 | + return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT]; |
|
| 694 | + } |
|
| 695 | + |
|
| 696 | + /** |
|
| 697 | + * @param array $components |
|
| 698 | + * @return $this |
|
| 699 | + */ |
|
| 700 | + public function setDocHeaderTopRightComponents(array $components): self |
|
| 701 | + { |
|
| 702 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT] = $components; |
|
| 703 | + return $this; |
|
| 704 | + } |
|
| 705 | + |
|
| 706 | + /** |
|
| 707 | + * @param string|array $components |
|
| 708 | + * @return $this |
|
| 709 | + */ |
|
| 710 | + public function addDocHeaderTopRightComponents($components): self |
|
| 711 | + { |
|
| 712 | + if (is_string($components)) { |
|
| 713 | + $components = [$components]; |
|
| 714 | + } |
|
| 715 | + $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT]; |
|
| 716 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT] = array_merge($currentComponents, $components); |
|
| 717 | + return $this; |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + /** |
|
| 721 | + * @return $array |
|
| 722 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 723 | + */ |
|
| 724 | + public function getDocHeaderBottomLeftComponents() |
|
| 725 | + { |
|
| 726 | + $configuration = $this->getModuleConfiguration(); |
|
| 727 | + return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT]; |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * @param array $components |
|
| 732 | + * @return $this |
|
| 733 | + */ |
|
| 734 | + public function setDocHeaderBottomLeftComponents(array $components): self |
|
| 735 | + { |
|
| 736 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT] = $components; |
|
| 737 | + return $this; |
|
| 738 | + } |
|
| 739 | + |
|
| 740 | + /** |
|
| 741 | + * @param string|array $components |
|
| 742 | + * @return $this |
|
| 743 | + */ |
|
| 744 | + public function addDocHeaderBottomLeftComponents($components): self |
|
| 745 | + { |
|
| 746 | + if (is_string($components)) { |
|
| 747 | + $components = [$components]; |
|
| 748 | + } |
|
| 749 | + $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT]; |
|
| 750 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT] = array_merge($currentComponents, $components); |
|
| 751 | + return $this; |
|
| 752 | + } |
|
| 753 | + |
|
| 754 | + /** |
|
| 755 | + * @return $array |
|
| 756 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 757 | + */ |
|
| 758 | + public function getDocHeaderBottomRightComponents() |
|
| 759 | + { |
|
| 760 | + $configuration = $this->getModuleConfiguration(); |
|
| 761 | + return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT]; |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + /** |
|
| 765 | + * @param array $components |
|
| 766 | + * @return $this |
|
| 767 | + */ |
|
| 768 | + public function setDocHeaderBottomRightComponents(array $components): self |
|
| 769 | + { |
|
| 770 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT] = $components; |
|
| 771 | + return $this; |
|
| 772 | + } |
|
| 773 | + |
|
| 774 | + /** |
|
| 775 | + * @param string|array $components |
|
| 776 | + * @return $this |
|
| 777 | + */ |
|
| 778 | + public function addDocHeaderBottomRightComponents($components): self |
|
| 779 | + { |
|
| 780 | + if (is_string($components)) { |
|
| 781 | + $components = [$components]; |
|
| 782 | + } |
|
| 783 | + $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT]; |
|
| 784 | + $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT] = array_merge($currentComponents, $components); |
|
| 785 | + return $this; |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + /** |
|
| 789 | + * @return $array |
|
| 790 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 791 | + */ |
|
| 792 | + public function getGridTopComponents() |
|
| 793 | + { |
|
| 794 | + $configuration = $this->getModuleConfiguration(); |
|
| 795 | + return $configuration['components'][ModulePosition::GRID][ModulePosition::TOP]; |
|
| 796 | + } |
|
| 797 | + |
|
| 798 | + /** |
|
| 799 | + * @param array $components |
|
| 800 | + * @return $this |
|
| 801 | + */ |
|
| 802 | + public function setGridTopComponents(array $components): self |
|
| 803 | + { |
|
| 804 | + $this->components[ModulePosition::GRID][ModulePosition::TOP] = $components; |
|
| 805 | + return $this; |
|
| 806 | + } |
|
| 807 | + |
|
| 808 | + /** |
|
| 809 | + * @param string|array $components |
|
| 810 | + * @return $this |
|
| 811 | + */ |
|
| 812 | + public function addGridTopComponents($components): self |
|
| 813 | + { |
|
| 814 | + if (is_string($components)) { |
|
| 815 | + $components = [$components]; |
|
| 816 | + } |
|
| 817 | + $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::TOP]; |
|
| 818 | + $this->components[ModulePosition::GRID][ModulePosition::TOP] = array_merge($currentComponents, $components); |
|
| 819 | + return $this; |
|
| 820 | + } |
|
| 821 | + |
|
| 822 | + /** |
|
| 823 | + * @return $array |
|
| 824 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 825 | + */ |
|
| 826 | + public function getGridBottomComponents() |
|
| 827 | + { |
|
| 828 | + $configuration = $this->getModuleConfiguration(); |
|
| 829 | + return $configuration['components'][ModulePosition::GRID][ModulePosition::BOTTOM]; |
|
| 830 | + } |
|
| 831 | + |
|
| 832 | + /** |
|
| 833 | + * @param array $components |
|
| 834 | + * @return $this |
|
| 835 | + */ |
|
| 836 | + public function setGridBottomComponents(array $components): self |
|
| 837 | + { |
|
| 838 | + $this->components[ModulePosition::GRID][ModulePosition::BOTTOM] = $components; |
|
| 839 | + return $this; |
|
| 840 | + } |
|
| 841 | + |
|
| 842 | + /** |
|
| 843 | + * @param string|array $components |
|
| 844 | + * @return $this |
|
| 845 | + */ |
|
| 846 | + public function addGridBottomComponents($components): self |
|
| 847 | + { |
|
| 848 | + if (is_string($components)) { |
|
| 849 | + $components = [$components]; |
|
| 850 | + } |
|
| 851 | + $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::BOTTOM]; |
|
| 852 | + $this->components[ModulePosition::GRID][ModulePosition::BOTTOM] = array_merge($currentComponents, $components); |
|
| 853 | + return $this; |
|
| 854 | + } |
|
| 855 | + |
|
| 856 | + /** |
|
| 857 | + * @return $array |
|
| 858 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 859 | + */ |
|
| 860 | + public function getGridButtonsComponents() |
|
| 861 | + { |
|
| 862 | + $configuration = $this->getModuleConfiguration(); |
|
| 863 | + return $configuration['components'][ModulePosition::GRID][ModulePosition::BUTTONS]; |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + /** |
|
| 867 | + * @param array $components |
|
| 868 | + * @return $this |
|
| 869 | + */ |
|
| 870 | + public function setGridButtonsComponents(array $components): self |
|
| 871 | + { |
|
| 872 | + $this->components[ModulePosition::GRID][ModulePosition::BUTTONS] = $components; |
|
| 873 | + return $this; |
|
| 874 | + } |
|
| 875 | + |
|
| 876 | + /** |
|
| 877 | + * @param string|array $components |
|
| 878 | + * @return $this |
|
| 879 | + */ |
|
| 880 | + public function addGridButtonsComponents($components): self |
|
| 881 | + { |
|
| 882 | + if (is_string($components)) { |
|
| 883 | + $components = [$components]; |
|
| 884 | + } |
|
| 885 | + $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::BUTTONS]; |
|
| 886 | + $this->components[ModulePosition::GRID][ModulePosition::BUTTONS] = array_merge($components, $currentComponents); |
|
| 887 | + return $this; |
|
| 888 | + } |
|
| 889 | + |
|
| 890 | + /** |
|
| 891 | + * @return $array |
|
| 892 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 893 | + */ |
|
| 894 | + public function getMenuMassActionComponents() |
|
| 895 | + { |
|
| 896 | + $configuration = $this->getModuleConfiguration(); |
|
| 897 | + return $configuration['components'][ModulePosition::MENU_MASS_ACTION]; |
|
| 898 | + } |
|
| 899 | + |
|
| 900 | + /** |
|
| 901 | + * @param array $components |
|
| 902 | + * @return $this |
|
| 903 | + */ |
|
| 904 | + public function setMenuMassActionComponents(array $components): self |
|
| 905 | + { |
|
| 906 | + $this->components[ModulePosition::MENU_MASS_ACTION] = $components; |
|
| 907 | + return $this; |
|
| 908 | + } |
|
| 909 | + |
|
| 910 | + /** |
|
| 911 | + * @param string|array $components |
|
| 912 | + * @return $this |
|
| 913 | + */ |
|
| 914 | + public function addMenuMassActionComponents($components): self |
|
| 915 | + { |
|
| 916 | + if (is_string($components)) { |
|
| 917 | + $components = [$components]; |
|
| 918 | + } |
|
| 919 | + $currentComponents = $this->components[ModulePosition::MENU_MASS_ACTION]; |
|
| 920 | + $this->components[ModulePosition::MENU_MASS_ACTION] = array_merge($components, $currentComponents); |
|
| 921 | + return $this; |
|
| 922 | + } |
|
| 923 | + |
|
| 924 | + /** |
|
| 925 | + * @return string |
|
| 926 | + */ |
|
| 927 | + protected function getAccess(): string |
|
| 928 | + { |
|
| 929 | + $moduleConfiguration = $this->getExistingMainConfiguration(); |
|
| 930 | + |
|
| 931 | + if ($this->access !== null) { |
|
| 932 | + $access = $this->access; |
|
| 933 | + } elseif ($moduleConfiguration['access']) { // existing configuration may override. |
|
| 934 | + $access = $moduleConfiguration['access']; |
|
| 935 | + } else { |
|
| 936 | + $access = Access::USER; //default value. |
|
| 937 | + } |
|
| 938 | + return $access; |
|
| 939 | + } |
|
| 940 | + |
|
| 941 | + /** |
|
| 942 | + * @param string $access |
|
| 943 | + * @return $this |
|
| 944 | + */ |
|
| 945 | + public function setAccess($access): self |
|
| 946 | + { |
|
| 947 | + $this->access = $access; |
|
| 948 | + return $this; |
|
| 949 | + } |
|
| 950 | + |
|
| 951 | + /** |
|
| 952 | + * @return \string[] |
|
| 953 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 954 | + */ |
|
| 955 | + public function getAdditionalJavaScriptFiles(): array |
|
| 956 | + { |
|
| 957 | + if (empty($this->additionalJavaScriptFiles)) { |
|
| 958 | + $this->additionalJavaScriptFiles = $this->getModuleConfiguration('additionalJavaScriptFiles'); |
|
| 959 | + } |
|
| 960 | + return $this->additionalJavaScriptFiles; |
|
| 961 | + } |
|
| 962 | + |
|
| 963 | + /** |
|
| 964 | + * @return \string[] |
|
| 965 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 966 | + */ |
|
| 967 | + public function getAdditionalStyleSheetFiles(): array |
|
| 968 | + { |
|
| 969 | + if (empty($this->additionalStyleSheetFiles)) { |
|
| 970 | + $this->additionalStyleSheetFiles = $this->getModuleConfiguration('additionalStyleSheetFiles'); |
|
| 971 | + } |
|
| 972 | + return $this->additionalStyleSheetFiles; |
|
| 973 | + } |
|
| 974 | + |
|
| 975 | + /** |
|
| 976 | + * @return array |
|
| 977 | + */ |
|
| 978 | + public function getComponents(): array |
|
| 979 | + { |
|
| 980 | + return $this->components; |
|
| 981 | + } |
|
| 982 | + |
|
| 983 | + /** |
|
| 984 | + * @param string $pluginName |
|
| 985 | + * @return bool |
|
| 986 | + */ |
|
| 987 | + public function hasPlugin($pluginName = ''): bool |
|
| 988 | + { |
|
| 989 | + $parameterPrefix = $this->getParameterPrefix(); |
|
| 990 | + $parameters = GeneralUtility::_GET($parameterPrefix); |
|
| 991 | + |
|
| 992 | + $hasPlugin = !empty($parameters['plugins']) && is_array($parameters['plugins']); |
|
| 993 | + if ($hasPlugin && $pluginName) { |
|
| 994 | + $hasPlugin = in_array($pluginName, $parameters['plugins']); |
|
| 995 | + } |
|
| 996 | + return $hasPlugin; |
|
| 997 | + } |
|
| 998 | + |
|
| 999 | + /** |
|
| 1000 | + * Compute the internal module code |
|
| 1001 | + * |
|
| 1002 | + * @param null|string $dataType |
|
| 1003 | + * @return string |
|
| 1004 | + */ |
|
| 1005 | + protected function getInternalModuleSignature($dataType = null): string |
|
| 1006 | + { |
|
| 1007 | + // Else we forge the module signature |
|
| 1008 | + if ($dataType === null) { |
|
| 1009 | + $dataType = $this->dataType; |
|
| 1010 | + } |
|
| 1011 | + $subModuleName = $dataType . '_' . $this->moduleKey; |
|
| 1012 | + |
|
| 1013 | + $mainModule = $this->mainModule ? : self::DEFAULT_MAIN_MODULE; |
|
| 1014 | + return $mainModule . '_Vidi' . GeneralUtility::underscoredToUpperCamelCase($subModuleName); |
|
| 1015 | + } |
|
| 1016 | 1016 | |
| 1017 | 1017 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | protected function getExistingMainConfiguration(): array |
| 176 | 176 | { |
| 177 | - $possibleConfiguration = $GLOBALS['TBE_MODULES']['_configuration'][$this->computeMainModule() . '_' . $this->getInternalModuleSignature()]; |
|
| 177 | + $possibleConfiguration = $GLOBALS['TBE_MODULES']['_configuration'][$this->computeMainModule().'_'.$this->getInternalModuleSignature()]; |
|
| 178 | 178 | return is_array($possibleConfiguration) ? $possibleConfiguration : []; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | ExtensionUtility::registerModule( |
| 297 | 297 | 'Fab.vidi', |
| 298 | 298 | $this->computeMainModule(), |
| 299 | - $this->dataType . '_' . $this->moduleKey, |
|
| 299 | + $this->dataType.'_'.$this->moduleKey, |
|
| 300 | 300 | $this->position, |
| 301 | 301 | [ |
| 302 | 302 | 'Content' => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard', |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | */ |
| 359 | 359 | public function getParameterPrefix(): string |
| 360 | 360 | { |
| 361 | - return 'tx_vidi_' . strtolower($this->getSignature()); |
|
| 361 | + return 'tx_vidi_'.strtolower($this->getSignature()); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -1008,10 +1008,10 @@ discard block |
||
| 1008 | 1008 | if ($dataType === null) { |
| 1009 | 1009 | $dataType = $this->dataType; |
| 1010 | 1010 | } |
| 1011 | - $subModuleName = $dataType . '_' . $this->moduleKey; |
|
| 1011 | + $subModuleName = $dataType.'_'.$this->moduleKey; |
|
| 1012 | 1012 | |
| 1013 | - $mainModule = $this->mainModule ? : self::DEFAULT_MAIN_MODULE; |
|
| 1014 | - return $mainModule . '_Vidi' . GeneralUtility::underscoredToUpperCamelCase($subModuleName); |
|
| 1013 | + $mainModule = $this->mainModule ?: self::DEFAULT_MAIN_MODULE; |
|
| 1014 | + return $mainModule.'_Vidi'.GeneralUtility::underscoredToUpperCamelCase($subModuleName); |
|
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | } |
@@ -17,29 +17,29 @@ |
||
| 17 | 17 | class VidiModulesAspect implements TableConfigurationPostProcessingHookInterface |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Initialize and populate TBE_MODULES_EXT with default data. |
|
| 22 | - * |
|
| 23 | - * @return void |
|
| 24 | - */ |
|
| 25 | - public function processData() |
|
| 26 | - { |
|
| 27 | - |
|
| 28 | - /** @var \Fab\Vidi\Module\ModuleLoader $moduleLoader */ |
|
| 29 | - $moduleLoader = GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleLoader::class); |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
| 33 | - \TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class |
|
| 34 | - )->get('vidi'); |
|
| 35 | - |
|
| 36 | - foreach (GeneralUtility::trimExplode(',', $configuration['data_types']) as $dataType) { |
|
| 37 | - if (!$moduleLoader->isRegistered($dataType)) { |
|
| 38 | - $moduleLoader->setDataType($dataType) |
|
| 39 | - #->isShown(false) |
|
| 40 | - ->register(); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - } |
|
| 20 | + /** |
|
| 21 | + * Initialize and populate TBE_MODULES_EXT with default data. |
|
| 22 | + * |
|
| 23 | + * @return void |
|
| 24 | + */ |
|
| 25 | + public function processData() |
|
| 26 | + { |
|
| 27 | + |
|
| 28 | + /** @var \Fab\Vidi\Module\ModuleLoader $moduleLoader */ |
|
| 29 | + $moduleLoader = GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleLoader::class); |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
| 33 | + \TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class |
|
| 34 | + )->get('vidi'); |
|
| 35 | + |
|
| 36 | + foreach (GeneralUtility::trimExplode(',', $configuration['data_types']) as $dataType) { |
|
| 37 | + if (!$moduleLoader->isRegistered($dataType)) { |
|
| 38 | + $moduleLoader->setDataType($dataType) |
|
| 39 | + #->isShown(false) |
|
| 40 | + ->register(); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | } |
@@ -21,102 +21,102 @@ |
||
| 21 | 21 | class NewButton extends AbstractComponentView |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Renders a "new" button to be placed in the doc header. |
|
| 26 | - * |
|
| 27 | - * @return string |
|
| 28 | - */ |
|
| 29 | - public function render() |
|
| 30 | - { |
|
| 31 | - // New button only for the current data type. |
|
| 32 | - return $this->makeLinkButton()->setHref($this->getNewUri()) |
|
| 33 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:newRecordGeneral')) |
|
| 34 | - ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)) |
|
| 35 | - ->render(); |
|
| 36 | - } |
|
| 24 | + /** |
|
| 25 | + * Renders a "new" button to be placed in the doc header. |
|
| 26 | + * |
|
| 27 | + * @return string |
|
| 28 | + */ |
|
| 29 | + public function render() |
|
| 30 | + { |
|
| 31 | + // New button only for the current data type. |
|
| 32 | + return $this->makeLinkButton()->setHref($this->getNewUri()) |
|
| 33 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:newRecordGeneral')) |
|
| 34 | + ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)) |
|
| 35 | + ->render(); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Render a create URI given a data type. |
|
| 40 | - * |
|
| 41 | - * @return string |
|
| 42 | - * @throws \InvalidArgumentException |
|
| 43 | - */ |
|
| 44 | - protected function getUriWizardNew() |
|
| 45 | - { |
|
| 46 | - // Return URL in any case. |
|
| 47 | - $arguments['returnUrl'] = $this->getModuleLoader()->getModuleUrl(); |
|
| 38 | + /** |
|
| 39 | + * Render a create URI given a data type. |
|
| 40 | + * |
|
| 41 | + * @return string |
|
| 42 | + * @throws \InvalidArgumentException |
|
| 43 | + */ |
|
| 44 | + protected function getUriWizardNew() |
|
| 45 | + { |
|
| 46 | + // Return URL in any case. |
|
| 47 | + $arguments['returnUrl'] = $this->getModuleLoader()->getModuleUrl(); |
|
| 48 | 48 | |
| 49 | - // Add possible id parameter |
|
| 50 | - if (GeneralUtility::_GP(Parameter::PID)) { |
|
| 51 | - $arguments['id'] = GeneralUtility::_GP(Parameter::PID); |
|
| 52 | - } |
|
| 49 | + // Add possible id parameter |
|
| 50 | + if (GeneralUtility::_GP(Parameter::PID)) { |
|
| 51 | + $arguments['id'] = GeneralUtility::_GP(Parameter::PID); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - $uri = BackendUtility::getModuleUrl( |
|
| 55 | - 'db_new', |
|
| 56 | - $arguments |
|
| 57 | - ); |
|
| 54 | + $uri = BackendUtility::getModuleUrl( |
|
| 55 | + 'db_new', |
|
| 56 | + $arguments |
|
| 57 | + ); |
|
| 58 | 58 | |
| 59 | - return $uri; |
|
| 60 | - } |
|
| 59 | + return $uri; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Render a create URI given a data type. |
|
| 64 | - * |
|
| 65 | - * @return string |
|
| 66 | - * @throws \InvalidArgumentException |
|
| 67 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 68 | - */ |
|
| 69 | - protected function getNewUri() |
|
| 70 | - { |
|
| 71 | - $uri = BackendUtility::getModuleUrl( |
|
| 72 | - 'record_edit', |
|
| 73 | - array( |
|
| 74 | - $this->getNewParameterName() => 'new', |
|
| 75 | - 'returnUrl' => $this->getModuleLoader()->getModuleUrl() |
|
| 76 | - ) |
|
| 77 | - ); |
|
| 78 | - return $uri; |
|
| 79 | - } |
|
| 62 | + /** |
|
| 63 | + * Render a create URI given a data type. |
|
| 64 | + * |
|
| 65 | + * @return string |
|
| 66 | + * @throws \InvalidArgumentException |
|
| 67 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 68 | + */ |
|
| 69 | + protected function getNewUri() |
|
| 70 | + { |
|
| 71 | + $uri = BackendUtility::getModuleUrl( |
|
| 72 | + 'record_edit', |
|
| 73 | + array( |
|
| 74 | + $this->getNewParameterName() => 'new', |
|
| 75 | + 'returnUrl' => $this->getModuleLoader()->getModuleUrl() |
|
| 76 | + ) |
|
| 77 | + ); |
|
| 78 | + return $uri; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * @return string |
|
| 83 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 84 | - * @throws \InvalidArgumentException |
|
| 85 | - */ |
|
| 86 | - protected function getNewParameterName() |
|
| 87 | - { |
|
| 88 | - return sprintf( |
|
| 89 | - 'edit[%s][%s]', |
|
| 90 | - $this->getModuleLoader()->getDataType(), |
|
| 91 | - $this->getStoragePid() |
|
| 92 | - ); |
|
| 93 | - } |
|
| 81 | + /** |
|
| 82 | + * @return string |
|
| 83 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 84 | + * @throws \InvalidArgumentException |
|
| 85 | + */ |
|
| 86 | + protected function getNewParameterName() |
|
| 87 | + { |
|
| 88 | + return sprintf( |
|
| 89 | + 'edit[%s][%s]', |
|
| 90 | + $this->getModuleLoader()->getDataType(), |
|
| 91 | + $this->getStoragePid() |
|
| 92 | + ); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Return the default configured pid. |
|
| 97 | - * |
|
| 98 | - * @return int |
|
| 99 | - * @throws \InvalidArgumentException |
|
| 100 | - * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 101 | - */ |
|
| 102 | - protected function getStoragePid() |
|
| 103 | - { |
|
| 104 | - if (GeneralUtility::_GP(Parameter::PID)) { |
|
| 105 | - $pid = GeneralUtility::_GP(Parameter::PID); |
|
| 106 | - } elseif ((int)Tca::table()->get('rootLevel') === 1) { |
|
| 107 | - $pid = 0; |
|
| 108 | - } else { |
|
| 109 | - // Get configuration from User TSConfig if any |
|
| 110 | - $tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->getModuleLoader()->getDataType()); |
|
| 111 | - $tsConfig = $this->getBackendUser()->getTSConfig($tsConfigPath); |
|
| 112 | - $pid = $tsConfig['value']; |
|
| 95 | + /** |
|
| 96 | + * Return the default configured pid. |
|
| 97 | + * |
|
| 98 | + * @return int |
|
| 99 | + * @throws \InvalidArgumentException |
|
| 100 | + * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException |
|
| 101 | + */ |
|
| 102 | + protected function getStoragePid() |
|
| 103 | + { |
|
| 104 | + if (GeneralUtility::_GP(Parameter::PID)) { |
|
| 105 | + $pid = GeneralUtility::_GP(Parameter::PID); |
|
| 106 | + } elseif ((int)Tca::table()->get('rootLevel') === 1) { |
|
| 107 | + $pid = 0; |
|
| 108 | + } else { |
|
| 109 | + // Get configuration from User TSConfig if any |
|
| 110 | + $tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->getModuleLoader()->getDataType()); |
|
| 111 | + $tsConfig = $this->getBackendUser()->getTSConfig($tsConfigPath); |
|
| 112 | + $pid = $tsConfig['value']; |
|
| 113 | 113 | |
| 114 | - // Get pid from Module Loader |
|
| 115 | - if (null === $pid) { |
|
| 116 | - $pid = $this->getModuleLoader()->getDefaultPid(); |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - return (int)$pid; |
|
| 120 | - } |
|
| 114 | + // Get pid from Module Loader |
|
| 115 | + if (null === $pid) { |
|
| 116 | + $pid = $this->getModuleLoader()->getDefaultPid(); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + return (int)$pid; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | 122 | } |
@@ -17,37 +17,37 @@ discard block |
||
| 17 | 17 | class RelationsCheck extends AbstractComponentView |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - protected $invalidFields = []; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Renders a button for uploading assets. |
|
| 27 | - * |
|
| 28 | - * @return string |
|
| 29 | - */ |
|
| 30 | - public function render() |
|
| 31 | - { |
|
| 32 | - |
|
| 33 | - $result = ''; |
|
| 34 | - |
|
| 35 | - // Check whether storage is configured or not. |
|
| 36 | - if (!$this->isTcaValid()) { |
|
| 37 | - $result .= $this->formatMessageTcaIsNotValid(); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - return $result; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Format a message whenever the storage is offline. |
|
| 45 | - * |
|
| 46 | - * @return string |
|
| 47 | - */ |
|
| 48 | - protected function formatMessageTcaIsNotValid() |
|
| 49 | - { |
|
| 50 | - $result = <<< EOF |
|
| 20 | + /** |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + protected $invalidFields = []; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Renders a button for uploading assets. |
|
| 27 | + * |
|
| 28 | + * @return string |
|
| 29 | + */ |
|
| 30 | + public function render() |
|
| 31 | + { |
|
| 32 | + |
|
| 33 | + $result = ''; |
|
| 34 | + |
|
| 35 | + // Check whether storage is configured or not. |
|
| 36 | + if (!$this->isTcaValid()) { |
|
| 37 | + $result .= $this->formatMessageTcaIsNotValid(); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + return $result; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Format a message whenever the storage is offline. |
|
| 45 | + * |
|
| 46 | + * @return string |
|
| 47 | + */ |
|
| 48 | + protected function formatMessageTcaIsNotValid() |
|
| 49 | + { |
|
| 50 | + $result = <<< EOF |
|
| 51 | 51 | <div class="-warning alert alert-warning"> |
| 52 | 52 | <div class="alert-title"> |
| 53 | 53 | Grid may have trouble to render because of wrong / missing TCA. |
@@ -62,19 +62,19 @@ discard block |
||
| 62 | 62 | </div> |
| 63 | 63 | </div> |
| 64 | 64 | EOF; |
| 65 | - return $result; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Check relations of current data type in the Grid. |
|
| 70 | - * |
|
| 71 | - * @return string |
|
| 72 | - */ |
|
| 73 | - protected function formatMessageHelperText() |
|
| 74 | - { |
|
| 75 | - $helperText = ''; |
|
| 76 | - foreach ($this->invalidFields as $invalidField) { |
|
| 77 | - $helperText .= <<<EOF |
|
| 65 | + return $result; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Check relations of current data type in the Grid. |
|
| 70 | + * |
|
| 71 | + * @return string |
|
| 72 | + */ |
|
| 73 | + protected function formatMessageHelperText() |
|
| 74 | + { |
|
| 75 | + $helperText = ''; |
|
| 76 | + foreach ($this->invalidFields as $invalidField) { |
|
| 77 | + $helperText .= <<<EOF |
|
| 78 | 78 | <br /> |
| 79 | 79 | In file EXT:my_ext/Configuration/TCA/{$this->getModuleLoader()->getDataType()}.php |
| 80 | 80 | <pre> |
@@ -108,42 +108,42 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | </pre> |
| 110 | 110 | EOF; |
| 111 | - } |
|
| 112 | - return $helperText; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Check relations of current data type in the Grid. |
|
| 117 | - * |
|
| 118 | - * @return boolean |
|
| 119 | - */ |
|
| 120 | - protected function isTcaValid() |
|
| 121 | - { |
|
| 122 | - |
|
| 123 | - $dataType = $this->getModuleLoader()->getDataType(); |
|
| 124 | - $table = Tca::table($dataType); |
|
| 125 | - |
|
| 126 | - foreach (Tca::grid($dataType)->getFields() as $fieldName => $configuration) { |
|
| 127 | - |
|
| 128 | - if ($table->hasField($fieldName) && $table->field($fieldName)->hasMany()) { |
|
| 129 | - if ($table->field($fieldName)->hasRelationManyToMany()) { |
|
| 130 | - |
|
| 131 | - $foreignTable = $table->field($fieldName)->getForeignTable(); |
|
| 132 | - $manyToManyTable = $table->field($fieldName)->getManyToManyTable(); |
|
| 133 | - $foreignField = $table->field($fieldName)->getForeignField(); |
|
| 134 | - |
|
| 135 | - if (!$foreignField) { |
|
| 136 | - $this->invalidFields[] = $fieldName; |
|
| 137 | - } elseif (!$foreignTable) { |
|
| 138 | - $this->invalidFields[] = $fieldName; |
|
| 139 | - } elseif (!$manyToManyTable) { |
|
| 140 | - $this->invalidFields[] = $fieldName; |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return empty($this->invalidFields); |
|
| 147 | - } |
|
| 111 | + } |
|
| 112 | + return $helperText; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Check relations of current data type in the Grid. |
|
| 117 | + * |
|
| 118 | + * @return boolean |
|
| 119 | + */ |
|
| 120 | + protected function isTcaValid() |
|
| 121 | + { |
|
| 122 | + |
|
| 123 | + $dataType = $this->getModuleLoader()->getDataType(); |
|
| 124 | + $table = Tca::table($dataType); |
|
| 125 | + |
|
| 126 | + foreach (Tca::grid($dataType)->getFields() as $fieldName => $configuration) { |
|
| 127 | + |
|
| 128 | + if ($table->hasField($fieldName) && $table->field($fieldName)->hasMany()) { |
|
| 129 | + if ($table->field($fieldName)->hasRelationManyToMany()) { |
|
| 130 | + |
|
| 131 | + $foreignTable = $table->field($fieldName)->getForeignTable(); |
|
| 132 | + $manyToManyTable = $table->field($fieldName)->getManyToManyTable(); |
|
| 133 | + $foreignField = $table->field($fieldName)->getForeignField(); |
|
| 134 | + |
|
| 135 | + if (!$foreignField) { |
|
| 136 | + $this->invalidFields[] = $fieldName; |
|
| 137 | + } elseif (!$foreignTable) { |
|
| 138 | + $this->invalidFields[] = $fieldName; |
|
| 139 | + } elseif (!$manyToManyTable) { |
|
| 140 | + $this->invalidFields[] = $fieldName; |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return empty($this->invalidFields); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | 149 | } |
@@ -20,72 +20,72 @@ discard block |
||
| 20 | 20 | class PidCheck extends AbstractComponentView |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * The data type (table) |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - protected $dataType = ''; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * The configured pid for the data type |
|
| 32 | - * |
|
| 33 | - * @var int |
|
| 34 | - */ |
|
| 35 | - protected $configuredPid = 0; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * The page record of the configured pid |
|
| 39 | - * |
|
| 40 | - * @var array |
|
| 41 | - */ |
|
| 42 | - protected $page = null; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * A collection of speaking error messages why the pid is invalid. |
|
| 46 | - * |
|
| 47 | - * @var array |
|
| 48 | - */ |
|
| 49 | - protected $errors = []; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Pseudo-Constructor, which ensures all dependencies are injected when called. |
|
| 53 | - */ |
|
| 54 | - public function initializeObject(): void |
|
| 55 | - { |
|
| 56 | - $this->dataType = $this->getModuleLoader()->getDataType(); |
|
| 57 | - $this->configuredPid = $this->getConfiguredPid(); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Renders warnings if storagePid is not properly configured. |
|
| 62 | - * |
|
| 63 | - * @return string |
|
| 64 | - */ |
|
| 65 | - public function render() |
|
| 66 | - { |
|
| 67 | - $result = ''; |
|
| 68 | - |
|
| 69 | - $this->validateRootLevel(); |
|
| 70 | - $this->validatePageExist(); |
|
| 71 | - $this->validateDoktype(); |
|
| 72 | - |
|
| 73 | - if (!empty($this->errors)) { |
|
| 74 | - $result .= $this->formatMessagePidIsNotValid(); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - return $result; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Format a message whenever the storage is offline. |
|
| 82 | - * |
|
| 83 | - * @return string |
|
| 84 | - */ |
|
| 85 | - protected function formatMessagePidIsNotValid(): string |
|
| 86 | - { |
|
| 87 | - $error = implode('<br />', $this->errors); |
|
| 88 | - $result = <<< EOF |
|
| 23 | + /** |
|
| 24 | + * The data type (table) |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + protected $dataType = ''; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * The configured pid for the data type |
|
| 32 | + * |
|
| 33 | + * @var int |
|
| 34 | + */ |
|
| 35 | + protected $configuredPid = 0; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * The page record of the configured pid |
|
| 39 | + * |
|
| 40 | + * @var array |
|
| 41 | + */ |
|
| 42 | + protected $page = null; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * A collection of speaking error messages why the pid is invalid. |
|
| 46 | + * |
|
| 47 | + * @var array |
|
| 48 | + */ |
|
| 49 | + protected $errors = []; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Pseudo-Constructor, which ensures all dependencies are injected when called. |
|
| 53 | + */ |
|
| 54 | + public function initializeObject(): void |
|
| 55 | + { |
|
| 56 | + $this->dataType = $this->getModuleLoader()->getDataType(); |
|
| 57 | + $this->configuredPid = $this->getConfiguredPid(); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Renders warnings if storagePid is not properly configured. |
|
| 62 | + * |
|
| 63 | + * @return string |
|
| 64 | + */ |
|
| 65 | + public function render() |
|
| 66 | + { |
|
| 67 | + $result = ''; |
|
| 68 | + |
|
| 69 | + $this->validateRootLevel(); |
|
| 70 | + $this->validatePageExist(); |
|
| 71 | + $this->validateDoktype(); |
|
| 72 | + |
|
| 73 | + if (!empty($this->errors)) { |
|
| 74 | + $result .= $this->formatMessagePidIsNotValid(); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + return $result; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Format a message whenever the storage is offline. |
|
| 82 | + * |
|
| 83 | + * @return string |
|
| 84 | + */ |
|
| 85 | + protected function formatMessagePidIsNotValid(): string |
|
| 86 | + { |
|
| 87 | + $error = implode('<br />', $this->errors); |
|
| 88 | + $result = <<< EOF |
|
| 89 | 89 | <div class="alert alert-warning"> |
| 90 | 90 | <div class="alert-title"> |
| 91 | 91 | Page id "{$this->configuredPid}" has found to be a wrong configuration for "{$this->dataType}" |
@@ -113,130 +113,130 @@ discard block |
||
| 113 | 113 | </div> |
| 114 | 114 | EOF; |
| 115 | 115 | |
| 116 | - return $result; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Check if pid is 0 and given table is allowed on root level. |
|
| 121 | - * |
|
| 122 | - * @return void |
|
| 123 | - */ |
|
| 124 | - protected function validateRootLevel(): void |
|
| 125 | - { |
|
| 126 | - if ($this->configuredPid > 0) { |
|
| 127 | - return; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - $isRootLevel = (bool)Tca::table()->get('rootLevel'); |
|
| 131 | - if (!$isRootLevel) { |
|
| 132 | - $this->errors[] = sprintf( |
|
| 133 | - 'You are not allowed to use page id "0" unless you set $GLOBALS[\'TCA\'][\'%1$s\'][\'ctrl\'][\'rootLevel\'] = 1;', |
|
| 134 | - $this->dataType |
|
| 135 | - ); |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * Check if a page exists for the configured pid |
|
| 141 | - * |
|
| 142 | - * @return void |
|
| 143 | - */ |
|
| 144 | - protected function validatePageExist(): void |
|
| 145 | - { |
|
| 146 | - if ($this->configuredPid === 0) { |
|
| 147 | - return; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - $page = $this->getPage(); |
|
| 151 | - if (empty($page)) { |
|
| 152 | - $this->errors[] = sprintf( |
|
| 153 | - 'No page found for the configured page id "%s".', |
|
| 154 | - $this->configuredPid |
|
| 155 | - ); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Check if configured page is a sysfolder and if it is allowed. |
|
| 161 | - * |
|
| 162 | - * @return void |
|
| 163 | - */ |
|
| 164 | - protected function validateDoktype(): void |
|
| 165 | - { |
|
| 166 | - if ($this->configuredPid === 0) { |
|
| 167 | - return; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - $page = $this->getPage(); |
|
| 171 | - if (!empty($page) |
|
| 172 | - && (int)$page['doktype'] !== PageRepository::DOKTYPE_SYSFOLDER |
|
| 173 | - && !$this->isTableAllowedOnStandardPages() |
|
| 174 | - && $this->getModuleLoader()->hasComponentInDocHeader(\Fab\Vidi\View\Button\NewButton::class)) { |
|
| 175 | - $this->errors[] = sprintf( |
|
| 176 | - 'The page with the id "%s" either has to be of the type "folder" (doktype=254) or the table "%s" has to be allowed on standard pages.', |
|
| 177 | - $this->configuredPid, |
|
| 178 | - $this->dataType |
|
| 179 | - ); |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * Check if given table is allowed on standard pages |
|
| 185 | - * |
|
| 186 | - * @see \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages() |
|
| 187 | - * @return bool |
|
| 188 | - */ |
|
| 189 | - protected function isTableAllowedOnStandardPages(): bool |
|
| 190 | - { |
|
| 191 | - $allowedTables = explode(',', $GLOBALS['PAGES_TYPES']['default']['allowedTables']); |
|
| 192 | - return in_array($this->dataType, $allowedTables, true); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Return the default configured pid. |
|
| 197 | - * |
|
| 198 | - * @return int |
|
| 199 | - */ |
|
| 200 | - protected function getConfiguredPid(): int |
|
| 201 | - { |
|
| 202 | - |
|
| 203 | - if (GeneralUtility::_GP(Parameter::PID)) { |
|
| 204 | - $pid = GeneralUtility::_GP(Parameter::PID); |
|
| 205 | - } else { |
|
| 206 | - |
|
| 207 | - // Get pid from User TSConfig if any. |
|
| 208 | - $tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->dataType); |
|
| 209 | - $result = $this->getBackendUser()->getTSConfig($tsConfigPath); |
|
| 210 | - $configuredPid = (int)$result['value']; |
|
| 211 | - |
|
| 212 | - // If no pid is configured, use default pid from Module Loader |
|
| 213 | - $pid = ($configuredPid) ?: $this->getModuleLoader()->getDefaultPid(); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - return $pid; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Return a pointer to the database. |
|
| 221 | - * |
|
| 222 | - * @return \Fab\Vidi\Database\DatabaseConnection |
|
| 223 | - */ |
|
| 224 | - protected function getDatabaseConnection(): \Fab\Vidi\Database\DatabaseConnection |
|
| 225 | - { |
|
| 226 | - return $GLOBALS['TYPO3_DB']; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * Returns the page record of the configured pid |
|
| 231 | - * |
|
| 232 | - * @return array |
|
| 233 | - */ |
|
| 234 | - public function getPage(): ?array |
|
| 235 | - { |
|
| 236 | - if ($this->page !== null) { |
|
| 237 | - return $this->page; |
|
| 238 | - } else { |
|
| 239 | - return $this->getDatabaseConnection()->exec_SELECTgetSingleRow('doktype', 'pages', 'deleted = 0 AND uid = ' . $this->configuredPid); |
|
| 240 | - } |
|
| 241 | - } |
|
| 116 | + return $result; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Check if pid is 0 and given table is allowed on root level. |
|
| 121 | + * |
|
| 122 | + * @return void |
|
| 123 | + */ |
|
| 124 | + protected function validateRootLevel(): void |
|
| 125 | + { |
|
| 126 | + if ($this->configuredPid > 0) { |
|
| 127 | + return; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + $isRootLevel = (bool)Tca::table()->get('rootLevel'); |
|
| 131 | + if (!$isRootLevel) { |
|
| 132 | + $this->errors[] = sprintf( |
|
| 133 | + 'You are not allowed to use page id "0" unless you set $GLOBALS[\'TCA\'][\'%1$s\'][\'ctrl\'][\'rootLevel\'] = 1;', |
|
| 134 | + $this->dataType |
|
| 135 | + ); |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * Check if a page exists for the configured pid |
|
| 141 | + * |
|
| 142 | + * @return void |
|
| 143 | + */ |
|
| 144 | + protected function validatePageExist(): void |
|
| 145 | + { |
|
| 146 | + if ($this->configuredPid === 0) { |
|
| 147 | + return; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + $page = $this->getPage(); |
|
| 151 | + if (empty($page)) { |
|
| 152 | + $this->errors[] = sprintf( |
|
| 153 | + 'No page found for the configured page id "%s".', |
|
| 154 | + $this->configuredPid |
|
| 155 | + ); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Check if configured page is a sysfolder and if it is allowed. |
|
| 161 | + * |
|
| 162 | + * @return void |
|
| 163 | + */ |
|
| 164 | + protected function validateDoktype(): void |
|
| 165 | + { |
|
| 166 | + if ($this->configuredPid === 0) { |
|
| 167 | + return; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + $page = $this->getPage(); |
|
| 171 | + if (!empty($page) |
|
| 172 | + && (int)$page['doktype'] !== PageRepository::DOKTYPE_SYSFOLDER |
|
| 173 | + && !$this->isTableAllowedOnStandardPages() |
|
| 174 | + && $this->getModuleLoader()->hasComponentInDocHeader(\Fab\Vidi\View\Button\NewButton::class)) { |
|
| 175 | + $this->errors[] = sprintf( |
|
| 176 | + 'The page with the id "%s" either has to be of the type "folder" (doktype=254) or the table "%s" has to be allowed on standard pages.', |
|
| 177 | + $this->configuredPid, |
|
| 178 | + $this->dataType |
|
| 179 | + ); |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * Check if given table is allowed on standard pages |
|
| 185 | + * |
|
| 186 | + * @see \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages() |
|
| 187 | + * @return bool |
|
| 188 | + */ |
|
| 189 | + protected function isTableAllowedOnStandardPages(): bool |
|
| 190 | + { |
|
| 191 | + $allowedTables = explode(',', $GLOBALS['PAGES_TYPES']['default']['allowedTables']); |
|
| 192 | + return in_array($this->dataType, $allowedTables, true); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Return the default configured pid. |
|
| 197 | + * |
|
| 198 | + * @return int |
|
| 199 | + */ |
|
| 200 | + protected function getConfiguredPid(): int |
|
| 201 | + { |
|
| 202 | + |
|
| 203 | + if (GeneralUtility::_GP(Parameter::PID)) { |
|
| 204 | + $pid = GeneralUtility::_GP(Parameter::PID); |
|
| 205 | + } else { |
|
| 206 | + |
|
| 207 | + // Get pid from User TSConfig if any. |
|
| 208 | + $tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->dataType); |
|
| 209 | + $result = $this->getBackendUser()->getTSConfig($tsConfigPath); |
|
| 210 | + $configuredPid = (int)$result['value']; |
|
| 211 | + |
|
| 212 | + // If no pid is configured, use default pid from Module Loader |
|
| 213 | + $pid = ($configuredPid) ?: $this->getModuleLoader()->getDefaultPid(); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + return $pid; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Return a pointer to the database. |
|
| 221 | + * |
|
| 222 | + * @return \Fab\Vidi\Database\DatabaseConnection |
|
| 223 | + */ |
|
| 224 | + protected function getDatabaseConnection(): \Fab\Vidi\Database\DatabaseConnection |
|
| 225 | + { |
|
| 226 | + return $GLOBALS['TYPO3_DB']; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * Returns the page record of the configured pid |
|
| 231 | + * |
|
| 232 | + * @return array |
|
| 233 | + */ |
|
| 234 | + public function getPage(): ?array |
|
| 235 | + { |
|
| 236 | + if ($this->page !== null) { |
|
| 237 | + return $this->page; |
|
| 238 | + } else { |
|
| 239 | + return $this->getDatabaseConnection()->exec_SELECTgetSingleRow('doktype', 'pages', 'deleted = 0 AND uid = ' . $this->configuredPid); |
|
| 240 | + } |
|
| 241 | + } |
|
| 242 | 242 | } |
@@ -3,173 +3,173 @@ |
||
| 3 | 3 | |
| 4 | 4 | call_user_func(function () { |
| 5 | 5 | |
| 6 | - // Check from Vidi configuration what default module should be loaded. |
|
| 7 | - // Make sure the class exists to avoid a Runtime Error |
|
| 8 | - if (TYPO3_MODE === 'BE') { |
|
| 9 | - |
|
| 10 | - // Add content main module before 'user' |
|
| 11 | - if (!isset($GLOBALS['TBE_MODULES']['content'])) { |
|
| 12 | - |
|
| 13 | - // Position module "content" after module "user" manually. No API is available for that, it seems... |
|
| 14 | - $modules = []; |
|
| 15 | - foreach ($GLOBALS['TBE_MODULES'] as $key => $val) { |
|
| 16 | - if ($key === 'user') { |
|
| 17 | - $modules['content'] = ''; |
|
| 18 | - } |
|
| 19 | - $modules[$key] = $val; |
|
| 20 | - } |
|
| 21 | - $GLOBALS['TBE_MODULES'] = $modules; |
|
| 22 | - |
|
| 23 | - // Register "data management" module. |
|
| 24 | - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule( |
|
| 25 | - 'content', |
|
| 26 | - '', |
|
| 27 | - '', |
|
| 28 | - '', |
|
| 29 | - [ |
|
| 30 | - 'name' => 'content', |
|
| 31 | - 'access' => 'user,group', |
|
| 32 | - 'labels' => [ |
|
| 33 | - 'll_ref' => 'LLL:EXT:vidi/Resources/Private/Language/content_module.xlf', |
|
| 34 | - ], |
|
| 35 | - ] |
|
| 36 | - ); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
| 40 | - \TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class |
|
| 41 | - )->get('vidi'); |
|
| 42 | - |
|
| 43 | - $pids = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $configuration['default_pid'], true); |
|
| 44 | - $defaultPid = array_shift($pids); |
|
| 45 | - $defaultPids = []; |
|
| 46 | - foreach ($pids as $dataTypeAndPid) { |
|
| 47 | - $parts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(':', $dataTypeAndPid); |
|
| 48 | - if (count($parts) === 2) { |
|
| 49 | - $defaultPids[$parts[0]] = $parts[1]; |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - // Loop around the data types and register them to be displayed within a BE module. |
|
| 54 | - if ($configuration['data_types']) { |
|
| 55 | - |
|
| 56 | - $dataTypes = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $configuration['data_types'], true); |
|
| 57 | - foreach ($dataTypes as $dataType) { |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - /** @var \Fab\Vidi\Module\ModuleLoader $moduleLoader */ |
|
| 61 | - $moduleLoader = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleLoader::class, $dataType); |
|
| 62 | - |
|
| 63 | - // Special case already defined in Vidi. |
|
| 64 | - if ($dataType === 'fe_users') { |
|
| 65 | - $languageFile = 'LLL:EXT:vidi/Resources/Private/Language/fe_users.xlf'; |
|
| 66 | - $icon = 'EXT:vidi/Resources/Public/Images/fe_users.svg'; |
|
| 67 | - } elseif ($dataType === 'fe_groups') { |
|
| 68 | - $languageFile = 'LLL:EXT:vidi/Resources/Private/Language/fe_groups.xlf'; |
|
| 69 | - $icon = 'EXT:vidi/Resources/Public/Images/fe_groups.svg'; |
|
| 70 | - } else { |
|
| 71 | - /** @var \Fab\Vidi\Backend\LanguageFileGenerator $languageService */ |
|
| 72 | - $languageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Fab\Vidi\Backend\LanguageFileGenerator::class); |
|
| 73 | - $languageFile = $languageService->generate($dataType); |
|
| 74 | - $icon = ''; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - $pid = $defaultPids[$dataType] ?? $defaultPid; |
|
| 78 | - |
|
| 79 | - /** @var \Fab\Vidi\Module\ModuleLoader $moduleLoader */ |
|
| 80 | - $moduleLoader->setIcon($icon) |
|
| 81 | - ->setModuleLanguageFile($languageFile) |
|
| 82 | - ->setDefaultPid($pid) |
|
| 83 | - ->register(); |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // Possible Static TS loading |
|
| 88 | - if (true === isset($configuration['autoload_typoscript']) && false === (bool)$configuration['autoload_typoscript']) { |
|
| 89 | - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile('vidi', 'Configuration/TypoScript', 'Vidi: versatile and interactive display'); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // Register List2 only if beta feature is enabled. |
|
| 93 | - // @todo let see what we do with that |
|
| 94 | - #if ($configuration['activate_beta_features']) { |
|
| 95 | - # $labelFile = 'LLL:EXT:vidi/Resources/Private/Language/locallang_module.xlf'; |
|
| 96 | - # |
|
| 97 | - # if (!$configuration['hide_module_list']) { |
|
| 98 | - # $labelFile = 'LLL:EXT:vidi/Resources/Private/Language/locallang_module_transitional.xlf'; |
|
| 99 | - # } |
|
| 100 | - # |
|
| 101 | - # \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( |
|
| 102 | - # 'vidi', |
|
| 103 | - # 'web', // Make module a submodule of 'web' |
|
| 104 | - # 'm1', // Submodule key |
|
| 105 | - # 'after:list', // Position |
|
| 106 | - # array( |
|
| 107 | - # 'Content' => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard', |
|
| 108 | - # 'Tool' => 'welcome, work', |
|
| 109 | - # 'Facet' => 'autoSuggest, autoSuggests', |
|
| 110 | - # 'Selection' => 'edit, update, create, delete, list, show', |
|
| 111 | - # 'UserPreferences' => 'save', |
|
| 112 | - # 'Clipboard' => 'save, flush, show', |
|
| 113 | - # ), array( |
|
| 114 | - # 'access' => 'user,group', |
|
| 115 | - # 'icon' => 'EXT:vidi/Resources/Public/Images/list.png', |
|
| 116 | - # 'labels' => $labelFile, |
|
| 117 | - # ) |
|
| 118 | - # ); |
|
| 119 | - #} |
|
| 120 | - #if ($configuration['hide_module_list']) { |
|
| 121 | - # |
|
| 122 | - # // Default User TSConfig to be added in any case. |
|
| 123 | - # TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(' |
|
| 124 | - # |
|
| 125 | - # # Hide the module in the BE. |
|
| 126 | - # options.hideModules.web := addToList(list) |
|
| 127 | - # '); |
|
| 128 | - #} |
|
| 129 | - |
|
| 130 | - /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */ |
|
| 131 | - $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); |
|
| 132 | - |
|
| 133 | - /** @var $signalSlotDispatcher \TYPO3\CMS\Extbase\SignalSlot\Dispatcher */ |
|
| 134 | - $signalSlotDispatcher = $objectManager->get('TYPO3\CMS\Extbase\SignalSlot\Dispatcher'); |
|
| 135 | - |
|
| 136 | - // Connect "processContentData" signal slot with the "ContentObjectProcessor". |
|
| 137 | - $signalSlotDispatcher->connect( |
|
| 138 | - 'Fab\Vidi\Controller\Backend\ContentController', |
|
| 139 | - 'processContentData', |
|
| 140 | - 'Fab\Vidi\Processor\ContentObjectProcessor', |
|
| 141 | - 'processRelations', |
|
| 142 | - true |
|
| 143 | - ); |
|
| 144 | - |
|
| 145 | - // Connect "processContentData" signal with the "MarkerProcessor". |
|
| 146 | - $signalSlotDispatcher->connect( |
|
| 147 | - 'Fab\Vidi\Controller\Backend\ContentController', |
|
| 148 | - 'processContentData', |
|
| 149 | - 'Fab\Vidi\Processor\MarkerProcessor', |
|
| 150 | - 'processMarkers', |
|
| 151 | - true |
|
| 152 | - ); |
|
| 153 | - |
|
| 154 | - // Register default Tools for Vidi. |
|
| 155 | - \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('*', 'Fab\Vidi\Tool\ModulePreferencesTool'); |
|
| 156 | - \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('*', 'Fab\Vidi\Tool\RelationAnalyserTool'); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - // Add new sprite icon. |
|
| 160 | - $icons = [ |
|
| 161 | - 'go' => 'EXT:vidi/Resources/Public/Images/bullet_go.png', |
|
| 162 | - 'query' => 'EXT:vidi/Resources/Public/Images/drive_disk.png', |
|
| 163 | - ]; |
|
| 164 | - /** @var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */ |
|
| 165 | - $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); |
|
| 166 | - foreach ($icons as $key => $icon) { |
|
| 167 | - $iconRegistry->registerIcon('extensions-vidi-' . $key, |
|
| 168 | - \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class, |
|
| 169 | - [ |
|
| 170 | - 'source' => $icon |
|
| 171 | - ] |
|
| 172 | - ); |
|
| 173 | - } |
|
| 174 | - unset($iconRegistry); |
|
| 6 | + // Check from Vidi configuration what default module should be loaded. |
|
| 7 | + // Make sure the class exists to avoid a Runtime Error |
|
| 8 | + if (TYPO3_MODE === 'BE') { |
|
| 9 | + |
|
| 10 | + // Add content main module before 'user' |
|
| 11 | + if (!isset($GLOBALS['TBE_MODULES']['content'])) { |
|
| 12 | + |
|
| 13 | + // Position module "content" after module "user" manually. No API is available for that, it seems... |
|
| 14 | + $modules = []; |
|
| 15 | + foreach ($GLOBALS['TBE_MODULES'] as $key => $val) { |
|
| 16 | + if ($key === 'user') { |
|
| 17 | + $modules['content'] = ''; |
|
| 18 | + } |
|
| 19 | + $modules[$key] = $val; |
|
| 20 | + } |
|
| 21 | + $GLOBALS['TBE_MODULES'] = $modules; |
|
| 22 | + |
|
| 23 | + // Register "data management" module. |
|
| 24 | + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule( |
|
| 25 | + 'content', |
|
| 26 | + '', |
|
| 27 | + '', |
|
| 28 | + '', |
|
| 29 | + [ |
|
| 30 | + 'name' => 'content', |
|
| 31 | + 'access' => 'user,group', |
|
| 32 | + 'labels' => [ |
|
| 33 | + 'll_ref' => 'LLL:EXT:vidi/Resources/Private/Language/content_module.xlf', |
|
| 34 | + ], |
|
| 35 | + ] |
|
| 36 | + ); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
| 40 | + \TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class |
|
| 41 | + )->get('vidi'); |
|
| 42 | + |
|
| 43 | + $pids = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $configuration['default_pid'], true); |
|
| 44 | + $defaultPid = array_shift($pids); |
|
| 45 | + $defaultPids = []; |
|
| 46 | + foreach ($pids as $dataTypeAndPid) { |
|
| 47 | + $parts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(':', $dataTypeAndPid); |
|
| 48 | + if (count($parts) === 2) { |
|
| 49 | + $defaultPids[$parts[0]] = $parts[1]; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + // Loop around the data types and register them to be displayed within a BE module. |
|
| 54 | + if ($configuration['data_types']) { |
|
| 55 | + |
|
| 56 | + $dataTypes = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $configuration['data_types'], true); |
|
| 57 | + foreach ($dataTypes as $dataType) { |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + /** @var \Fab\Vidi\Module\ModuleLoader $moduleLoader */ |
|
| 61 | + $moduleLoader = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleLoader::class, $dataType); |
|
| 62 | + |
|
| 63 | + // Special case already defined in Vidi. |
|
| 64 | + if ($dataType === 'fe_users') { |
|
| 65 | + $languageFile = 'LLL:EXT:vidi/Resources/Private/Language/fe_users.xlf'; |
|
| 66 | + $icon = 'EXT:vidi/Resources/Public/Images/fe_users.svg'; |
|
| 67 | + } elseif ($dataType === 'fe_groups') { |
|
| 68 | + $languageFile = 'LLL:EXT:vidi/Resources/Private/Language/fe_groups.xlf'; |
|
| 69 | + $icon = 'EXT:vidi/Resources/Public/Images/fe_groups.svg'; |
|
| 70 | + } else { |
|
| 71 | + /** @var \Fab\Vidi\Backend\LanguageFileGenerator $languageService */ |
|
| 72 | + $languageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Fab\Vidi\Backend\LanguageFileGenerator::class); |
|
| 73 | + $languageFile = $languageService->generate($dataType); |
|
| 74 | + $icon = ''; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + $pid = $defaultPids[$dataType] ?? $defaultPid; |
|
| 78 | + |
|
| 79 | + /** @var \Fab\Vidi\Module\ModuleLoader $moduleLoader */ |
|
| 80 | + $moduleLoader->setIcon($icon) |
|
| 81 | + ->setModuleLanguageFile($languageFile) |
|
| 82 | + ->setDefaultPid($pid) |
|
| 83 | + ->register(); |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // Possible Static TS loading |
|
| 88 | + if (true === isset($configuration['autoload_typoscript']) && false === (bool)$configuration['autoload_typoscript']) { |
|
| 89 | + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile('vidi', 'Configuration/TypoScript', 'Vidi: versatile and interactive display'); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // Register List2 only if beta feature is enabled. |
|
| 93 | + // @todo let see what we do with that |
|
| 94 | + #if ($configuration['activate_beta_features']) { |
|
| 95 | + # $labelFile = 'LLL:EXT:vidi/Resources/Private/Language/locallang_module.xlf'; |
|
| 96 | + # |
|
| 97 | + # if (!$configuration['hide_module_list']) { |
|
| 98 | + # $labelFile = 'LLL:EXT:vidi/Resources/Private/Language/locallang_module_transitional.xlf'; |
|
| 99 | + # } |
|
| 100 | + # |
|
| 101 | + # \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( |
|
| 102 | + # 'vidi', |
|
| 103 | + # 'web', // Make module a submodule of 'web' |
|
| 104 | + # 'm1', // Submodule key |
|
| 105 | + # 'after:list', // Position |
|
| 106 | + # array( |
|
| 107 | + # 'Content' => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard', |
|
| 108 | + # 'Tool' => 'welcome, work', |
|
| 109 | + # 'Facet' => 'autoSuggest, autoSuggests', |
|
| 110 | + # 'Selection' => 'edit, update, create, delete, list, show', |
|
| 111 | + # 'UserPreferences' => 'save', |
|
| 112 | + # 'Clipboard' => 'save, flush, show', |
|
| 113 | + # ), array( |
|
| 114 | + # 'access' => 'user,group', |
|
| 115 | + # 'icon' => 'EXT:vidi/Resources/Public/Images/list.png', |
|
| 116 | + # 'labels' => $labelFile, |
|
| 117 | + # ) |
|
| 118 | + # ); |
|
| 119 | + #} |
|
| 120 | + #if ($configuration['hide_module_list']) { |
|
| 121 | + # |
|
| 122 | + # // Default User TSConfig to be added in any case. |
|
| 123 | + # TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(' |
|
| 124 | + # |
|
| 125 | + # # Hide the module in the BE. |
|
| 126 | + # options.hideModules.web := addToList(list) |
|
| 127 | + # '); |
|
| 128 | + #} |
|
| 129 | + |
|
| 130 | + /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */ |
|
| 131 | + $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); |
|
| 132 | + |
|
| 133 | + /** @var $signalSlotDispatcher \TYPO3\CMS\Extbase\SignalSlot\Dispatcher */ |
|
| 134 | + $signalSlotDispatcher = $objectManager->get('TYPO3\CMS\Extbase\SignalSlot\Dispatcher'); |
|
| 135 | + |
|
| 136 | + // Connect "processContentData" signal slot with the "ContentObjectProcessor". |
|
| 137 | + $signalSlotDispatcher->connect( |
|
| 138 | + 'Fab\Vidi\Controller\Backend\ContentController', |
|
| 139 | + 'processContentData', |
|
| 140 | + 'Fab\Vidi\Processor\ContentObjectProcessor', |
|
| 141 | + 'processRelations', |
|
| 142 | + true |
|
| 143 | + ); |
|
| 144 | + |
|
| 145 | + // Connect "processContentData" signal with the "MarkerProcessor". |
|
| 146 | + $signalSlotDispatcher->connect( |
|
| 147 | + 'Fab\Vidi\Controller\Backend\ContentController', |
|
| 148 | + 'processContentData', |
|
| 149 | + 'Fab\Vidi\Processor\MarkerProcessor', |
|
| 150 | + 'processMarkers', |
|
| 151 | + true |
|
| 152 | + ); |
|
| 153 | + |
|
| 154 | + // Register default Tools for Vidi. |
|
| 155 | + \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('*', 'Fab\Vidi\Tool\ModulePreferencesTool'); |
|
| 156 | + \Fab\Vidi\Tool\ToolRegistry::getInstance()->register('*', 'Fab\Vidi\Tool\RelationAnalyserTool'); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + // Add new sprite icon. |
|
| 160 | + $icons = [ |
|
| 161 | + 'go' => 'EXT:vidi/Resources/Public/Images/bullet_go.png', |
|
| 162 | + 'query' => 'EXT:vidi/Resources/Public/Images/drive_disk.png', |
|
| 163 | + ]; |
|
| 164 | + /** @var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */ |
|
| 165 | + $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); |
|
| 166 | + foreach ($icons as $key => $icon) { |
|
| 167 | + $iconRegistry->registerIcon('extensions-vidi-' . $key, |
|
| 168 | + \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class, |
|
| 169 | + [ |
|
| 170 | + 'source' => $icon |
|
| 171 | + ] |
|
| 172 | + ); |
|
| 173 | + } |
|
| 174 | + unset($iconRegistry); |
|
| 175 | 175 | }); |