[ticket/16737] Use twig syntax

PHPBB3-16737
This commit is contained in:
rubencm 2021-03-27 20:37:06 +01:00
parent 4e1e7f03da
commit e5d5c0e29f
4 changed files with 98 additions and 124 deletions

View file

@ -1,4 +1,4 @@
<!-- INCLUDE overall_header.html -->
{% include 'overall_header.html' %}
<a id="maincontent"></a>
@ -11,36 +11,36 @@
{
close_waitscreen = 0;
// no scrollbars
popup('{UA_PROGRESS_BAR}&amp;type=' + progress_type, 400, 240, '_index');
popup('{{ UA_PROGRESS_BAR }}&amp;type=' + progress_type, 400, 240, '_index');
}
// ]]>
</script>
<h1>{L_ACP_SEARCH_INDEX}</h1>
<h1>{{ lang('ACP_SEARCH_INDEX') }}</h1>
<p>{L_ACP_SEARCH_INDEX_EXPLAIN}</p>
<p>{{ lang('ACP_SEARCH_INDEX_EXPLAIN') }}</p>
<!-- BEGIN backend -->
{% for backend in loops.backend %}
{% 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.TYPE }}" method="post" action="{{ U_ACTION }}">
<fieldset class="tabulated">
{backend.S_HIDDEN_FIELDS}
{{ backend.S_HIDDEN_FIELDS }}
<legend>{L_INDEX_STATS}{L_COLON} {backend.L_NAME} <!-- IF backend.S_ACTIVE -->({L_ACTIVE}) <!-- ENDIF --></legend>
<legend>{{ lang('INDEX_STATS') }}{{ lang('COLON') }} {{ backend.NAME }} {% if backend.S_ACTIVE %}({{ lang('ACTIVE') }}) {% endif %}</legend>
<table class="table1">
<caption>{backend.L_NAME} <!-- IF backend.S_ACTIVE -->({L_ACTIVE}) <!-- ENDIF --></caption>
<caption>{{ backend.NAME }} {% if backend.S_ACTIVE %}({{ lang('ACTIVE') }}) {% endif %}</caption>
<col class="col1" /><col class="col2" /><col class="col1" /><col class="col2" />
<thead>
<tr>
<th>{L_STATISTIC}</th>
<th>{L_VALUE}</th>
<th>{L_STATISTIC}</th>
<th>{L_VALUE}</th>
<th>{{ lang('STATISTIC') }}</th>
<th>{{ lang('VALUE') }}</th>
<th>{{ lang('STATISTIC') }}</th>
<th>{{ lang('VALUE') }}</th>
</tr>
</thead>
<tbody>
@ -48,7 +48,7 @@
<tr>
{% for key, value in stat %}
{% if value is not empty %}
<td>{{ key }}{L_COLON}</td>
<td>{{ key }}{{ lang('COLON') }}</td>
<td>{{ value }}</td>
{% else %}
<td></td>
@ -63,18 +63,18 @@
{% endif %}
<p class="quick">
<!-- IF backend.S_INDEXED -->
{% if backend.S_INDEXED %}
<input type="hidden" name="action" value="delete" />
<input class="button2" type="submit" value="{L_DELETE_INDEX}" onclick="popup_progress_bar('delete');" />
<!-- ELSE -->
<input class="button2" type="submit" value="{{ lang('DELETE_INDEX') }}" onclick="popup_progress_bar('delete');" />
{% else %}
<input type="hidden" name="action" value="create" />
<input class="button2" type="submit" value="{L_CREATE_INDEX}" onclick="popup_progress_bar('create');" />
<!-- ENDIF -->
<input class="button2" type="submit" value="{{ lang('CREATE_INDEX') }}" onclick="popup_progress_bar('create');" />
{% endif %}
</p>
{S_FORM_TOKEN}
{{ S_FORM_TOKEN }}
</fieldset>
</form>
<!-- END backend -->
{% endfor %}
<!-- INCLUDE overall_footer.html -->
{% include 'overall_footer.html' %}

View file

