/** * Adds a module (main or sub) to the backend interface * FOR USE IN ext_tables.php FILES * * @param string $main The main module key, $sub is the submodule key. So $main would be an index in the $TBE_MODULES array and $sub could be an element in the lists there. * @param string $sub The submodule key. If $sub is not set a blank $main module is created. * @param string $position Can be used to set the position of the $sub module within the list of existing submodules for the main module. $position has this syntax: [cmd]:[submodule-key]. cmd can be "after", "before" or "top" (or blank which is default). If "after"/"before" then submodule will be inserted after/before the existing submodule with [submodule-key] if found. If not found, the bottom of list. If "top" the module is inserted in the top of the submodule list. * @param string $path The absolute path to the module. If this value is defined the path is added as an entry in $TBE_MODULES['_PATHS'][ main_sub ] = $path; and thereby tells the backend where the newly added modules is found in the system. * @param array $moduleConfiguration additional configuration, previously put in "conf.php" of the module directory * @return void */ public static function addModule($main, $sub = '', $position = '', $path = '', $moduleConfiguration = array()) { // If there is already a main module by this name: // Adding the submodule to the correct position: if (isset($GLOBALS['TBE_MODULES'][$main]) && $sub) { list($place, $modRef) = GeneralUtility::trimExplode(':', $position, TRUE); $modules = ',' . $GLOBALS['TBE_MODULES'][$main] . ','; if ($place === NULL || $modRef !== NULL && !GeneralUtility::inList($modules, $modRef)) { $place = 'bottom'; } $modRef = ',' . $modRef . ','; if (!GeneralUtility::inList($modules, $sub)) { switch (strtolower($place)) { case 'after': $modules = str_replace($modRef, $modRef . $sub . ',', $modules); break; case 'before': $modules = str_replace($modRef, ',' . $sub . $modRef, $modules); break; case 'top': $modules = $sub . $modules; break; case 'bottom': default: $modules = $modules . $sub; } } // Re-inserting the submodule list: $GLOBALS['TBE_MODULES'][$main] = trim($modules, ','); } else { // Create new main modules with only one submodule, $sub (or none if $sub is blank) $GLOBALS['TBE_MODULES'][$main] = $sub; } $fullModuleSignature = $main . ($sub ? '_' . $sub : ''); // Adding path: if ($path) { if (substr($path, 0, 4) === 'EXT:') { list($extensionKey, $relativePath) = explode('/', substr($path, 4), 2); $path = self::extPath($extensionKey) . $relativePath; } $GLOBALS['TBE_MODULES']['_PATHS'][$fullModuleSignature] = $path; } // add additional configuration if (is_array($moduleConfiguration) && count($moduleConfiguration) > 0) { $GLOBALS['TBE_MODULES']['_configuration'][$fullModuleSignature] = $moduleConfiguration; } }