diff --git a/lib/outputlib.php b/lib/outputlib.php index 414f51dbaaa..35282f97d5b 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -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)) { diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index bda21547f9e..0e5c9599fcc 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -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; diff --git a/lib/pagelib.php b/lib/pagelib.php index 6098fafbf40..19940fb2cf2 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -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; + } }