@ -1,4 +1,4 @@
<!-- INCLUDE overall_header.html -->
{% include 'overall_header.html' %}
<a id="maincontent"></a>
@ -11,24 +11,24 @@
{
close_waitscreen = 0;
// no scrollbars
popup('{UA_PROGRESS_BAR}&amp;type=' + progress_type, 400, 240, '_index');
popup('{{ UA_PROGRESS_BAR }}&amp;type=' + progress_type, 400, 240, '_index');
}
// ]]>
</script>
<h1>{L_CONTINUE}</h1>
<h1>{{ lang('CONTINUE') }}</h1>
<p>{L_CONTINUE_EXPLAIN}</p>
<p>{{ lang('CONTINUE_EXPLAIN') }}</p>
<form id="acp_search_continue" method="post" action="{U_ACTION}">
<form id="acp_search_continue" method="post" action="{{ U_ACTION }}">
<fieldset>
<legend>{L_ACP_SUBMIT_CHANGES}</legend>
<legend>{{ lang('ACP_SUBMIT_CHANGES') }}</legend>
<p class="submit-buttons">
<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" onclick="popup_progress_bar('{S_ACTION}');" />&nbsp;
<input class="button2" type="submit" id="cancel" name="cancel" value="{L_CANCEL}" />
<input class="button1" type="submit" id="submit" name="submit" value="{{ lang('SUBMIT') }}" onclick="popup_progress_bar('{{ S_ACTION }}');" />&nbsp;
<input class="button2" type="submit" id="cancel" name="cancel" value="{{ lang('CANCEL') }}" />
</p>
{S_FORM_TOKEN}
{{ S_FORM_TOKEN }}
</fieldset>
</form>
<!-- INCLUDE overall_footer.html -->
{% include 'overall_footer.html' %}

View file

