From e89dfdbce62ad5be906cb2d822fa0f746cf6afd6 Mon Sep 17 00:00:00 2001 From: Nadav Kavalerchik Date: Mon, 26 Aug 2013 01:06:55 +0300 Subject: [PATCH] MDL-39871 Blocks,Themes: Swap block regions in RTL mode (using pre-defined array) --- lib/outputlib.php | 5 +++++ theme/base/config.php | 4 ++++ theme/base/layout/frontpage.php | 33 +++++++++------------------------ theme/base/layout/general.php | 27 ++++----------------------- theme/base/style/pagelayout.css | 17 ++++++++++++++++- 5 files changed, 38 insertions(+), 48 deletions(-) diff --git a/lib/outputlib.php b/lib/outputlib.php index be02e35db1e..59b8cd259e3 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -487,6 +487,11 @@ class theme_config { } } + // Use parent theme's "blockrtlmanipulations" if it was defined and if it was not defined on current theme. + if (empty($this->blockrtlmanipulations) and !empty($parent_config->blockrtlmanipulations)) { + $this->blockrtlmanipulations = $parent_config->blockrtlmanipulations; + } + //fix arrows if needed $this->check_theme_arrows(); } diff --git a/theme/base/config.php b/theme/base/config.php index bb9e2c4b389..881ee946932 100644 --- a/theme/base/config.php +++ b/theme/base/config.php @@ -174,3 +174,7 @@ $THEME->hidefromselector = true; /** List of javascript files that need to included on each page */ $THEME->javascripts = array(); $THEME->javascripts_footer = array(); + +// Swap side-pre with side-post blocks regions, in RTL mode (can be override on derived themes) +$THEME->blockrtlmanipulations = array('side-pre'=>'side-post','side-post'=>'side-pre'); + diff --git a/theme/base/layout/frontpage.php b/theme/base/layout/frontpage.php index 330416942e6..f068b23ee89 100644 --- a/theme/base/layout/frontpage.php +++ b/theme/base/layout/frontpage.php @@ -10,17 +10,9 @@ $hascustommenu = (empty($PAGE->layout_options['nocustommenu']) && !empty($custom $bodyclasses = array(); if ($showsidepre && !$showsidepost) { - if (!right_to_left()) { - $bodyclasses[] = 'side-pre-only'; - }else{ - $bodyclasses[] = 'side-post-only'; - } + $bodyclasses[] = 'side-pre-only'; } else if ($showsidepost && !$showsidepre) { - if (!right_to_left()) { - $bodyclasses[] = 'side-post-only'; - }else{ - $bodyclasses[] = 'side-pre-only'; - } + $bodyclasses[] = 'side-post-only'; } else if (!$showsidepost && !$showsidepre) { $bodyclasses[] = 'content-only'; } @@ -66,29 +58,22 @@ echo $OUTPUT->doctype() ?> - +
- blocks_for_region('side-pre'); - } elseif ($hassidepost) { - echo $OUTPUT->blocks_for_region('side-post'); - } ?> - + ?>
- +
- blocks_for_region('side-post'); - } elseif ($hassidepre) { - echo $OUTPUT->blocks_for_region('side-pre'); - } ?> + blocks_for_region('side-post'); + ?>
diff --git a/theme/base/layout/general.php b/theme/base/layout/general.php index 1a0f9e41d6a..ecda10c55bf 100644 --- a/theme/base/layout/general.php +++ b/theme/base/layout/general.php @@ -25,17 +25,9 @@ if (empty($PAGE->layout_options['nocourseheaderfooter'])) { $bodyclasses = array(); if ($showsidepre && !$showsidepost) { - if (!right_to_left()) { $bodyclasses[] = 'side-pre-only'; - }else{ - $bodyclasses[] = 'side-post-only'; - } } else if ($showsidepost && !$showsidepre) { - if (!right_to_left()) { $bodyclasses[] = 'side-post-only'; - }else{ - $bodyclasses[] = 'side-pre-only'; - } } else if (!$showsidepost && !$showsidepre) { $bodyclasses[] = 'content-only'; } @@ -96,29 +88,18 @@ echo $OUTPUT->doctype() ?> - +
- blocks_for_region('side-pre'); - } elseif ($hassidepost) { - echo $OUTPUT->blocks_for_region('side-post'); - } ?> - + blocks_for_region('side-pre'); ?>
- +
- blocks_for_region('side-post'); - } elseif ($hassidepre) { - echo $OUTPUT->blocks_for_region('side-pre'); - } ?> + blocks_for_region('side-post'); ?>
diff --git a/theme/base/style/pagelayout.css b/theme/base/style/pagelayout.css index ac8ffaf9f63..eb369da5d34 100644 --- a/theme/base/style/pagelayout.css +++ b/theme/base/style/pagelayout.css @@ -97,4 +97,19 @@ body {margin:auto 0px;width:auto;} .ie6.pagelayout-report #report-main-content {float:none;width:auto;} .ie6.pagelayout-report #report-region-wrap {float:none;width:200px;left:auto;position:absolute;top:0;} .ie6.pagelayout-report #report-region-pre, -.ie6.pagelayout-report #report-region-pre .block {width:100%;} \ No newline at end of file +.ie6.pagelayout-report #report-region-pre .block {width:100%;} + +/** Only side PRE **/ +.dir-rtl.side-pre-only #page-content #region-main-box {left:0px;} +.dir-rtl.side-pre-only #page-content #region-post-box {margin-left:-200px;} +.dir-rtl.side-pre-only #page-content #region-main {margin-left:200px;} +.dir-rtl.side-pre-only #page-content #region-post {width:0px;} +.dir-rtl.side-pre-only #page-content #region-pre {left:50%; width: 200px;} + +/**RTL Only side POST **/ +.dir-rtl.side-post-only #page-content {clear:both;float:left;overflow:hidden;position:relative;width:100%;min-width:900px;} +.dir-rtl.side-post-only #page-content #region-main-box {float:left;left:200px;position:relative;width:200%;} +.dir-rtl.side-post-only #page-content #region-post-box {margin-left:-200px;} +.dir-rtl.side-post-only #page-content #region-main {margin-left:200px;} +.dir-rtl.side-post-only #page-content #region-pre {width: 0;} +.dir-rtl.side-post-only #page-content #region-post {float:left;left:0px;overflow:hidden;position:relative;width:200px;margin-left:-50%;}