mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/17100] Move forum selects to HTML files
PHPBB3-17100
This commit is contained in:
parent
9ee130fc59
commit
4b17de74a4
3 changed files with 51 additions and 25 deletions
|
@ -1120,6 +1120,8 @@ class acp_board
|
|||
*
|
||||
* @param string $value Current date format value
|
||||
* @param string $key Date format key
|
||||
*
|
||||
* @return array Date format select data
|
||||
*/
|
||||
public function dateformat_select(string $value, string $key): array
|
||||
{
|
||||
|
@ -1184,40 +1186,62 @@ class acp_board
|
|||
}
|
||||
|
||||
/**
|
||||
* Select multiple forums
|
||||
*/
|
||||
function select_news_forums($value, $key)
|
||||
* Select for multiple forums
|
||||
*
|
||||
* @param mixed $value Config value, unused
|
||||
* @param string $key Config key
|
||||
*
|
||||
* @return array Forum select data
|
||||
*/
|
||||
public function select_news_forums($value, string $key)
|
||||
{
|
||||
$forum_list = make_forum_select(false, false, true, true, true, false, true);
|
||||
|
||||
// Build forum options
|
||||
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
|
||||
foreach ($forum_list as $f_id => $f_row)
|
||||
{
|
||||
$f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_NEWS, $f_row['forum_options']);
|
||||
|
||||
$s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
|
||||
}
|
||||
$s_forum_options .= '</select>';
|
||||
|
||||
return $s_forum_options;
|
||||
return $this->get_forum_select($key);
|
||||
}
|
||||
|
||||
function select_exclude_forums($value, $key)
|
||||
/**
|
||||
* Select for multiple forums to exclude
|
||||
*
|
||||
* @param mixed $value Config value, unused
|
||||
* @param string $key Config key
|
||||
*
|
||||
* @return array Forum select data
|
||||
*/
|
||||
public function select_exclude_forums($value, string $key): array
|
||||
{
|
||||
return $this->get_forum_select($key, FORUM_OPTION_FEED_EXCLUDE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get forum select data for specified key and option
|
||||
*
|
||||
* @param string $key Config key
|
||||
* @param int $forum_option Forum option bit
|
||||
*
|
||||
* @return array Forum select data
|
||||
*/
|
||||
protected function get_forum_select(string $key, int $forum_option = FORUM_OPTION_FEED_NEWS): array
|
||||
{
|
||||
$forum_list = make_forum_select(false, false, true, true, true, false, true);
|
||||
|
||||
// Build forum options
|
||||
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
|
||||
$forum_options = [];
|
||||
foreach ($forum_list as $f_id => $f_row)
|
||||
{
|
||||
$f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $f_row['forum_options']);
|
||||
|
||||
$s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
|
||||
$forum_options[] = [
|
||||
'value' => $f_id,
|
||||
'selected' => phpbb_optionget($forum_option, $f_row['forum_options']),
|
||||
'disabled' => $f_row['disabled'],
|
||||
'label' => $f_row['padding'] . $f_row['forum_name'],
|
||||
];
|
||||
}
|
||||
$s_forum_options .= '</select>';
|
||||
|
||||
return $s_forum_options;
|
||||
return [
|
||||
'tag' => 'select',
|
||||
'id' => $key,
|
||||
'name' => $key . '[]',
|
||||
'multiple' => true,
|
||||
'options' => $forum_options,
|
||||
];
|
||||
}
|
||||
|
||||
function store_feed_forums($option, $key)
|
||||
|
|
|
@ -184,6 +184,7 @@ class forms extends AbstractExtension
|
|||
'GROUP_ONLY' => (bool) ($form_data['group_only'] ?? false),
|
||||
'DATA' => $form_data['data'] ?? [],
|
||||
'SIZE' => (int) ($form_data['size'] ?? 0),
|
||||
'MULTIPLE' => (bool) ($form_data['multiple'] ?? false),
|
||||
]);
|
||||
}
|
||||
catch (\Twig\Error\Error $e)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
{% for attribute, attribute_value in DATA %}
|
||||
data-{{ attribute|e }}="{{ attribute_value|e('html_attr') }}"
|
||||
{% endfor %}
|
||||
{% if MULTIPLE %}multiple="multiple" {% endif %}
|
||||
{% if SIZE %}size="{{ SIZE }}" {% endif %}>
|
||||
{% endapply %}
|
||||
{% for element in OPTIONS %}
|
||||
|
@ -19,11 +20,11 @@
|
|||
{% endfor %}>
|
||||
{% endapply %}
|
||||
{% for option in element.options %}
|
||||
<option value="{{ option.value }}"{% if option.selected %} selected="selected"{% endif %}>{{ option.label }}</option>
|
||||
<option value="{{ option.value }}"{% if option.selected %} selected="selected"{% endif %}{% if option.disabled %} disabled="disabled" class="disabled-option"{% endif %}>{{ option.label }}</option>
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
{% else %}
|
||||
<option value="{{ element.value }}"{% if element.selected %} selected="selected"{% endif %}>{{ element.label }}</option>
|
||||
<option value="{{ element.value }}"{% if element.selected %} selected="selected"{% endif %}{% if element.disabled %} disabled="disabled" class="disabled-option"{% endif %}>{{ element.label }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
|
Loading…
Add table
Reference in a new issue