[ticket/17100] Move html of build_select to templates

PHPBB3-17100
This commit is contained in:
Marc Alexander 2022-04-18 22:33:30 +02:00
parent d91f11d55f
commit b09af35c90
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
4 changed files with 16 additions and 18 deletions

View file

@ -65,7 +65,8 @@
<!-- ENDIF --> <!-- ENDIF -->
<fieldset class="quick"> <fieldset class="quick">
<select name="action">{S_INACTIVE_OPTIONS}</select> {% from 'form_macros.twig' import select %}
{{ select(INACTIVE_OPTIONS) }}
<input class="button2" type="submit" name="submit" value="{L_SUBMIT}" /> <input class="button2" type="submit" name="submit" value="{L_SUBMIT}" />
<p class="small"><a href="#" onclick="marklist('inactive', 'mark', true); return false;">{L_MARK_ALL}</a> &bull; <a href="#" onclick="marklist('inactive', 'mark', false); return false;">{L_UNMARK_ALL}</a></p> <p class="small"><a href="#" onclick="marklist('inactive', 'mark', true); return false;">{L_MARK_ALL}</a> &bull; <a href="#" onclick="marklist('inactive', 'mark', false); return false;">{L_UNMARK_ALL}</a></p>
{S_FORM_TOKEN} {S_FORM_TOKEN}

View file

@ -306,7 +306,10 @@ class acp_inactive
$template->assign_vars(array( $template->assign_vars(array(
'S_INACTIVE_USERS' => true, 'S_INACTIVE_USERS' => true,
'S_INACTIVE_OPTIONS' => build_select($option_ary), 'INACTIVE_OPTIONS' => [
'name' => 'action',
'options' => build_select($option_ary),
],
'S_LIMIT_DAYS' => $s_limit_days, 'S_LIMIT_DAYS' => $s_limit_days,
'S_SORT_KEY' => $s_sort_key, 'S_SORT_KEY' => $s_sort_key,

View file

@ -626,16 +626,7 @@ class acp_main
)); ));
} }
$option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE'); $template->assign_var('S_INACTIVE_USERS', true);
if ($config['email_enable'])
{
$option_ary += array('remind' => 'REMIND');
}
$template->assign_vars(array(
'S_INACTIVE_USERS' => true,
'S_INACTIVE_OPTIONS' => build_select($option_ary))
);
} }
// Warn if install is still present // Warn if install is still present

View file

@ -209,18 +209,21 @@ function adm_back_link($u_action)
/** /**
* Build select field options in acp pages * Build select field options in acp pages
*/ */
function build_select($option_ary, $option_default = false) function build_select($option_ary, $option_default = false): array
{ {
global $user; global $language;
$html = ''; $options = [];
foreach ($option_ary as $value => $title) foreach ($option_ary as $value => $title)
{ {
$selected = ($option_default !== false && $value == $option_default) ? ' selected="selected"' : ''; $options[] = [
$html .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$title] . '</option>'; 'value' => $value,
'selected' => $option_default !== false && $value == $option_default,
'label' => $language->lang($title),
];
} }
return $html; return $options;
} }
/** /**