From 8de8878d5e48b1c9febb311859bf3a10f9559ff3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 5 Oct 2024 20:56:58 +0200 Subject: [PATCH] [ticket/17414] Move captcha acp html to html files PHPBB-17414 --- phpBB/adm/style/acp_captcha.html | 16 +++++++-------- phpBB/includes/acp/acp_captcha.php | 33 ++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/phpBB/adm/style/acp_captcha.html b/phpBB/adm/style/acp_captcha.html index 4353becd2f..880adcbe97 100644 --- a/phpBB/adm/style/acp_captcha.html +++ b/phpBB/adm/style/acp_captcha.html @@ -8,12 +8,12 @@

{L_ACP_VC_EXT_GET_MORE}

- +{% if ERRORS %}
-

{L_WARNING}

-

{ERROR_MSG}

+

{{ lang('WARNING') }}

+

{{ ERRORS|join('
') }}

- +{% endif %}
@@ -47,10 +47,10 @@
{L_AVAILABLE_CAPTCHAS} -
-

{L_CAPTCHA_SELECT_EXPLAIN}
-
-
+
+

{{ lang('CAPTCHA_SELECT_EXPLAIN') }}
+
{{ FormsSelect(CAPTCHA_SELECT | merge({id: 'captcha_select', onchange: "(document.getElementById('acp_captcha')).submit()"})) }}
+

{L_CAPTCHA_CONFIGURE_EXPLAIN}
diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index 69e13463ab..e03d2a3901 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -95,7 +95,7 @@ class acp_captcha add_form_key($form_key); $submit = $request->variable('main_submit', false); - $error = $cfg_array = array(); + $errors = $cfg_array = array(); if ($submit) { @@ -103,13 +103,13 @@ class acp_captcha { $cfg_array[$config_var] = $request->variable($config_var, $options['default']); } - validate_config_vars($config_vars, $cfg_array, $error); + validate_config_vars($config_vars, $cfg_array, $errors); if (!check_form_key($form_key)) { - $error[] = $user->lang['FORM_INVALID']; + $errors[] = $user->lang['FORM_INVALID']; } - if ($error) + if ($errors) { $submit = false; } @@ -143,17 +143,24 @@ class acp_captcha } else { - $captcha_select = ''; + $captcha_options = []; foreach ($captchas['available'] as $value => $title) { - $current = ($selected !== false && $value == $selected) ? ' selected="selected"' : ''; - $captcha_select .= ''; + $captcha_options[] = [ + 'value' => $value, + 'label' => $user->lang($title), + 'selected' => $selected !== false && $value == $selected, + ]; } foreach ($captchas['unavailable'] as $value => $title) { - $current = ($selected !== false && $value == $selected) ? ' selected="selected"' : ''; - $captcha_select .= ''; + $captcha_options[] = [ + 'value' => $value, + 'label' => $user->lang($title), + 'selected' => $selected !== false && $value == $selected, + 'class' => 'disabled-option', + ]; } $demo_captcha = $factory->get_instance($selected); @@ -166,8 +173,12 @@ class acp_captcha $template->assign_vars(array( 'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id), 'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(), - 'CAPTCHA_SELECT' => $captcha_select, - 'ERROR_MSG' => implode('
', $error), + 'CAPTCHA_SELECT' => [ + 'tag' => 'select', + 'name' => 'select_captcha', + 'options' => $captcha_options, + ], + 'ERRORS' => $errors, 'U_ACTION' => $this->u_action, ));