diff --git a/admin/calendar.html b/admin/calendar.html
index b3d0510c9f1..0bd93fba4f1 100644
--- a/admin/calendar.html
+++ b/admin/calendar.html
@@ -55,14 +55,14 @@
-
+
forcetimezone)) echo 'checked="checked"';?> />
forcetimezone)) echo 'checked="checked"';?> />
- forcetimezone) ? '' : $CFG->forcetimezone), get_string('choose').'...', 'form.timezone2.checked=\'checked\'', ''); ?>
+ forcetimezone) ? '' : $CFG->forcetimezone), get_string('choose').'...', 'form.timezone2.checked=\'checked\'', ''); ?>
diff --git a/admin/calendar.php b/admin/calendar.php
index 1f695f7120a..8fe546ecd90 100644
--- a/admin/calendar.php
+++ b/admin/calendar.php
@@ -83,32 +83,7 @@
require_once($CFG->dirroot.'/calendar/lib.php');
// Populate some variables we 're going to need in calendar.html
- $records = get_records_sql('SELECT id, name FROM '.$CFG->prefix.'timezone GROUP BY name');
- $presets = array();
-
- if (!empty($records)) {
- foreach($records as $preset) {
- if (!empty($preset->name)) {
- $presets[$preset->name] = get_string(strtolower($preset->name), 'timezones');
- if (substr($presets[$preset->name], 0, 1) == '[') { // No translation found
- $presets[$preset->name] = $preset->name;
- }
- }
- }
- }
-
- asort($presets); // Sort before adding trivial presets because string sorts mess up their order
-
- for ($i = -13; $i <= 13; $i += .5) {
- $tzstring = 'GMT';
- if ($i < 0) {
- $presets[sprintf("%.1f", $i)] = $tzstring . $i;
- } else if ($i > 0) {
- $presets[sprintf("%.1f", $i)] = $tzstring . '+' . $i;
- } else {
- $presets[sprintf("%.1f", $i)] = $tzstring;
- }
- }
+ $timezones = get_list_of_timezones();
$weekdays = array(
0 => get_string('sunday', 'calendar'),
diff --git a/admin/configvars.php b/admin/configvars.php
index f88419c943f..c457e9325a4 100644
--- a/admin/configvars.php
+++ b/admin/configvars.php
@@ -225,32 +225,9 @@ class configvarrss extends configvar {
'' );
/// timezone
- $records = get_records_sql('SELECT id, name FROM '.$CFG->prefix.'timezone GROUP BY name');
- $timezones = array();
-
- if(!empty($records)) {
- foreach($records as $preset) {
- $timezones[$preset->name] = get_string($preset->name, 'timezones');
- }
- }
-
- asort($timezones); // Sort before adding trivial presets because string sorts mess up their order
-
- for($i = -13; $i <= 13; $i += .5) {
- $tzstring = get_string('unspecifiedlocation', 'timezones').' / GMT';
- if($i < 0) {
- $timezones[sprintf("%.1f", $i)] = $tzstring . $i;
- }
- else if($i > 0) {
- $timezones[sprintf("%.1f", $i)] = $tzstring . '+' . $i;
- }
- else {
- $timezones[sprintf("%.1f", $i)] = $tzstring;
- }
- }
$interface['timezone'] = new configvar ( get_string('configtimezone', 'admin'),
- choose_from_menu ($timezones, 'timezone', $config->timezone, get_string('serverlocaltime'), '', '99', true ) );
+ choose_from_menu (get_list_of_timezones(), 'timezone', $config->timezone, get_string('serverlocaltime'), '', '99', true ) );
/// country
$interface['country'] = new configvar ( get_string('configcountry', 'admin'),
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index ada40c011b4..0de5aac357e 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -4282,6 +4282,48 @@ function get_list_of_pixnames() {
return $string;
}
+/**
+ * Returns a list of picture names in the current language
+ *
+ * @uses $CFG
+ * @return string?
+ * @todo Finish documenting this function.
+ */
+function get_list_of_timezones() {
+ global $CFG;
+
+ $lang = current_language();
+
+ if (!file_exists($CFG->dirroot .'/lang/'. $lang .'/timezones.php')) {
+ if ($parentlang = get_string('parentlanguage')) {
+ if (file_exists($CFG->dirroot .'/lang/'. $parentlang .'/timezones.php')) {
+ $lang = $parentlang;
+ } else {
+ $lang = 'en'; // timezones.php must exist in this pack
+ }
+ } else {
+ $lang = 'en'; // timezones.php must exist in this pack
+ }
+ }
+
+ include_once($CFG->dirroot .'/lang/'. $lang .'/timezones.php');
+
+ asort($string);
+
+ for ($i = -13; $i <= 13; $i += .5) {
+ $tzstring = 'GMT';
+ if ($i < 0) {
+ $string[sprintf("%.1f", $i)] = $tzstring . $i;
+ } else if ($i > 0) {
+ $string[sprintf("%.1f", $i)] = $tzstring . '+' . $i;
+ } else {
+ $string[sprintf("%.1f", $i)] = $tzstring;
+ }
+ }
+
+ return $string;
+}
+
/**
* Can include a given document file (depends on second
* parameter) or just return info about it.
diff --git a/user/edit.html b/user/edit.html
index 6f49f45bbca..866491692de 100644
--- a/user/edit.html
+++ b/user/edit.html
@@ -208,34 +208,11 @@ if (isadmin()) {
| : |
prefix.'timezone GROUP BY name');
- $presets = array();
-
- if(!empty($records)) {
- foreach($records as $preset) {
- $presets[$preset->name] = get_string($preset->name, 'timezones');
- }
- }
-
- asort($presets); // Sort before adding trivial presets because string sorts mess up their order
-
- for($i = -13; $i <= 13; $i += .5) {
- $tzstring = get_string('unspecifiedlocation', 'timezones').' / GMT';
- if($i < 0) {
- $presets[sprintf("%.1f", $i)] = $tzstring . $i;
- }
- else if($i > 0) {
- $presets[sprintf("%.1f", $i)] = $tzstring . '+' . $i;
- }
- else {
- $presets[sprintf("%.1f", $i)] = $tzstring;
- }
- }
- if(!empty($CFG->forcetimezone)) {
- choose_from_menu($presets, 'timezone', $CFG->forcetimezone, get_string('serverlocaltime'), '', '99', false, true);
- }
- else {
- choose_from_menu($presets, 'timezone', $user->timezone, get_string('serverlocaltime'), '', '99');
+ $timezones = get_list_of_timezones();
+ if (!empty($CFG->forcetimezone)) {
+ choose_from_menu($timezones, 'timezone', $CFG->forcetimezone, get_string('serverlocaltime'), '', '99', false, true);
+ } else {
+ choose_from_menu($timezones, 'timezone', $user->timezone, get_string('serverlocaltime'), '', '99');
}
?>
|