MDL-56586 blocks: allow theme to manage "Add a block" select

This commit is contained in:
Marina Glancy 2016-11-18 17:27:38 +08:00
parent 692c1bf345
commit b11916d3e7
8 changed files with 140 additions and 18 deletions

View file

@ -3764,6 +3764,19 @@ class flat_navigation extends navigation_node_collection {
$flat->key = 'sitesettings';
$this->add($flat);
}
// Add-a-block in editing mode.
if (isset($this->page->theme->addblockposition) &&
$this->page->theme->addblockposition == BLOCK_ADDBLOCK_POSITION_FLATNAV &&
$PAGE->user_is_editing() && $PAGE->user_can_edit_blocks() &&
$PAGE->blocks->get_addable_blocks()) {
$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->key = 'addblock';
$this->add($flat);
}
}
}