From 29cb1e83b002fffed98beda8a7734f927b8ae3ed Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 17 Jun 2013 13:20:28 +0800 Subject: [PATCH] MDL-18375 calendar: only display the YUI2 calendar when the Gregorian type is used --- lib/form/dateselector.php | 15 ++++++++++----- lib/form/datetimeselector.php | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/form/dateselector.php b/lib/form/dateselector.php index 5e6ddea89a9..c608e192c37 100644 --- a/lib/form/dateselector.php +++ b/lib/form/dateselector.php @@ -98,8 +98,10 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group { } } } - // MDL-18375, Multi-Calendar Support - // form_init_date_js(); + // The YUI2 calendar only supports the gregorian calendar type. + if (calendar_type_plugin_factory::get_calendar_type() === 'gregorian') { + form_init_date_js(); + } } /** @@ -123,10 +125,13 @@ class MoodleQuickForm_date_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('image', 'calendar', $OUTPUT->pix_url('i/calendar', 'moodle'), - array('title' => get_string('calendar', 'calendar'), 'class' => 'visibleifjs')); + // The YUI2 calendar only supports the gregorian calendar type so only display the calendar image if this is being used. + if (calendar_type_plugin_factory::get_calendar_type() === 'gregorian') { + $this->_elements[] = @MoodleQuickForm::createElement('image', 'calendar', $OUTPUT->pix_url('i/calendar', 'moodle'), + array('title' => get_string('calendar', 'calendar'), 'class' => 'visibleifjs')); + } // If optional we add a checkbox which the user can use to turn if on - if($this->_options['optional']) { + if ($this->_options['optional']) { $this->_elements[] = @MoodleQuickForm::createElement('checkbox', 'enabled', null, get_string('enable'), $this->getAttributes(), true); } foreach ($this->_elements as $element){ diff --git a/lib/form/datetimeselector.php b/lib/form/datetimeselector.php index 40a58132d95..6bee569de54 100644 --- a/lib/form/datetimeselector.php +++ b/lib/form/datetimeselector.php @@ -100,8 +100,10 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group { } } } - // MDL-18375, Multi-Calendar Support - // form_init_date_js(); + // The YUI2 calendar only supports the gregorian calendar type. + if (calendar_type_plugin_factory::get_calendar_type() === 'gregorian') { + form_init_date_js(); + } } /** @@ -138,10 +140,13 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group { $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); } - $this->_elements[] = @MoodleQuickForm::createElement('image', 'calendar', $OUTPUT->pix_url('i/calendar', 'moodle'), - array('title' => get_string('calendar', 'calendar'), 'class' => 'visibleifjs')); + // The YUI2 calendar only supports the gregorian calendar type so only display the calendar image if this is being used. + if (calendar_type_plugin_factory::get_calendar_type() === 'gregorian') { + $this->_elements[] = @MoodleQuickForm::createElement('image', 'calendar', $OUTPUT->pix_url('i/calendar', 'moodle'), + array('title' => get_string('calendar', 'calendar'), 'class' => 'visibleifjs')); + } // If optional we add a checkbox which the user can use to turn if on - if($this->_options['optional']) { + if ($this->_options['optional']) { $this->_elements[] = @MoodleQuickForm::createElement('checkbox', 'enabled', null, get_string('enable'), $this->getAttributes(), true); } foreach ($this->_elements as $element){