Пример #1
0
 public static function embedPdfJs($file, $options)
 {
     $height = (int) $options['height'];
     $pdfJsViewer = web_path_to('pdf-embed-js/web/viewer.html');
     $hash = ($lang = get_html_lang()) == 'en-US' ? '' : '#locale=' . rawurlencode($lang);
     $attrs['src'] = $pdfJsViewer . '?file=' . rawurlencode($file->getWebPath('original')) . $hash;
     $attrs['style'] = "width: 100%; height: {$height}px";
     $attrString = tag_attributes($attrs);
     return "<iframe {$attrString}></iframe>";
 }
Пример #2
0
<!DOCTYPE html>
<html lang="<?php 
echo get_html_lang();
?>
">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php 
if ($description = option('description')) {
    ?>
        <meta name="description" content="<?php 
    echo $description;
    ?>
" />
    <?php 
}
?>

    <!-- Will build the page <title> -->
    <?php 
if (isset($title)) {
    $titleParts[] = strip_formatting($title);
}
$titleParts[] = option('site_title');
?>
    <title><?php 
echo implode(' &middot; ', $titleParts);
?>
</title>
Пример #3
0
    /**
     * Output basic html page.
     * @static
     * @param string $title page title
     * @param string $content page content
     * @param string $meta meta tag
     * @return string html page
     */
    protected static function plain_page($title, $content, $meta = '')
    {
        if (function_exists('get_string') && function_exists('get_html_lang')) {
            $htmllang = get_html_lang();
        } else {
            $htmllang = '';
        }
        return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" ' . $htmllang . '>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
' . $meta . '
<title>' . $title . '</title>
</head><body>' . $content . '</body></html>';
    }
Пример #4
0
    /**
     * Output basic html page.
     * @static
     * @param string $title page title
     * @param string $content page content
     * @param string $meta meta tag
     * @return string html page
     */
    public static function plain_page($title, $content, $meta = '')
    {
        if (function_exists('get_string') && function_exists('get_html_lang')) {
            $htmllang = get_html_lang();
        } else {
            $htmllang = '';
        }
        $footer = '';
        if (MDL_PERF_TEST) {
            $perfinfo = get_performance_info();
            $footer = '<footer>' . $perfinfo['html'] . '</footer>';
        }
        return '<!DOCTYPE html>
<html ' . $htmllang . '>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
' . $meta . '
<title>' . $title . '</title>
</head><body>' . $content . $footer . '</body></html>';
    }
Пример #5
0
 /**
  * The attributes that should be added to the <html> tag. Designed to
  * be called in theme layout.php files.
  *
  * @return string HTML fragment.
  */
 public function htmlattributes() {
     $return = get_html_lang(true);
     if ($this->page->theme->doctype !== 'html5') {
         $return .= ' xmlns="http://www.w3.org/1999/xhtml"';
     }
     return $return;
 }
Пример #6
0
 /**
  * The attributes that should be added to the <html> tag. Designed to
  * be called in theme layout.php files.
  *
  * @return string HTML fragment.
  */
 public function htmlattributes()
 {
     return get_html_lang(true) . ' xmlns="http://www.w3.org/1999/xhtml"';
 }
