mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'wip-MDL-37762-m25' of https://github.com/samhemelryk/moodle
This commit is contained in:
commit
23718dade9
@ -2971,6 +2971,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()) {
|
||||
@ -3007,6 +3008,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) {
|
||||
@ -3015,6 +3019,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) {
|
||||
@ -3039,6 +3046,28 @@ 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 = coursecat::get($id);
|
||||
$url = new moodle_url('/course/category.php', array('id' => $id));
|
||||
$categories[] = navigation_node::create($category->get_formatted_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
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user