From: moquist Date: Thu, 10 Aug 2006 05:01:57 +0000 (+0000) Subject: Added $return=false parameter to print_header() and print_header_simple() using X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=36b6bcecc052a42e4a5337d051f29d2638e9c92b;p=moodle.git Added $return=false parameter to print_header() and print_header_simple() using output control functions to deal with the include() of the themed header HTML file. --- diff --git a/lib/weblib.php b/lib/weblib.php index 9dc6893fe9..bf1af71a2f 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1889,9 +1889,11 @@ function highlightfast($needle, $haystack) { * @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 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=' ', $menu='', $usexml=false, $bodytags='') { +function print_header ($title='', $heading='', $navigation='', $focus='', + $meta='', $cache=true, $button=' ', $menu='', + $usexml=false, $bodytags='', $return=false) { global $USER, $CFG, $THEME, $SESSION, $ME, $SITE, $HTTPSPAGEREQUIRED; @@ -2081,10 +2083,19 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $meta= $bodytags .= ' class="'.$pageclass.'" id="'.$pageid.'"'; + ob_start(); include ($CFG->themedir.current_theme().'/header.html'); + $output = ob_get_contents(); + ob_end_clean(); if (!empty($CFG->messaging)) { - echo message_popup_window(); + $output .= message_popup_window(); + } + + if ($return) { + return $output; + } else { + echo $output; } } @@ -2103,9 +2114,10 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $meta= * @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 tag (useful for onload() etc) + * @param bool $return If true, return the visible elements of the header instead of echoing them. */ function print_header_simple($title='', $heading='', $navigation='', $focus='', $meta='', - $cache=true, $button=' ', $menu='', $usexml=false, $bodytags='') { + $cache=true, $button=' ', $menu='', $usexml=false, $bodytags='', $return=false) { global $course,$CFG; // The same hack is used in print_header @@ -2114,8 +2126,14 @@ function print_header_simple($title='', $heading='', $navigation='', $focus='', $shortname = ''. $course->shortname .' ->'; } - print_header($course->shortname .': '. $title, $course->fullname .' '. $heading, $shortname .' '. $navigation, $focus, $meta, - $cache, $button, $menu, $usexml, $bodytags); + $output = print_header($course->shortname .': '. $title, $course->fullname .' '. $heading, $shortname .' '. $navigation, $focus, $meta, + $cache, $button, $menu, $usexml, $bodytags, $return); + + if ($return) { + return $output; + } else { + echo $output; + } }