Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 36b6bcecc052a42e4a5337d051f29d2638e9c92b 1 parent eaeaf96
moquist authored

Showing 1 changed file with 24 additions and 6 deletions. Show diff stats Hide diff stats

  1. +24 6 lib/weblib.php
30 lib/weblib.php
@@ -1889,9 +1889,11 @@ function highlightfast($needle, $haystack) {
1889 1889 * @param string $menu HTML code for a popup menu
1890 1890 * @param boolean $usexml use XML for this page
1891 1891 * @param string $bodytags This text will be included verbatim in the <body> tag (useful for onload() etc)
  1892 + * @param bool $return If true, return the visible elements of the header instead of echoing them.
1892 1893 */
1893   -function print_header ($title='', $heading='', $navigation='', $focus='', $meta='',
1894   - $cache=true, $button='&nbsp;', $menu='', $usexml=false, $bodytags='') {
  1894 +function print_header ($title='', $heading='', $navigation='', $focus='',
  1895 + $meta='', $cache=true, $button='&nbsp;', $menu='',
  1896 + $usexml=false, $bodytags='', $return=false) {
1895 1897
1896 1898 global $USER, $CFG, $THEME, $SESSION, $ME, $SITE, $HTTPSPAGEREQUIRED;
1897 1899
@@ -2081,10 +2083,19 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $meta=
2081 2083
2082 2084 $bodytags .= ' class="'.$pageclass.'" id="'.$pageid.'"';
2083 2085
  2086 + ob_start();
2084 2087 include ($CFG->themedir.current_theme().'/header.html');
  2088 + $output = ob_get_contents();
  2089 + ob_end_clean();
2085 2090
2086 2091 if (!empty($CFG->messaging)) {
2087   - echo message_popup_window();
  2092 + $output .= message_popup_window();
  2093 + }
  2094 +
  2095 + if ($return) {
  2096 + return $output;
  2097 + } else {
  2098 + echo $output;
2088 2099 }
2089 2100 }
2090 2101
@@ -2103,9 +2114,10 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $meta=
2103 2114 * @param string $menu HTML code for a popup menu
2104 2115 * @param boolean $usexml use XML for this page
2105 2116 * @param string $bodytags This text will be included verbatim in the <body> tag (useful for onload() etc)
  2117 + * @param bool $return If true, return the visible elements of the header instead of echoing them.
2106 2118 */
2107 2119 function print_header_simple($title='', $heading='', $navigation='', $focus='', $meta='',
2108   - $cache=true, $button='&nbsp;', $menu='', $usexml=false, $bodytags='') {
  2120 + $cache=true, $button='&nbsp;', $menu='', $usexml=false, $bodytags='', $return=false) {
2109 2121
2110 2122 global $course,$CFG; // The same hack is used in print_header
2111 2123
@@ -2114,8 +2126,14 @@ function print_header_simple($title='', $heading='', $navigation='', $focus='',
2114 2126 $shortname = '<a href="'.$CFG->wwwroot.'/course/view.php?id='. $course->id .'">'. $course->shortname .'</a> ->';
2115 2127 }
2116 2128
2117   - print_header($course->shortname .': '. $title, $course->fullname .' '. $heading, $shortname .' '. $navigation, $focus, $meta,
2118   - $cache, $button, $menu, $usexml, $bodytags);
  2129 + $output = print_header($course->shortname .': '. $title, $course->fullname .' '. $heading, $shortname .' '. $navigation, $focus, $meta,
  2130 + $cache, $button, $menu, $usexml, $bodytags, $return);
  2131 +
  2132 + if ($return) {
  2133 + return $output;
  2134 + } else {
  2135 + echo $output;
  2136 + }
2119 2137 }
2120 2138
2121 2139

0 comments on commit 36b6bce

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