Index: Classes/Utility/Extension.php =================================================================== --- Classes/Utility/Extension.php (revision 1493) +++ Classes/Utility/Extension.php (working copy) @@ -315,6 +315,63 @@ t3lib_extMgm::addModule($main, $sub, $position); } + + /** + * Registers a "Function menu module" ('third level module') to an existing function menu for some other backend module + * The arguments values are generally determined by which function menu this is supposed to interact with. + * FOR USE IN ext_tables.php FILES + * + * @param string $extensionName The extension name (in UpperCamelCase) or the extension key (in lower_underscore) + * @param string $moduleName The module name + * @param array $controllerActions is an array of allowed combinations of controller and action stored in an array (controller name as key and a comma separated list of action names as value, the first controller and its first action is chosen as default) + * @param array $config The configuration options of the module (icon, locallang.xml file) + * @return void + */ + public static function registerModuleFunction($extensionName, $moduleName, array $controllerActions, $config = array()) { + if (empty($extensionName)) { + throw new InvalidArgumentException('The extension name was invalid (must not be empty and must match /[A-Za-z][_A-Za-z0-9]/)', 1239891989); + } + $extensionKey = $extensionName; // FIXME This will break if the $extensionName is given as BlogExample + $extensionName = str_replace(' ', '', ucwords(str_replace('_', ' ', $extensionName))); + + $path = t3lib_extMgm::extPath($extensionKey, 'Classes/Controller/'); + + if (!is_array($config) || count($config) == 0) { + $config['title'] = 'Unknown title'; + $config['workspaces'] = ''; + } + if (!isset($config['menuKey']) || empty($config['menuKey'])) { + $config['menuKey'] = 'function'; + } + + $controllers = array_keys($controllerActions); + $defaultController = $controllers[0] . 'Controller'; + $defaultControllerFullName = 'Tx_' . $extensionName . '_Controller_' . $defaultController; + + t3lib_extMgm::insertModuleFunction( + $moduleName, + $defaultControllerFullName, + $path . $defaultController . '.php', + $config['title'], + $config['menuKey'], + $config['workspaces'] + ); + + // Register additional Extbase information + //$moduleConfig = &$GLOBALS['TBE_MODULES_EXT'][$moduleName]['MOD_MENU'][$config['menuKey']][$defaultControllerFullName]; + //$moduleConfig['extensionKey'] = $extensionKey; + //$moduleConfig['extensionName'] = $extensionName; + //$moduleConfig['controllerActions'] = $controllerActions; + //$moduleConfig['config'] = $config; + $moduleConfig = array( + 'name' => $moduleName, + 'extensionKey' => $extensionKey, + 'extensionName' => $extensionName, + 'controllerActions' => $controllerActions, + 'config' => $config, + ); + $GLOBALS['TBE_MODULES'][$defaultControllerFullName] = $moduleConfig; + } // TODO PHPdoc public static function convertCamelCaseToLowerCaseUnderscored($string) { @@ -492,4 +549,4 @@ } } -?> +?> \ No newline at end of file