/** * Displays the page header * @param string The name of the page (will be showed in the page title) * @param string Optional help file name * @param string $page_header */ public static function display_header($tool_name = '', $help = null, $page_header = null) { $origin = api_get_origin(); $showHeader = true; if (isset($origin) && $origin == 'learnpath') { $showHeader = false; } self::$global_template = new Template($tool_name, $showHeader, $showHeader); // Fixing tools with any help it takes xxx part of main/xxx/index.php if (empty($help)) { $currentURL = api_get_self(); preg_match('/main\\/([^*\\/]+)/', $currentURL, $matches); $toolList = self::toolList(); if (!empty($matches)) { foreach ($matches as $match) { if (in_array($match, $toolList)) { $help = explode('_', $match); $help = array_map('ucfirst', $help); $help = implode('', $help); break; } } } } self::$global_template->set_help($help); if (!empty(self::$preview_style)) { self::$global_template->preview_theme = self::$preview_style; self::$global_template->set_css_files(); self::$global_template->set_js_files(); } if (!empty($page_header)) { self::$global_template->assign('header', $page_header); } echo self::$global_template->show_header_template(); }
/** * Return the link to the forum search page * * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version April 2008, dokeos 1.8.5 */ function search_link() { $return = ''; $origin = api_get_origin(); if ($origin != 'learnpath') { $return = '<a href="forumsearch.php?' . api_get_cidreq() . '&action=search"> '; $return .= Display::return_icon('search.png', get_lang('Search'), '', ICON_SIZE_MEDIUM) . '</a>'; if (!empty($_GET['search'])) { $return .= ': ' . Security::remove_XSS($_GET['search']) . ' '; $url = api_get_self() . '?'; $url_parameter = array(); foreach ($_GET as $key => $value) { if ($key != 'search') { $url_parameter[] = Security::remove_XSS($key) . '=' . Security::remove_XSS($value); } } $url = $url . implode('&', $url_parameter); $return .= '<a href="' . $url . '">' . Display::return_icon('delete.gif', get_lang('RemoveSearchResults')) . '</a>'; } } return $return; }
/** * Returns the cidreq parameter name + current course id taken from * $GLOBALS['_cid'] and returns a string like 'cidReq=ABC&id_session=123 * * @param bool $addSessionId * @param bool $addGroupId * @return string Course & session references to add to a URL * */ function api_get_cidreq($addSessionId = true, $addGroupId = true) { $courseCode = api_get_course_id(); $url = empty($courseCode) ? '' : 'cidReq=' . htmlspecialchars($courseCode); $origin = api_get_origin(); if ($addSessionId) { if (!empty($url)) { $url .= api_get_session_id() == 0 ? '&id_session=0' : '&id_session=' . api_get_session_id(); } } if ($addGroupId) { if (!empty($url)) { $url .= api_get_group_id() == 0 ? '&gidReq=0' : '&gidReq=' . api_get_group_id(); } } $url .= '&gradebook=' . intval(api_is_in_gradebook()); $url .= '&origin=' . $origin; return $url; }
/** * Returns the cidreq parameter name + current course id taken from * $GLOBALS['_cid'] and returns a string like 'cidReq=ABC&id_session=123 * * @param bool $addSessionId * @param bool $addGroupId * @return string Course & session references to add to a URL * */ function api_get_cidreq($addSessionId = true, $addGroupId = true) { $url = empty($GLOBALS['_cid']) ? '' : 'cidReq=' . htmlspecialchars($GLOBALS['_cid']); $origin = api_get_origin(); if ($addSessionId) { if (!empty($url)) { $url .= api_get_session_id() == 0 ? '&id_session=0' : '&id_session=' . api_get_session_id(); } } if ($addGroupId) { if (!empty($url)) { $url .= api_get_group_id() == 0 ? '&gidReq=0' : '&gidReq=' . api_get_group_id(); } } $url .= '&origin=' . $origin; return $url; }
/** * @param string $title * @param bool $show_header * @param bool $show_footer * @param bool $show_learnpath * @param bool $hide_global_chat * @param bool $load_plugins * @param bool $sendHeaders send http headers or not */ public function __construct($title = '', $show_header = true, $show_footer = true, $show_learnpath = false, $hide_global_chat = false, $load_plugins = true, $sendHeaders = true) { // Page title $this->title = $title; $this->show_learnpath = $show_learnpath; if (empty($this->show_learnpath)) { $origin = api_get_origin(); if ($origin == 'learnpath') { $this->show_learnpath = true; $show_footer = false; $show_header = false; } } $this->hide_global_chat = $hide_global_chat; $this->load_plugins = $load_plugins; $template_paths = array(api_get_path(SYS_CODE_PATH) . 'template/overrides', api_get_path(SYS_CODE_PATH) . 'template', api_get_path(SYS_PLUGIN_PATH)); $cache_folder = api_get_path(SYS_ARCHIVE_PATH) . 'twig'; $loader = new Twig_Loader_Filesystem($template_paths); //Setting Twig options depending on the server see http://twig.sensiolabs.org/doc/api.html#environment-options if (api_get_setting('server_type') == 'test') { $options = array('autoescape' => false, 'debug' => true, 'auto_reload' => true, 'optimizations' => 0, 'strict_variables' => false); } else { $options = array('cache' => $cache_folder, 'autoescape' => false, 'debug' => false, 'auto_reload' => false, 'optimizations' => -1, 'strict_variables' => false); } $this->twig = new Twig_Environment($loader, $options); $this->twig->addFilter('get_plugin_lang', new Twig_Filter_Function('get_plugin_lang')); $this->twig->addFilter('get_lang', new Twig_Filter_Function('get_lang')); $this->twig->addFilter('get_path', new Twig_Filter_Function('api_get_path')); $this->twig->addFilter('get_setting', new Twig_Filter_Function('api_get_setting')); $this->twig->addFilter('var_dump', new Twig_Filter_Function('var_dump')); $this->twig->addFilter('return_message', new Twig_Filter_Function('Display::return_message_and_translate')); $this->twig->addFilter('display_page_header', new Twig_Filter_Function('Display::page_header_and_translate')); $this->twig->addFilter('display_page_subheader', new Twig_Filter_Function('Display::page_subheader_and_translate')); $this->twig->addFilter('icon', new Twig_Filter_Function('Template::get_icon_path')); $this->twig->addFilter('img', new Twig_Filter_Function('Template::get_image')); $this->twig->addFilter('format_date', new Twig_Filter_Function('Template::format_date')); $this->twig->addFilter('api_get_local_time', new Twig_Filter_Function('api_get_local_time')); /* $lexer = new Twig_Lexer($this->twig, array( //'tag_comment' => array('{*', '*}'), //'tag_comment' => array('{#', '#}'), //'tag_block' => array('{', '}'), //'tag_variable' => array('{$', '}'), )); $this->twig->setLexer($lexer); */ //Setting system variables $this->set_system_parameters(); //Setting user variables $this->set_user_parameters(); //Setting course variables $this->set_course_parameters(); //Setting administrator variables $this->setAdministratorParams(); $this->setCSSEditor(); //header and footer are showed by default $this->set_footer($show_footer); $this->set_header($show_header); $this->set_header_parameters($sendHeaders); $this->set_footer_parameters(); $defaultStyle = api_get_configuration_value('default_template'); if (!empty($defaultStyle)) { $this->templateFolder = $defaultStyle; } $this->assign('template', $this->templateFolder); $this->assign('locale', api_get_language_isocode()); $this->assign('css_styles', $this->theme); $this->assign('login_class', null); $this->setLoginForm(); // Chamilo plugins if ($this->show_header) { if ($this->load_plugins) { $this->plugin = new AppPlugin(); //1. Showing installed plugins in regions $plugin_regions = $this->plugin->get_plugin_regions(); foreach ($plugin_regions as $region) { $this->set_plugin_region($region); } //2. Loading the course plugin info global $course_plugin; if (isset($course_plugin) && !empty($course_plugin) && !empty($this->course_id)) { //Load plugin get_langs $this->plugin->load_plugin_lang_variables($course_plugin); } } } }