Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

Conflicts:
	lib/pagelib.php
  • Loading branch information...
commit d89fbe0285ffd56bb4632566a92073a3df9f3f5b 1 parent ddf1b07
Sam Hemelryk samhemelryk authored
Showing with 40 additions and 1 deletion.
  1. +9 −1 lib/outputlib.php
  2. +1 −0  lib/outputrenderers.php
  3. +30 −0 lib/pagelib.php
10 lib/outputlib.php
View
@@ -326,6 +326,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 @@ private function __construct($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  lib/outputrenderers.php
View
@@ -1228,6 +1228,7 @@ public function list_block_contents($icons, $items) {
* @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 lib/pagelib.php
View
@@ -639,6 +639,22 @@ protected function magic_get_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 @@ public function get_popup_notification_allowed() {
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;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.