* @return string|void If return=true then string else void
*/
function print_header($title='', $heading='', $navigation='', $focus='',
- $meta='', $cache=true, $button=' ', $menu='',
+ $meta='', $cache=true, $button=' ', $menu=null,
$usexml=false, $bodytags='', $return=false) {
global $PAGE, $OUTPUT;
$button = ' ';
}
$PAGE->set_button($button);
+ $PAGE->set_headingmenu($menu);
// TODO $menu
throw new coding_exception('The $bodytags parameter to print_header is no longer supported.');
}
- $output = $OUTPUT->header($menu);
+ $output = $OUTPUT->header();
if ($return) {
return $output;
* Not that, in due course, the remaining $navigation, $menu parameters here
* will be replaced by more properties of $PAGE, but that is still to do.
*
- * @param string $navigation legacy, like the old parameter to print_header. Will be
- * removed when there is a $PAGE->... replacement.
- * @param string $menu legacy, like the old parameter to print_header. Will be
- * removed when there is a $PAGE->... replacement.
* @return string HTML that you must output this, preferably immediately.
*/
- public function header($menu='') {
+ public function header() {
// TODO remove $navigation and $menu arguments - replace with $PAGE->navigation
global $USER, $CFG;
$templatefile = $this->page->theme->template_for_page($this->page->generaltype);
if ($templatefile) {
// Render the template.
- $template = $this->render_page_template($templatefile, $menu);
+ $template = $this->render_page_template($templatefile);
} else {
// New style template not found, fall back to using header.html and footer.html.
- $template = $this->handle_legacy_theme($menu);
+ $template = $this->handle_legacy_theme();
}
// Slice the template output into header and footer.
* @param array $navigation The navigation that will be used in the included file
* @return string HTML code
*/
- protected function render_page_template($templatefile, $menu) {
+ protected function render_page_template($templatefile) {
global $CFG, $SITE, $THEME, $USER;
// The next lines are a bit tricky. The point is, here we are in a method
// of a renderer class, and this object may, or may not, be the same as
* @param array $menu The menu that will be used in the included file
* @return string HTML code
*/
- protected function handle_legacy_theme($menu) {
+ protected function handle_legacy_theme() {
global $CFG, $SITE, $USER;
// Set a pretend global from the properties of this class.
// See the comment in render_page_template for a fuller explanation.
$pageclass = $this->page->bodyclasses;
$bodytags = ' class="' . $pageclass . '" id="' . $pageid . '"';
$home = $this->page->generaltype == 'home';
+ $menu = $this->page->headingmenu;
$meta = $this->standard_head_html();
// The next line is a nasty hack. having set $meta to standard_head_html, we have already
protected $_settingsnav = null;
/** @var null|navbar Contains the navbar structure*/
protected $_navbar = null;
+ /** @var string */
+ protected $_headingmenu = null;
/**
* Then the theme is initialsed, we save the stack trace, for use in error messages.
return $this->_heading;
}
+ /**
+ * Please do not call this method directly, use the ->heading syntax. {@link __get()}.
+ * @return string The menu (or actions) to display in the heading
+ */
+ public function get_headingmenu() {
+ return $this->_headingmenu;
+ }
+
/**
* Please do not call this method directly, use the ->docspath syntax. {@link __get()}.
* @return string the path to the Moodle docs for this page.
}
/**
- * $param string $title the title that should go in the <head> section of the HTML of this page.
+ * @param string $title the title that should go in the <head> section of the HTML of this page.
*/
public function set_title($title) {
$title = format_string($title);
}
/**
- * $param string $heading the main heading that should be displayed at the top of the <body>.
+ * @param string $heading the main heading that should be displayed at the top of the <body>.
*/
public function set_heading($heading) {
$this->_heading = format_string($heading);
}
+ /**
+ * @param string $menu The menu/content to show in the heading
+ */
+ public function set_headingmenu($menu) {
+ $this->_headingmenu = $menu;
+ }
+
/**
* Set the course category this page belongs to manually. This automatically
* sets $PAGE->course to be the site coures. You cannot use this method if
<div id="header-home" class="clearfix">
<h1 class="headermain"><?php echo $PAGE->heading ?></h1>
<div class="headermenu"><?php
- if ($menu) {
- echo $menu;
+ if ($PAGE->headingmenu) {
+ echo $PAGE->headingmenu;
} else {
echo $OUTPUT->login_info();
}
<?php if ($PAGE->heading) { ?>
<div id="header" class="clearfix">
<h1 class="headermain"><?php echo $PAGE->heading ?></h1>
- <div class="headermenu"><?php echo $menu ?></div>
+ <div class="headermenu"><?php echo $PAGE->headingmenu ?></div>
</div>
<?php } ?>
<?php if ($PAGE->heading) { ?>
<div id="header" class="clearfix">
<h1 class="headermain"><?php echo $PAGE->heading ?></h1>
- <div class="headermenu"><?php echo $menu ?></div>
+ <div class="headermenu"><?php echo $PAGE->headingmenu ?></div>
</div>
<?php } ?>
<?php if ($PAGE->heading) { ?>
<div id="header" class="clearfix">
<h1 class="headermain"><?php echo $PAGE->heading ?></h1>
- <div class="headermenu"><?php echo $menu ?></div>
+ <div class="headermenu"><?php echo $PAGE->headingmenu ?></div>
</div>
<?php } ?>