Skip to content
Browse files

Added $return=false parameter to print_header() and print_header_simp…

…le() using

output control functions to deal with the include() of the themed header HTML
file.
  • Loading branch information...
1 parent eaeaf96 commit 36b6bcecc052a42e4a5337d051f29d2638e9c92b moquist committed Aug 10, 2006
Showing with 24 additions and 6 deletions.
  1. +24 −6 lib/weblib.php
View
30 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 <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='') {
+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, $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 <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_simple($title='', $heading='', $navigation='', $focus='', $meta='',
- $cache=true, $button='&nbsp;', $menu='', $usexml=false, $bodytags='') {
+ $cache=true, $button='&nbsp;', $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 = '<a href="'.$CFG->wwwroot.'/course/view.php?id='. $course->id .'">'. $course->shortname .'</a> ->';
}
- 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;
+ }
}

0 comments on commit 36b6bce

Please sign in to comment.
Something went wrong with that request. Please try again.