@ -1,39 +1,39 @@
<!-- INCLUDE overall_header.html -->
{% include 'overall_header.html' %}
<a id="maincontent"></a>
<h1>{L_ACP_SEARCH_SETTINGS}</h1>
<h1>{{ lang('ACP_SEARCH_SETTINGS') }}</h1>
<p>{L_ACP_SEARCH_SETTINGS_EXPLAIN}</p>
<p>{{ lang('ACP_SEARCH_SETTINGS_EXPLAIN') }}</p>
<form id="acp_search" method="post" action="{U_ACTION}">
<form id="acp_search" method="post" action="{{ U_ACTION }}">
<fieldset>
<legend>{L_GENERAL_SEARCH_SETTINGS}</legend>
<legend>{{ lang('GENERAL_SEARCH_SETTINGS') }}</legend>
<dl>
<dt><label for="load_search">{L_YES_SEARCH}{L_COLON}</label><br /><span>{L_YES_SEARCH_EXPLAIN}</span></dt>
<dd><label><input type="radio" class="radio" id="load_search" name="config[load_search]" value="1"<!-- IF S_YES_SEARCH --> checked="checked"<!-- ENDIF --> /> {L_YES}</label>
<label><input type="radio" class="radio" name="config[load_search]" value="0"<!-- IF not S_YES_SEARCH --> checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
<dt><label for="load_search">{{ lang('YES_SEARCH') }}{{ lang('COLON') }}</label><br /><span>{{ lang('YES_SEARCH_EXPLAIN') }}</span></dt>
<dd><label><input type="radio" class="radio" id="load_search" name="config[load_search]" value="1"{% if S_YES_SEARCH %} checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="config[load_search]" value="0"{% if not S_YES_SEARCH %} checked="checked"{% endif %} /> {{ lang('NO') }}</label></dd>
</dl>
<dl>
<dt><label for="search_interval">{L_SEARCH_INTERVAL}{L_COLON}</label><br /><span>{L_SEARCH_INTERVAL_EXPLAIN}</span></dt>
<dd><input id="search_interval" type="number" min="0" max="9999" name="config[search_interval]" value="{SEARCH_INTERVAL}" /> {L_SECONDS}</dd>
<dt><label for="search_interval">{{ lang('SEARCH_INTERVAL') }}{{ lang('COLON') }}</label><br /><span>{{ lang('SEARCH_INTERVAL_EXPLAIN') }}</span></dt>
<dd><input id="search_interval" type="number" min="0" max="9999" name="config[search_interval]" value="{{ SEARCH_INTERVAL }}" /> {{ lang('SECONDS') }}</dd>
</dl>
<dl>
<dt><label for="search_anonymous_interval">{L_SEARCH_GUEST_INTERVAL}{L_COLON}</label><br /><span>{L_SEARCH_GUEST_INTERVAL_EXPLAIN}</span></dt>
<dd><input id="search_anonymous_interval" type="number" min="0" max="9999" name="config[search_anonymous_interval]" value="{SEARCH_GUEST_INTERVAL}" /> {L_SECONDS}</dd>
<dt><label for="search_anonymous_interval">{{ lang('SEARCH_GUEST_INTERVAL') }}{{ lang('COLON') }}</label><br /><span>{{ lang('SEARCH_GUEST_INTERVAL_EXPLAIN') }}</span></dt>
<dd><input id="search_anonymous_interval" type="number" min="0" max="9999" name="config[search_anonymous_interval]" value="{{ SEARCH_GUEST_INTERVAL }}" /> {{ lang('SECONDS') }}</dd>
</dl>
<dl>
<dt><label for="limit_search_load">{L_LIMIT_SEARCH_LOAD}{L_COLON}</label><br /><span>{L_LIMIT_SEARCH_LOAD_EXPLAIN}</span></dt>
<dd><input id="limit_search_load" type="text" size="4" maxlength="4" name="config[limit_search_load]" value="{LIMIT_SEARCH_LOAD}" /></dd>
<dt><label for="limit_search_load">{{ lang('LIMIT_SEARCH_LOAD') }}{{ lang('COLON') }}</label><br /><span>{{ lang('LIMIT_SEARCH_LOAD_EXPLAIN') }}</span></dt>
<dd><input id="limit_search_load" type="text" size="4" maxlength="4" name="config[limit_search_load]" value="{{ LIMIT_SEARCH_LOAD }}" /></dd>
</dl>
<dl>
<dt><label for="min_search_author_chars">{L_MIN_SEARCH_AUTHOR_CHARS}{L_COLON}</label><br /><span>{L_MIN_SEARCH_AUTHOR_CHARS_EXPLAIN}</span></dt>
<dd><input id="min_search_author_chars" type="number" min="0" max="9999" name="config[min_search_author_chars]" value="{MIN_SEARCH_AUTHOR_CHARS}" /></dd>
<dt><label for="min_search_author_chars">{{ lang('MIN_SEARCH_AUTHOR_CHARS') }}{{ lang('COLON') }}</label><br /><span>{{ lang('MIN_SEARCH_AUTHOR_CHARS_EXPLAIN') }}</span></dt>
<dd><input id="min_search_author_chars" type="number" min="0" max="9999" name="config[min_search_author_chars]" value="{{ MIN_SEARCH_AUTHOR_CHARS }}" /></dd>
</dl>
<dl>
<dt><label for="max_num_search_keywords">{L_MAX_NUM_SEARCH_KEYWORDS}{L_COLON}</label><br /><span>{L_MAX_NUM_SEARCH_KEYWORDS_EXPLAIN}</span></dt>
<dd><input id="max_num_search_keywords" type="number" min="0" max="9999" name="config[max_num_search_keywords]" value="{MAX_NUM_SEARCH_KEYWORDS}" /></dd>
<dt><label for="max_num_search_keywords">{{ lang('MAX_NUM_SEARCH_KEYWORDS') }}{{ lang('COLON') }}</label><br /><span>{{ lang('MAX_NUM_SEARCH_KEYWORDS_EXPLAIN') }}</span></dt>
<dd><input id="max_num_search_keywords" type="number" min="0" max="9999" name="config[max_num_search_keywords]" value="{{ MAX_NUM_SEARCH_KEYWORDS }}" /></dd>
</dl>
<dl>
<dt>
@ -43,36 +43,36 @@
<dd><input id="default_search_return_chars" name="config[default_search_return_chars]" type="number" value="{{ DEFAULT_SEARCH_RETURN_CHARS }}" min="0" max="9999"></dd>
</dl>
<dl>
<dt><label for="search_store_results">{L_SEARCH_STORE_RESULTS}{L_COLON}</label><br /><span>{L_SEARCH_STORE_RESULTS_EXPLAIN}</span></dt>
<dd><input id="search_store_results" type="number" min="0" max="999999" name="config[search_store_results]" value="{SEARCH_STORE_RESULTS}" /> {L_SECONDS}</dd>
<dt><label for="search_store_results">{{ lang('SEARCH_STORE_RESULTS') }}{{ lang('COLON') }}</label><br /><span>{{ lang('SEARCH_STORE_RESULTS_EXPLAIN') }}</span></dt>
<dd><input id="search_store_results" type="number" min="0" max="999999" name="config[search_store_results]" value="{{ SEARCH_STORE_RESULTS }}" /> {{ lang('SECONDS') }}</dd>
</dl>
</fieldset>
<fieldset>
<legend>{L_SEARCH_TYPE}</legend>
<legend>{{ lang('SEARCH_TYPE') }}</legend>
<dl>
<dt><label for="search_type">{L_SEARCH_TYPE}{L_COLON}</label><br /><span>{L_SEARCH_TYPE_EXPLAIN}</span></dt>
<dd><select id="search_type" name="config[search_type]" data-togglable-settings="true">{S_SEARCH_TYPES}</select></dd>
<dt><label for="search_type">{{ lang('SEARCH_TYPE') }}{{ lang('COLON') }}</label><br /><span>{{ lang('SEARCH_TYPE_EXPLAIN') }}</span></dt>
<dd><select id="search_type" name="config[search_type]" data-togglable-settings="true">{{ S_SEARCH_TYPES }}</select></dd>
</dl>
</fieldset>
<!-- BEGIN backend -->
{% for backend in loops.backend %}
<fieldset id="search_{backend.IDENTIFIER}_settings">
<legend>{backend.NAME}</legend>
{backend.SETTINGS}
<fieldset id="search_{{ backend.IDENTIFIER }}_settings">
<legend>{{ backend.NAME }}</legend>
{{ backend.SETTINGS }}
</fieldset>
<!-- END backend -->
{% endfor %}
<fieldset>
<legend>{L_ACP_SUBMIT_CHANGES}</legend>
<legend>{{ lang('ACP_SUBMIT_CHANGES') }}</legend>
<p class="submit-buttons">
<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" />
<input class="button1" type="submit" id="submit" name="submit" value="{{ lang('SUBMIT') }}" />&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{{ lang('RESET') }}" />
</p>
{S_FORM_TOKEN}
{{ S_FORM_TOKEN }}
</fieldset>
</form>
<!-- INCLUDE overall_footer.html -->
{% include 'overall_footer.html' %}