Пример #7
0
function restore_open_html($restore, $course_header)
{
    global $CFG;
    $status = true;
    //Open file for writing
    //First, we check the course_id backup data folder exists and create it as necessary in CFG->dataroot
    if (!($dest_dir = make_upload_directory("{$restore->course_id}/backupdata"))) {
        // Backup folder
        error("Could not create backupdata folder.  The site administrator needs to fix the file permissions");
    }
    $status = check_dir_exists($dest_dir, true);
    $restorelog_file = fopen("{$dest_dir}/restorelog.html", "a");
    //Add the stylesheet
    $stylesheetshtml = '';
    foreach ($CFG->stylesheets as $stylesheet) {
        $stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="' . $stylesheet . '" />' . "\n";
    }
    ///Accessibility: added the 'lang' attribute to $direction, used in theme <html> tag.
    $languagehtml = get_html_lang($dir = true);
    //Write the header in the new logging file
    fwrite($restorelog_file, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"");
    fwrite($restorelog_file, " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">  ");
    fwrite($restorelog_file, "<html dir=\"ltr\".{$languagehtml}.");
    fwrite($restorelog_file, "<head>");
    fwrite($restorelog_file, $stylesheetshtml);
    fwrite($restorelog_file, "<title>" . $course_header->course_shortname . " Restored </title>");
    fwrite($restorelog_file, "</head><body><br/><h1>The following changes were made during the Restoration of this Course.</h1><br/><br/>");
    fwrite($restorelog_file, "The Course ShortName is now - " . $course_header->course_shortname . " The FullName is now - " . $course_header->course_fullname . "<br/><br/>");
    $startdate = addslashes($course_header->course_startdate);
    $date = usergetdate($startdate);
    fwrite($restorelog_file, "The Originating Courses Start Date was " . $date['weekday'] . ", " . $date['mday'] . " " . $date['month'] . " " . $date['year'] . "");
    $startdate += $restore->course_startdateoffset;
    $date = usergetdate($startdate);
    fwrite($restorelog_file, "&nbsp;&nbsp;&nbsp;This Courses Start Date is now  " . $date['weekday'] . ",  " . $date['mday'] . " " . $date['month'] . " " . $date['year'] . "<br/><br/>");
    if ($status) {
        return $restorelog_file;
    } else {
        return false;
    }
}
Пример #8
0
/**
 * Internal function - do not use directly!!
 * This function is used if fatal error occures before the themes are fully initialised (eg. in lib/setup.php)
 */
function _print_early_error($errorcode, $module, $a, $backtrace = null, $debuginfo = null)
{
    $message = get_string($errorcode, $module, $a);
    if ($module === 'error' and strpos($message, '[[') === 0) {
        //search in moodle file if error specified - needed for backwards compatibility
        $message = get_string($errorcode, 'moodle', $a);
    }
    $message = clean_text($message);
    // In the name of protocol correctness, monitoring and performance
    // profiling, set the appropriate error headers for machine comsumption
    if (isset($_SERVER['SERVER_PROTOCOL'])) {
        // Avoid it with cron.php. Note that we assume it's HTTP/1.x
        @header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
    }
    // better disable any caching
    @header('Content-Type: text/html; charset=utf-8');
    @header('Cache-Control: no-store, no-cache, must-revalidate');
    @header('Cache-Control: post-check=0, pre-check=0', false);
    @header('Pragma: no-cache');
    @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT');
    @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" ' . get_html_lang() . '>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>' . get_string('error') . '</title>
</head><body>
<div style="margin-top: 6em; margin-left:auto; margin-right:auto; color:#990000; text-align:center; font-size:large; border-width:1px;
    border-color:black; background-color:#ffffee; border-style:solid; border-radius: 20px; border-collapse: collapse;
    width: 80%; -moz-border-radius: 20px; padding: 15px">
' . $message . '
</div>';
    if (debugging('', DEBUG_DEVELOPER)) {
        if ($debuginfo) {
            debugging($debuginfo, DEBUG_DEVELOPER, $backtrace);
        } else {
            if ($backtrace) {
                notify('Stack trace:' . print_backtrace($backtrace, true), 'notifytiny');
            }
        }
    }
    echo '</body></html>';
    die;
}
Пример #9
0
/**
 * Print a standard header
 *
 * @uses $USER
 * @uses $CFG
 * @uses $SESSION
 * @param string  $title Appears at the top of the window
 * @param string  $heading Appears at the top of the page
 * @param array   $navigation Array of $navlinks arrays (keys: name, link, type) for use as breadcrumbs links
 * @param string  $focus Indicates form element to get cursor focus on load eg  inputform.password
 * @param string  $meta Meta tags to be added to the header
 * @param boolean $cache Should this page be cacheable?
 * @param string  $button HTML code for a button (usually for module editing)
 * @param string  $menu HTML code for a popup menu
 * @param boolean $usexml use XML for this page
 * @param string  $bodytags This text will be included verbatim in the <body> tag (useful for onload() etc)
 * @param bool    $return If true, return the visible elements of the header instead of echoing them.
 */
function print_header($title = '', $heading = '', $navigation = '', $focus = '', $meta = '', $cache = true, $button = '&nbsp;', $menu = '', $usexml = false, $bodytags = '', $return = false)
{
    global $USER, $CFG, $THEME, $SESSION, $ME, $SITE, $COURSE;
    global $MODULE_INCLUDE;
    if ($MODULE_INCLUDE) {
        return;
    }
    if (gettype($navigation) == 'string' && strlen($navigation) != 0 && $navigation != 'home') {
        debugging("print_header() was sent a string as 3rd ({$navigation}) parameter. " . "This is deprecated in favour of an array built by build_navigation(). Please upgrade your code.", DEBUG_DEVELOPER);
    }
    $heading = format_string($heading);
    // Fix for MDL-8582
    /// This makes sure that the header is never repeated twice on a page
    if (defined('HEADER_PRINTED')) {
        debugging('print_header() was called more than once - this should not happen.  Please check the code for this page closely. Note: error() and redirect() are now safe to call after print_header().');
        return;
    }
    define('HEADER_PRINTED', 'true');
    /// Perform a browser environment check for the flash version.  Should only run once per login session.
    if (isloggedin() && !empty($CFG->excludeoldflashclients) && empty($SESSION->flashversion)) {
        // Unfortunately we can't use require_js here and keep it all clean in 1.9 ...
        // require_js(array('yui_yahoo', 'yui_event', 'yui_connection', $CFG->httpswwwroot."/lib/swfobject/swfobject.js"));
        $meta .= '<script type="text/javascript"  src="' . $CFG->wwwroot . '/lib/yui/yahoo/yahoo-min.js"></script>';
        $meta .= '<script type="text/javascript"  src="' . $CFG->wwwroot . '/lib/yui/event/event-min.js"></script>';
        $meta .= '<script type="text/javascript"  src="' . $CFG->wwwroot . '/lib/yui/connection/connection-min.js"></script>';
        $meta .= '<script type="text/javascript"  src="' . $CFG->wwwroot . '/lib/swfobject/swfobject.js"></script>';
        $meta .= "<script type=\"text/javascript\">\n" . "  var flashversion = swfobject.getFlashPlayerVersion();\n" . "  YAHOO.util.Connect.asyncRequest('GET','" . $CFG->wwwroot . "/login/environment.php?sesskey=" . sesskey() . "&amp;flashversion='+flashversion.major+'.'+flashversion.minor+'.'+flashversion.release);\n" . "</script>";
    }
    /// Add the required stylesheets
    $stylesheetshtml = '';
    foreach ($CFG->stylesheets as $stylesheet) {
        $stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="' . $stylesheet . '" />' . "\n";
    }
    $meta = $stylesheetshtml . $meta;
    /// Add the meta page from the themes if any were requested
    $metapage = '';
    if (!isset($THEME->standardmetainclude) || $THEME->standardmetainclude) {
        ob_start();
        include_once $CFG->dirroot . '/theme/standard/meta.php';
        $metapage .= ob_get_contents();
        ob_end_clean();
    }
    if ($THEME->parent && (!isset($THEME->parentmetainclude) || $THEME->parentmetainclude)) {
        if (file_exists($CFG->dirroot . '/theme/' . $THEME->parent . '/meta.php')) {
            ob_start();
            include_once $CFG->dirroot . '/theme/' . $THEME->parent . '/meta.php';
            $metapage .= ob_get_contents();
            ob_end_clean();
        }
    }
    if (!isset($THEME->metainclude) || $THEME->metainclude) {
        if (file_exists($CFG->dirroot . '/theme/' . current_theme() . '/meta.php')) {
            ob_start();
            include_once $CFG->dirroot . '/theme/' . current_theme() . '/meta.php';
            $metapage .= ob_get_contents();
            ob_end_clean();
        }
    }
    $meta = $meta . "\n" . $metapage;
    $meta .= "\n" . require_js('', 1);
    /// Set up some navigation variables
    if (is_newnav($navigation)) {
        $home = false;
    } else {
        if ($navigation == 'home') {
            $home = true;
            $navigation = '';
        } else {
            $home = false;
        }
    }
    /// This is another ugly hack to make navigation elements available to print_footer later
    $THEME->title = $title;
    $THEME->heading = $heading;
    $THEME->navigation = $navigation;
    $THEME->button = $button;
    $THEME->menu = $menu;
    $navmenulist = isset($THEME->navmenulist) ? $THEME->navmenulist : '';
    if ($button == '') {
        $button = '&nbsp;';
    }
    if (file_exists($CFG->dataroot . '/' . SITEID . '/maintenance.html')) {
        $button = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/maintenance.php">' . get_string('maintenancemode', 'admin') . '</a> ' . $button;
        if (!empty($title)) {
            $title .= ' - ';
        }
        $title .= get_string('maintenancemode', 'admin');
    }
    if (!$menu and $navigation) {
        if (empty($CFG->loginhttps)) {
            $wwwroot = $CFG->wwwroot;
        } else {
            $wwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
        }
        $menu = user_login_string($COURSE);
    }
    if (isset($SESSION->justloggedin)) {
        unset($SESSION->justloggedin);
        if (!empty($CFG->displayloginfailures)) {
            if (!empty($USER->username) and $USER->username != 'guest') {
                if ($count = count_login_failures($CFG->displayloginfailures, $USER->username, $USER->lastlogin)) {
                    $menu .= '&nbsp;<font size="1">';
                    if (empty($count->accounts)) {
                        $menu .= get_string('failedloginattempts', '', $count);
                    } else {
                        $menu .= get_string('failedloginattemptsall', '', $count);
                    }
                    if (has_capability('coursereport/log:view', get_context_instance(CONTEXT_SYSTEM))) {
                        $menu .= ' (<a href="' . $CFG->wwwroot . '/course/report/log/index.php' . '?chooselog=1&amp;id=1&amp;modid=site_errors">' . get_string('logs') . '</a>)';
                    }
                    $menu .= '</font>';
                }
            }
        }
    }
    $meta = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n" . $meta . "\n";
    if (!$usexml) {
        @header('Content-Type: text/html; charset=utf-8');
    }
    @header('Content-Script-Type: text/javascript');
    @header('Content-Style-Type: text/css');
    //Accessibility: added the 'lang' attribute to $direction, used in theme <html> tag.
    $direction = get_html_lang($dir = true);
    if ($cache) {
        // Allow caching on "back" (but not on normal clicks)
        @header('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
        @header('Pragma: no-cache');
        @header('Expires: ');
    } else {
        // Do everything we can to always prevent clients and proxies caching
        @header('Cache-Control: no-store, no-cache, must-revalidate');
        @header('Cache-Control: post-check=0, pre-check=0', false);
        @header('Pragma: no-cache');
        @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT');
        @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        $meta .= "\n<meta http-equiv=\"pragma\" content=\"no-cache\" />";
        $meta .= "\n<meta http-equiv=\"expires\" content=\"0\" />";
    }
    @header('Accept-Ranges: none');
    $currentlanguage = current_language();
    if (empty($usexml)) {
        $direction = ' xmlns="http://www.w3.org/1999/xhtml"' . $direction;
        // See debug_header
    } else {
        $mathplayer = preg_match("/MathPlayer/i", $_SERVER['HTTP_USER_AGENT']);
        if (!$mathplayer) {
            header('Content-Type: application/xhtml+xml');
        }
        echo '<?xml version="1.0" ?>' . "\n";
        if (!empty($CFG->xml_stylesheets)) {
            $stylesheets = explode(';', $CFG->xml_stylesheets);
            foreach ($stylesheets as $stylesheet) {
                echo '<?xml-stylesheet type="text/xsl" href="' . $CFG->wwwroot . '/' . $stylesheet . '" ?>' . "\n";
            }
        }
        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1';
        if (!empty($CFG->xml_doctype_extra)) {
            echo ' plus ' . $CFG->xml_doctype_extra;
        }
        echo '//' . strtoupper($currentlanguage) . '" "' . $CFG->xml_dtd . '">' . "\n";
        $direction = " xmlns=\"http://www.w3.org/1999/xhtml\"\n                       xmlns:math=\"http://www.w3.org/1998/Math/MathML\"\n                       xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n                       {$direction}";
        if ($mathplayer) {
            $meta .= '<object id="mathplayer" classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">' . "\n";
            $meta .= '<!--comment required to prevent this becoming an empty tag-->' . "\n";
            $meta .= '</object>' . "\n";
            $meta .= '<?import namespace="math" implementation="#mathplayer" ?>' . "\n";
        }
    }
    // Clean up the title
    $title = format_string($title);
    // fix for MDL-8582
    $title = str_replace('"', '&quot;', $title);
    // Create class and id for this page
    page_id_and_class($pageid, $pageclass);
    $pageclass .= ' course-' . $COURSE->id;
    if (!isloggedin()) {
        $pageclass .= ' notloggedin';
    }
    if (!empty($USER->editing)) {
        $pageclass .= ' editing';
    }
    if (!empty($CFG->blocksdrag)) {
        $pageclass .= ' drag';
    }
    $pageclass .= ' dir-' . get_string('thisdirection');
    $pageclass .= ' lang-' . $currentlanguage;
    $bodytags .= ' class="' . $pageclass . '" id="' . $pageid . '"';
    ob_start();
    include $CFG->header;
    $output = ob_get_contents();
    ob_end_clean();
    // container debugging info
    $THEME->open_header_containers = open_containers();
    // Skip to main content, see skip_main_destination().
    if ($pageid == 'course-view' or $pageid == 'site-index' or $pageid == 'course-index') {
        $skiplink = '<a class="skip" href="#maincontent">' . get_string('tocontent', 'access') . '</a>';
        if (!preg_match('/(.*<div[^>]+id="page"[^>]*>)(.*)/s', $output, $matches)) {
            preg_match('/(.*<body.*?>)(.*)/s', $output, $matches);
        }
        $output = $matches[1] . "\n" . $skiplink . $matches[2];
    }
    $output = force_strict_header($output);
    if (!empty($CFG->messaging)) {
        $output .= message_popup_window();
    }
    // Add in any extra JavaScript libraries that occurred during the header
    $output .= require_js('', 2);
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
 public function htmlattributes()
 {
     $parts = explode(' ', trim(get_html_lang(true)));
     return $parts[0] . ' ' . $parts[1];
     // Ditch xml:lang part.
 }
Пример #11
0
    $lang = 'en';
}
// Find DragMath language.
$langmapping = array('cs' => 'cz', 'pt_br' => 'pt-br');
// Fix non-standard lang names.
if (array_key_exists($lang, $langmapping)) {
    $lang = $langmapping[$lang];
}
if (!file_exists("{$CFG->dirroot}/lib/dragmath/applet/lang/{$lang}.xml")) {
    $lang = 'en';
}
$editor = get_texteditor('tinymce');
$plugin = $editor->get_plugin('dragmath');
// Prevent https security problems.
$relroot = preg_replace('|^http.?://[^/]+|', '', $CFG->wwwroot);
$htmllang = get_html_lang();
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html <?php 
echo $htmllang;
?>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php 
print_string('title', 'tinymce_dragmath');
?>
</title>
<script type="text/javascript" src="<?php 
echo $editor->get_tinymce_base_url();
?>
    /**
     * Output basic html page.
     * @static
     * @param string $title page title
     * @param string $content page content
     * @param string $meta meta tag
     * @return string html page
     */
    public static function plain_page($title, $content, $meta = '')
    {
        if (function_exists('get_string') && function_exists('get_html_lang')) {
            $htmllang = get_html_lang();
        } else {
            $htmllang = '';
        }
        return '<!DOCTYPE html>
<html ' . $htmllang . '>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
' . $meta . '
<title>' . $title . '</title>
</head><body>' . $content . '</body></html>';
    }
 private function _head()
 {
     if (Zend_Registry::isRegistered('Zend_Translate')) {
         $l10n = array('language' => substr(get_html_lang(), 0, 2), 'strings' => array('Download File' => __('Download File'), 'Play/Pause' => __('Play/Pause'), 'Mute Toggle' => __('Mute Toggle'), 'Fullscreen' => __('Fullscreen'), 'Captions/Subtitles' => __('Captions/Subtitles'), 'None' => __('None'), 'Turn off Fullscreen' => __('Turn off Fullscreen'), 'Go Fullscreen' => __('Go Fullscreen'), 'Unmute' => __('Unmute'), 'Mute' => __('Mute'), 'Download Video' => __('Download Video'), 'Close' => __('Close')));
         $l10nScript = 'mejsL10n = ' . js_escape($l10n) . ';';
         queue_js_string($l10nScript);
     }
     queue_js_file('mediaelement-and-player.min', 'mediaelement');
     queue_css_file('mediaelementplayer', 'all', false, 'mediaelement');
     if (is_admin_theme()) {
         queue_css_file('html5media-mejs-overrides', 'all');
     }
 }
 public function hookPublicHead($args)
 {
     queue_css_file('geolocation-aux');
     queue_css_file('geolocation-items-map');
     queue_css_file('jquery-ui');
     $key = urlencode(get_option('geolocation_google_api_key'));
     if ($key) {
         $key = "key=" . $key . "&";
     }
     queue_js_url("https://maps.google.com/maps/api/js?" . $key . "language=" . get_html_lang());
     # sensor=false&
     queue_js_file('map');
 }
Пример #15
0
/**
 * Print a standard header
 *
 * @uses $USER
 * @uses $CFG
 * @uses $SESSION
 * @param string $title Appears at the top of the window
 * @param string $heading Appears at the top of the page
 * @param string $navigation Premade navigation string (for use as breadcrumbs links)
 * @param string $focus Indicates form element to get cursor focus on load eg  inputform.password
 * @param string $meta Meta tags to be added to the header
 * @param boolean $cache Should this page be cacheable?
 * @param string $button HTML code for a button (usually for module editing)
 * @param string $menu HTML code for a popup menu
 * @param boolean $usexml use XML for this page
 * @param string $bodytags This text will be included verbatim in the <body> tag (useful for onload() etc)
 * @param bool   $return If true, return the visible elements of the header instead of echoing them.
 */
function print_header($title = '', $heading = '', $navigation = '', $focus = '', $meta = '', $cache = true, $button = '&nbsp;', $menu = '', $usexml = false, $bodytags = '', $return = false)
{
    global $USER, $CFG, $THEME, $SESSION, $ME, $SITE, $COURSE;
    $heading = format_string($heading);
    // Fix for MDL-8582
    /// This makes sure that the header is never repeated twice on a page
    if (defined('HEADER_PRINTED')) {
        debugging('print_header() was called more than once - this should not happen.  Please check the code for this page closely. Note: error() and redirect() are now safe to call after print_header().');
        return;
    }
    define('HEADER_PRINTED', 'true');
    /// Add the required stylesheets
    $stylesheetshtml = '';
    foreach ($CFG->stylesheets as $stylesheet) {
        $stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="' . $stylesheet . '" />' . "\n";
    }
    $meta = $stylesheetshtml . $meta;
    /// Add the meta page from the themes if any were requested
    $metapage = '';
    if (!isset($THEME->standardmetainclude) || $THEME->standardmetainclude) {
        ob_start();
        include_once $CFG->dirroot . '/theme/standard/meta.php';
        $metapage .= ob_get_contents();
        ob_end_clean();
    }
    if ($THEME->parent && (!isset($THEME->parentmetainclude) || $THEME->parentmetainclude)) {
        if (file_exists($CFG->dirroot . '/theme/' . $THEME->parent . '/meta.php')) {
            ob_start();
            include_once $CFG->dirroot . '/theme/' . $THEME->parent . '/meta.php';
            $metapage .= ob_get_contents();
            ob_end_clean();
        }
    }
    if (!isset($THEME->metainclude) || $THEME->metainclude) {
        if (file_exists($CFG->dirroot . '/theme/' . current_theme() . '/meta.php')) {
            ob_start();
            include_once $CFG->dirroot . '/theme/' . current_theme() . '/meta.php';
            $metapage .= ob_get_contents();
            ob_end_clean();
        }
    }
    $meta = $meta . "\n" . $metapage;
    /// Add the required JavaScript Libraries
    $meta .= "\n" . require_js();
    if ($navigation == 'home') {
        $home = true;
        $navigation = '';
    } else {
        $home = false;
    }
    /// This is another ugly hack to make navigation elements available to print_footer later
    $THEME->title = $title;
    $THEME->heading = $heading;
    $THEME->navigation = $navigation;
    $THEME->button = $button;
    $THEME->menu = $menu;
    $navmenulist = isset($THEME->navmenulist) ? $THEME->navmenulist : '';
    if ($button == '') {
        $button = '&nbsp;';
    }
    if (!$menu and $navigation) {
        if (empty($CFG->loginhttps)) {
            $wwwroot = $CFG->wwwroot;
        } else {
            $wwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
        }
        $menu = user_login_string($COURSE);
    }
    if (isset($SESSION->justloggedin)) {
        unset($SESSION->justloggedin);
        if (!empty($CFG->displayloginfailures)) {
            if (!empty($USER->username) and $USER->username != 'guest') {
                if ($count = count_login_failures($CFG->displayloginfailures, $USER->username, $USER->lastlogin)) {
                    $menu .= '&nbsp;<font size="1">';
                    if (empty($count->accounts)) {
                        $menu .= get_string('failedloginattempts', '', $count);
                    } else {
                        $menu .= get_string('failedloginattemptsall', '', $count);
                    }
                    if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
                        $menu .= ' (<a href="' . $CFG->wwwroot . '/course/report/log/index.php' . '?chooselog=1&amp;id=1&amp;modid=site_errors">' . get_string('logs') . '</a>)';
                    }
                    $menu .= '</font>';
                }
            }
        }
    }
    $meta = '<meta http-equiv="content-type" content="text/html; charset=utf-8" />' . "\n" . $meta . "\n";
    if (!$usexml) {
        @header('Content-type: text/html; charset=utf-8');
    }
    //Accessibility: added the 'lang' attribute to $direction, used in theme <html> tag.
    $direction = get_html_lang($dir = true);
    if ($cache) {
        // Allow caching on "back" (but not on normal clicks)
        @header('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
        @header('Pragma: no-cache');
        @header('Expires: ');
    } else {
        // Do everything we can to always prevent clients and proxies caching
        @header('Cache-Control: no-store, no-cache, must-revalidate');
        @header('Cache-Control: post-check=0, pre-check=0', false);
        @header('Pragma: no-cache');
        @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT');
        @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        $meta .= "\n<meta http-equiv=\"pragma\" content=\"no-cache\" />";
        $meta .= "\n<meta http-equiv=\"expires\" content=\"0\" />";
    }
    @header('Accept-Ranges: none');
    $currentlanguage = current_language();
    if (empty($usexml)) {
        $direction = ' xmlns="http://www.w3.org/1999/xhtml"' . $direction;
        // See debug_header
    } else {
        $mathplayer = preg_match("/MathPlayer/i", $_SERVER['HTTP_USER_AGENT']);
        if (!$mathplayer) {
            header('Content-Type: application/xhtml+xml');
        }
        echo '<?xml version="1.0" ?>' . "\n";
        if (!empty($CFG->xml_stylesheets)) {
            $stylesheets = explode(';', $CFG->xml_stylesheets);
            foreach ($stylesheets as $stylesheet) {
                echo '<?xml-stylesheet type="text/xsl" href="' . $CFG->wwwroot . '/' . $stylesheet . '" ?>' . "\n";
            }
        }
        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1';
        if (!empty($CFG->xml_doctype_extra)) {
            echo ' plus ' . $CFG->xml_doctype_extra;
        }
        echo '//' . strtoupper($currentlanguage) . '" "' . $CFG->xml_dtd . '">' . "\n";
        $direction = " xmlns=\"http://www.w3.org/1999/xhtml\"\n                       xmlns:math=\"http://www.w3.org/1998/Math/MathML\"\n                       xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n                       {$direction}";
        if ($mathplayer) {
            $meta .= '<object id="mathplayer" classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">' . "\n";
            $meta .= '<!--comment required to prevent this becoming an empty tag-->' . "\n";
            $meta .= '</object>' . "\n";
            $meta .= '<?import namespace="math" implementation="#mathplayer" ?>' . "\n";
        }
    }
    // Clean up the title
    $title = format_string($title);
    // fix for MDL-8582
    $title = str_replace('"', '&quot;', $title);
    // Create class and id for this page
    page_id_and_class($pageid, $pageclass);
    $pageclass .= ' course-' . $COURSE->id;
    if ($pageid != 'site-index' && $pageid != 'course-view' && strstr($pageid, 'admin') === FALSE) {
        $pageclass .= ' nocoursepage';
    }
    if (!isloggedin()) {
        $pageclass .= ' notloggedin';
    }
    if (!empty($USER->editing)) {
        $pageclass .= ' editing';
    }
    if (!empty($CFG->blocksdrag)) {
        $pageclass .= ' drag';
    }
    $pageclass .= ' lang-' . $currentlanguage;
    $bodytags .= ' class="' . $pageclass . '" id="' . $pageid . '"';
    ob_start();
    include $CFG->header;
    $output = ob_get_contents();
    ob_end_clean();
    $output = force_strict_header($output);
    if (!empty($CFG->messaging)) {
        $output .= message_popup_window();
    }
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
Пример #16
0
 /**
  * Sdd calendar sheet / date picker / Greg/Jul conversion functionality
  */
 public function hookAdminHead()
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $module = $request->getModuleName();
     if (is_null($module)) {
         $module = 'default';
     }
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     if ($module === 'default' && $controller === 'items' && in_array($action, array('add', 'edit'))) {
         queue_js_file('datesearch');
         queue_js_file('rangyinputs-jquery');
         queue_css_file('datesearch');
         queue_js_file('jquery.plugin.min');
         queue_js_file('jquery.mousewheel.min');
         queue_js_file('jquery.calendars.all.min');
         queue_js_file('jquery.calendars.julian.min');
         queue_js_file('jquery.calendars.picker.min');
         $locale = get_html_lang();
         $underscore = strpos($locale, "-");
         $locale = $underscore ? substr($locale, 0, $underscore) : $locale;
         if ($locale != "en") {
             queue_js_file('jquery.calendars-' . $locale);
             queue_js_file('jquery.calendars.picker-' . $locale);
         }
         queue_css_file('jquery.calendars.picker');
         $timespan = __("Time Span");
         $gregorian = __("Gregorian");
         $julian = __("Julian");
         $date = __("Date (without prefix)");
         $convert = __("Convert");
         $selectFirst = __("Please select a target text area first.");
         $cancel = __("Cancel");
         $selectDate = __("Please select a date or time span to convert.");
         $cantEdit = __("Can not edit selected date as %.");
         $cantConvert = __("Can not convert selected date to %, as it is already %.");
         $dateEntry = __("Date Entry");
         queue_js_string("\n\t\t\t\tvar dateSearchLocale='{$locale}';\n\t\t\t\tvar dateSearchTimeSpan='{$timespan}';\n\t\t\t\tvar dateSearchConvert='{$convert}';\n\t\t\t\tvar dateSearchGregorian='{$gregorian}';\n\t\t\t\tvar dateSearchJulian='{$julian}';\n\t\t\t\tvar dateSearchDate='{$date}';\n\t\t\t\tvar dateSearchSelectFirst='{$selectFirst}';\n\t\t\t\tvar dateSearchCancel='{$cancel}';\n\t\t\t\tvar dateSearchSelectDate='{$selectDate}';\n\t\t\t\tvar dateSearchCantEdit='{$cantEdit}';\n\t\t\t\tvar dateSearchCantConvert='{$cantConvert}';\n\t\t\t\tvar dateSearchDateEntry='{$dateEntry}';\n\t\t\t");
     }
 }