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