1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-21 23:13:43 +02:00

[ticket/16737] Move template logic to template

PHPBB3-16737
This commit is contained in:
rubencm 2021-03-24 22:25:36 +01:00
parent 381cf4b9f1
commit b78efaadc1
2 changed files with 18 additions and 40 deletions

View File

@ -113,7 +113,7 @@
<!-- BEGIN backend --> <!-- BEGIN backend -->
<!-- IF backend.S_STATS --> {% if backend.S_STATS is not empty %}
<form id="acp_search_index_{backend.NAME}" method="post" action="{U_ACTION}"> <form id="acp_search_index_{backend.NAME}" method="post" action="{U_ACTION}">
@ -135,18 +135,23 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<!-- BEGIN data --> {% for stat in backend.S_STATS | batch(2, '') %}
<tr> <tr>
<td>{backend.data.STATISTIC_1}{L_COLON}</td> {% for key, value in stat %}
<td>{backend.data.VALUE_1}</td> {% if value is not empty %}
<td>{backend.data.STATISTIC_2}<!-- IF backend.data.STATISTIC_2 -->{L_COLON}<!-- ENDIF --></td> <td>{{ key }}{L_COLON}</td>
<td>{backend.data.VALUE_2}</td> <td>{{ value }}</td>
{% else %}
<td></td>
<td></td>
{% endif %}
{% endfor %}
</tr> </tr>
<!-- END data --> {% endfor %}
</tbody> </tbody>
</table> </table>
<!-- ENDIF --> {% endif %}
<p class="quick"> <p class="quick">
<!-- IF backend.S_INDEXED --> <!-- IF backend.S_INDEXED -->

View File

@ -189,7 +189,7 @@ class acp_search
} }
unset($cfg_array); unset($cfg_array);
$this->tpl_name = 'acp_search'; $this->tpl_name = 'acp_search_settings';
$this->page_title = 'ACP_SEARCH_SETTINGS'; $this->page_title = 'ACP_SEARCH_SETTINGS';
$template->assign_vars([ $template->assign_vars([
@ -340,45 +340,18 @@ class acp_search
$name = $search->get_name(); $name = $search->get_name();
$data = $search->index_stats(); $data = $search->index_stats();
$statistics = array();
foreach ($data as $statistic => $value)
{
$n = count($statistics);
if ($n && count($statistics[$n - 1]) < 3)
{
$statistics[$n - 1] += array('statistic_2' => $statistic, 'value_2' => $value);
}
else
{
$statistics[] = array('statistic_1' => $statistic, 'value_1' => $value);
}
}
$template->assign_block_vars('backend', array( $template->assign_block_vars('backend', array(
'L_NAME' => $name, 'L_NAME' => $name,
'NAME' => $type, 'NAME' => $type,
'S_ACTIVE' => ($type == $config['search_type']) ? true : false, 'S_ACTIVE' => $type == $config['search_type'],
'S_HIDDEN_FIELDS' => build_hidden_fields(array('search_type' => $type)), 'S_HIDDEN_FIELDS' => build_hidden_fields(array('search_type' => $type)),
'S_INDEXED' => (bool) $search->index_created(), 'S_INDEXED' => (bool) $search->index_created(),
'S_STATS' => (bool) count($statistics)) 'S_STATS' => $data,
); ));
foreach ($statistics as $statistic)
{
$template->assign_block_vars('backend.data', array(
'STATISTIC_1' => $statistic['statistic_1'],
'VALUE_1' => $statistic['value_1'],
'STATISTIC_2' => (isset($statistic['statistic_2'])) ? $statistic['statistic_2'] : '',
'VALUE_2' => (isset($statistic['value_2'])) ? $statistic['value_2'] : '')
);
}
} }
unset($search);
unset($statistics);
unset($data);
$this->tpl_name = 'acp_search'; $this->tpl_name = 'acp_search_index';
$this->page_title = 'ACP_SEARCH_INDEX'; $this->page_title = 'ACP_SEARCH_INDEX';
$template->assign_vars(array( $template->assign_vars(array(