From: samhemelryk Date: Tue, 1 Sep 2009 03:47:07 +0000 (+0000) Subject: navigation MDL-14632 Deprecate print_header menu argument and provide PAGE method X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e120c61d2498f945825850602b23f70a07645173;p=moodle.git navigation MDL-14632 Deprecate print_header menu argument and provide PAGE method --- diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 401806092b..e17ce7180c 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -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; diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 7ff798f2ab..65f734725f 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -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 diff --git a/lib/pagelib.php b/lib/pagelib.php index 376df134d8..3acf7bd597 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -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 section of the HTML of this page. + * @param string $title the title that should go in the 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 . + * @param string $heading the main heading that should be displayed at the top of the . */ 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 diff --git a/theme/standard/layout-home.php b/theme/standard/layout-home.php index 452e6568a7..eef0391605 100644 --- a/theme/standard/layout-home.php +++ b/theme/standard/layout-home.php @@ -14,8 +14,8 @@

heading ?>

headingmenu) { + echo $PAGE->headingmenu; } else { echo $OUTPUT->login_info(); } diff --git a/theme/standard/layout-popup.php b/theme/standard/layout-popup.php index e62ec7f328..49fdb2b802 100644 --- a/theme/standard/layout-popup.php +++ b/theme/standard/layout-popup.php @@ -13,7 +13,7 @@ heading) { ?> diff --git a/theme/standard/layout-topframe.php b/theme/standard/layout-topframe.php index e62ec7f328..49fdb2b802 100644 --- a/theme/standard/layout-topframe.php +++ b/theme/standard/layout-topframe.php @@ -13,7 +13,7 @@ heading) { ?> diff --git a/theme/standard/layout.php b/theme/standard/layout.php index 8227aa41bc..d328d110a9 100644 --- a/theme/standard/layout.php +++ b/theme/standard/layout.php @@ -13,7 +13,7 @@ heading) { ?>