mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-11 13:58:54 +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 $value Current date format value
|
||||||
* @param string $key Date format key
|
* @param string $key Date format key
|
||||||
|
*
|
||||||
|
* @return array Date format select data
|
||||||
*/
|
*/
|
||||||
public function dateformat_select(string $value, string $key): array
|
public function dateformat_select(string $value, string $key): array
|
||||||
{
|
{
|
||||||
|
@ -1184,40 +1186,62 @@ class acp_board
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select multiple forums
|
* Select for multiple forums
|
||||||
*/
|
*
|
||||||
function select_news_forums($value, $key)
|
* @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);
|
return $this->get_forum_select($key);
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
$forum_list = make_forum_select(false, false, true, true, true, false, true);
|
||||||
|
|
||||||
// Build forum options
|
// Build forum options
|
||||||
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
|
$forum_options = [];
|
||||||
foreach ($forum_list as $f_id => $f_row)
|
foreach ($forum_list as $f_id => $f_row)
|
||||||
{
|
{
|
||||||
$f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $f_row['forum_options']);
|
$forum_options[] = [
|
||||||
|
'value' => $f_id,
|
||||||
$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>';
|
'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)
|
function store_feed_forums($option, $key)
|
||||||
|
|
|
@ -184,6 +184,7 @@ class forms extends AbstractExtension
|
||||||
'GROUP_ONLY' => (bool) ($form_data['group_only'] ?? false),
|
'GROUP_ONLY' => (bool) ($form_data['group_only'] ?? false),
|
||||||
'DATA' => $form_data['data'] ?? [],
|
'DATA' => $form_data['data'] ?? [],
|
||||||
'SIZE' => (int) ($form_data['size'] ?? 0),
|
'SIZE' => (int) ($form_data['size'] ?? 0),
|
||||||
|
'MULTIPLE' => (bool) ($form_data['multiple'] ?? false),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
catch (\Twig\Error\Error $e)
|
catch (\Twig\Error\Error $e)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
{% for attribute, attribute_value in DATA %}
|
{% for attribute, attribute_value in DATA %}
|
||||||
data-{{ attribute|e }}="{{ attribute_value|e('html_attr') }}"
|
data-{{ attribute|e }}="{{ attribute_value|e('html_attr') }}"
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% if MULTIPLE %}multiple="multiple" {% endif %}
|
||||||
{% if SIZE %}size="{{ SIZE }}" {% endif %}>
|
{% if SIZE %}size="{{ SIZE }}" {% endif %}>
|
||||||
{% endapply %}
|
{% endapply %}
|
||||||
{% for element in OPTIONS %}
|
{% for element in OPTIONS %}
|
||||||
|
@ -19,11 +20,11 @@
|
||||||
{% endfor %}>
|
{% endfor %}>
|
||||||
{% endapply %}
|
{% endapply %}
|
||||||
{% for option in element.options %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</optgroup>
|
</optgroup>
|
||||||
{% else %}
|
{% 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 %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Add table
Reference in a new issue