From ea951c5924f4bdd0f36c51aa2caf4b4cb0ceb28c Mon Sep 17 00:00:00 2001 From: David Scotson Date: Tue, 23 Apr 2013 22:13:45 +0100 Subject: [PATCH] MDL-38979 Add lang menu to empty custommenu Show custom menu even when no custom menu items if lang menu needs to be shown. --- theme/bootstrapbase/renderers/core.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/theme/bootstrapbase/renderers/core.php b/theme/bootstrapbase/renderers/core.php index 056d334df7e..3e6b395b3ce 100644 --- a/theme/bootstrapbase/renderers/core.php +++ b/theme/bootstrapbase/renderers/core.php @@ -67,7 +67,6 @@ class theme_bootstrapbase_core_renderer extends core_renderer { * Overriding the custom_menu function ensures the custom menu is * always shown, even if no menu items are configured in the global * theme settings page. - * We use the sitename as the first menu item. */ public function custom_menu($custommenuitems = '') { global $CFG; @@ -85,25 +84,24 @@ class theme_bootstrapbase_core_renderer extends core_renderer { * This renderer is needed to enable the Bootstrap style navigation. */ protected function render_custom_menu(custom_menu $menu) { - // If the menu has no children return an empty string. - if (!$menu->has_children()) { - return ''; - } + global $CFG; + $addlangmenu = true; $langs = get_string_manager()->get_list_of_translations(); - if ($this->page->course != SITEID and !empty($this->page->course->lang)) { - // Do not show lang menu if language forced. + if (count($langs) < 2 + or empty($CFG->langmenu) + or ($this->page->course != SITEID and !empty($this->page->course->lang))) { $addlangmenu = false; } - if (count($langs) < 2) { - $addlangmenu = false; + + if (!$menu->has_children() && $addlangmenu === false) { + return ''; } if ($addlangmenu) { $language = $menu->add(get_string('language'), new moodle_url('#'), get_string('language'), 10000); foreach ($langs as $langtype => $langname) { - $language->add($langname, - new moodle_url($this->page->url, array('lang' => $langtype)), $langname); + $language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname); } }