mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-55074 blocks: navigation and settings blocks optional
This is a theme config setting. They are forced on for behat always.
This commit is contained in:
parent
4a3d8169f3
commit
0f73f3ab42
@ -108,6 +108,9 @@ class behat_util extends testing_util {
|
||||
set_config('debug', DEBUG_DEVELOPER);
|
||||
set_config('debugdisplay', 1);
|
||||
|
||||
// Force the navigation and settings blocks, even if the theme has made them optional.
|
||||
set_config('undeletableblocktypes', 'navigation,settings');
|
||||
|
||||
// Disable some settings that are not wanted on test sites.
|
||||
set_config('noemailever', 1);
|
||||
|
||||
|
@ -363,14 +363,20 @@ class block_manager {
|
||||
* @return array names of block types that cannot be added or deleted. E.g. array('navigation','settings').
|
||||
*/
|
||||
public static function get_undeletable_block_types() {
|
||||
global $CFG;
|
||||
global $CFG, $PAGE;
|
||||
$undeletableblocks = false;
|
||||
if (isset($CFG->undeletableblocktypes)) {
|
||||
$undeletableblocks = $CFG->undeletableblocktypes;
|
||||
} else if (isset($PAGE->theme->undeletableblocktypes)) {
|
||||
$undeletableblocks = $PAGE->theme->undeletableblocktypes;
|
||||
}
|
||||
|
||||
if (!isset($CFG->undeletableblocktypes) || (!is_array($CFG->undeletableblocktypes) && !is_string($CFG->undeletableblocktypes))) {
|
||||
if ($undeletableblocks === false) {
|
||||
return array('navigation','settings');
|
||||
} else if (is_string($CFG->undeletableblocktypes)) {
|
||||
return explode(',', $CFG->undeletableblocktypes);
|
||||
} else if (is_string($undeletableblocks)) {
|
||||
return explode(',', $undeletableblocks);
|
||||
} else {
|
||||
return $CFG->undeletableblocktypes;
|
||||
return $undeletableblocks;
|
||||
}
|
||||
}
|
||||
|
||||
@ -711,6 +717,10 @@ class block_manager {
|
||||
}
|
||||
|
||||
public function add_block_at_end_of_default_region($blockname) {
|
||||
if (empty($this->birecordsbyregion)) {
|
||||
// No blocks or block regions exist yet.
|
||||
return;
|
||||
}
|
||||
$defaulregion = $this->get_default_region();
|
||||
|
||||
$lastcurrentblock = end($this->birecordsbyregion[$defaulregion]);
|
||||
@ -947,9 +957,30 @@ class block_manager {
|
||||
* method, before any output is done.
|
||||
*/
|
||||
public function create_all_block_instances() {
|
||||
global $PAGE;
|
||||
|
||||
// If there are any un-removable blocks that were not created - force them.
|
||||
$undeletable = $this->get_undeletable_block_types();
|
||||
foreach ($undeletable as $forced) {
|
||||
if (empty($forced)) {
|
||||
continue;
|
||||
}
|
||||
$found = false;
|
||||
foreach ($this->get_regions() as $region) {
|
||||
foreach($this->birecordsbyregion[$region] as $instance) {
|
||||
if ($instance->blockname == $forced) {
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
$this->add_block_at_end_of_default_region($forced);
|
||||
}
|
||||
}
|
||||
foreach ($this->get_regions() as $region) {
|
||||
$this->ensure_instances_exist($region);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2272,7 +2303,7 @@ function blocks_add_default_system_blocks() {
|
||||
|
||||
$page = new moodle_page();
|
||||
$page->set_context(context_system::instance());
|
||||
$page->blocks->add_blocks(array(BLOCK_POS_LEFT => array('navigation', 'settings')), '*', null, true);
|
||||
$page->blocks->add_blocks(array(BLOCK_POS_LEFT => block_manager::get_undeletable_block_types()), '*', null, true);
|
||||
$page->blocks->add_blocks(array(BLOCK_POS_LEFT => array('admin_bookmarks')), 'admin-*', null, null, 2);
|
||||
|
||||
if ($defaultmypage = $DB->get_record('my_pages', array('userid' => null, 'name' => '__default', 'private' => 1))) {
|
||||
|
@ -3700,25 +3700,26 @@ class flat_navigation extends navigation_node_collection {
|
||||
|
||||
$course = $PAGE->course;
|
||||
|
||||
$PAGE->navigation->build_flat_navigation_list($this);
|
||||
$this->page->navigation->initialise();
|
||||
$this->page->navigation->build_flat_navigation_list($this);
|
||||
|
||||
// First walk the nav tree looking for "flat_navigation" nodes.
|
||||
if ($course->id > 1) {
|
||||
// It's a real course.
|
||||
// 'dh' is an unused param used to give this node a different url to the default.
|
||||
// This is so we don't have 2 nodes in the flat have with the same url (both would be highlighted).
|
||||
// 'dh' means "don't highlight".
|
||||
$url = new moodle_url('/course/view.php', array('id' => $course->id, 'dh' => 1));
|
||||
$url = new moodle_url('/course/view.php', array('id' => $course->id));
|
||||
$flat = new flat_navigation_node(navigation_node::create($course->shortname, $url), 0);
|
||||
$flat->key = 'coursehome';
|
||||
$flat->set_showdivider(true);
|
||||
$this->add($flat);
|
||||
|
||||
$coursenode = $PAGE->navigation->find_active_node();
|
||||
while ($coursenode->type != navigation_node::TYPE_COURSE) {
|
||||
$coursenode = $coursenode->parent;
|
||||
}
|
||||
if ($coursenode) {
|
||||
foreach ($coursenode->children as $child) {
|
||||
if ($child->action) {
|
||||
$flat = new flat_navigation_node($child, 1);
|
||||
$flat = new flat_navigation_node($child, 0);
|
||||
$this->add($flat);
|
||||
}
|
||||
}
|
||||
|
@ -344,6 +344,12 @@ class theme_config {
|
||||
*/
|
||||
public $doctype = 'html5';
|
||||
|
||||
/**
|
||||
* @var string undeletableblocktypes If set to a string, will list the block types that cannot be deleted. Defaults to
|
||||
* navigation and settings.
|
||||
*/
|
||||
public $undeletableblocktypes = false;
|
||||
|
||||
//==Following properties are not configurable from theme config.php==
|
||||
|
||||
/**
|
||||
@ -524,7 +530,7 @@ class theme_config {
|
||||
$configurable = array(
|
||||
'parents', 'sheets', 'parents_exclude_sheets', 'plugins_exclude_sheets',
|
||||
'javascripts', 'javascripts_footer', 'parents_exclude_javascripts',
|
||||
'layouts', 'enable_dock', 'enablecourseajax',
|
||||
'layouts', 'enable_dock', 'enablecourseajax', 'undeletableblocktypes',
|
||||
'rendererfactory', 'csspostprocess', 'editor_sheets', 'rarrow', 'larrow', 'uarrow', 'darrow',
|
||||
'hidefromselector', 'doctype', 'yuicssmodules', 'blockrtlmanipulations',
|
||||
'lessfile', 'extralesscallback', 'lessvariablescallback', 'blockrendermethod',
|
||||
|
@ -149,3 +149,4 @@ $THEME->extrascsscallback = 'theme_boost_get_extra_scss';
|
||||
$THEME->prescsscallback = 'theme_boost_get_pre_scss';
|
||||
$THEME->yuicssmodules = array();
|
||||
$THEME->rendererfactory = 'theme_overridden_renderer_factory';
|
||||
$THEME->undeletableblocktypes = '';
|
||||
|
@ -3,6 +3,7 @@ information provided here is intended especially for theme designer.
|
||||
|
||||
=== 3.2 ===
|
||||
|
||||
* A new theme config 'undeletableblocktypes' allows a theme to define which blocks are deletable.
|
||||
* A new core setting now enables admins to upload the logos of their site. Using the
|
||||
following methods, themers can instantly support branding logos without the need
|
||||
to implement specific theme settings:
|
||||
|
Loading…
x
Reference in New Issue
Block a user