MDL-74033 theme_boost: Ability to remove primary nav items in boost

This commit is contained in:
Shamim Rezaie 2022-03-07 18:43:07 +11:00
parent 1d99ba19a2
commit c6a74d4752
3 changed files with 29 additions and 9 deletions

View File

@ -38,27 +38,44 @@ class primary extends view {
}
$this->id = 'primary_navigation';
$showhomenode = empty($this->page->theme->removedprimarynavitems) ||
!in_array('home', $this->page->theme->removedprimarynavitems);
// We do not need to change the text for the home/dashboard depending on the set homepage.
$sitehome = $this->add(get_string('home'), new \moodle_url('/'), self::TYPE_SYSTEM,
null, 'home', new \pix_icon('i/home', ''));
if ($showhomenode) {
$sitehome = $this->add(get_string('home'), new \moodle_url('/'), self::TYPE_SYSTEM,
null, 'home', new \pix_icon('i/home', ''));
}
if (isloggedin() ) {
if (!isguestuser()) {
$homepage = get_home_page();
if ($homepage == HOMEPAGE_MY || $homepage == HOMEPAGE_MYCOURSES) {
// We need to stop automatic redirection.
$sitehome->action->param('redirect', '0');
if ($showhomenode) {
$sitehome->action->param('redirect', '0');
}
}
// Add the dashboard link.
$this->add(get_string('myhome'), new \moodle_url('/my/'),
self::TYPE_SETTING, null, 'myhome', new \pix_icon('i/dashboard', ''));
$showmyhomenode = empty($this->page->theme->removedprimarynavitems) ||
!in_array('myhome', $this->page->theme->removedprimarynavitems);
if ($showmyhomenode) {
$this->add(get_string('myhome'), new \moodle_url('/my/'),
self::TYPE_SETTING, null, 'myhome', new \pix_icon('i/dashboard', ''));
}
}
// Add the mycourses link.
$this->add(get_string('mycourses'), new \moodle_url('/my/courses.php'), self::TYPE_ROOTNODE, null, 'courses');
$showcoursesnode = empty($this->page->theme->removedprimarynavitems) ||
!in_array('courses', $this->page->theme->removedprimarynavitems);
if ($showcoursesnode) {
$this->add(get_string('mycourses'), new \moodle_url('/my/courses.php'), self::TYPE_ROOTNODE, null, 'courses');
}
}
if ($node = $this->get_site_admin_node()) {
$showsiteadminnode = empty($this->page->theme->removedprimarynavitems) ||
!in_array('siteadminnode', $this->page->theme->removedprimarynavitems);
if ($showsiteadminnode && $node = $this->get_site_admin_node()) {
// We don't need everything from the node just the initial link.
$this->add($node->text, $node->action(), self::TYPE_SITE_ADMIN, null, 'siteadminnode', $node->icon);
}

View File

@ -753,14 +753,16 @@ class theme_config {
$baseconfig = $config;
}
$configurable = array(
$configurable = [
'parents', 'sheets', 'parents_exclude_sheets', 'plugins_exclude_sheets', 'usefallback',
'javascripts', 'javascripts_footer', 'parents_exclude_javascripts',
'layouts', 'enablecourseajax', 'requiredblocks',
'rendererfactory', 'csspostprocess', 'editor_sheets', 'editor_scss', 'rarrow', 'larrow', 'uarrow', 'darrow',
'hidefromselector', 'doctype', 'yuicssmodules', 'blockrtlmanipulations', 'blockrendermethod',
'scss', 'extrascsscallback', 'prescsscallback', 'csstreepostprocessor', 'addblockposition',
'iconsystem', 'precompiledcsscallback', 'haseditswitch', 'usescourseindex', 'activityheaderconfig');
'iconsystem', 'precompiledcsscallback', 'haseditswitch', 'usescourseindex', 'activityheaderconfig',
'removedprimarynavitems',
];
foreach ($config as $key=>$value) {
if (in_array($key, $configurable)) {

View File

@ -2,6 +2,7 @@ This files describes API changes in /theme/* themes,
information provided here is intended especially for theme designer.
=== 4.0 ===
* A new theme config 'removedprimarynavitems' allows a theme to customise primary navigation by specifying the list of items to remove.
* A new theme config 'usescourseindex' allows a theme to specify whether it implements and uses course index.
* A new theme setting 'unaddableblocks' allows admins to define the blocks that won't be displayed in the "Add a block" list.