Ejemplo n.º 1
0
    /**
     * Set header parameters
     */
    private function set_header_parameters()
    {
        global $httpHeadXtra, $_course, $interbreadcrumb, $language_file, $noPHP_SELF, $_configuration, $this_section;
        $help = $this->help;
        $nameTools             = $this->title;
        $navigation            = return_navigation_array();
        $this->menu_navigation = $navigation['menu_navigation'];

        $this->assign('system_charset', api_get_system_encoding());

        if (isset($httpHeadXtra) && $httpHeadXtra) {
            foreach ($httpHeadXtra as & $thisHttpHead) {
                header($thisHttpHead);
            }
        }

        $this->assign('online_button', Display::return_icon('online.png'));
        $this->assign('offline_button',Display::return_icon('offline.png'));

        // Get language iso-code for this page - ignore errors
        $this->assign('document_language', api_get_language_isocode());

        $course_title = isset($_course['name']) ? $_course['name'] : null;

        $title_list = array();

        $title_list[] = api_get_setting('Institution');
        $title_list[] = api_get_setting('siteName');

        if (!empty($course_title)) {
            $title_list[] = $course_title;
        }
        if ($nameTools != '') {
            $title_list[] = $nameTools;
        }

        $title_string = '';
        for ($i = 0; $i < count($title_list); $i++) {
            $title_string .= $title_list[$i];
            if (isset($title_list[$i + 1])) {
                $item = trim($title_list[$i + 1]);
                if (!empty($item)) {
                    $title_string .= ' - ';
                }
            }
        }

        $this->assign('title_string', $title_string);

        //Setting the theme and CSS files
        $this->set_css_files();
        $this->set_js_files();
        //$this->set_js_files_post();

        $browser = api_browser_support('check_browser');
        if ($browser[0] == 'Internet Explorer' && $browser[1] >= '11') {
            $browser_head = '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />';
            $this->assign('browser_specific_head', $browser_head);
        }

        // Implementation of prefetch.
        // See http://cdn.chamilo.org/main/img/online.png for details
        $prefetch = '';
        if (!empty($_configuration['cdn_enable'])) {
            $prefetch .= '<meta http-equiv="x-dns-prefetch-control" content="on">';
            foreach ($_configuration['cdn'] as $host => $exts) {
                $prefetch .= '<link rel="dns-prefetch" href="'.$host.'">';
            }
        }

        $this->assign('prefetch', $prefetch);
        $this->assign('text_direction', api_get_text_direction());
        $this->assign('section_name', 'section-'.$this_section);

        $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />';

        if (isset($_configuration['multiple_access_urls']) && $_configuration['multiple_access_urls']) {
            $access_url_id = api_get_current_access_url_id();
            if ($access_url_id != -1) {
                $url_info  = api_get_access_url($access_url_id);
                $url       = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
                $clean_url = replace_dangerous_char($url);
                $clean_url = str_replace('/', '-', $clean_url);
                $clean_url .= '/';
                $homep           = api_get_path(REL_PATH).'home/'.$clean_url; //homep for Home Path
                $icon_real_homep = api_get_path(SYS_PATH).'home/'.$clean_url;

                //we create the new dir for the new sites
                if (is_file($icon_real_homep.'favicon.ico')) {
                    $favico = '<link rel="shortcut icon" href="'.$homep.'favicon.ico" type="image/x-icon" />';
                }
            }
        }

        $this->assign('favico', $favico);

        $this->set_help();

        //@todo move this in the template
        $bug_notification_link = '';
        if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) {
            $bug_notification_link = '<li class="report">
		        						<a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank">
		        						<img src="'.api_get_path(WEB_IMG_PATH).'bug.large.png" style="vertical-align: middle;" alt="'.get_lang('ReportABug').'" title="'.get_lang(
                    'ReportABug'
                ).'"/></a>
		    						  </li>';
        }

        $this->assign('bug_notification_link', $bug_notification_link);

        $notification = return_notification_menu();
        $this->assign('notification_menu', $notification);

        //Preparing values for the menu

        //Logout link
        if (isset($_configuration['hide_logout_button']) && $_configuration['hide_logout_button'] == 'true') {
            $this->assign('logout_link', null);
        } else {
            $this->assign('logout_link', api_get_path(WEB_PATH).'index.php?logout=logout&uid='.api_get_user_id());
        }

        //Profile link
        if (api_get_setting('allow_social_tool') == 'true') {
            $profile_url  = api_get_path(WEB_CODE_PATH).'social/home.php';
            $profile_link = Display::url(get_lang('Profile'), $profile_url);
        } else {
            $profile_url  = api_get_path(WEB_CODE_PATH).'auth/profile.php';
            $profile_link = Display::url(get_lang('Profile'), $profile_url);
        }
        $this->assign('profile_link', $profile_link);
        $this->assign('profile_url', $profile_url);

        //Message link
        $message_link = null;
        $message_url  = null;
        if (api_get_setting('allow_message_tool') == 'true') {
            $message_url  = api_get_path(WEB_CODE_PATH).'messages/inbox.php';
            $message_link = '<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">'.get_lang('Inbox').'</a>';
        }
        $this->assign('message_link', $message_link);
        $this->assign('message_url', $message_url);

        $institution = api_get_setting('Institution');
        $portal_name = empty($institution) ? api_get_setting('siteName') : $institution;

        $this->assign('portal_name', $portal_name);

        //Menu
        $menu = return_menu();
        $this->assign('menu', $menu);

        //Setting notifications


        $count_unread_message = 0;
        if (api_get_setting('allow_message_tool') == 'true') {
            // get count unread message and total invitations
            $count_unread_message = MessageManager::get_number_of_messages(true);
        }

        $total_invitations = 0;
        if (api_get_setting('allow_social_tool') == 'true') {
            $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(
                api_get_user_id()
            );
            $group_pending_invitations        = GroupPortalManager::get_groups_by_user(
                api_get_user_id(),
                GROUP_USER_PERMISSION_PENDING_INVITATION,
                false
            );
            $group_pending_invitations        = 0;
            if (!empty($group_pending_invitations)) {
                $group_pending_invitations = count($group_pending_invitations);
            }
            $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval(
                    $count_unread_message
                );
        }
        $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : null);

        $this->assign('user_notifications', $total_invitations);


        //Breadcrumb
        $breadcrumb = return_breadcrumb($interbreadcrumb, $language_file, $nameTools);
        $this->assign('breadcrumb', $breadcrumb);

        //Extra content
        $extra_header = null;
        if (!api_is_platform_admin()) {
            $extra_header = trim(api_get_setting('header_extra_content'));
        }
        $this->assign('header_extra_content', $extra_header);

        //if ($this->show_header == 1) {
            header('Content-Type: text/html; charset='.api_get_system_encoding());
            header(
                'X-Powered-By: '.$_configuration['software_name'].' '.substr($_configuration['system_version'], 0, 1)
            );
        //}
    }
