[ticket/17414] Move captcha acp html to html files

PHPBB-17414
This commit is contained in:
Marc Alexander 2024-10-05 20:56:58 +02:00
parent c27c1fa7a3
commit 8de8878d5e
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
2 changed files with 30 additions and 19 deletions

View file

@ -8,12 +8,12 @@
<p>{L_ACP_VC_EXT_GET_MORE}</p>
<!-- IF ERROR_MSG -->
{% if ERRORS %}
<div class="errorbox">
<h3>{L_WARNING}</h3>
<p>{ERROR_MSG}</p>
<h3>{{ lang('WARNING') }}</h3>
<p>{{ ERRORS|join('<br>') }}</p>
</div>
<!-- ENDIF -->
{% endif %}
<form id="acp_captcha" method="post" action="{U_ACTION}">
@ -47,10 +47,10 @@
<fieldset>
<legend>{L_AVAILABLE_CAPTCHAS}</legend>
<dl>
<dt><label for="captcha_select">{L_CAPTCHA_SELECT}{L_COLON}</label><br /><span>{L_CAPTCHA_SELECT_EXPLAIN}</span></dt>
<dd><select id="captcha_select" name="select_captcha" onchange="(document.getElementById('acp_captcha')).submit()" >{CAPTCHA_SELECT}</select></dd>
</dl>
<dl>
<dt><label for="captcha_select">{{ lang('CAPTCHA_SELECT') ~ lang('COLON') }}</label><br><span>{{ lang('CAPTCHA_SELECT_EXPLAIN') }}</span></dt>
<dd>{{ FormsSelect(CAPTCHA_SELECT | merge({id: 'captcha_select', onchange: "(document.getElementById('acp_captcha')).submit()"})) }}</dd>
</dl>
<!-- IF S_CAPTCHA_HAS_CONFIG -->
<dl>
<dt><label for="configure">{L_CAPTCHA_CONFIGURE}{L_COLON}</label><br /><span>{L_CAPTCHA_CONFIGURE_EXPLAIN}</span></dt>

View file

@ -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 .= '<option value="' . $value . '"' . $current . '>' . $user->lang($title) . '</option>';
$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 .= '<option value="' . $value . '"' . $current . ' class="disabled-option">' . $user->lang($title) . '</option>';
$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('<br />', $error),
'CAPTCHA_SELECT' => [
'tag' => 'select',
'name' => 'select_captcha',
'options' => $captcha_options,
],
'ERRORS' => $errors,
'U_ACTION' => $this->u_action,
));