aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
authorChris Smith <toonarmy@phpbb.com>2010-07-08 21:56:51 +0100
committerOleg Pudeyev <oleg@bsdpower.com>2012-03-14 22:57:30 -0400
commit0f320a6c48d63154bba45c2937adeee79165816c (patch)
treee03dc122b5b80db25b5d7b3f5cdb797d67a626be /phpBB/includes/functions.php
parent1665434853fb09e70337d23955e1c9a5f3f0d19d (diff)
downloadforums-0f320a6c48d63154bba45c2937adeee79165816c.tar
forums-0f320a6c48d63154bba45c2937adeee79165816c.tar.gz
forums-0f320a6c48d63154bba45c2937adeee79165816c.tar.bz2
forums-0f320a6c48d63154bba45c2937adeee79165816c.tar.xz
forums-0f320a6c48d63154bba45c2937adeee79165816c.zip
[feature/new-tz-handling] Update tz_select() to use the PHP timezone database.
tz_select() now uses the PHP timezone database to generate the timezone selection box, it tries to use a translated language string otherwise falls back to a label produced from the timezone identifier. I've done this so new timezones are available immediately without a new language pack. PHPBB3-9558
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;