diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2012-06-04 19:06:46 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2012-06-18 15:07:12 +0200 |
commit | 50936cb2eff3f80d99390c76ef6ac535e73f6cc3 (patch) | |
tree | 7b2aee8eba0a921d19f0bf1fdd319914d0292efa /phpBB/includes/functions.php | |
parent | 8f027b68d64c1baa99b272d45f382c17310f1480 (diff) | |
download | forums-50936cb2eff3f80d99390c76ef6ac535e73f6cc3.tar forums-50936cb2eff3f80d99390c76ef6ac535e73f6cc3.tar.gz forums-50936cb2eff3f80d99390c76ef6ac535e73f6cc3.tar.bz2 forums-50936cb2eff3f80d99390c76ef6ac535e73f6cc3.tar.xz forums-50936cb2eff3f80d99390c76ef6ac535e73f6cc3.zip |
[feature/new-tz-handling] Fix selecting and validating of timezone in UCP
PHPBB3-9558
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r-- | phpBB/includes/functions.php | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3ec4b76091..55f7f0531c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1139,34 +1139,38 @@ function tz_select($default = '', $truncate = false) if (!isset($timezones)) { - $timezones = DateTimeZone::listIdentifiers(); + $unsorted_timezones = DateTimeZone::listIdentifiers(); + $timezones = array(); - foreach ($timezones as &$timezone) + foreach ($unsorted_timezones as $timezone) { $tz = new DateTimeZone($timezone); $dt = new phpbb_datetime('now', $tz); $offset = $dt->getOffset(); $offset_string = phpbb_format_timezone_offset($offset); - $timezone = 'GMT' . $offset_string . ' - ' . $timezone; + $timezones['GMT' . $offset_string . ' - ' . $timezone] = array( + 'tz' => $timezone, + 'label' => 'GMT' . $offset_string . ' - ' . $timezone, + ); } - unset($timezone); + unset($unsorted_timezones); - usort($timezones, 'tz_select_compare'); + uksort($timezones, 'tz_select_compare'); } $tz_select = ''; foreach ($timezones as $timezone) { - if (isset($user->lang['timezones'][$timezone])) + if (isset($user->lang['timezones'][$timezone['tz']])) { - $title = $label = $user->lang['timezones'][$timezone]; + $title = $label = $user->lang['timezones'][$timezone['tz']]; } else { // No label, we'll figure one out // @todo rtl languages? - $bits = explode('/', str_replace('_', ' ', $timezone)); + $bits = explode('/', str_replace('_', ' ', $timezone['label'])); $title = $label = implode(' - ', $bits); } @@ -1176,8 +1180,8 @@ function tz_select($default = '', $truncate = false) $label = truncate_string($label, 50, 255, false, '...'); } - $selected = ($timezone === $default) ? ' selected="selected"' : ''; - $tz_select .= '<option title="' . $title . '" value="' . $timezone . '"' . $selected . '>' . $label . '</option>'; + $selected = ($timezone['tz'] === $default) ? ' selected="selected"' : ''; + $tz_select .= '<option title="' . $title . '" value="' . $timezone['tz'] . '"' . $selected . '>' . $label . '</option>'; } return $tz_select; |