MDL-39871 themes: can now specify regions to swap when using rtl langs

Conflicts:
	lib/pagelib.php
This commit is contained in:
Sam Hemelryk
2013-06-10 09:31:05 +12:00
parent ddf1b0741d
commit d89fbe0285
3 changed files with 40 additions and 1 deletions
+9 -1
View File
@@ -325,6 +325,14 @@ class theme_config {
*/
public $yuicssmodules = array('cssreset', 'cssfonts', 'cssgrids', 'cssbase');
/**
* An associative array of block manipulations that should be made if the user is using an rtl language.
* The key is the original block region, and the value is the block region to change to.
* This is used when displaying blocks for regions only.
* @var array
*/
public $blockrtlmanipulations = array();
/**
* @var renderer_factory Instance of the renderer_factory implementation
* we are using. Implementation detail.
@@ -418,7 +426,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');
'yuicssmodules', 'blockrtlmanipulations');
foreach ($config as $key=>$value) {
if (in_array($key, $configurable)) {
+1
View File
@@ -1228,6 +1228,7 @@ class core_renderer extends renderer_base {
* @return string the HTML to be output.
*/
public function blocks_for_region($region) {
$region = $this->page->apply_theme_region_manipulations($region);
$blockcontents = $this->page->blocks->get_content_for_region($region, $this);
$blocks = $this->page->blocks->get_blocks_for_region($region);
$lastblock = null;
+30
View File
@@ -638,6 +638,22 @@ class moodle_page {
return $this->_theme;
}
/**
* Returns an array of minipulations or false if there are none to make.
*
* @since 2.5.1 2.6
* @return bool|array
*/
protected function magic_get_blockmanipulations() {
if (!right_to_left()) {
return false;
}
if (is_null($this->_theme)) {
$this->initialise_theme_and_output();
}
return $this->_theme->blockrtlmanipulations;
}
/**
* Please do not call this method directly, use the ->devicetypeinuse syntax. {@link moodle_page::__get()}.
* @return string The device type being used.
@@ -1826,4 +1842,18 @@ class moodle_page {
public function set_popup_notification_allowed($allowed) {
$this->_popup_notification_allowed = $allowed;
}
/**
* Returns the block region having made any required theme manipulations.
*
* @since 2.5.1 2.6
* @param string $region
* @return string
*/
public function apply_theme_region_manipulations($region) {
if ($this->blockmanipulations && isset($this->blockmanipulations[$region])) {
return $this->blockmanipulations[$region];
}
return $region;
}
}