Merge branch 'wip-MDL-37762-m24' of https://github.com/samhemelryk/moodle into MOODLE_24_STABLE
This commit is contained in:
@@ -3016,6 +3016,7 @@ class navbar extends navigation_node {
|
||||
* @return array
|
||||
*/
|
||||
public function get_items() {
|
||||
global $CFG;
|
||||
$items = array();
|
||||
// Make sure that navigation is initialised
|
||||
if (!$this->has_items()) {
|
||||
@@ -3052,6 +3053,9 @@ class navbar extends navigation_node {
|
||||
if (!$navigationactivenode->mainnavonly) {
|
||||
$items[] = $navigationactivenode;
|
||||
}
|
||||
if (!empty($CFG->navshowcategories) && $navigationactivenode->type === self::TYPE_COURSE && $navigationactivenode->parent->key === 'currentcourse') {
|
||||
$items = array_merge($items, $this->get_course_categories());
|
||||
}
|
||||
$navigationactivenode = $navigationactivenode->parent;
|
||||
}
|
||||
} else if ($navigationactivenode) {
|
||||
@@ -3060,6 +3064,9 @@ class navbar extends navigation_node {
|
||||
if (!$navigationactivenode->mainnavonly) {
|
||||
$items[] = $navigationactivenode;
|
||||
}
|
||||
if (!empty($CFG->navshowcategories) && $navigationactivenode->type === self::TYPE_COURSE && $navigationactivenode->parent->key === 'currentcourse') {
|
||||
$items = array_merge($items, $this->get_course_categories());
|
||||
}
|
||||
$navigationactivenode = $navigationactivenode->parent;
|
||||
}
|
||||
} else if ($settingsactivenode) {
|
||||
@@ -3084,6 +3091,29 @@ class navbar extends navigation_node {
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of categories leading to this course.
|
||||
*
|
||||
* This function is used by {@link navbar::get_items()} to add back the "courses"
|
||||
* node and category chain leading to the current course. Note that this is only ever
|
||||
* called for the current course, so we don't need to bother taking in any parameters.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_course_categories() {
|
||||
$categories = array();
|
||||
$id = $this->page->course->category;
|
||||
while ($id) {
|
||||
$category = get_course_category($id);
|
||||
$url = new moodle_url('/course/category.php', array('id' => $id));
|
||||
$name = format_string($category->name, true, context_coursecat::instance($category->id));
|
||||
$categories[] = navigation_node::create($name, $url, self::TYPE_CATEGORY, null, $id);
|
||||
$id = $category->parent;
|
||||
}
|
||||
$categories[] = $this->page->navigation->get('courses');
|
||||
return $categories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new navigation_node to the navbar, overrides parent::add
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user