From c223acda18c2ce1d79025402eee1b1dd35b4114a Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 6 Sep 2007 07:30:51 +0000 Subject: [PATCH] Merged fixes for RTL support in 1.8 from Sharar Dolev and the Hebrew translation team see MDL-10768 --- admin/langimport.php | 2 +- blocks/moodleblock.class.php | 13 ++++++-- course/lib.php | 13 ++++++-- install.php | 15 ++++++---- lib/editor/htmlarea/htmlarea.php | 2 +- lib/form/datetimeselector.php | 9 ++++-- lib/weblib.php | 46 ++++++++++++++++++++++++++++- mod/quiz/report/analysis/report.php | 2 +- mod/quiz/review.php | 2 +- 9 files changed, 87 insertions(+), 17 deletions(-) diff --git a/admin/langimport.php b/admin/langimport.php index 94a1b4bb843..b8d3d473d09 100755 --- a/admin/langimport.php +++ b/admin/langimport.php @@ -308,7 +308,7 @@ } if ($remote) { echo ''; - echo '
'; + echo '
'; } echo ''; echo ''; diff --git a/blocks/moodleblock.class.php b/blocks/moodleblock.class.php index ec6d9c84b39..f2ac60c05df 100644 --- a/blocks/moodleblock.class.php +++ b/blocks/moodleblock.class.php @@ -324,6 +324,15 @@ class block_base { $this->str->assignroles = get_string('assignroles', 'role'); } + // RTL support - exchange right and left arrows + if (right_to_left()) { + $rightarrow = 'left.gif'; + $leftarrow = 'right.gif'; + } else { + $rightarrow = 'right.gif'; + $leftarrow = 'left.gif'; + } + $movebuttons = '
'; if ($this->instance->visible) { @@ -362,7 +371,7 @@ class block_base { if ($options & BLOCK_MOVE_LEFT) { $movebuttons .= '' . - ''. $this->str->moveleft .''; + ''. $this->str->moveleft .''; } if ($options & BLOCK_MOVE_UP) { $movebuttons .= '' . @@ -374,7 +383,7 @@ class block_base { } if ($options & BLOCK_MOVE_RIGHT) { $movebuttons .= '' . - ''. $this->str->moveright .''; + ''. $this->str->moveright .''; } $movebuttons .= '
'; diff --git a/course/lib.php b/course/lib.php index 95a5647b137..f3ba22f1c34 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2309,16 +2309,25 @@ function make_editing_buttons($mod, $absolute=false, $moveselect=true, $indent=- } $leftright = ""; + + if (right_to_left()) { // Exchange arrows on RTL + $rightarrow = 'left.gif'; + $leftarrow = 'right.gif'; + } else { + $rightarrow = 'right.gif'; + $leftarrow = 'left.gif'; + } + if ($indent > 0) { $leftright .= ''."\n"; } if ($indent >= 0) { $leftright .= ''."\n"; } diff --git a/install.php b/install.php index 2f411caca6b..4e772cae75c 100644 --- a/install.php +++ b/install.php @@ -549,7 +549,7 @@ if ($nextstage == SAVE) { //==========================================================================// ?> - + Moodle Install @@ -670,7 +670,7 @@ if ($nextstage == SAVE) { echo "\n"; echo "
\n"; - echo "
\n"; + echo "
\n"; echo "
\n";
         print_r(s($str));
         echo "
\n"; @@ -924,8 +924,8 @@ function form_table($nextstage = WELCOME, $formaction = "install.php") { } ?> - \n" : " \n" ?> - WELCOME) ? "\n" : " \n" ?> + \n" : " \n" ?> + WELCOME) ? "\n" : " \n" ?> ; font-weight: bold; } .td_right { - text-align: left; + text-align: ; } .main { width: 500px; @@ -1204,6 +1204,9 @@ function css_styles() { #mysql, #postgres7, #mssql, #mssql_n, #odbc_mssql, #oci8po { display: none; } + #menulanguage { + direction: ltr; + } diff --git a/lib/editor/htmlarea/htmlarea.php b/lib/editor/htmlarea/htmlarea.php index 8a3f14b2779..641dff26819 100644 --- a/lib/editor/htmlarea/htmlarea.php +++ b/lib/editor/htmlarea/htmlarea.php @@ -728,7 +728,7 @@ HTMLArea.prototype.generate = function () { html += '\n'; if (editor.config.baseURL) html += ''; - html += '\n"; + html += '\n"; // RTL support: direction added for RTL support html += "\n"; html += '\n'; html += editor._textArea.value; diff --git a/lib/form/datetimeselector.php b/lib/form/datetimeselector.php index 49e5e065620..4aef36e5939 100644 --- a/lib/form/datetimeselector.php +++ b/lib/form/datetimeselector.php @@ -84,8 +84,13 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group{ $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes(), true); $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes(), true); $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes(), true); - $this->_elements[] =& MoodleQuickForm::createElement('select', 'hour', get_string('hour', 'form'), $hours, $this->getAttributes(), true); - $this->_elements[] =& MoodleQuickForm::createElement('select', 'minute', get_string('minute', 'form'), $minutes, $this->getAttributes(), true); + if (right_to_left()) { // Switch order of elements for Right-to-Left + $this->_elements[] =& MoodleQuickForm::createElement('select', 'minute', get_string('minute', 'form'), $minutes, $this->getAttributes(), true); + $this->_elements[] =& MoodleQuickForm::createElement('select', 'hour', get_string('hour', 'form'), $hours, $this->getAttributes(), true); + } else { + $this->_elements[] =& MoodleQuickForm::createElement('select', 'hour', get_string('hour', 'form'), $hours, $this->getAttributes(), true); + $this->_elements[] =& MoodleQuickForm::createElement('select', 'minute', get_string('minute', 'form'), $minutes, $this->getAttributes(), true); + } // If optional we add a checkbox which the user can use to turn if on if($this->_options['optional']) { $this->_elements[] =& MoodleQuickForm::createElement('checkbox', 'off', null, get_string('disable'), $this->getAttributes(), true); diff --git a/lib/weblib.php b/lib/weblib.php index fa207cc4e20..f11cd752ac4 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2745,6 +2745,12 @@ function theme_setup($theme = '', $params=NULL) { } } +/// RTL support - only for RTL languages, add RTL CSS + if (get_string('thisdirection') == 'rtl') { + $CFG->stylesheets[] = $CFG->themewww.'/standard/rtl.css'.$paramstring; + $CFG->stylesheets[] = $CFG->themewww.'/'.$theme.'/rtl.css'.$paramstring; + } + } @@ -2853,6 +2859,13 @@ function check_theme_arrows() { $THEME->rarrow = '>'; $THEME->larrow = '<'; } + + /// RTL support - in RTL languages, swap r and l arrows + if (right_to_left()) { + $t = $THEME->rarrow; + $THEME->rarrow = $THEME->larrow; + $THEME->larrow = $t; + } } } @@ -3601,7 +3614,7 @@ function print_table($table, $return=false) { if (isset($table->align)) { foreach ($table->align as $key => $aa) { if ($aa) { - $align[$key] = ' text-align:'. $aa.';'; + $align[$key] = ' text-align:'. fix_align_rtl($aa) .';'; // Fix for RTL languages } else { $align[$key] = ''; } @@ -5970,5 +5983,36 @@ function print_location_comment($file, $line, $return = false) echo "\n"; } } + +/** +* Returns boolean true if the current language is right-to-left (Hebrew, Arabic etc) +* +*/ +function right_to_left() { + static $result; + + if (isset($result)) { + return $result; + } + return $result = (get_string('thisdirection') == 'rtl'); +} + + +/** +* Returns swapped left<=>right if in RTL environment. +* part of RTL support +* +* @param string $align align to check +* @return string +*/ +function fix_align_rtl($align) { + if (!right_to_left()) { + return $align; + } + if ($align=='left') { return 'right'; } + if ($align=='right') { return 'left'; } + return $align; +} + // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140: ?> diff --git a/mod/quiz/report/analysis/report.php b/mod/quiz/report/analysis/report.php index 0e643f14b91..bc75164014e 100644 --- a/mod/quiz/report/analysis/report.php +++ b/mod/quiz/report/analysis/report.php @@ -337,7 +337,7 @@ class quiz_report extends quiz_default_report { $responses[] = $response; } - $facility = format_float($q['facility']*100,0)." %"; + $facility = format_float($q['facility']*100,0)."%"; $qsd = format_float($q['qsd'],3); $di = format_float($q['disc_index'],2); $dc = format_float($q['disc_coeff'],2); diff --git a/mod/quiz/review.php b/mod/quiz/review.php index 653a447d130..a2bfe7dda50 100644 --- a/mod/quiz/review.php +++ b/mod/quiz/review.php @@ -199,7 +199,7 @@ $a->grade = $grade; $a->maxgrade = $quiz->grade; $rawscore = round($attempt->sumgrades, $CFG->quiz_decimalpoints); - $table->data[] = array("$strscore:", "$rawscore/$quiz->sumgrades ($percentage %)"); + $table->data[] = array("$strscore:", "$rawscore/$quiz->sumgrades ($percentage%)"); $table->data[] = array("$strgrade:", get_string('outof', 'quiz', $a)); } }