diff --git a/phpBB/adm/style/form_macros.twig b/phpBB/adm/style/form_macros.twig
index 845d039ddd..35fe1bf4df 100644
--- a/phpBB/adm/style/form_macros.twig
+++ b/phpBB/adm/style/form_macros.twig
@@ -37,10 +37,30 @@
{% endmacro %}
-{% macro select(form_data) %}
- ';
}
- 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,
+ ],
);
/**
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index ae8b978c69..48efdca0d8 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -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) ? '' : '';
- $tz_select .= '';
- return $tz_select;
+ return $tz_data;
}
// Functions handling topic/post tracking/marking
diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php
index 77b2ef4220..95def7b7e9 100644
--- a/phpBB/includes/functions_compatibility.php
+++ b/phpBB/includes/functions_compatibility.php
@@ -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);
}
/**
diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php
index 625ade741c..dcbd2624f2 100644
--- a/phpBB/includes/ucp/ucp_prefs.php
+++ b/phpBB/includes/ucp/ucp_prefs.php
@@ -156,7 +156,7 @@ class ucp_prefs
}
$dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '';
- 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)
);
diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php
index bdece67890..b739cb6ce8 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -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,
diff --git a/phpBB/styles/all/template/macros/form_macros.twig b/phpBB/styles/all/template/macros/form_macros.twig
index 845d039ddd..074891a5ee 100644
--- a/phpBB/styles/all/template/macros/form_macros.twig
+++ b/phpBB/styles/all/template/macros/form_macros.twig
@@ -37,11 +37,31 @@
{% endmacro %}
-{% macro select(form_data) %}
-
- {% for option in form_data.options %}
-
- {% endfor %}
+{% macro select(form_data, class, id, name, group_only) %}
+ {% apply replace({"\n": ' ', '\t': ''}) %}
+
+ {% endapply %}
+ {% for element in form_data.options %}
+ {% if not group_only and element.options %}
+ {% apply replace({"\n": ' ', '\t': ''}) %}
+
+ {% else %}
+
+ {% endif %}
+ {% endfor %}
{% endmacro %}
diff --git a/phpBB/styles/prosilver/template/timezone_option.html b/phpBB/styles/prosilver/template/timezone_option.html
index 01786d5ef4..47da5f63c1 100644
--- a/phpBB/styles/prosilver/template/timezone_option.html
+++ b/phpBB/styles/prosilver/template/timezone_option.html
@@ -1,28 +1,17 @@
-
-
- -
-
-
-
-
-
-
+ {% from "macros/form_macros.twig" import select %}
+
+ {% if TIMEZONE_OPTIONS %}
+ -
+ {% set tz_date_data = TIMEZONE_OPTIONS|merge({ options: [{ value: "", label: lang('SELECT_CURRENT_TIME') }]|merge(TIMEZONE_OPTIONS.options) }) %}
+ {{ select(tz_date_data, 'autowidth tz_select', 'tz_date', 'tz_date', true) }}
-
+ {% endif %}
-
-
-
-
-
-
-
+ {% set tz_select_data = TIMEZONE_OPTIONS|merge({ options: [{ value: "", label: lang('SELECT_TIMEZONE') }]|merge(TIMEZONE_OPTIONS.options) }) %}
+ {{ select(tz_select_data, 'autowidth tz_select timezone', 'timezone') }}
-
+ {% INCLUDEJS('timezone.js') %}