mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-25 20:44:01 +01:00
[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
This commit is contained in:
parent
1665434853
commit
0f320a6c48
@ -1071,28 +1071,45 @@ function style_select($default = '', $all = false)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Pick a timezone
|
* Pick a timezone
|
||||||
|
* @todo Possible HTML escaping
|
||||||
*/
|
*/
|
||||||
function tz_select($default = '', $truncate = false)
|
function tz_select($default = '', $truncate = false)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$tz_select = '';
|
static $timezones;
|
||||||
foreach ($user->lang['tz_zones'] as $offset => $zone)
|
|
||||||
|
if (!isset($timezones))
|
||||||
{
|
{
|
||||||
if ($truncate)
|
$timezones = DateTimeZone::listIdentifiers();
|
||||||
|
|
||||||
|
sort($timezones);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tz_select = '';
|
||||||
|
|
||||||
|
foreach ($timezones as $timezone)
|
||||||
|
{
|
||||||
|
if (isset($user->lang['timezones'][$timezone]))
|
||||||
{
|
{
|
||||||
$zone_trunc = truncate_string($zone, 50, 255, false, '...');
|
$title = $label = $user->lang['timezones'][$timezone];
|
||||||
}
|
}
|
||||||
else
|
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"' : '';
|
$label = truncate_string($label, 50, 255, false, '...');
|
||||||
$tz_select .= '<option title="' . $zone . '" value="' . $offset . '"' . $selected . '>' . $zone_trunc . '</option>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$selected = ($timezone === $default) ? ' selected="selected"' : '';
|
||||||
|
$tz_select .= '<option title="' . $title . '" value="' . $timezone . '"' . $selected . '>' . $label . '</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tz_select;
|
return $tz_select;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user