mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
navigation MDL-14632 Deprecate print_header menu argument and provide PAGE method
This commit is contained in:
parent
b7510c3aa8
commit
e120c61d24
7 changed files with 33 additions and 18 deletions
|
@ -2120,7 +2120,7 @@ function print_continue($link, $return = false) {
|
|||
* @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;
|
||||
|
||||
|
@ -2132,6 +2132,7 @@ function print_header($title='', $heading='', $navigation='', $focus='',
|
|||
$button = ' ';
|
||||
}
|
||||
$PAGE->set_button($button);
|
||||
$PAGE->set_headingmenu($menu);
|
||||
|
||||
// TODO $menu
|
||||
|
||||
|
@ -2146,7 +2147,7 @@ function print_header($title='', $heading='', $navigation='', $focus='',
|
|||
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;
|
||||
|
|
|
@ -685,13 +685,9 @@ class moodle_core_renderer extends moodle_renderer_base {
|
|||
* 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;
|
||||
|
||||
|
@ -701,10 +697,10 @@ class moodle_core_renderer extends moodle_renderer_base {
|
|||
$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.
|
||||
|
@ -734,7 +730,7 @@ class moodle_core_renderer extends moodle_renderer_base {
|
|||
* @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
|
||||
|
@ -762,7 +758,7 @@ class moodle_core_renderer extends moodle_renderer_base {
|
|||
* @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.
|
||||
|
@ -780,6 +776,7 @@ class moodle_core_renderer extends moodle_renderer_base {
|
|||
$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
|
||||
|
|
|
@ -132,6 +132,8 @@ class moodle_page {
|
|||
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.
|
||||
|
@ -322,6 +324,14 @@ class moodle_page {
|
|||
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.
|
||||
|
@ -705,7 +715,7 @@ class moodle_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);
|
||||
|
@ -714,12 +724,19 @@ class moodle_page {
|
|||
}
|
||||
|
||||
/**
|
||||
* $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
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
<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();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<?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 } ?>
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<?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 } ?>
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<?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 } ?>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue