diff --git a/lib/form/dateselector.php b/lib/form/dateselector.php index c7dfad279b5..73249687a67 100644 --- a/lib/form/dateselector.php +++ b/lib/form/dateselector.php @@ -128,6 +128,10 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group { $this->_elements = array(); $dateformat = $calendartype->get_date_order($this->_options['startyear'], $this->_options['stopyear']); + // Reverse date element (Day, Month, Year), in RTL mode. + if (right_to_left()) { + $dateformat = array_reverse($dateformat); + } foreach ($dateformat as $key => $value) { // E_STRICT creating elements without forms is nasty because it internally uses $this $this->_elements[] = @MoodleQuickForm::createElement('select', $key, get_string($key, 'form'), $value, $this->getAttributes(), true); diff --git a/lib/form/datetimeselector.php b/lib/form/datetimeselector.php index aa4951b3d44..8fec06806d6 100644 --- a/lib/form/datetimeselector.php +++ b/lib/form/datetimeselector.php @@ -137,16 +137,23 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group { $this->_elements = array(); $dateformat = $calendartype->get_date_order($this->_options['startyear'], $this->_options['stopyear']); + if (right_to_left()) { // Display time to the right of date, in RTL mode. + $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); + // Reverse date element (Should be: Day, Month, Year), in RTL mode. + $dateformat = array_reverse($dateformat); + } foreach ($dateformat as $key => $date) { // E_STRICT creating elements without forms is nasty because it internally uses $this $this->_elements[] = @MoodleQuickForm::createElement('select', $key, get_string($key, 'form'), $date, $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 (!right_to_left()) { // Display time to the left of date, in LTR mode. + $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); } // The YUI2 calendar only supports the gregorian calendar type so only display the calendar image if this is being used. if ($calendartype->get_name() === 'gregorian') {