예제 #1
0
 /** 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);
         }
     }
 }
예제 #2
0
function exponent_theme_showModule($module, $view = "Default", $title = "", $source = null, $pickable = false, $section = null)
{
    if (!AUTHORIZED_SECTION && $module != 'navigationmodule' && $module != 'loginmodule') {
        return;
    }
    global $db;
    // Ensure that we have a section
    if ($section == null) {
        $section_id = exponent_sessions_get('last_section');
        if ($section_id == null) {
            $section_id = SITE_DEFAULT_SECTION;
        }
        $section = $db->selectObject('section', 'id=' . $section_id);
    }
    if ($module == "loginmodule" && defined("PREVIEW_READONLY") && PREVIEW_READONLY == 1) {
        return;
    }
    if (exponent_sessions_isset("themeopt_override")) {
        $config = exponent_sessions_get("themeopt_override");
        if (in_array($module, $config['ignore_mods'])) {
            return;
        }
    }
    $loc = exponent_core_makeLocation($module, $source . "");
    if ($db->selectObject("locationref", "module='{$module}' AND source='" . $loc->src . "'") == null) {
        $locref = null;
        $locref->module = $module;
        $locref->source = $loc->src;
        $locref->internal = "";
        $locref->refcount = 1000;
        $db->insertObject($locref, "locationref");
        if ($section != null) {
            $locref->section = $section->id;
            $locref->is_original = 1;
            $db->insertObject($locref, 'sectionref');
        }
    }
    if (defined("SELECTOR") && call_user_func(array($module, "hasSources"))) {
        containermodule::wrapOutput($module, $view, $loc, $title);
    } else {
        if (is_callable(array($module, "show"))) {
            call_user_func(array($module, "show"), $view, $loc, $title);
        } else {
            $i18n = exponent_lang_loadFile('subsystems/theme.php');
            echo sprintf($i18n['mod_not_found'], $module);
        }
    }
}