Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
Fix #825.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Jun 2, 2017
1 parent 1a45e0d commit 20dc37e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
New in 3.3.0.2
==============
- FIX: Issue #824: Header area/slide show/bullet-menu "on top".
- FIX: Issue #825: Missing region_main_settings_menu() when using flat navigation.
- FIX: Issue #827: Flat navigation does not show if blocks were previously docked.
- FIX: Double section summary editing cog.
- NEW: Update to flat navigation to be more similar to Boost markup. Initially for the Grid format.
Expand Down
77 changes: 76 additions & 1 deletion classes/output/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,80 @@ public function context_header_settings_menu() {
}
}

/**
* This is an optional menu that can be added to a layout by a theme. It contains the
* menu for the most specific thing from the settings block. E.g. Module administration.
*
* @return string
*/
public function region_main_settings_menu() {
$context = $this->page->context;
$menu = null;

if ($context->contextlevel == CONTEXT_MODULE) {

$this->page->navigation->initialise();
$node = $this->page->navigation->find_active_node();
$buildmenu = false;
// If the settings menu has been forced then show the menu.
if ($this->page->is_settings_menu_forced()) {
$buildmenu = true;
} else if (!empty($node) && ($node->type == navigation_node::TYPE_ACTIVITY ||
$node->type == navigation_node::TYPE_RESOURCE)) {

$items = $this->page->navbar->get_items();
$navbarnode = end($items);
// We only want to show the menu on the first page of the activity. This means
// the breadcrumb has no additional nodes.
if ($navbarnode && ($navbarnode->key === $node->key && $navbarnode->type == $node->type)) {
$buildmenu = true;
}
}
if ($buildmenu) {
// Get the course admin node from the settings navigation.
$node = $this->page->settingsnav->find('modulesettings', navigation_node::TYPE_SETTING);
if ($node) {
// Build an action menu based on the visible nodes from this navigation tree.
$menu = new action_menu();
$title = get_string('modulesettingstitle', 'theme_essential');
$this->build_action_menu_from_navigation($menu, $node);
}
}

} else if ($context->contextlevel == CONTEXT_COURSECAT) {
// For course category context, show category settings menu, if we're on the course category page.
if ($this->page->pagetype === 'course-index-category') {
$node = $this->page->settingsnav->find('categorysettings', navigation_node::TYPE_CONTAINER);
if ($node) {
// Build an action menu based on the visible nodes from this navigation tree.
$menu = new action_menu();
$title = get_string('coursecategorysettingstitle', 'theme_essential');
$this->build_action_menu_from_navigation($menu, $node);
}
}

} else {
$items = $this->page->navbar->get_items();
$navbarnode = end($items);

if ($navbarnode && ($navbarnode->key === 'participants')) {
$node = $this->page->settingsnav->find('users', navigation_node::TYPE_CONTAINER);
if ($node) {
// Build an action menu based on the visible nodes from this navigation tree.
$menu = new action_menu();
$title = get_string('participants');
$this->build_action_menu_from_navigation($menu, $node);
}

}
}
if ($menu) {
return $this->render_navbar_action_menu($menu, $title, 'i/settings');
} else {
return '';
}
}

/**
* Renders an action menu component.
*
Expand All @@ -473,13 +547,14 @@ public function context_header_settings_menu() {
* @param string $title Menu title.
* @return string HTML
*/
protected function render_navbar_action_menu(action_menu $menu, $title) {
protected function render_navbar_action_menu(action_menu $menu, $title, $icon_key = 't/edit_menu') {
$context = $menu->export_for_template($this);
$context->classes .= ' navbarrightitem';
$context->primary->caret = $this->getfontawesomemarkup('caret-right');
$context->primary->classes .= ' nav';
$context->primary->title = $title;
$context->primary->icon['title'] = $context->primary->title;
$context->primary->icon['key'] = $icon_key;
$context->primary->menutrigger = true;
return $this->render_from_template('theme_essential/navbar_action_menu', $context);
}
Expand Down
2 changes: 2 additions & 0 deletions lang/en/theme_essential.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@
$string['flatnavigation'] = 'Enable flat navigation.';
$string['flatnavigationdesc'] = 'If enabled flat navigation will be used instead of the navigation and settings blocks.';
$string['coursesettingstitle'] = 'Course settings';
$string['coursecategorysettingstitle'] = 'Course category settings';
$string['frontpagesettingstitle'] = 'Frontpage settings';
$string['modulesettingstitle'] = 'Module settings';
$string['usersettingstitle'] = 'User settings';

$string['pagebackground'] = 'Page background image';
Expand Down
1 change: 1 addition & 0 deletions layout/tiles/navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<?php echo $OUTPUT->custom_menu_goto_bottom(); ?>
</div>
<?php echo $OUTPUT->context_header_settings_menu(); ?>
<?php echo $OUTPUT->region_main_settings_menu(); ?>
<div id="custom_menu_editing" class="navbarrightitem">
<?php echo $OUTPUT->custom_menu_editing(); ?>
</div>
Expand Down

0 comments on commit 20dc37e

Please sign in to comment.