diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index d0ced6788f..1f8f632788 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -851,7 +851,7 @@ class acp_board /* @var $auth_providers \phpbb\auth\provider_collection */ $auth_providers = $phpbb_container->get('auth.provider_collection'); - $auth_plugins = array(); + $auth_plugins = []; foreach ($auth_providers as $key => $value) { @@ -864,14 +864,22 @@ class acp_board sort($auth_plugins); - $auth_select = ''; + $auth_select_options = []; foreach ($auth_plugins as $method) { - $selected = ($selected_method == $method) ? ' selected="selected"' : ''; - $auth_select .= "'; + $auth_select_options[] = [ + 'value' => $method, + 'selected' => $selected_method == $method, + 'label' => ucfirst($method), + 'data' => [ + 'toggle-setting' => "#auth_{$method}_settings", + ], + ]; } - return $auth_select; + return [ + 'options' => $auth_select_options, + ]; } /** @@ -881,15 +889,21 @@ class acp_board { global $user; - $auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP'); - $s_smtp_auth_options = ''; + $auth_methods = ['PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP']; + $s_smtp_auth_options = []; foreach ($auth_methods as $method) { - $s_smtp_auth_options .= ''; + $s_smtp_auth_options[] = [ + 'value' => $method, + 'selected' => $selected_method == $method, + 'label' => $user->lang('SMTP_' . str_replace('-', '_', $method)), + ]; } - return $s_smtp_auth_options; + return [ + 'options' => $s_smtp_auth_options, + ]; } /** @@ -899,7 +913,22 @@ class acp_board { global $user; - return ''; + $full_folder_select_options = [ + 0 => [ + 'value' => 1, + 'selected' => $value == 1, + 'label' => $user->lang('DELETE_OLDEST_MESSAGES'), + ], + 1 => [ + 'value' => 2, + 'selected' => $value == 2, + 'label' => $user->lang('HOLD_NEW_MESSAGES_SHORT'), + ], + ]; + + return [ + 'options' => $full_folder_select_options, + ]; } /** @@ -907,7 +936,7 @@ class acp_board */ function select_ip_check($value, $key = '') { - $radio_ary = array(4 => 'ALL', 3 => 'CLASS_C', 2 => 'CLASS_B', 0 => 'NO_IP_VALIDATION'); + $radio_ary = [4 => 'ALL', 3 => 'CLASS_C', 2 => 'CLASS_B', 0 => 'NO_IP_VALIDATION']; return h_radio('config[ip_check]', $radio_ary, $value, $key); } @@ -917,7 +946,7 @@ class acp_board */ function select_ref_check($value, $key = '') { - $radio_ary = array(REFERER_VALIDATE_PATH => 'REF_PATH', REFERER_VALIDATE_HOST => 'REF_HOST', REFERER_VALIDATE_NONE => 'NO_REF_VALIDATION'); + $radio_ary = [REFERER_VALIDATE_PATH => 'REF_PATH', REFERER_VALIDATE_HOST => 'REF_HOST', REFERER_VALIDATE_NONE => 'NO_REF_VALIDATION']; return h_radio('config[referer_validation]', $radio_ary, $value, $key); } @@ -929,23 +958,28 @@ class acp_board { global $user, $config; - $act_ary = array( - 'ACC_DISABLE' => array(true, USER_ACTIVATION_DISABLE), - 'ACC_NONE' => array(true, USER_ACTIVATION_NONE), - 'ACC_USER' => array($config['email_enable'], USER_ACTIVATION_SELF), - 'ACC_ADMIN' => array($config['email_enable'], USER_ACTIVATION_ADMIN), - ); + $act_ary = [ + 'ACC_DISABLE' => [true, USER_ACTIVATION_DISABLE], + 'ACC_NONE' => [true, USER_ACTIVATION_NONE], + 'ACC_USER' => [$config['email_enable'], USER_ACTIVATION_SELF], + 'ACC_ADMIN' => [$config['email_enable'], USER_ACTIVATION_ADMIN], + ]; - $act_options = ''; + $act_options = []; foreach ($act_ary as $key => $data) { list($available, $value) = $data; - $selected = ($selected_value == $value) ? ' selected="selected"' : ''; - $class = (!$available) ? ' class="disabled-option"' : ''; - $act_options .= ''; + $act_options[] = [ + 'value' => $value, + 'selected' => $selected_value == $value, + 'label' => $user->lang($key), + 'disabled' => !$available, + ]; } - return $act_options; + return [ + 'options' => $act_options, + ]; } /** @@ -955,7 +989,27 @@ class acp_board { global $user; - return ' ' . $user->lang['MIN_CHARS'] . ' ' . $user->lang['MAX_CHARS']; + return [ + [ + 'tag' => 'input', + 'id' => $key, + 'type' => 'number', + 'name' => 'config[min_name_chars]', + 'min' => 1, + 'max' => 999, + 'value' => $value, + 'append' => $user->lang('MIN_CHARS') . ' ', + ], + [ + 'tag' => 'input', + 'type' => 'number', + 'name' => 'config[max_name_chars]', + 'min' => 8, + 'max' => 180, + 'value' => $this->new_config['max_name_chars'], + 'append' => $user->lang('MAX_CHARS'), + ], + ]; } /** @@ -965,15 +1019,20 @@ class acp_board { global $user; - $user_char_ary = array('USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII'); - $user_char_options = ''; + $user_char_ary = ['USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII']; + $user_char_options = []; foreach ($user_char_ary as $user_type) { - $selected = ($selected_value == $user_type) ? ' selected="selected"' : ''; - $user_char_options .= ''; + $user_char_options[] = [ + 'value' => $user_type, + 'selected' => $selected_value == $user_type, + 'label' => $user->lang($user_type), + ]; } - return $user_char_options; + return [ + 'options' => $user_char_options, + ]; } /** @@ -983,7 +1042,16 @@ class acp_board { global $user; - return ' ' . $user->lang['MIN_CHARS']; + return [ + [ + 'tag' => 'input', + 'id' => $key, + 'type' => 'number', + 'name' => 'config[min_pass_chars]', + 'value' => $value, + 'append' => $user->lang('MIN_CHARS'), + ], + ]; } /** @@ -994,14 +1062,20 @@ class acp_board global $user; $pass_type_ary = array('PASS_TYPE_ANY', 'PASS_TYPE_CASE', 'PASS_TYPE_ALPHA', 'PASS_TYPE_SYMBOL'); - $pass_char_options = ''; + $pass_char_options = []; foreach ($pass_type_ary as $pass_type) { - $selected = ($selected_value == $pass_type) ? ' selected="selected"' : ''; - $pass_char_options .= ''; + $pass_char_options[] = [ + 'tag' => 'select', + 'value' => $pass_type, + 'selected' => $selected_value == $pass_type, + 'label' => $user->lang[$pass_type], + ]; } - return $pass_char_options; + return [ + 'options' => $pass_char_options, + ]; } /** @@ -1359,8 +1433,22 @@ class acp_board { global $user; - return ' - '; + return [ + [ + 'tag' => 'input', + 'type' => 'submit', + 'name' => $key, + 'id' => $key, + 'class' => 'button2', + 'value' => $user->lang('SEND_TEST_EMAIL'), + ], + [ + 'tag' => 'textarea', + 'name' => $key . '_text', + 'id' => $key . '_text', + 'placeholder' => $user->lang('MESSAGE'), + ], + ]; } /** diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index bca9a97c48..0bdb36eb79 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -291,7 +291,9 @@ function phpbb_language_select(\phpbb\db\driver\driver_interface $db, string $de ]; } - return $lang_options; + return [ + 'options' => $lang_options + ]; } /** @@ -319,14 +321,20 @@ function style_select($default = '', $all = false, array $styledata = []) $db->sql_freeresult($result); } - $style_options = ''; + $style_options = []; foreach ($styledata as $row) { - $selected = ($row['style_id'] == $default) ? ' selected="selected"' : ''; - $style_options .= ''; + $style_options[] = [ + 'tag' => 'select', + 'value' => $row['style_id'], + 'selected' => $row['style_id'] == $default, + 'label' => $row['style_name'], + ]; } - return $style_options; + return [ + 'options' => $style_options, + ]; } /** diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index b8f007cdfd..6058b948fb 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -398,6 +398,32 @@ function phpbb_build_cfg_template(array $tpl_type, string $key, &$new_ary, $conf $tpl['buttons'] = [$no_button, $yes_button]; } break; + + case 'select': + $tpl = [ + 'tag' => 'select', + 'class' => $tpl_type['class'] ?? false, + 'id' => $key, + 'data' => $tpl_type['data'] ?? [], + 'name' => $name, + 'toggleable' => !empty($tpl_type[2]) || !empty($tpl_type['toggleable']), + 'options' => $tpl_type['options'], + 'group_only' => $tpl_type['group_only'] ?? false, + 'size' => $tpl_type[1] ?? $tpl_type['size'] ?? 1, + 'multiple' => $tpl_type['multiple'] ?? false, + ]; + break; + + case 'button': + $tpl = [ + 'tag' => 'input', + 'class' => $tpl_type['options']['class'], + 'id' => $key, + 'type' => $tpl_type['options']['type'], + 'name' => $tpl_type['options']['name'] ?? $name, + 'value' => $tpl_type['options']['value'], + ]; + break; } return $tpl; @@ -484,38 +510,15 @@ function build_cfg_template($tpl_type, $key, &$new_ary, $config_key, $vars) $return = call_user_func_array($call, $args); - if ($tpl_type[0] == 'select') + if (in_array($tpl_type[0], ['select', 'button'])) { - $size = (isset($tpl_type[1])) ? (int) $tpl_type[1] : 1; - - if (is_string($return)) - { - $data_toggle = (!empty($tpl_type[2])) ? ' data-togglable-settings="true"' : ''; - - $tpl = ''; - } - else - { - $tpl = [ - 'tag' => 'select', - 'id' => $key, - 'name' => $name, - 'toggleable' => !empty($tpl_type[2]), - 'options' => $return, - ]; - - // Add size if it differs from default value of 1 - if ($size != 1) - { - $tpl['size'] = $size; - } - } + $tpl_type = array_merge($tpl_type, $return); + $tpl = phpbb_build_cfg_template($tpl_type, $key, $new_ary, $config_key, $vars); } else { $tpl = $return; } - break; default: diff --git a/phpBB/phpbb/template/twig/extension/forms.php b/phpBB/phpbb/template/twig/extension/forms.php index 4d8de94b9d..ee47e19449 100644 --- a/phpBB/phpbb/template/twig/extension/forms.php +++ b/phpBB/phpbb/template/twig/extension/forms.php @@ -179,7 +179,7 @@ class forms extends AbstractExtension 'CLASS' => (string) ($form_data['class'] ?? ''), 'ID' => (string) ($form_data['id'] ?? ''), 'DATA' => $form_data['data'] ?? [], - 'NAME' => (string) $form_data['name'], + 'NAME' => (string) ($form_data['name'] ?? ''), 'TOGGLEABLE' => (bool) ($form_data['toggleable'] ?? false), 'OPTIONS' => $form_data['options'] ?? [], 'GROUP_ONLY' => (bool) ($form_data['group_only'] ?? false), @@ -206,13 +206,14 @@ class forms extends AbstractExtension try { return $environment->render('macros/forms/textarea.twig', [ - 'CLASS' => (string) ($form_data['class'] ?? ''), + 'CLASS' => (string) ($form_data['class'] ?? ''), 'ID' => (string) $form_data['id'], - 'DATA' => $form_data['data'] ?? [], + 'DATA' => $form_data['data'] ?? [], 'NAME' => (string) $form_data['name'], - 'ROWS' => (int) $form_data['rows'], - 'COLS' => (int) $form_data['cols'], - 'CONTENT' => (string) $form_data['content'], + 'ROWS' => (int) ($form_data['rows'] ?? ''), + 'COLS' => (int) ($form_data['cols'] ?? ''), + 'CONTENT' => (string) ($form_data['content'] ?? ''), + 'PLACEHOLDER' => (string) ($form_data['placeholder'] ?? ''), ]); } catch (\Twig\Error\Error $e) diff --git a/phpBB/styles/all/template/macros/forms/select.twig b/phpBB/styles/all/template/macros/forms/select.twig index 3cab1e7199..1ff690268f 100644 --- a/phpBB/styles/all/template/macros/forms/select.twig +++ b/phpBB/styles/all/template/macros/forms/select.twig @@ -21,11 +21,18 @@ label="{{ element.label }}"> {% endapply %} {% for option in element.options %} - + {% endfor %} {% else %} - + {% endif %} {% endfor %} diff --git a/phpBB/styles/all/template/macros/forms/textarea.twig b/phpBB/styles/all/template/macros/forms/textarea.twig index e4fada13f2..a81c5a09cf 100644 --- a/phpBB/styles/all/template/macros/forms/textarea.twig +++ b/phpBB/styles/all/template/macros/forms/textarea.twig @@ -7,4 +7,5 @@ {% endfor %} name="{{ NAME }}" rows="{{ ROWS }}" - cols="{{ COLS }}">{% endapply %}{{ CONTENT }} + cols="{{ COLS }}" + {% if PLACEHOLDER %}placeholder="{{ PLACEHOLDER }}"{% endif %}>{% endapply %}{{ CONTENT }} diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html index 4e81b78fb3..fe1ea17c74 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html @@ -61,7 +61,9 @@