/** construct an output page in HTML * * This constructs a full HTML-page, starting at the DTD * and ending with the html closing tag. * * This routine returns a full HTML-page, including a navigation * menu and a footer with links to printer friendly version + logout. * If the page is called with print=1 as one of the get-parameters, the * background and navigation menu are suppressed by including the * additional print.css stylesheet (configurable). * This more or less allows for making a clean print of only the content. * This additional stylesheet is added only once, even if this routine is * called more than once (shouldn't happen). This stylesheet is configurable * just like the regular stylesheet. * * Suppressing the background image (for printing) involves NOT generating * the container div with id="page", or rather: we use a different id when * viewed in regulare mode (id="page") or when viewed in print mode * (id="print"). This allows for different tricks in print.css and at the * very least allows for suppressing the background image. * * @return string complete HTML-page, ready for output */ function get_html() { global $CFG, $USER; static $dejavu = 0; if (isset($_GET['print']) && intval($_GET['print']) == 1 && $dejavu++ == 0) { if (isset($this->config['style_usage_static']) && $this->config['style_usage_static'] && isset($this->config['stylesheet_print'])) { $this->add_stylesheet($this->config['stylesheet_print']); } } $container = $dejavu ? "print" : "page"; // helpers for CSS-design // $this->add_popup_top('Test TOP'); // $this->add_message('Test Message'); // $this->add_popup_bottom('Test BOTTOM'); // 0 -- Prepare for the lastupdate and copyright message $current_year = intval(strftime('%Y')); $create_year = intval(substr($this->node_record['ctime'], 0, 4)); $aparams = array('{UPDATE_YEAR}' => substr($this->node_record['mtime'], 0, 4), '{UPDATE_MONTH}' => substr($this->node_record['mtime'], 5, 2), '{UPDATE_DAY}' => substr($this->node_record['mtime'], 8, 2), '{SITENAME}' => $CFG->title, '{COPYRIGHT_YEAR}' => $current_year == $create_year ? strval($current_year) : strval($create_year) . '-' . strval($current_year)); $separator = ' |'; // 1 -- Construct the page in one go (KISS). $s = $this->dtd . "\n" . "<html>\n" . "<head>\n" . " <!-- Website@School CMS licensed under GNU/AGPLv3 - http://websiteatschool.eu\n" . " Theme name: 'axis'\n" . " Implemented by: Peter Fokker <*****@*****.**> (April 2012)\n" . " -->\n" . $this->get_html_head(' ') . "</head>\n" . "<body>\n" . " <div id=\"top\">\n" . $this->get_popups($this->messages_top, ' ') . " </div>\n" . " <div id=\"{$container}\">\n" . " <div id=\"header\"></div>\n" . " <div id=\"menu\">\n" . $this->get_menu(' ', $this->tree[0]['first_child_id']) . " </div>\n" . " <!-- content -->\n" . " <div id=\"content\">\n\n" . $this->get_div_messages(' ') . " <h2 id=\"content_title\">" . htmlspecialchars($this->node_record['title']) . "</h2>\n" . $this->get_content() . "\n" . " </div>\n" . " <!-- end content -->\n\n" . " <!-- start page bottom -->\n" . " <div id=\"footer\">\n" . " <div id=\"footer-left\">" . t('copyright', $this->domain, $aparams) . "</div>\n" . " <div id=\"footer-right\">\n" . $this->axis_logout($separator, ' ') . $this->axis_printpage($separator, ' ') . appropriate_legal_notices(TRUE, ' ') . "\n" . " </div>\n" . " </div>\n" . " <div id=\"address\">\n" . $this->get_address(' ') . " </div>\n" . " </div>\n" . " <div id=\"bottom\">\n" . $this->get_popups($this->messages_bottom, ' ') . " </div>\n" . "</body>\n" . "</html>\n"; return $s; }
/** show footer text, maybe some quicklinks and 'powered by' * * @param string $m left margin for increased readability * @return string performance report */ function get_bottomline($m = '') { $separator = empty($this->quickbottom_separator) ? '' : ' ' . $this->quickbottom_separator; // readability $s = empty($this->config['footer_text']) ? '' : $m . $this->config['footer_text'] . $separator . "\n"; $t = $this->get_quickbottom($m); $s .= empty($t) ? '' : rtrim($t) . $separator . "\n"; $s .= appropriate_legal_notices(TRUE, $m) . "\n"; return $s; }
/** report basic performance indicators in a single line * * This calculates the execution time of the script and the * number of queries. Note a special trick: we retrieve * the translated string in a dummy variable before calculating * the number of queries because otherwise we might miss one * or more query from the language/translation subsystem. * * Note that the message containing the performance indicators * is only generated when debug is TRUE; the information is not * that interesting for ordinary users. * * @param string $m left margin for increased readability * @return string performance report */ function get_bottomline($m = '') { global $CFG; $bottom_line = appropriate_legal_notices($this->text_only, $m) . "\n"; if ($CFG->debug) { $dummy = t('generated_in', 'admin'); $a = array('{DATE}' => strftime("%Y-%m-%d %T"), '{QUERIES}' => performance_get_queries(), '{SECONDS}' => sprintf("%01.3f", performance_get_seconds())); $bottom_line .= $m . "| " . t('generated_in', 'admin', $a) . "\n"; } return $bottom_line; }
/** emergency exit of program in case there is something really, really wrong * * This routine outputs a short message and a 'cryptic' condition code * and exits the program. It is called when something goes horribly wrong * during the early stages of running the program, e.g. the database cannot * be opened or there is a version mismatch between the program code (the * .php-files) and the database. The complete condition code is the WAS * release number followed by a slash followed by the WAS version number * followed by a slash and the bare condition code. The message ends with * a link to about.html with 'Powered by' or 'Based on', depending on the * WAS original flag. Note that we try to show graphics (including logo) but * that we switch back to text-only if it is too early, ie. * before {@link waslib.php} is included. * * Here is an overview of meaning of the condition codes used. * * - 010: cannot find config.php, is W@S installed at all? * - 015: cannot find program/main_XXXXX.php, is W@S installed at all? * - 017: cannot calculate wasentry_script_name, are we being tricked? * - 020: configuration error, invalid database type * - 030: cannot connect to database, busy or configuration error? * - 040: error accessing the database, is W@S installed at all? * - 050: version mismatch, update to new version necessary * - 060: magic_quotes_sybase is On * - 070: there is no (default) node available in this (default) area * - 080: there is no area available * - 090: there is no valid theme available * * The condition code is numeric because it is easier to report for * non-English speaking users than a complicated English sentence. * (The language files are not yet loaded when error_exit() is called). * * @param string the bare condition code to report * @param string the title to show in the generated HTML-page * @return void this function never returns * @uses WAS_VERSION indicate internal version in 'cryptic' message * @uses $CFG * @todo do we really want to 'leak' a link to the main site? */ function error_exit($bare_condition_code, $page_title = 'Fatal Error') { global $CFG; $was_release = htmlspecialchars(WAS_RELEASE); $was_version = htmlspecialchars(WAS_VERSION); $anchor_self = ''; if (isset($CFG->www) && !empty($CFG->www)) { $anchor_self = "\n <p>\n <a href=\"{$CFG->www}\">{$CFG->www}</a>"; } if (function_exists('appropriate_legal_notices')) { $poweredby = appropriate_legal_notices(); } else { $poweredby = sprintf('%s <a href="%s/about.html" target="_blank">Website@School<a>', WAS_ORIGINAL ? 'Powered by' : 'Based on', $CFG->progwww); } echo <<<EOT <html> <head> <title>{$page_title}</title> </head> <body> <h1>{$page_title}</h1> <b>There is a problem with this site.</b> <p> Please contact the site owner mentioning the following condition code: <p> <b>{$was_release} / {$was_version} / {$bare_condition_code}</b> <p> Thank you for your cooperation!{$anchor_self} <p> {$poweredby} </body> </html> EOT; exit(1); }
/** show 'powered by' and (maybe) report basic performance indicators * * This calculates the execution time of the script and the * number of queries. Note a special trick: we retrieve * the translated string in a dummy variable before calculating * the number of queries because otherwise we might miss one * or more query from the language/translation subsystem. * * Note: for the time being the performance report commented out (2010-12-08). * Update: as from 2011-05-20 the performance report only displayed while debug is on, * * @param string $m left margin for increased readability * @return string performance report */ function get_bottomline($m = '') { global $CFG; $dummy = t('generated_in', 'admin'); $a = array('{DATE}' => strftime("%Y-%m-%d %T"), '{QUERIES}' => performance_get_queries(), '{SECONDS}' => sprintf("%01.3f", performance_get_seconds())); $s = appropriate_legal_notices($this->text_only, $m) . "\n"; if ($CFG->debug) { $separator = empty($this->quickbottom_separator) ? '' : $this->quickbottom_separator . ' '; // readability $s .= $m . $separator . t('generated_in', 'admin', $a) . "\n"; } return $s; }