/** * This function will run the specified module and action in the indicated scope. * * @attention * This function should only be called after the loadAllModules function has been executed. If not, this * function will fail as the include files are not loaded yet. * * @param $module The name of the module to run. * @param $action The name of the action to run. */ function runModule($module, $action) { // Convert everything to lowercase $scope = YDSimpleCMS::getScope(); $module = strtolower($module); $action = strtolower($action); // Get the classname for the module $moduleClassName = YD_SIMPLECMS_MODULE_PREFIX . $module; // Check if the class exists if (!class_exists($moduleClassName)) { YDSimpleCMS::showError('Module class not found: %s', $moduleClassName); } // Create the class instance $moduleInstance = new $moduleClassName(); // Set the correct template scope $moduleInstance->tpl->scope = $scope; // Sort the admin menu items if ($scope == YD_SIMPLECMS_SCOPE_ADMIN) { $adminMenu =& YDSimpleCMS::getAdminMenu(); $moduleInstance->tpl->assign('adminMenu', $adminMenu); } // Create a link to ourselves $moduleInstance->manager =& $this; // Run the action $moduleInstance->runAction($action); }