mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-62142-master' of git://github.com/damyon/moodle
This commit is contained in:
commit
2baf5722ab
@ -430,15 +430,16 @@ class navigation_node implements renderable {
|
||||
*
|
||||
* @param flat_navigation $nodes List of the found flat navigation nodes.
|
||||
* @param boolean $showdivider Show a divider before the first node.
|
||||
* @param string $label A label for the collection of navigation links.
|
||||
*/
|
||||
public function build_flat_navigation_list(flat_navigation $nodes, $showdivider = false) {
|
||||
public function build_flat_navigation_list(flat_navigation $nodes, $showdivider = false, $label = '') {
|
||||
if ($this->showinflatnavigation) {
|
||||
$indent = 0;
|
||||
if ($this->type == self::TYPE_COURSE || $this->key === self::COURSE_INDEX_PAGE) {
|
||||
$indent = 1;
|
||||
}
|
||||
$flat = new flat_navigation_node($this, $indent);
|
||||
$flat->set_showdivider($showdivider);
|
||||
$flat->set_showdivider($showdivider, $label);
|
||||
$nodes->add($flat);
|
||||
}
|
||||
foreach ($this->children as $child) {
|
||||
@ -913,6 +914,12 @@ class navigation_node_collection implements IteratorAggregate, Countable {
|
||||
*/
|
||||
protected $count = 0;
|
||||
|
||||
/**
|
||||
* Label for collection of nodes.
|
||||
* @var string
|
||||
*/
|
||||
protected $collectionlabel = '';
|
||||
|
||||
/**
|
||||
* Adds a navigation node to the collection
|
||||
*
|
||||
@ -988,6 +995,24 @@ class navigation_node_collection implements IteratorAggregate, Countable {
|
||||
return $keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a label for this collection.
|
||||
*
|
||||
* @param string $label
|
||||
*/
|
||||
public function set_collectionlabel($label) {
|
||||
$this->collectionlabel = $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a label for this collection.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_collectionlabel() {
|
||||
return $this->collectionlabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a node from this collection.
|
||||
*
|
||||
@ -3770,6 +3795,9 @@ class flat_navigation_node extends navigation_node {
|
||||
/** @var $showdivider bool Show a divider before this element */
|
||||
private $showdivider = false;
|
||||
|
||||
/** @var $collectionlabel string Label for a group of nodes */
|
||||
private $collectionlabel = '';
|
||||
|
||||
/**
|
||||
* A proxy constructor
|
||||
*
|
||||
@ -3791,6 +3819,31 @@ class flat_navigation_node extends navigation_node {
|
||||
$this->indent = $indent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter, a label is required for a flat navigation node that shows a divider.
|
||||
*
|
||||
* @param string $label
|
||||
*/
|
||||
public function set_collectionlabel($label) {
|
||||
$this->collectionlabel = $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter, get the label for this flat_navigation node, or it's parent if it doesn't have one.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_collectionlabel() {
|
||||
if (!empty($this->collectionlabel)) {
|
||||
return $this->collectionlabel;
|
||||
}
|
||||
if ($this->parent && ($this->parent instanceof flat_navigation_node || $this->parent instanceof flat_navigation)) {
|
||||
return $this->parent->get_collectionlabel();
|
||||
}
|
||||
debugging('Navigation region requires a label', DEBUG_DEVELOPER);
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this node represent a course section link.
|
||||
* @return boolean
|
||||
@ -3828,9 +3881,15 @@ class flat_navigation_node extends navigation_node {
|
||||
/**
|
||||
* Setter for "showdivider"
|
||||
* @param $val boolean
|
||||
* @param $label string Label for the group of nodes
|
||||
*/
|
||||
public function set_showdivider($val) {
|
||||
public function set_showdivider($val, $label = '') {
|
||||
$this->showdivider = $val;
|
||||
if ($this->showdivider && empty($label)) {
|
||||
debugging('Navigation region requires a label', DEBUG_DEVELOPER);
|
||||
} else {
|
||||
$this->set_collectionlabel($label);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3848,7 +3907,6 @@ class flat_navigation_node extends navigation_node {
|
||||
public function set_indent($val) {
|
||||
$this->indent = $val;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3903,6 +3961,7 @@ class flat_navigation extends navigation_node_collection {
|
||||
format_string($course->fullname, true, array('context' => $coursecontext));
|
||||
|
||||
$flat = new flat_navigation_node(navigation_node::create($coursename, $url), 0);
|
||||
$flat->set_collectionlabel($coursename);
|
||||
$flat->key = 'coursehome';
|
||||
$flat->icon = new pix_icon('i/course', '');
|
||||
|
||||
@ -3930,9 +3989,9 @@ class flat_navigation extends navigation_node_collection {
|
||||
}
|
||||
}
|
||||
|
||||
$this->page->navigation->build_flat_navigation_list($this, true);
|
||||
$this->page->navigation->build_flat_navigation_list($this, true, get_string('site'));
|
||||
} else {
|
||||
$this->page->navigation->build_flat_navigation_list($this, false);
|
||||
$this->page->navigation->build_flat_navigation_list($this, false, get_string('site'));
|
||||
}
|
||||
|
||||
$admin = $PAGE->settingsnav->find('siteadministration', navigation_node::TYPE_SITE_ADMIN);
|
||||
@ -3942,7 +4001,7 @@ class flat_navigation extends navigation_node_collection {
|
||||
}
|
||||
if ($admin) {
|
||||
$flat = new flat_navigation_node($admin, 0);
|
||||
$flat->set_showdivider(true);
|
||||
$flat->set_showdivider(true, get_string('sitesettings'));
|
||||
$flat->key = 'sitesettings';
|
||||
$flat->icon = new pix_icon('t/preferences', '');
|
||||
$this->add($flat);
|
||||
@ -3956,7 +4015,7 @@ class flat_navigation extends navigation_node_collection {
|
||||
$url = new moodle_url($PAGE->url, ['bui_addblock' => '', 'sesskey' => sesskey()]);
|
||||
$addablock = navigation_node::create(get_string('addblock'), $url);
|
||||
$flat = new flat_navigation_node($addablock, 0);
|
||||
$flat->set_showdivider(true);
|
||||
$flat->set_showdivider(true, get_string('blocksaddedit'));
|
||||
$flat->key = 'addblock';
|
||||
$flat->icon = new pix_icon('i/addblock', '');
|
||||
$this->add($flat);
|
||||
@ -3969,6 +4028,26 @@ class flat_navigation extends navigation_node_collection {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override the parent so we can set a label for this collection if it has not been set yet.
|
||||
*
|
||||
* @param navigation_node $node Node to add
|
||||
* @param string $beforekey If specified, adds before a node with this key,
|
||||
* otherwise adds at end
|
||||
* @return navigation_node Added node
|
||||
*/
|
||||
public function add(navigation_node $node, $beforekey=null) {
|
||||
$result = parent::add($node, $beforekey);
|
||||
// Extend the parent to get a name for the collection of nodes if required.
|
||||
if (empty($this->collectionlabel)) {
|
||||
if ($node instanceof flat_navigation_node) {
|
||||
$this->set_collectionlabel($node->get_collectionlabel());
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,6 +3,7 @@ information provided here is intended especially for developers.
|
||||
|
||||
=== 3.7 ===
|
||||
|
||||
* Nodes in the navigation api can have labels for each group. See set/get_collectionlabel().
|
||||
* The method core_user::is_real_user() now returns false for userid = 0 parameter
|
||||
* 'mform1' dependencies (in themes, js...) will stop working because a randomly generated string has been added to the id
|
||||
attribute on forms to avoid collisions in forms loaded in AJAX requests.
|
||||
|
@ -51,6 +51,8 @@ $templatecontext = [
|
||||
'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu)
|
||||
];
|
||||
|
||||
$templatecontext['flatnavigation'] = $PAGE->flatnav;
|
||||
$nav = $PAGE->flatnav;
|
||||
$templatecontext['flatnavigation'] = $nav;
|
||||
$templatecontext['firstcollectionlabel'] = $nav->get_collectionlabel();
|
||||
echo $OUTPUT->render_from_template('theme_boost/columns2', $templatecontext);
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
||||
<div id="page" class="container-fluid">
|
||||
<div id="page-content" class="row pb-3">
|
||||
<div id="region-main-box" class="col-12">
|
||||
<section id="region-main">
|
||||
<section id="region-main" aria-label="{{#str}}content{{/str}}">
|
||||
{{{ output.course_content_header }}}
|
||||
{{{ output.main_content }}}
|
||||
{{{ output.activity_navigation }}}
|
||||
|
@ -68,7 +68,7 @@
|
||||
<div> {{{ output.region_main_settings_menu }}} </div>
|
||||
</div>
|
||||
{{/hasregionmainsettingsmenu}}
|
||||
<section id="region-main" {{#hasblocks}}class="has-blocks mb-3"{{/hasblocks}}>
|
||||
<section id="region-main" {{#hasblocks}}class="has-blocks mb-3"{{/hasblocks}} aria-label="{{#str}}content{{/str}}">
|
||||
|
||||
{{#hasregionmainsettingsmenu}}
|
||||
<div class="region_main_settings_menu_proxy"></div>
|
||||
@ -80,7 +80,7 @@
|
||||
|
||||
</section>
|
||||
{{#hasblocks}}
|
||||
<section data-region="blocks-column" class="d-print-none">
|
||||
<section data-region="blocks-column" class="d-print-none" aria-label="{{#str}}blocks{{/str}}">
|
||||
{{{ sidepreblocks }}}
|
||||
</section>
|
||||
{{/hasblocks}}
|
||||
|
@ -63,7 +63,7 @@
|
||||
]
|
||||
}
|
||||
}}
|
||||
<nav role="navigation">
|
||||
<nav role="navigation" aria-label="{{#str}}breadcrumb, access{{/str}}">
|
||||
<ol class="breadcrumb">
|
||||
{{#get_items}}
|
||||
{{#has_action}}
|
||||
|
@ -55,11 +55,11 @@
|
||||
]
|
||||
}
|
||||
}}
|
||||
<nav class="list-group">
|
||||
<nav class="list-group" aria-label="{{firstcollectionlabel}}">
|
||||
{{# flatnavigation }}
|
||||
{{#showdivider}}
|
||||
</nav>
|
||||
<nav class="list-group m-t-1">
|
||||
<nav class="list-group m-t-1" aria-label="{{get_collectionlabel}}">
|
||||
{{/showdivider}}
|
||||
{{#action}}
|
||||
<a class="list-group-item list-group-item-action {{#isactive}}active{{/isactive}}" href="{{{action}}}" data-key="{{key}}" data-isexpandable="{{isexpandable}}" data-indent="{{get_indent}}" data-showdivider="{{showdivider}}" data-type="{{type}}" data-nodetype="{{nodetype}}" data-collapse="{{collapse}}" data-forceopen="{{forceopen}}" data-isactive="{{isactive}}" data-hidden="{{hidden}}" data-preceedwithhr="{{preceedwithhr}}" {{#parent.key}}data-parent-key="{{.}}"{{/parent.key}}>
|
||||
|
@ -28,7 +28,7 @@
|
||||
{{{ output.login_info }}}
|
||||
<div class="tool_usertours-resettourcontainer"></div>
|
||||
{{{ output.home_link }}}
|
||||
<nav class="nav navbar-nav d-md-none">
|
||||
<nav class="nav navbar-nav d-md-none" aria-label="{{#str}}custommenu, admin{{/str}}">
|
||||
{{# output.custom_menu_flat }}
|
||||
<ul class="list-unstyled pt-3">
|
||||
{{> theme_boost/custom_menu_footer }}
|
||||
@ -38,4 +38,4 @@
|
||||
{{{ output.standard_footer_html }}}
|
||||
{{{ output.standard_end_of_body_html }}}
|
||||
</div>
|
||||
</footer>
|
||||
</footer>
|
||||
|
@ -40,7 +40,7 @@
|
||||
<div id="page" class="container-fluid mt-0">
|
||||
<div id="page-content" class="row">
|
||||
<div id="region-main-box" class="col-12">
|
||||
<section id="region-main" class="col-12">
|
||||
<section id="region-main" class="col-12" aria-label="{{#str}}content{{/str}}">
|
||||
{{{ output.course_content_header }}}
|
||||
{{{ output.main_content }}}
|
||||
{{{ output.course_content_footer }}}
|
||||
|
@ -56,7 +56,7 @@
|
||||
</div>
|
||||
|
||||
<div id="page-content" class="row">
|
||||
<section id="region-main" class="col-12">
|
||||
<section id="region-main" class="col-12" aria-label="{{#str}}content{{/str}}">
|
||||
{{{ output.main_content }}}
|
||||
</section>
|
||||
</div>
|
||||
|
@ -17,7 +17,7 @@
|
||||
{{!
|
||||
secure navbar.
|
||||
}}
|
||||
<nav class="fixed-top navbar navbar-light bg-white navbar-expand moodle-has-zindex">
|
||||
<nav class="fixed-top navbar navbar-light bg-white navbar-expand moodle-has-zindex" aria-label="{{#str}}navigation{{/str}}">
|
||||
|
||||
<a href="{{{ config.wwwroot }}}" class="navbar-brand {{# output.should_display_navbar_logo }}has-logo{{/ output.should_display_navbar_logo }}
|
||||
{{^ output.should_display_navbar_logo }}
|
||||
@ -37,4 +37,4 @@
|
||||
{{{ output.secure_login_info }}}
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</nav>
|
||||
|
@ -59,7 +59,7 @@
|
||||
|
||||
<div id="page-content" class="row">
|
||||
<div id="region-main-box" class="col-12">
|
||||
<section id="region-main" {{#hasblocks}}class="has-blocks"{{/hasblocks}}>
|
||||
<section id="region-main" {{#hasblocks}}class="has-blocks"{{/hasblocks}} aria-label="{{#str}}content{{/str}}">
|
||||
|
||||
{{{ output.course_content_header }}}
|
||||
{{{ output.main_content }}}
|
||||
@ -67,7 +67,7 @@
|
||||
|
||||
</section>
|
||||
{{#hasblocks}}
|
||||
<section data-region="blocks-column">
|
||||
<section data-region="blocks-column" aria-label="{{#str}}blocks{{/str}}">
|
||||
{{{ sidepreblocks }}}
|
||||
</section>
|
||||
{{/hasblocks}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user