Skip to content

Commit

Permalink
MDL-72930 navigation: Remove duplicated navigation boxes.
Browse files Browse the repository at this point in the history
Some pages have settings that really aren't required anymore.
These have been removed and a function has been aded so that other
developers can turn off the navigation overflow if they want.
  • Loading branch information
abgreeve committed Jan 4, 2022
1 parent f56ecc2 commit 0a04ebd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
22 changes: 1 addition & 21 deletions grade/grading/lib.php
Expand Up @@ -453,33 +453,13 @@ public function extend_settings_navigation(settings_navigation $settingsnav, nav
// no money, no funny
return;

} else if (count($areas) == 1) {
} else {
// make just a single node for the management screen
$areatitle = reset($areas);
$areaname = key($areas);
$this->set_area($areaname);
$method = $this->get_active_method();
$managementnode = $modulenode->add(get_string('gradingmanagement', 'core_grading'),
$this->get_management_url(), settings_navigation::TYPE_CUSTOM, null, 'advgrading');
if ($method) {
$controller = $this->get_controller($method);
$controller->extend_settings_navigation($settingsnav, $managementnode);
}

} else {
// make management screen node for each area
$managementnode = $modulenode->add(get_string('gradingmanagement', 'core_grading'),
null, settings_navigation::TYPE_CUSTOM, null, 'advgrading');
foreach ($areas as $areaname => $areatitle) {
$this->set_area($areaname);
$method = $this->get_active_method();
$node = $managementnode->add($areatitle,
$this->get_management_url(), settings_navigation::TYPE_CUSTOM);
if ($method) {
$controller = $this->get_controller($method);
$controller->extend_settings_navigation($settingsnav, $node);
}
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions lib/classes/navigation/views/secondary.php
Expand Up @@ -433,6 +433,11 @@ protected function nodes_match_current_url(navigation_node $node): ?navigation_n
* @return url_select|null The overflow menu data.
*/
public function get_overflow_menu_data(): ?url_select {

if (!$this->page->get_navigation_overflow_state()) {
return null;
}

$activenode = $this->find_active_node();
$incourseadmin = false;

Expand Down
24 changes: 24 additions & 0 deletions lib/pagelib.php
Expand Up @@ -408,6 +408,11 @@ class moodle_page {
*/
protected $_activityheader;

/**
* @var bool The value of displaying the navigation overflow.
*/
protected $_navigationoverflow = true;

/**
* Force the settings menu to be displayed on this page. This will only force the
* settings menu on an activity / resource page that is being displayed on a theme that
Expand Down Expand Up @@ -2258,4 +2263,23 @@ public function set_primary_active_tab(string $navkey): void {
public function get_primary_activate_tab(): ?string {
return $this->_activenodeprimary;
}

/**
* Sets the navigation overflow state. This allows developers to turn off the overflow menu if they perhaps are using
* some other navigation to show settings.
*
* @param bool $state The state of whether to show the navigation overflow.
*/
public function set_navigation_overflow_state(bool $state): void {
$this->_navigationoverflow = $state;
}

/**
* Gets the navigation overflow state.
*
* @return bool The navigation overflow state.
*/
public function get_navigation_overflow_state(): bool {
return $this->_navigationoverflow;
}
}
8 changes: 1 addition & 7 deletions mod/data/lib.php
Expand Up @@ -3633,14 +3633,8 @@ function data_extend_settings_navigation(settings_navigation $settings, navigati

$datanode->add(get_string('fields', 'data'),
new moodle_url('/mod/data/field.php', array('d' => $data->id)));
$templates = $datanode->add(get_string('templates', 'data'),
$datanode->add(get_string('templates', 'data'),
new moodle_url('/mod/data/templates.php', array('d' => $data->id)));

$templatelist = array ('listtemplate', 'singletemplate', 'asearchtemplate', 'addtemplate', 'rsstemplate', 'csstemplate', 'jstemplate');
foreach ($templatelist as $template) {
$templates->add(get_string($template, 'data'), new moodle_url('/mod/data/templates.php', array('d'=>$data->id,'mode'=>$template)));
}

$datanode->add(get_string('presets', 'data'), new moodle_url('/mod/data/preset.php', array('d' => $data->id)));
}

Expand Down

0 comments on commit 0a04ebd

Please sign in to comment.