]> git.mjollnir.org Git - moodle.git/commitdiff
navigation MDL-14632 Fixed bug with deprecated build_navigation function
authorsamhemelryk <samhemelryk>
Tue, 1 Sep 2009 04:13:00 +0000 (04:13 +0000)
committersamhemelryk <samhemelryk>
Tue, 1 Sep 2009 04:13:00 +0000 (04:13 +0000)
lib/deprecatedlib.php
lib/navigationlib.php

index e17ce7180c5b89f937f69405a9aa1bd7e88d72f9..e7d2d71ab1c838091e8d66c4fd43a4c47a2ae286 100644 (file)
@@ -3635,7 +3635,11 @@ function build_navigation($extranavlinks, $cm = null) {
         # debugging('build_navigation() has been deprecated, please replace with $PAGE->navbar methods', DEBUG_DEVELOPER);
         foreach ($extranavlinks as $nav) {
             if (array_key_exists('name', $nav)) {
-                $link = (array_key_exists('link', $nav))?$nav['link']:null;
+                if (array_key_exists('link', $nav) && !empty($nav['link'])) {
+                    $link = $nav['link'];
+                } else {
+                    $link = null;
+                }
                 $PAGE->navbar->add($nav['name'],null, null, navbar::TYPE_CUSTOM, $link);
             }
         }
index fc38ec42add431b0ca9e81f0be6997deb73083e5..b6d2a1b1070bffe067a0a4da2e59c462eaea0963 100644 (file)
@@ -1852,23 +1852,20 @@ class navbar extends navigation_node {
         // For screen readers
         $output = get_accesshide(get_string('youarehere','access'), 'h2')."<ul>\n";
         
-        $firstnode = true;
         $customchildren = (count($this->children) > 0);
         // Check if navigation contains the active node
         if ($this->page->navigation->contains_active_node()) {
             // Parse the navigation tree to get the active node
-            $output .= $this->parse_branch_to_html($this->page->navigation->children, $firstnode, $customchildren);
-            $firstnode = false;
+            $output .= $this->parse_branch_to_html($this->page->navigation->children, true, $customchildren);
         } else if ($this->page->settingsnav->contains_active_node()) {
             // Parse the settings navigation to get the active node
-            $output .= $this->parse_branch_to_html($this->page->settingsnav->children, $firstnode, $customchildren);
-            $firstnode = false;
+            $output .= $this->parse_branch_to_html($this->page->settingsnav->children, true, $customchildren);
         }
 
         // Check if there are any children added by code
         if ($customchildren) {
             // Add the custom children
-            $output .= $this->parse_branch_to_html($this->children,$firstnode, false);
+            $output .= $this->parse_branch_to_html($this->children, false, false);
         }
         $output .= "</ul>\n";
         $this->content = $output;
@@ -1958,7 +1955,8 @@ class navbar extends navigation_node {
         $this->keys[] = $key;
         $child = $this->get_by_path($this->keys);
         if ($child!==false) {
-            $child->forceopen = true;
+            // This ensure that the child will be shown
+            $child->make_active();
         }
         return $key;
     }