View file

@ -277,6 +277,8 @@ class acp_search
}
/**
* Execute action
*
* @param string $id
* @param string $mode
* @throws Exception
@ -337,8 +339,8 @@ class acp_search
foreach ($this->search_backend_collection as $search)
{
$this->template->assign_block_vars('backend', [
'L_NAME' => $search->get_name(),
'NAME' => $search->get_type(),
'NAME' => $search->get_name(),
'TYPE' => $search->get_type(),
'S_ACTIVE' => $search->get_type() === $this->config['search_type'],
'S_HIDDEN_FIELDS' => build_hidden_fields(['search_type' => $search->get_type()]),
@ -407,67 +409,39 @@ class acp_search
$action = $state[self::STATE_ACTION];
$post_counter = &$state[self::STATE_POST_COUNTER];
switch ($action)
// Execute create/delete
$search = $this->search_backend_factory->get($type);
try
{
case 'delete':
$search = $this->search_backend_factory->get($type);
$status = ($action == 'create') ? $search->create_index($post_counter) : $search->delete_index($post_counter);
if ($status) // Status is not null, so action is in progress....
{
$this->save_state($state); // update $post_counter in $state in the database
try
{
if ($status = $search->delete_index($post_counter)) // Status is not null, so deleting is in progress....
{
$this->save_state($state); // update $post_counter in $state in the database
$u_action = append_sid($this->phpbb_admin_path . "index." . $this->php_ex, "i=$id&mode=$mode&action=$action&hash=" . generate_link_hash('acp_search'), false);
meta_refresh(1, $u_action);
$u_action = append_sid($this->phpbb_admin_path . "index." . $this->php_ex, "i=$id&mode=$mode&action=delete&hash=" . generate_link_hash('acp_search'), false);
meta_refresh(1, $u_action);
trigger_error($this->language->lang('SEARCH_INDEX_DELETE_REDIRECT', (int) $status['row_count'], $status['post_counter']) . $this->language->lang('SEARCH_INDEX_DELETE_REDIRECT_RATE', $status['rows_per_second']));
}
}
catch (Exception $e)
{
$this->save_state([]); // Unexpected error, cancel action
trigger_error($e->getMessage() . adm_back_link($this->u_action) . $this->close_popup_js(), E_USER_WARNING);
}
$search->tidy();
$this->save_state([]); // finished operation, cancel action
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_SEARCH_INDEX_REMOVED', false, [$search->get_name()]);
trigger_error($this->language->lang('SEARCH_INDEX_REMOVED') . adm_back_link($this->u_action) . $this->close_popup_js());
break;
case 'create':
$search = $this->search_backend_factory->get($type);
try
{
$search = $this->search_backend_factory->get($type);
if ($status = $search->create_index($post_counter)) // Status is not null, so indexing is in progress....
{
$this->save_state($state); // update $post_counter in $state in the database
$u_action = append_sid($this->phpbb_admin_path . "index." . $this->php_ex, "i=$id&mode=$mode&action=create&hash=" . generate_link_hash('acp_search'), false);
meta_refresh(1, $u_action);
trigger_error($this->language->lang('SEARCH_INDEX_CREATE_REDIRECT', (int) $status['row_count'], $status['post_counter']) . $this->language->lang('SEARCH_INDEX_CREATE_REDIRECT_RATE', $status['rows_per_second']));
}
}
catch (Exception $e)
{
// Error executing create_index
$this->save_state([]);
trigger_error($e->getMessage() . adm_back_link($this->u_action) . $this->close_popup_js(), E_USER_WARNING);
}
$search->tidy();
$this->save_state([]); // finished operation, cancel action
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_SEARCH_INDEX_CREATED', false, [$search->get_name()]);
trigger_error($this->language->lang('SEARCH_INDEX_CREATED') . adm_back_link($this->u_action) . $this->close_popup_js());
break;
$message_redirect = $this->language->lang(($action == 'create') ? 'SEARCH_INDEX_CREATE_REDIRECT' : 'SEARCH_INDEX_DELETE_REDIRECT', (int) $status['row_count'], $status['post_counter']);
$message_rate = $this->language->lang(($action == 'create') ? 'SEARCH_INDEX_CREATE_REDIRECT_RATE' : 'SEARCH_INDEX_DELETE_REDIRECT_RATE', $status['rows_per_second']);
trigger_error($message_redirect . $message_rate);
}
}
catch (Exception $e)
{
$this->save_state([]); // Unexpected error, cancel action
trigger_error($e->getMessage() . adm_back_link($this->u_action) . $this->close_popup_js(), E_USER_WARNING);
}
$search->tidy();
$this->save_state([]); // finished operation, cancel action
$log_operation = ($action == 'create') ? 'LOG_SEARCH_INDEX_CREATED' : 'LOG_SEARCH_INDEX_REMOVED';
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, $log_operation, false, [$search->get_name()]);
$message = $this->language->lang(($action == 'create') ? 'SEARCH_INDEX_CREATED' : 'SEARCH_INDEX_REMOVED');
trigger_error($message . adm_back_link($this->u_action) . $this->close_popup_js());
}
/**