[ticket/17100] Move filesize config HTML from PHP files

PHPBB3-17100
This commit is contained in:
Marc Alexander 2022-04-19 21:45:02 +02:00
parent b09af35c90
commit 540097eed7
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
5 changed files with 37 additions and 10 deletions

View file

@ -208,7 +208,11 @@
</dl>
<dl>
<dt><label for="extgroup_filesize">{L_MAX_EXTGROUP_FILESIZE}{L_COLON}</label></dt>
<dd><input type="number" id="extgroup_filesize" min="0" max="999999999999999" step="any" name="max_filesize" value="{EXTGROUP_FILESIZE}" /> <select name="size_select">{S_EXT_GROUP_SIZE_OPTIONS}</select></dd>
<dd>
<input type="number" id="extgroup_filesize" min="0" max="999999999999999" step="any" name="max_filesize" value="{EXTGROUP_FILESIZE}" />
{% from 'form_macros.twig' import select %}
{{ select(EXT_GROUP_SIZE_OPTIONS) }}
</dd>
</dl>
<dl>
<dt><label for="assigned_extensions">{L_ASSIGNED_EXTENSIONS}{L_COLON}</label></dt>

View file

@ -8,6 +8,7 @@
{% if form_data.maxlength %}maxlength="{{ form_data.maxlength }}"{% endif %}
{% if form_data.min %}min="{{ form_data.min }}"{% endif %}
{% if form_data.max %}max="{{ form_data.max }}"{% endif %}
{% if form_data.step %}step="{{ form_data.step }}"{% endif %}
{% if form_data.type == 'password' %}autocomplete="off"{% endif %}
{% if form_data.checked %}checked="checked"{% endif %}
{% if form_data.class %}class="{{ form_data.class }}"{% endif %}

View file

@ -794,7 +794,10 @@ class acp_attachments
'ASSIGNED_EXTENSIONS' => $assigned_extensions,
'S_CATEGORY_SELECT' => $this->category_select('special_category', $group_id, 'category'),
'S_EXT_GROUP_SIZE_OPTIONS' => size_select_options($size_format),
'EXT_GROUP_SIZE_OPTIONS' => [
'name' => 'size_select',
'options' => size_select_options($size_format),
],
'S_EXTENSION_OPTIONS' => $s_extension_options,
'S_FILENAME_LIST' => $filename_list,
'S_EDIT_GROUP' => true,
@ -1723,8 +1726,23 @@ class acp_attachments
$size_var = $filesize['si_identifier'];
$value = $filesize['value'];
// size and maxlength must not be specified for input of type number
return '<input type="number" id="' . $key . '" min="0" max="999999999999999" step="any" name="config[' . $key . ']" value="' . $value . '" /> <select name="' . $key . '">' . size_select_options($size_var) . '</select>';
return [
[
'tag' => 'input',
'id' => $key,
'type' => 'number',
'name' => 'config[' . $key . ']',
'min' => 0,
'max' => 999999999999999,
'step' => 'any',
'value' => $value,
],
[
'tag' => 'select',
'name' => $key,
'options' => size_select_options($size_var),
]
];
}
/**

View file

@ -160,20 +160,23 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
*/
function size_select_options($size_compare)
{
global $user;
global $language;
$size_types_text = array($user->lang['BYTES'], $user->lang['KIB'], $user->lang['MIB']);
$size_types_text = array($language->lang('BYTES'), $language->lang('KIB'), $language->lang('MIB'));
$size_types = array('b', 'kb', 'mb');
$s_size_options = '';
$size_options = [];
for ($i = 0, $size = count($size_types_text); $i < $size; $i++)
{
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
$s_size_options .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
$size_options[] = [
'value' => $size_types[$i],
'selected' => $size_compare == $size_types[$i],
'label' => $size_types_text[$i],
];
}
return $s_size_options;
return $size_options;
}
/**

View file

@ -8,6 +8,7 @@
{% if form_data.maxlength %}maxlength="{{ form_data.maxlength }}"{% endif %}
{% if form_data.min %}min="{{ form_data.min }}"{% endif %}
{% if form_data.max %}max="{{ form_data.max }}"{% endif %}
{% if form_data.step %}step="{{ form_data.step }}"{% endif %}
{% if form_data.type == 'password' %}autocomplete="off"{% endif %}
{% if form_data.checked %}checked="checked"{% endif %}
{% if form_data.class %}class="{{ form_data.class }}"{% endif %}