Skip to content
Permalink
Browse files

MDL-46714 Calendar: Properly order Date & Time fields in RTL mode

  • Loading branch information...
nadavkav authored and FMCorz committed Nov 5, 2016
1 parent 44047dc commit a162f636d89cc537ecf9162c169621db59987bfe
Showing with 17 additions and 6 deletions.
  1. +4 −0 lib/form/dateselector.php
  2. +13 −6 lib/form/datetimeselector.php
@@ -128,6 +128,10 @@ function _createElements() {
$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[] = $this->createFormElement('select', $key, get_string($key, 'form'), $value, $this->getAttributes(), true);
@@ -137,16 +137,23 @@ function _createElements() {
$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[] = $this->createFormElement('select', 'minute', get_string('minute', 'form'),
$minutes, $this->getAttributes(), true);
$this->_elements[] = $this->createFormElement('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[] = $this->createFormElement('select', $key, get_string($key, 'form'), $date, $this->getAttributes(), true);
}
if (right_to_left()) { // Switch order of elements for Right-to-Left
$this->_elements[] = $this->createFormElement('select', 'minute', get_string('minute', 'form'), $minutes, $this->getAttributes(), true);
$this->_elements[] = $this->createFormElement('select', 'hour', get_string('hour', 'form'), $hours, $this->getAttributes(), true);
} else {
$this->_elements[] = $this->createFormElement('select', 'hour', get_string('hour', 'form'), $hours, $this->getAttributes(), true);
$this->_elements[] = $this->createFormElement('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[] = $this->createFormElement('select', 'hour', get_string('hour', 'form'), $hours,
$this->getAttributes(), true);
$this->_elements[] = $this->createFormElement('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') {

0 comments on commit a162f63

Please sign in to comment.
You can’t perform that action at this time.