MDL-41511 blocks: improved how custom block regions were being rendered.

There is a new theme property 'blockrendermethod' that can be set by the
theme in its config.php and tells Moodle what method it is using to render
blocks in the layout files.
Either blocks, or blocks_for_region.
Then when adding custom block regions to a page content we ensure we use
the same method the theme is using elsewhere.

This is really a hack becuase we (I) didn't properly deprecate
blocks_for_region when I added the blocks method.

Conflicts:
	lib/outputlib.php
This commit is contained in:
Sam Hemelryk
2014-04-06 15:17:42 +12:00
parent 89117976b8
commit a65cbb009c
11 changed files with 78 additions and 9 deletions
+34 -1
View File
@@ -356,6 +356,13 @@ class theme_config {
*/
private $usesvg = null;
/**
* Sets the render method that should be used for rendering custom block regions by scripts such as my/index.php
* Defaults to {@link core_renderer::blocks_for_region()}
* @var string
*/
public $blockrendermethod = null;
/**
* Load the config.php file for a particular theme, and return an instance
* of this class. (That is, this is a factory method.)
@@ -424,7 +431,7 @@ class theme_config {
$configurable = array('parents', 'sheets', 'parents_exclude_sheets', 'plugins_exclude_sheets', 'javascripts', 'javascripts_footer',
'parents_exclude_javascripts', 'layouts', 'enable_dock', 'enablecourseajax', 'supportscssoptimisation',
'rendererfactory', 'csspostprocess', 'editor_sheets', 'rarrow', 'larrow', 'hidefromselector', 'doctype',
'yuicssmodules', 'blockrtlmanipulations');
'yuicssmodules', 'blockrtlmanipulations', 'blockrendermethod');
foreach ($config as $key=>$value) {
if (in_array($key, $configurable)) {
@@ -1642,6 +1649,32 @@ class theme_config {
public function get_theme_name() {
return get_string('pluginname', 'theme_'.$this->name);
}
/**
* Returns the block render method.
*
* It is set by the theme via:
* $THEME->blockrendermethod = '...';
*
* It can be one of two values, blocks or blocks_for_region.
* It should be set to the method being used by the theme layouts.
*
* @return string
*/
public function get_block_render_method() {
if ($this->blockrendermethod) {
// Return the specified block render method.
return $this->blockrendermethod;
}
// Its not explicitly set, check the parent theme configs.
foreach ($this->parent_configs as $config) {
if (isset($config->blockrendermethod)) {
return $config->blockrendermethod;
}
}
// Default it to blocks.
return 'blocks';
}
}
/**