/** exdoc * Calls the necessary methods to show a specific module * * @param string $module The classname of the module to display * @param string $view The name of the view to display the module with * @param string $title The title of the module (support is view-dependent) * @param string $source The source of the module. * @param bool $pickable Whether or not the module is pickable in the Source Picker. * @param null $section * @param bool $hide_menu * @param array $params * @return * @node Subsystems:Theme */ public static function showModule($module, $view = "Default", $title = "", $source = null, $pickable = false, $section = null, $hide_menu = false, $params = array()) { if (!AUTHORIZED_SECTION && $module != 'navigationmodule' && $module != 'loginController') { return; } global $db, $sectionObj, $module_scope; // Ensure that we have a section //FJD - changed to $sectionObj if ($sectionObj == null) { $section_id = expSession::get('last_section'); if ($section_id == null) { $section_id = SITE_DEFAULT_SECTION; } $sectionObj = $db->selectObject('section', 'id=' . $section_id); //$section->id = $section_id; } if ($module == "loginController" && defined('PREVIEW_READONLY') && PREVIEW_READONLY == 1) { return; } // if (expSession::is_set("themeopt_override")) { // $config = expSession::get("themeopt_override"); // if (in_array($module,$config['ignore_mods'])) return; // } $loc = expCore::makeLocation($module, $source . ""); if (empty($module_scope[$source][$module]->scope)) { $module_scope[$source][$module]->scope = 'global'; } // make sure we've added this module to the sectionref table if ($db->selectObject("sectionref", "module='{$module}' AND source='" . $loc->src . "'") == null) { $secref = null; $secref->module = $module; $secref->source = $loc->src; $secref->internal = ""; $secref->refcount = 1000; if ($sectionObj != null) { $secref->section = $sectionObj->id; } $secref->is_original = 1; $db->insertObject($secref, 'sectionref'); } $iscontroller = expModules::controllerExists($module); if (defined('SELECTOR') && call_user_func(array($module, "hasSources"))) { containermodule::wrapOutput($module, $view, $loc, $title); } else { if (is_callable(array($module, "show")) || $iscontroller) { // FIXME: we are checking here for a new MVC style controller or an old school module. We only need to perform // this check until we get the old modules all gone...until then we have the check and a lot of code duplication // in the if blocks below...oh well, that's life. if (!$iscontroller) { if (!$hide_menu && $loc->mod != "containermodule" && (call_user_func(array($module, "hasSources")) || $db->tableExists($loc->mod . "_config"))) { $container->permissions = array('administrate' => expPermissions::check('administrate', $loc) ? 1 : 0, 'configure' => expPermissions::check('configure', $loc) ? 1 : 0); if ($container->permissions['administrate'] || $container->permissions['configure']) { $container->randomizer = mt_rand(1, ceil(microtime(1))); $container->view = $view; $container->info['class'] = $loc->mod; $container->info['module'] = call_user_func(array($module, "name")); $container->info['source'] = $loc->src; $container->info['hasConfig'] = $db->tableExists($loc->mod . "_config"); $template = new template('containermodule', '_hardcoded_module_menu', $loc); $template->assign('container', $container); $template->output(); } } } else { // if we hit here we're dealing with a controller...not a module if (!$hide_menu) { $controller = expModules::getController($module); $container->permissions = array('administrate' => expPermissions::check('administrate', $loc) ? 1 : 0, 'configure' => expPermissions::check('configure', $loc) ? 1 : 0); if ($container->permissions['administrate'] || $container->permissions['configure']) { $container->randomizer = mt_rand(1, ceil(microtime(1))); $container->view = $view; $container->action = $params['action']; $container->info['class'] = $loc->mod; $container->info['module'] = $controller->displayname(); $container->info['source'] = $loc->src; $container->info['hasConfig'] = true; $template = new template('containermodule', '_hardcoded_module_menu', $loc); $template->assign('container', $container); $template->output(); } } } if ($iscontroller) { $params['src'] = $loc->src; $params['controller'] = $module; $params['view'] = $view; $params['moduletitle'] = $title; if (empty($params['action'])) { $params['action'] = $view; } renderAction($params); } else { call_user_func(array($module, "show"), $view, $loc, $title); } } else { echo sprintf(gt('The module "%s" was not found in the system.'), $module); } } }
public function isMappedURL() { // figure out if this action is mapped via the mapping file (router_maps.php) $part_count = count($this->url_parts); foreach ($this->maps as $map) { $matched = true; $pairs = array(); $i = 0; if ($part_count == count($map['url_parts'])) { foreach ($map['url_parts'] as $key => $map_part) { $res = preg_match("/^{$map_part}/", $this->url_parts[$i]); if ($res != 1) { $matched = false; break; } $pairs[$key] = $this->url_parts[$i]; $i++; } } else { $matched = false; } if ($matched) { // safeguard against false matches when a real action was what the user really wanted. if (method_exists(expModules::getController($this->url_parts[0]), $this->url_parts[1])) { return false; } $this->url_parts = array(); $this->url_parts[0] = $map['controller']; $this->url_parts[1] = $map['action']; if (isset($map['view'])) { $this->url_parts[2] = 'view'; $this->url_parts[3] = $map['view']; } foreach ($map as $key => $value) { if ($key != 'controller' && $key != 'action' && $key != 'view' && $key != 'url_parts') { $this->url_parts[] = $key; $this->url_parts[] = $value; } } foreach ($pairs as $key => $value) { if ($key != 'controller') { $this->url_parts[] = $key; $this->url_parts[] = $value; } } $this->params = $this->convertPartsToParams(); return true; } } return false; }