mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-14 04:42:04 +02:00
Merge pull request #2844 from marc1706/ticket/12858
[ticket/12858] Remove hard-coded GMT from timezone drop-down and rename to UTC
This commit is contained in:
commit
85bc9b69ae
@ -1,17 +1,25 @@
|
||||
<dl>
|
||||
<dt><label for="timezone">{L_BOARD_TIMEZONE}{L_COLON}</label></dt>
|
||||
<!-- IF S_TZ_DATE_OPTIONS -->
|
||||
<!-- IF .timezone_date -->
|
||||
<dd id="tz_select_date" style="display: none;">
|
||||
<select name="tz_date" id="tz_date" class="autowidth tz_select">
|
||||
<option value="">{L_SELECT_CURRENT_TIME}</option>
|
||||
{S_TZ_DATE_OPTIONS}
|
||||
<!-- BEGIN timezone_date -->
|
||||
<option value="{timezone_date.VALUE}"<!-- IF timezone_date.SELECTED --> selected="selected"<!-- ENDIF -->>{timezone_date.TITLE}</option>
|
||||
<!-- END timezone_date -->
|
||||
</select>
|
||||
</dd>
|
||||
<!-- ENDIF -->
|
||||
<dd>
|
||||
<select name="tz" id="timezone" class="autowidth tz_select">
|
||||
<option value="">{L_SELECT_TIMEZONE}</option>
|
||||
{S_TZ_OPTIONS}
|
||||
<!-- BEGIN timezone_select -->
|
||||
<optgroup label="{timezone_select.LABEL}" data-tz-value="{timezone_select.VALUE}">
|
||||
<!-- BEGIN timezone_options -->
|
||||
<option title="{timezone_select.timezone_options.TITLE}" value="{timezone_select.timezone_options.VALUE}"<!-- IF timezone_select.timezone_options.SELECTED --> selected="selected"<!-- ENDIF -->>{timezone_select.timezone_options.LABEL}</option>
|
||||
<!-- END timezone_options -->
|
||||
</optgroup>
|
||||
<!-- END timezone_select -->
|
||||
</select>
|
||||
|
||||
<!-- INCLUDEJS timezone.js -->
|
||||
|
@ -786,7 +786,7 @@ phpbb.timezoneSwitchDate = function(keepSelection) {
|
||||
}
|
||||
|
||||
if ($tzDate.val() !== '') {
|
||||
$timezone.children('optgroup').remove(':not([label="' + $('#tz_date').val() + '"])');
|
||||
$timezone.children('optgroup').remove(':not([data-tz-value="' + $('#tz_date').val() + '"])');
|
||||
}
|
||||
|
||||
if ($tzDate.val() === $tzSelectDateSuggest.attr('data-suggested-tz')) {
|
||||
@ -795,7 +795,7 @@ phpbb.timezoneSwitchDate = function(keepSelection) {
|
||||
$tzSelectDateSuggest.css('display', 'inline');
|
||||
}
|
||||
|
||||
var $tzOptions = $timezone.children('optgroup[label="' + $tzDate.val() + '"]').children('option');
|
||||
var $tzOptions = $timezone.children('optgroup[data-tz-value="' + $tzDate.val() + '"]').children('option');
|
||||
|
||||
if ($tzOptions.length === 1) {
|
||||
// If there is only one timezone for the selected date, we just select that automatically.
|
||||
@ -849,7 +849,7 @@ phpbb.timezonePreselectSelect = function(forceSelector) {
|
||||
minutes = minutes.toString();
|
||||
}
|
||||
|
||||
var prefix = 'GMT' + sign + hours + ':' + minutes;
|
||||
var prefix = 'UTC' + sign + hours + ':' + minutes;
|
||||
var prefixLength = prefix.length;
|
||||
var selectorOptions = $('option', '#tz_date');
|
||||
var i;
|
||||
|
@ -904,12 +904,11 @@ class acp_board
|
||||
*/
|
||||
function timezone_select($value, $key)
|
||||
{
|
||||
global $user;
|
||||
global $template, $user;
|
||||
|
||||
$timezone_select = phpbb_timezone_select($user, $value, true);
|
||||
$timezone_select['tz_select'];
|
||||
$timezone_select = phpbb_timezone_select($template, $user, $value, true);
|
||||
|
||||
return '<select name="config[' . $key . ']" id="' . $key . '">' . $timezone_select['tz_select'] . '</select>';
|
||||
return '<select name="config[' . $key . ']" id="' . $key . '">' . $timezone_select . '</select>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1661,7 +1661,7 @@ class acp_users
|
||||
${'s_sort_' . $sort_option . '_dir'} .= '</select>';
|
||||
}
|
||||
|
||||
$timezone_selects = phpbb_timezone_select($user, $data['tz'], true);
|
||||
phpbb_timezone_select($template, $user, $data['tz'], true);
|
||||
$user_prefs_data = array(
|
||||
'S_PREFS' => true,
|
||||
'S_JABBER_DISABLED' => ($config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml')) ? false : true,
|
||||
@ -1700,8 +1700,6 @@ class acp_users
|
||||
|
||||
'S_LANG_OPTIONS' => language_select($data['lang']),
|
||||
'S_STYLE_OPTIONS' => style_select($data['style']),
|
||||
'S_TZ_OPTIONS' => $timezone_selects['tz_select'],
|
||||
'S_TZ_DATE_OPTIONS' => $timezone_selects['tz_dates'],
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -937,14 +937,20 @@ 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 && $show_null == false)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$offset_seconds = $time_offset % 3600;
|
||||
$offset_minutes = $offset_seconds / 60;
|
||||
$offset_hours = ($time_offset - $offset_seconds) / 3600;
|
||||
@ -1040,13 +1046,14 @@ function phpbb_get_timezone_identifiers($selected_timezone)
|
||||
/**
|
||||
* Options to pick a timezone and date/time
|
||||
*
|
||||
* @param \phpbb\template\template $template phpBB template object
|
||||
* @param \phpbb\user $user Object of the current user
|
||||
* @param string $default A timezone to select
|
||||
* @param boolean $truncate Shall we truncate the options text
|
||||
*
|
||||
* @return array Returns an array, also containing the options for the time selector.
|
||||
* @return array Returns an array containing the options for the time selector.
|
||||
*/
|
||||
function phpbb_timezone_select($user, $default = '', $truncate = false)
|
||||
function phpbb_timezone_select($template, $user, $default = '', $truncate = false)
|
||||
{
|
||||
static $timezones;
|
||||
|
||||
@ -1062,15 +1069,15 @@ function phpbb_timezone_select($user, $default = '', $truncate = false)
|
||||
$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);
|
||||
@ -1078,18 +1085,27 @@ function phpbb_timezone_select($user, $default = '', $truncate = false)
|
||||
uksort($timezones, 'phpbb_tz_select_compare');
|
||||
}
|
||||
|
||||
$tz_select = $tz_dates = $opt_group = '';
|
||||
$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('timezone_select', array(
|
||||
'LABEL' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']),
|
||||
'VALUE' => $key . ' - ' . $timezone['current'],
|
||||
));
|
||||
|
||||
$selected = ($default_offset == $timezone['offset']) ? ' selected="selected"' : '';
|
||||
$tz_dates .= '<option value="' . $timezone['offset'] . ' - ' . $timezone['current'] . '"' . $selected . '>' . $timezone['offset'] . ' - ' . $timezone['current'] . '</option>';
|
||||
$selected = (!empty($default_offset) && strpos($key, $default_offset) !== false) ? ' selected="selected"' : '';
|
||||
$template->assign_block_vars('timezone_date', array(
|
||||
'VALUE' => $key . ' - ' . $timezone['current'],
|
||||
'SELECTED' => !empty($selected),
|
||||
'TITLE' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']),
|
||||
));
|
||||
}
|
||||
|
||||
$label = $timezone['tz'];
|
||||
@ -1097,22 +1113,26 @@ function phpbb_timezone_select($user, $default = '', $truncate = false)
|
||||
{
|
||||
$label = $user->lang['timezones'][$label];
|
||||
}
|
||||
$title = $timezone['offset'] . ' - ' . $label;
|
||||
$title = $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $label);
|
||||
|
||||
if ($truncate)
|
||||
{
|
||||
$label = truncate_string($label, 50, 255, false, '...');
|
||||
}
|
||||
|
||||
// Also generate timezone_select for backwards compatibility
|
||||
$selected = ($timezone['tz'] === $default) ? ' selected="selected"' : '';
|
||||
$tz_select .= '<option title="' . $title . '" value="' . $timezone['tz'] . '"' . $selected . '>' . $label . '</option>';
|
||||
$template->assign_block_vars('timezone_select.timezone_options', array(
|
||||
'TITLE' => $title,
|
||||
'VALUE' => $timezone['tz'],
|
||||
'SELECTED' => !empty($selected),
|
||||
'LABEL' => $label,
|
||||
));
|
||||
}
|
||||
$tz_select .= '</optgroup>';
|
||||
|
||||
return array(
|
||||
'tz_select' => $tz_select,
|
||||
'tz_dates' => $tz_dates,
|
||||
);
|
||||
return $tz_select;
|
||||
}
|
||||
|
||||
// Functions handling topic/post tracking/marking
|
||||
@ -4903,7 +4923,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
|
||||
}
|
||||
|
||||
$dt = $user->create_datetime();
|
||||
$timezone_offset = 'GMT' . phpbb_format_timezone_offset($dt->getOffset());
|
||||
$timezone_offset = $user->lang(array('timezones', 'UTC_OFFSET'), phpbb_format_timezone_offset($dt->getOffset()));
|
||||
$timezone_name = $user->timezone->getName();
|
||||
if (isset($user->lang['timezones'][$timezone_name]))
|
||||
{
|
||||
|
@ -133,10 +133,9 @@ function phpbb_clean_path($path)
|
||||
*/
|
||||
function tz_select($default = '', $truncate = false)
|
||||
{
|
||||
global $user;
|
||||
global $template, $user;
|
||||
|
||||
$timezone_select = phpbb_timezone_select($user, $default, $truncate);
|
||||
return $timezone_select['tz_select'];
|
||||
return phpbb_timezone_select($template, $user, $default, $truncate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,7 +154,7 @@ class ucp_prefs
|
||||
}
|
||||
$dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>';
|
||||
|
||||
$timezone_selects = phpbb_timezone_select($user, $data['tz'], true);
|
||||
phpbb_timezone_select($template, $user, $data['tz'], true);
|
||||
|
||||
// check if there are any user-selectable languages
|
||||
$sql = 'SELECT COUNT(lang_id) as languages_count
|
||||
@ -208,8 +208,6 @@ class ucp_prefs
|
||||
|
||||
'S_LANG_OPTIONS' => language_select($data['lang']),
|
||||
'S_STYLE_OPTIONS' => ($config['override_user_style']) ? '' : style_select($data['user_style']),
|
||||
'S_TZ_OPTIONS' => $timezone_selects['tz_select'],
|
||||
'S_TZ_DATE_OPTIONS' => $timezone_selects['tz_dates'],
|
||||
'S_CAN_HIDE_ONLINE' => ($auth->acl_get('u_hideonline')) ? true : false,
|
||||
'S_SELECT_NOTIFY' => ($config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml')) ? true : false)
|
||||
);
|
||||
|
@ -452,7 +452,7 @@ class ucp_register
|
||||
break;
|
||||
}
|
||||
|
||||
$timezone_selects = phpbb_timezone_select($user, $data['tz'], true);
|
||||
$timezone_selects = phpbb_timezone_select($template, $user, $data['tz'], true);
|
||||
$template->assign_vars(array(
|
||||
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
|
||||
'USERNAME' => $data['username'],
|
||||
@ -465,8 +465,6 @@ class ucp_register
|
||||
'L_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars']), $user->lang('CHARACTERS', (int) $config['max_pass_chars'])),
|
||||
|
||||
'S_LANG_OPTIONS' => language_select($data['lang']),
|
||||
'S_TZ_OPTIONS' => $timezone_selects['tz_select'],
|
||||
'S_TZ_DATE_OPTIONS' => $timezone_selects['tz_dates'],
|
||||
'S_TZ_PRESELECT' => !$submit,
|
||||
'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false,
|
||||
'S_REGISTRATION' => true,
|
||||
|
@ -937,32 +937,34 @@ $lang = array_merge($lang, array(
|
||||
// Timezones can be translated. We use this for the Etc/GMT timezones here,
|
||||
// because they are named invers to their offset.
|
||||
'timezones' => array(
|
||||
'UTC' => 'UTC',
|
||||
'UTC' => 'UTC',
|
||||
'UTC_OFFSET' => 'UTC%1$s',
|
||||
'UTC_OFFSET_CURRENT' => 'UTC%1$s - %2$s',
|
||||
|
||||
'Etc/GMT-12' => 'GMT+12',
|
||||
'Etc/GMT-11' => 'GMT+11',
|
||||
'Etc/GMT-10' => 'GMT+10',
|
||||
'Etc/GMT-9' => 'GMT+9',
|
||||
'Etc/GMT-8' => 'GMT+8',
|
||||
'Etc/GMT-7' => 'GMT+7',
|
||||
'Etc/GMT-6' => 'GMT+6',
|
||||
'Etc/GMT-5' => 'GMT+5',
|
||||
'Etc/GMT-4' => 'GMT+4',
|
||||
'Etc/GMT-3' => 'GMT+3',
|
||||
'Etc/GMT-2' => 'GMT+2',
|
||||
'Etc/GMT-1' => 'GMT+1',
|
||||
'Etc/GMT+1' => 'GMT-1',
|
||||
'Etc/GMT+2' => 'GMT-2',
|
||||
'Etc/GMT+3' => 'GMT-3',
|
||||
'Etc/GMT+4' => 'GMT-4',
|
||||
'Etc/GMT+5' => 'GMT-5',
|
||||
'Etc/GMT+6' => 'GMT-6',
|
||||
'Etc/GMT+7' => 'GMT-7',
|
||||
'Etc/GMT+8' => 'GMT-8',
|
||||
'Etc/GMT+9' => 'GMT-9',
|
||||
'Etc/GMT+10' => 'GMT-10',
|
||||
'Etc/GMT+11' => 'GMT-11',
|
||||
'Etc/GMT+12' => 'GMT-12',
|
||||
'Etc/GMT-12' => 'UTC+12',
|
||||
'Etc/GMT-11' => 'UTC+11',
|
||||
'Etc/GMT-10' => 'UTC+10',
|
||||
'Etc/GMT-9' => 'UTC+9',
|
||||
'Etc/GMT-8' => 'UTC+8',
|
||||
'Etc/GMT-7' => 'UTC+7',
|
||||
'Etc/GMT-6' => 'UTC+6',
|
||||
'Etc/GMT-5' => 'UTC+5',
|
||||
'Etc/GMT-4' => 'UTC+4',
|
||||
'Etc/GMT-3' => 'UTC+3',
|
||||
'Etc/GMT-2' => 'UTC+2',
|
||||
'Etc/GMT-1' => 'UTC+1',
|
||||
'Etc/GMT+1' => 'UTC-1',
|
||||
'Etc/GMT+2' => 'UTC-2',
|
||||
'Etc/GMT+3' => 'UTC-3',
|
||||
'Etc/GMT+4' => 'UTC-4',
|
||||
'Etc/GMT+5' => 'UTC-5',
|
||||
'Etc/GMT+6' => 'UTC-6',
|
||||
'Etc/GMT+7' => 'UTC-7',
|
||||
'Etc/GMT+8' => 'UTC-8',
|
||||
'Etc/GMT+9' => 'UTC-9',
|
||||
'Etc/GMT+10' => 'UTC-10',
|
||||
'Etc/GMT+11' => 'UTC-11',
|
||||
'Etc/GMT+12' => 'UTC-12',
|
||||
|
||||
'Africa/Abidjan' => 'Africa/Abidjan',
|
||||
'Africa/Accra' => 'Africa/Accra',
|
||||
|
@ -1,10 +1,12 @@
|
||||
<dl>
|
||||
<dt><label for="timezone">{L_BOARD_TIMEZONE}{L_COLON}</label></dt>
|
||||
<!-- IF S_TZ_DATE_OPTIONS -->
|
||||
<!-- IF .timezone_date -->
|
||||
<dd id="tz_select_date" style="display: none;">
|
||||
<select name="tz_date" id="tz_date" class="autowidth tz_select">
|
||||
<option value="">{L_SELECT_CURRENT_TIME}</option>
|
||||
{S_TZ_DATE_OPTIONS}
|
||||
<!-- BEGIN timezone_date -->
|
||||
<option value="{timezone_date.VALUE}"<!-- IF timezone_date.SELECTED --> selected="selected"<!-- ENDIF -->>{timezone_date.TITLE}</option>
|
||||
<!-- END timezone_date -->
|
||||
</select>
|
||||
<input type="button" id="tz_select_date_suggest" class="button2" style="display: none;" timezone-preselect="<!-- IF S_TZ_PRESELECT -->true<!-- ELSE -->false<!-- ENDIF -->" data-l-suggestion="{L_TIMEZONE_DATE_SUGGESTION}" value="{L_TIMEZONE_DATE_SUGGESTION}" />
|
||||
</dd>
|
||||
@ -12,7 +14,13 @@
|
||||
<dd>
|
||||
<select name="tz" id="timezone" class="autowidth tz_select">
|
||||
<option value="">{L_SELECT_TIMEZONE}</option>
|
||||
{S_TZ_OPTIONS}
|
||||
<!-- BEGIN timezone_select -->
|
||||
<optgroup label="{timezone_select.LABEL}" data-tz-value="{timezone_select.VALUE}">
|
||||
<!-- BEGIN timezone_options -->
|
||||
<option title="{timezone_select.timezone_options.TITLE}" value="{timezone_select.timezone_options.VALUE}"<!-- IF timezone_select.timezone_options.SELECTED --> selected="selected"<!-- ENDIF -->>{timezone_select.timezone_options.LABEL}</option>
|
||||
<!-- END timezone_options -->
|
||||
</optgroup>
|
||||
<!-- END timezone_select -->
|
||||
</select>
|
||||
|
||||
<!-- INCLUDEJS timezone.js -->
|
||||
|
@ -1,18 +1,26 @@
|
||||
<tr>
|
||||
<td class="row1" width="50%"><b class="genmed">{L_BOARD_TIMEZONE}{L_COLON}</b></td>
|
||||
<td class="row2">
|
||||
<!-- IF S_TZ_DATE_OPTIONS -->
|
||||
<!-- IF .timezone_date -->
|
||||
<div id="tz_select_date" style="display: none;">
|
||||
<select name="tz_date" id="tz_date" class="autowidth tz_select">
|
||||
<option value="">{L_SELECT_CURRENT_TIME}</option>
|
||||
{S_TZ_DATE_OPTIONS}
|
||||
<!-- BEGIN timezone_date -->
|
||||
<option value="{timezone_date.VALUE}"<!-- IF timezone_date.SELECTED --> selected="selected"<!-- ENDIF -->>{timezone_date.TITLE}</option>
|
||||
<!-- END timezone_date -->
|
||||
</select><br />
|
||||
<input type="button" id="tz_select_date_suggest" class="btnlite" style="display: none;" timezone-preselect="<!-- IF S_TZ_PRESELECT -->true<!-- ELSE -->false<!-- ENDIF -->" data-l-suggestion="{L_TIMEZONE_DATE_SUGGESTION}" value="{L_TIMEZONE_DATE_SUGGESTION}" />
|
||||
</div>
|
||||
<!-- ENDIF -->
|
||||
<select name="tz" id="timezone" class="autowidth tz_select">
|
||||
<option value="">{L_SELECT_TIMEZONE}</option>
|
||||
{S_TZ_OPTIONS}
|
||||
<!-- BEGIN timezone_select -->
|
||||
<optgroup label="{timezone_select.LABEL}" data-tz-value="{timezone_select.VALUE}">
|
||||
<!-- BEGIN timezone_options -->
|
||||
<option title="{timezone_select.timezone_options.TITLE}" value="{timezone_select.timezone_options.VALUE}"<!-- IF timezone_select.timezone_options.SELECTED --> selected="selected"<!-- ENDIF -->>{timezone_select.timezone_options.LABEL}</option>
|
||||
<!-- END timezone_options -->
|
||||
</optgroup>
|
||||
<!-- END timezone_select -->
|
||||
</select>
|
||||
|
||||
<!-- INCLUDEJS timezone.js -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user