Browse files

navigation MDL-25578 Fixed up navbar when viewing categories.

  • Loading branch information...
1 parent 668c450 commit afc45eb16021463beb6dfd79c6eabb4e80a5f33c Sam Hemelryk committed Dec 8, 2010
Showing with 25 additions and 7 deletions.
  1. +9 −4 course/category.php
  2. +12 −3 lib/adminlib.php
  3. +4 −0 lib/navigationlib.php
View
13 course/category.php
@@ -31,7 +31,8 @@
if ($perpage) {
$urlparams['perpage'] = $perpage;
}
- $PAGE->set_url('/course/category.php', $urlparams);
+ $PAGE->set_url(new moodle_url('/course/category.php', array('id' => $id)));
+ navigation_node::override_active_url($PAGE->url);
$context = $PAGE->context;
$category = $PAGE->category;
@@ -161,11 +162,15 @@
require_once($CFG->libdir . '/adminlib.php');
admin_externalpage_setup('coursemgmt', '', $urlparams, $CFG->wwwroot . '/course/category.php');
$PAGE->set_context($context); // Ensure that we are actually showing blocks etc for the cat context
+
+ $settingsnode = $PAGE->settingsnav->find_active_node();
+ if ($settingsnode) {
+ $settingsnode->make_inactive();
+ $settingsnode->force_open();
+ $PAGE->navbar->add($settingsnode->text, $settingsnode->action);
+ }
echo $OUTPUT->header();
} else {
- $PAGE->navbar->add($strcategories, new moodle_url('/course/index.php'));
- $PAGE->navbar->add($category->name);
- $PAGE->navbar->add($strcourses);
$PAGE->set_title("$site->shortname: $category->name");
$PAGE->set_heading($site->fullname);
$PAGE->set_button(print_course_search('', true, 'navbar'));
View
15 lib/adminlib.php
@@ -5436,6 +5436,8 @@ public function search($query) {
*
* This function must be called on each admin page before other code.
*
+ * @global moodle_page $PAGE
+ *
* @param string $section name of page
* @param string $extrabutton extra HTML that is added after the blocks editing on/off button.
* @param array $extraurlparams an array paramname => paramvalue, or parameters that need to be
@@ -5482,9 +5484,6 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
$actualurl = $extpage->url;
}
- $extraurlparams = (array)$extraurlparams;
- $extraurlparams['section'] = $section; // TODO: this is an ugly hack for navigation that must be eliminated!
-
$PAGE->set_url($actualurl, $extraurlparams);
if (strpos($PAGE->pagetype, 'admin-') !== 0) {
$PAGE->set_pagetype('admin-' . $PAGE->pagetype);
@@ -5500,6 +5499,16 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
$PAGE->set_cacheable(false);
return;
}
+
+ // Locate the current item on the navigation and make it active when found.
+ $path = $extpage->path;
+ $node = $PAGE->settingsnav;
+ while ($node && count($path) > 0) {
+ $node = $node->get(array_pop($path));
+ }
+ if ($node) {
+ $node->make_active();
+ }
// Normal case.
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
View
4 lib/navigationlib.php
@@ -963,9 +963,13 @@ public function initialise() {
// Next load context specific content into the navigation
switch ($this->page->context->contextlevel) {
case CONTEXT_SYSTEM :
+ // This has already been loaded we just need to map the variable
+ $coursenode = $frontpagecourse;
+ break;
case CONTEXT_COURSECAT :
// This has already been loaded we just need to map the variable
$coursenode = $frontpagecourse;
+ $this->load_all_categories($this->page->context->instanceid);
break;
case CONTEXT_BLOCK :
case CONTEXT_COURSE :

0 comments on commit afc45eb

Please sign in to comment.