Skip to content

Commit

Permalink
Merge branch 'MDL-46714-master-nadav' of git://github.com/FMCorz/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Dec 12, 2016
2 parents 5ef81f2 + bb13339 commit c8c3df5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions lib/form/dateselector.php
Expand Up @@ -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);
Expand Down
19 changes: 13 additions & 6 deletions lib/form/datetimeselector.php
Expand Up @@ -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') {
Expand Down

0 comments on commit c8c3df5

Please sign in to comment.