aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php31
1 files changed, 24 insertions, 7 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 9e2e57dd5e..fb8ea93e32 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1071,28 +1071,45 @@ function style_select($default = '', $all = false)
/**
* Pick a timezone
+* @todo Possible HTML escaping
*/
function tz_select($default = '', $truncate = false)
{
global $user;
+ static $timezones;
+
+ if (!isset($timezones))
+ {
+ $timezones = DateTimeZone::listIdentifiers();
+
+ sort($timezones);
+ }
+
$tz_select = '';
- foreach ($user->lang['tz_zones'] as $offset => $zone)
+
+ foreach ($timezones as $timezone)
{
- if ($truncate)
+ if (isset($user->lang['timezones'][$timezone]))
{
- $zone_trunc = truncate_string($zone, 50, 255, false, '...');
+ $title = $label = $user->lang['timezones'][$timezone];
}
else
{
- $zone_trunc = $zone;
+ // No label, we'll figure one out
+ // @todo rtl languages?
+ $bits = explode('/', strtolower(str_replace('_', ' ', $timezone)));
+
+ $title = $label = ucwords(implode(' - ', $bits));
}
- if (is_numeric($offset))
+ if ($truncate)
{
- $selected = ($offset == $default) ? ' selected="selected"' : '';
- $tz_select .= '<option title="' . $zone . '" value="' . $offset . '"' . $selected . '>' . $zone_trunc . '</option>';
+ $label = truncate_string($label, 50, 255, false, '...');
}
+
+ $selected = ($timezone === $default) ? ' selected="selected"' : '';
+ $tz_select .= '<option title="' . $title . '" value="' . $timezone . '"' . $selected . '>' . $label . '</option>';
}
return $tz_select;