aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2014-09-17 15:54:00 +0200
committerMarc Alexander <admin@m-a-styles.de>2014-09-17 17:56:04 +0200
commit9a3aeb8a99e7edeb38b5791adf71cfd13059957b (patch)
tree3e7c4c0225fa25f8d5a1d0b8f30f1431b4238725 /phpBB/includes
parent3dbac0f88ba056b19b29fdcabd76074a8dd250d5 (diff)
downloadforums-9a3aeb8a99e7edeb38b5791adf71cfd13059957b.tar
forums-9a3aeb8a99e7edeb38b5791adf71cfd13059957b.tar.gz
forums-9a3aeb8a99e7edeb38b5791adf71cfd13059957b.tar.bz2
forums-9a3aeb8a99e7edeb38b5791adf71cfd13059957b.tar.xz
forums-9a3aeb8a99e7edeb38b5791adf71cfd13059957b.zip
[ticket/12858] Remove hardcoded language entries from timezone selects
PHPBB3-12858
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions.php30
1 files changed, 16 insertions, 14 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index d5a7bd925b..0678ea7fda 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -937,15 +937,16 @@ function style_select($default = '', $all = false)
* Format the timezone offset with hours and minutes
*
* @param int $tz_offset Timezone offset in seconds
+* @param bool $show_null Whether null offsets should be shown
* @return string Normalized offset string: -7200 => -02:00
* 16200 => +04:30
*/
-function phpbb_format_timezone_offset($tz_offset)
+function phpbb_format_timezone_offset($tz_offset, $show_null = false)
{
$sign = ($tz_offset < 0) ? '-' : '+';
$time_offset = abs($tz_offset);
- if ($time_offset == 0)
+ if ($time_offset == 0 && $show_null == false)
{
return '';
}
@@ -1068,15 +1069,15 @@ function phpbb_timezone_select($template, $user, $default = '', $truncate = fals
$dt = $user->create_datetime('now', $tz);
$offset = $dt->getOffset();
$current_time = $dt->format($user->lang['DATETIME_FORMAT'], true);
- $offset_string = phpbb_format_timezone_offset($offset);
- $timezones['GMT' . $offset_string . ' - ' . $timezone] = array(
+ $offset_string = phpbb_format_timezone_offset($offset, true);
+ $timezones['UTC' . $offset_string . ' - ' . $timezone] = array(
'tz' => $timezone,
- 'offset' => 'GMT' . $offset_string,
+ 'offset' => $offset_string,
'current' => $current_time,
);
if ($timezone === $default)
{
- $default_offset = 'GMT' . $offset_string;
+ $default_offset = 'UTC' . $offset_string;
}
}
unset($unsorted_timezones);
@@ -1086,23 +1087,24 @@ function phpbb_timezone_select($template, $user, $default = '', $truncate = fals
$tz_select = $opt_group = '';
- foreach ($timezones as $timezone)
+ foreach ($timezones as $key => $timezone)
{
if ($opt_group != $timezone['offset'])
{
// Generate tz_select for backwards compatibility
$tz_select .= ($opt_group) ? '</optgroup>' : '';
- $tz_select .= '<optgroup label="' . $timezone['offset'] . ' - ' . $timezone['current'] . '">';
+ $tz_select .= '<optgroup label="' . $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']) . '">';
$opt_group = $timezone['offset'];
$template->assign_block_vars('tz_select', array(
- 'LABEL' => $timezone['offset'] . ' - ' . $timezone['current'],
+ 'LABEL' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']),
+ 'VALUE' => $key . ' - ' . $timezone['current'],
));
- $selected = ($default_offset == $timezone['offset']) ? ' selected="selected"' : '';
+ $selected = (!empty($default_offset) && strpos($key, $default_offset) !== false) ? ' selected="selected"' : '';
$template->assign_block_vars('tz_date', array(
- 'VALUE' => $timezone['offset'] . ' - ' . $timezone['current'],
- 'SELECTED' => $selected,
- 'TITLE' => $timezone['offset'] . ' - ' . $timezone['current'],
+ 'VALUE' => $key . ' - ' . $timezone['current'],
+ 'SELECTED' => !empty($selected),
+ 'TITLE' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']),
));
}
@@ -1124,7 +1126,7 @@ function phpbb_timezone_select($template, $user, $default = '', $truncate = fals
$template->assign_block_vars('tz_select.tz_options', array(
'TITLE' => $title,
'VALUE' => $timezone['tz'],
- 'SELECTED' => $timezone['tz'] === $default,
+ 'SELECTED' => !empty($selected),
'LABEL' => $label,
));
}