mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 16:56:44 +02:00
[ticket/17100] Move timezone select HTML from PHP file
PHPBB3-17100
This commit is contained in:
@@ -1052,11 +1052,15 @@ class acp_board
|
||||
*/
|
||||
function timezone_select($value, $key)
|
||||
{
|
||||
global $template, $user;
|
||||
global $user;
|
||||
|
||||
$timezone_select = phpbb_timezone_select($template, $user, $value, true);
|
||||
$timezone_select = phpbb_timezone_select($user, $value, true);
|
||||
|
||||
return '<select name="config[' . $key . ']" id="' . $key . '">' . $timezone_select . '</select>';
|
||||
return [
|
||||
'tag' => 'select',
|
||||
'name' => 'config[' . $key . ']',
|
||||
'options' => $timezone_select,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1795,7 +1795,7 @@ class acp_users
|
||||
${'s_sort_' . $sort_option . '_dir'} .= '</select>';
|
||||
}
|
||||
|
||||
phpbb_timezone_select($template, $user, $data['tz'], true);
|
||||
$timezone_select = phpbb_timezone_select($user, $data['tz'], true);
|
||||
$lang_options = phpbb_language_select($db, $data['lang']);
|
||||
|
||||
$user_prefs_data = array(
|
||||
@@ -1839,6 +1839,11 @@ class acp_users
|
||||
'options' => $lang_options,
|
||||
],
|
||||
'S_STYLE_OPTIONS' => style_select($data['style']),
|
||||
'TIMEZONE_OPTIONS' => [
|
||||
'tag' => 'select',
|
||||
'name' => 'tz',
|
||||
'options' => $timezone_select,
|
||||
],
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -443,14 +443,13 @@ 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 string Returns an array containing the options for the time selector.
|
||||
*/
|
||||
function phpbb_timezone_select($template, $user, $default = '', $truncate = false)
|
||||
function phpbb_timezone_select($user, $default = '', $truncate = false)
|
||||
{
|
||||
static $timezones;
|
||||
|
||||
@@ -482,27 +481,22 @@ function phpbb_timezone_select($template, $user, $default = '', $truncate = fals
|
||||
uksort($timezones, 'phpbb_tz_select_compare');
|
||||
}
|
||||
|
||||
$tz_select = $opt_group = '';
|
||||
$opt_group = '';
|
||||
$tz_data = [];
|
||||
|
||||
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="' . $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'],
|
||||
));
|
||||
$tz_data[$timezone['offset']] = [
|
||||
'label' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']),
|
||||
'value' => $key . ' - ' . $timezone['current'],
|
||||
'options' => [],
|
||||
'selected' => !empty($default_offset) && strpos($key, $default_offset) !== false,
|
||||
'data' => ['tz-value' => $key . ' - ' . $timezone['current']],
|
||||
];
|
||||
|
||||
$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']),
|
||||
));
|
||||
$opt_group = $timezone['offset'];
|
||||
}
|
||||
|
||||
$label = $timezone['tz'];
|
||||
@@ -517,19 +511,15 @@ function phpbb_timezone_select($template, $user, $default = '', $truncate = fals
|
||||
$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(
|
||||
$tz_data[$timezone['offset']]['options'][] = [
|
||||
'TITLE' => $title,
|
||||
'VALUE' => $timezone['tz'],
|
||||
'SELECTED' => !empty($selected),
|
||||
'LABEL' => $label,
|
||||
));
|
||||
'value' => $timezone['tz'],
|
||||
'selected' => $timezone['tz'] === $default,
|
||||
'label' => $label,
|
||||
];
|
||||
}
|
||||
$tz_select .= '</optgroup>';
|
||||
|
||||
return $tz_select;
|
||||
return $tz_data;
|
||||
}
|
||||
|
||||
// Functions handling topic/post tracking/marking
|
||||
|
@@ -111,9 +111,9 @@ function phpbb_clean_path($path)
|
||||
*/
|
||||
function tz_select($default = '', $truncate = false)
|
||||
{
|
||||
global $template, $user;
|
||||
global $user;
|
||||
|
||||
return phpbb_timezone_select($template, $user, $default, $truncate);
|
||||
return phpbb_timezone_select($user, $default, $truncate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -156,7 +156,7 @@ class ucp_prefs
|
||||
}
|
||||
$dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>';
|
||||
|
||||
phpbb_timezone_select($template, $user, $data['tz'], true);
|
||||
$timezone_select = phpbb_timezone_select($user, $data['tz'], true);
|
||||
|
||||
// check if there are any user-selectable languages
|
||||
$sql = 'SELECT lang_iso, lang_local_name
|
||||
@@ -206,6 +206,11 @@ class ucp_prefs
|
||||
'options' => $lang_options,
|
||||
],
|
||||
'S_STYLE_OPTIONS' => ($config['override_user_style']) ? '' : style_select($data['user_style'], false, $styles_row),
|
||||
'TIMEZONE_OPTIONS' => [
|
||||
'tag' => 'select',
|
||||
'name' => 'tz',
|
||||
'options' => $timezone_select,
|
||||
],
|
||||
'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)
|
||||
);
|
||||
|
@@ -626,7 +626,7 @@ class ucp_register
|
||||
}
|
||||
|
||||
// Assign template vars for timezone select
|
||||
phpbb_timezone_select($template, $user, $data['tz'], true);
|
||||
$timezone_select = phpbb_timezone_select($user, $data['tz'], true);
|
||||
|
||||
// Checking amount of available languages
|
||||
$sql = 'SELECT lang_iso, lang_local_name
|
||||
@@ -653,6 +653,11 @@ class ucp_register
|
||||
'name' => 'lang',
|
||||
'options' => $lang_options,
|
||||
],
|
||||
'TIMEZONE_OPTIONS' => [
|
||||
'tag' => 'select',
|
||||
'name' => 'tz',
|
||||
'options' => $timezone_select,
|
||||
],
|
||||
'S_TZ_PRESELECT' => !$submit,
|
||||
'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false,
|
||||
'S_REGISTRATION' => true,
|
||||
|
Reference in New Issue
Block a user