Ejemplo n.º 2
0
    /**
     * Set header parameters
     * @param bool $sendHeaders send headers
     */
    private function set_header_parameters($sendHeaders)
    {
        global $httpHeadXtra, $interbreadcrumb, $language_file, $_configuration, $this_section;
        $_course = api_get_course_info();
        $help = $this->help;
        $nameTools = $this->title;
        $navigation = return_navigation_array();
        $this->menu_navigation = $navigation['menu_navigation'];
        $this->assign('system_charset', api_get_system_encoding());
        if (isset($httpHeadXtra) && $httpHeadXtra) {
            foreach ($httpHeadXtra as &$thisHttpHead) {
                header($thisHttpHead);
            }
        }
        $this->assign('online_button', Display::return_icon('statusonline.png', null, null, ICON_SIZE_ATOM));
        $this->assign('offline_button', Display::return_icon('statusoffline.png', null, null, ICON_SIZE_ATOM));
        // Get language iso-code for this page - ignore errors
        $this->assign('document_language', api_get_language_isocode());
        $course_title = isset($_course['name']) ? $_course['name'] : null;
        $title_list = array();
        $title_list[] = api_get_setting('platform.institution');
        $title_list[] = api_get_setting('platform.site_name');
        if (!empty($course_title)) {
            $title_list[] = $course_title;
        }
        if ($nameTools != '') {
            $title_list[] = $nameTools;
        }
        $title_string = '';
        for ($i = 0; $i < count($title_list); $i++) {
            $title_string .= $title_list[$i];
            if (isset($title_list[$i + 1])) {
                $item = trim($title_list[$i + 1]);
                if (!empty($item)) {
                    $title_string .= ' - ';
                }
            }
        }
        $this->assign('title_string', $title_string);
        //Setting the theme and CSS files
        $css = $this->setCssFiles();
        $this->set_js_files();
        $this->setCssCustomFiles($css);
        //$this->set_js_files_post();
        $browser = api_browser_support('check_browser');
        if ($browser[0] == 'Internet Explorer' && $browser[1] >= '11') {
            $browser_head = '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />';
            $this->assign('browser_specific_head', $browser_head);
        }
        // Implementation of prefetch.
        // See http://cdn.chamilo.org/main/img/online.png for details
        $prefetch = '';
        if (!empty($_configuration['cdn_enable'])) {
            $prefetch .= '<meta http-equiv="x-dns-prefetch-control" content="on">';
            foreach ($_configuration['cdn'] as $host => $exts) {
                $prefetch .= '<link rel="dns-prefetch" href="' . $host . '">';
            }
        }
        $this->assign('prefetch', $prefetch);
        $this->assign('text_direction', api_get_text_direction());
        $this->assign('section_name', 'section-' . $this_section);
        //Defaul root chamilo favicon
        $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_PATH) . 'favicon.ico" type="image/x-icon" />';
        //Added to verify if in the current Chamilo Theme exist a favicon
        $favicoThemeUrl = api_get_path(SYS_CSS_PATH) . 'themes/' . $this->theme . '/images/';
        //If exist pick the current chamilo theme favicon
        if (is_file($favicoThemeUrl . 'favicon.ico')) {
            $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_CSS_PATH) . 'themes/' . $this->theme . '/images/favicon.ico" type="image/x-icon" />';
        }
        if (api_is_multiple_url_enabled()) {
            $access_url_id = api_get_current_access_url_id();
            if ($access_url_id != -1) {
                $url_info = api_get_access_url($access_url_id);
                $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url']));
                $clean_url = api_replace_dangerous_char($url);
                $clean_url = str_replace('/', '-', $clean_url);
                $clean_url .= '/';
                $homep = api_get_path(REL_PATH) . 'home/' . $clean_url;
                //homep for Home Path
                $icon_real_homep = api_get_path(SYS_APP_PATH) . 'home/' . $clean_url;
                //we create the new dir for the new sites
                if (is_file($icon_real_homep . 'favicon.ico')) {
                    $favico = '<link rel="shortcut icon" href="' . $homep . 'favicon.ico" type="image/x-icon" />';
                }
            }
        }
        $this->assign('favico', $favico);
        $this->setHelp();
        //@todo move this in the template
        $bug_notification_link = '';
        if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) {
            $bug_notification_link = '<li class="report">
		        						<a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank">
		        						<img src="' . api_get_path(WEB_IMG_PATH) . 'bug.large.png" style="vertical-align: middle;" alt="' . get_lang('ReportABug') . '" title="' . get_lang('ReportABug') . '"/></a>
		    						  </li>';
        }
        $this->assign('bug_notification_link', $bug_notification_link);
        $notification = return_notification_menu();
        $this->assign('notification_menu', $notification);
        $resize = '';
        if (api_get_setting('accessibility_font_resize') == 'true') {
            $resize .= '<div class="resize_font">';
            $resize .= '<div class="btn-group">';
            $resize .= '<a title="' . get_lang('DecreaseFontSize') . '" href="#" class="decrease_font btn btn-default"><em class="fa fa-font"></em></a>';
            $resize .= '<a title="' . get_lang('ResetFontSize') . '" href="#" class="reset_font btn btn-default"><em class="fa fa-font"></em></a>';
            $resize .= '<a title="' . get_lang('IncreaseFontSize') . '" href="#" class="increase_font btn btn-default"><em class="fa fa-font"></em></a>';
            $resize .= '</div>';
            $resize .= '</div>';
        }
        $this->assign('accessibility', $resize);
        // Preparing values for the menu
        // Logout link
        $hideLogout = api_get_setting('hide_logout_button');
        if ($hideLogout === 'true') {
            $this->assign('logout_link', null);
        } else {
            $this->assign('logout_link', api_get_path(WEB_PATH) . 'index.php?logout=logout&uid=' . api_get_user_id());
        }
        //Profile link
        if (api_get_setting('social.allow_social_tool') == 'true') {
            $profile_url = api_get_path(WEB_CODE_PATH) . 'social/home.php';
            $profile_link = Display::url(get_lang('Profile'), $profile_url);
        } else {
            $profile_url = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
            $profile_link = Display::url(get_lang('Profile'), $profile_url);
        }
        $this->assign('profile_link', $profile_link);
        $this->assign('profile_url', $profile_url);
        //Message link
        $message_link = null;
        $message_url = null;
        if (api_get_setting('message.allow_message_tool') == 'true') {
            $message_url = api_get_path(WEB_CODE_PATH) . 'messages/inbox.php';
            $message_link = '<a href="' . api_get_path(WEB_CODE_PATH) . 'messages/inbox.php">' . get_lang('Inbox') . '</a>';
        }
        $this->assign('message_link', $message_link);
        $this->assign('message_url', $message_url);
        $institution = api_get_setting('platform.institution');
        $portal_name = empty($institution) ? api_get_setting('platform.site_name') : $institution;
        $this->assign('portal_name', $portal_name);
        //Menu
        $menu = return_menu();
        $this->assign('menu', $menu);
        // Setting notifications
        $count_unread_message = 0;
        if (api_get_setting('message.allow_message_tool') == 'true') {
            // get count unread message and total invitations
            $count_unread_message = MessageManager::get_number_of_messages(true);
        }
        $total_invitations = 0;
        if (api_get_setting('social.allow_social_tool') == 'true') {
            $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
            $usergroup = new UserGroup();
            $group_pending_invitations = $usergroup->get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false);
            if (!empty($group_pending_invitations)) {
                $group_pending_invitations = count($group_pending_invitations);
            } else {
                $group_pending_invitations = 0;
            }
            $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval($count_unread_message);
        }
        $total_invitations = !empty($total_invitations) ? Display::badge($total_invitations) : null;
        $this->assign('user_notifications', $total_invitations);
        // Block Breadcrumb
        $breadcrumb = return_breadcrumb($interbreadcrumb, $language_file, $nameTools);
        $this->assign('breadcrumb', $breadcrumb);
        //Extra content
        $extra_header = null;
        if (!api_is_platform_admin()) {
            $extra_header = trim(api_get_setting('header_extra_content'));
        }
        $this->assign('header_extra_content', $extra_header);
        if ($sendHeaders) {
            header('Content-Type: text/html; charset=' . api_get_system_encoding());
            header('X-Powered-By: ' . $_configuration['software_name'] . ' ' . substr($_configuration['system_version'], 0, 1));
        }
        $socialMeta = '';
        $metaTitle = api_get_setting('meta_title');
        if (!empty($metaTitle)) {
            $socialMeta .= '<meta name="twitter:card" content="summary" />' . "\n";
            $socialMeta .= '<meta property="og:title" content="' . $metaTitle . '" />' . "\n";
            $socialMeta .= '<meta property="og:url" content="' . api_get_path(WEB_PATH) . '" />' . "\n";
            $metaDescription = api_get_setting('meta_description');
            if (!empty($metaDescription)) {
                $socialMeta .= '<meta property="og:description" content="' . $metaDescription . '" />' . "\n";
            }
            $metaSite = api_get_setting('meta_twitter_site');
            if (!empty($metaSite)) {
                $socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n";
                $metaCreator = api_get_setting('meta_twitter_creator');
                if (!empty($metaCreator)) {
                    $socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\n";
                }
            }
            $metaImage = api_get_setting('meta_image_path');
            if (!empty($metaImage)) {
                if (is_file(api_get_path(SYS_PATH) . $metaImage)) {
                    $path = api_get_path(WEB_PATH) . $metaImage;
                    $socialMeta .= '<meta property="og:image" content="' . $path . '" />' . "\n";
                }
            }
        }
        $this->assign('social_meta', $socialMeta);
    }