]> git.mjollnir.org Git - moodle.git/commitdiff
navigation MDL-14632 Deprecate print_header menu argument and provide PAGE method
authorsamhemelryk <samhemelryk>
Tue, 1 Sep 2009 03:47:07 +0000 (03:47 +0000)
committersamhemelryk <samhemelryk>
Tue, 1 Sep 2009 03:47:07 +0000 (03:47 +0000)
lib/deprecatedlib.php
lib/outputrenderers.php
lib/pagelib.php
theme/standard/layout-home.php
theme/standard/layout-popup.php
theme/standard/layout-topframe.php
theme/standard/layout.php

index 401806092b1dac99b1aa9a23622a18dc7c78744e..e17ce7180c5b89f937f69405a9aa1bd7e88d72f9 100644 (file)
@@ -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='&nbsp;', $menu='',
+                      $meta='', $cache=true, $button='&nbsp;', $menu=null,
                       $usexml=false, $bodytags='', $return=false) {
     global $PAGE, $OUTPUT;
 
@@ -2132,6 +2132,7 @@ function print_header($title='', $heading='', $navigation='', $focus='',
         $button = '&nbsp;';
     }
     $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;
index 7ff798f2abe842341bc8f8cf37342dc79ee785b0..65f734725f9d29aea01401a3d242f5368c363e76 100644 (file)
@@ -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
index 376df134d8d3741e016a0faa6a4c2dee9ab506fe..3acf7bd5976cf06393430f7f8154f2accee83b43 100644 (file)
@@ -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
index 452e6568a70d2eb8009264868955e7ad327a74c3..eef0391605eafbbd61127cb2a3498ab899073ea6 100644 (file)
@@ -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();
         }
index e62ec7f328316426755b03219f963dab56c6472c..49fdb2b802a839c048f9f9cbe1109fc2faa4f0a6 100644 (file)
@@ -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 } ?>
 
index e62ec7f328316426755b03219f963dab56c6472c..49fdb2b802a839c048f9f9cbe1109fc2faa4f0a6 100644 (file)
@@ -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 } ?>
 
index 8227aa41bcdeab1308b7a6dc2e14c92efd8bb0c6..d328d110a9d8bdf03b282ac7cfd8f0fba9359c83 100644 (file)
@@ -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 } ?>