Skip to content

Commit

Permalink
navigation MDL-25578 Fixed up navbar when viewing categories.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Dec 8, 2010
1 parent 668c450 commit afc45eb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
13 changes: 9 additions & 4 deletions course/category.php
Expand Up @@ -31,7 +31,8 @@
if ($perpage) { if ($perpage) {
$urlparams['perpage'] = $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; $context = $PAGE->context;
$category = $PAGE->category; $category = $PAGE->category;


Expand Down Expand Up @@ -161,11 +162,15 @@
require_once($CFG->libdir . '/adminlib.php'); require_once($CFG->libdir . '/adminlib.php');
admin_externalpage_setup('coursemgmt', '', $urlparams, $CFG->wwwroot . '/course/category.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 $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(); echo $OUTPUT->header();
} else { } 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_title("$site->shortname: $category->name");
$PAGE->set_heading($site->fullname); $PAGE->set_heading($site->fullname);
$PAGE->set_button(print_course_search('', true, 'navbar')); $PAGE->set_button(print_course_search('', true, 'navbar'));
Expand Down
15 changes: 12 additions & 3 deletions lib/adminlib.php
Expand Up @@ -5436,6 +5436,8 @@ public function search($query) {
* *
* This function must be called on each admin page before other code. * This function must be called on each admin page before other code.
* *
* @global moodle_page $PAGE
*
* @param string $section name of page * @param string $section name of page
* @param string $extrabutton extra HTML that is added after the blocks editing on/off button. * @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 * @param array $extraurlparams an array paramname => paramvalue, or parameters that need to be
Expand Down Expand Up @@ -5482,9 +5484,6 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
$actualurl = $extpage->url; $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); $PAGE->set_url($actualurl, $extraurlparams);
if (strpos($PAGE->pagetype, 'admin-') !== 0) { if (strpos($PAGE->pagetype, 'admin-') !== 0) {
$PAGE->set_pagetype('admin-' . $PAGE->pagetype); $PAGE->set_pagetype('admin-' . $PAGE->pagetype);
Expand All @@ -5500,6 +5499,16 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
$PAGE->set_cacheable(false); $PAGE->set_cacheable(false);
return; 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. // Normal case.
$adminediting = optional_param('adminedit', -1, PARAM_BOOL); $adminediting = optional_param('adminedit', -1, PARAM_BOOL);
Expand Down
4 changes: 4 additions & 0 deletions lib/navigationlib.php
Expand Up @@ -963,9 +963,13 @@ public function initialise() {
// Next load context specific content into the navigation // Next load context specific content into the navigation
switch ($this->page->context->contextlevel) { switch ($this->page->context->contextlevel) {
case CONTEXT_SYSTEM : case CONTEXT_SYSTEM :
// This has already been loaded we just need to map the variable
$coursenode = $frontpagecourse;
break;
case CONTEXT_COURSECAT : case CONTEXT_COURSECAT :
// This has already been loaded we just need to map the variable // This has already been loaded we just need to map the variable
$coursenode = $frontpagecourse; $coursenode = $frontpagecourse;
$this->load_all_categories($this->page->context->instanceid);
break; break;
case CONTEXT_BLOCK : case CONTEXT_BLOCK :
case CONTEXT_COURSE : case CONTEXT_COURSE :
Expand Down

0 comments on commit afc45eb

Please sign in to comment.