From a45f8f0796d9f11ee88080618ffd29b2f90a7f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dark=E2=9D=B6?= <25451052+Dark1z@users.noreply.github.com> Date: Fri, 11 Feb 2022 23:03:33 +0530 Subject: [PATCH 1/2] [ticket/16913] Add Search Index Progress Bar with Stats - Update SQL for count of posts - Update search index test - Removed "Pop-up Progress Bar". - For first run display the "Success Message". - Display the Info from "Pop-up Progress Bar" to "Success Message". - Only display "Redirect" & "Rate" of post refreshed "Success Message". - Minor Language Fix. - Use `ORDER BY post_id ASC` for progress stats. - Removed HTML from Lang String. - Moved HTML to PHP file. - Increased the size of Progress-Bar by 2x. PHPBB3-16913 --- phpBB/adm/style/acp_search.html | 19 +---- phpBB/includes/acp/acp_search.php | 124 +++++++++++++++++++----------- phpBB/language/en/acp/search.php | 13 ++-- tests/functional/search/base.php | 30 ++++++++ 4 files changed, 118 insertions(+), 68 deletions(-) diff --git a/phpBB/adm/style/acp_search.html b/phpBB/adm/style/acp_search.html index af7bb86be5..cba7660e1e 100644 --- a/phpBB/adm/style/acp_search.html +++ b/phpBB/adm/style/acp_search.html @@ -78,24 +78,11 @@ - -

{L_ACP_SEARCH_INDEX}

{L_CONTINUE_EXPLAIN}

+ {% if L_CONTINUE_PROGRESS %}
{{ L_CONTINUE_PROGRESS }}
{% endif %}
@@ -151,10 +138,10 @@

- + - +

{S_FORM_TOKEN} diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index c4bf11e4cf..151e3b95ca 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -262,11 +262,6 @@ class acp_search { switch ($action) { - case 'progress_bar': - $type = $request->variable('type', ''); - $this->display_progress_bar($type); - break; - case 'delete': $this->state[1] = 'delete'; break; @@ -311,14 +306,24 @@ class acp_search { $this->state = array(''); $this->save_state(); - trigger_error($error . adm_back_link($this->u_action) . $this->close_popup_js(), E_USER_WARNING); + trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING); } } + else if ($submit) + { + meta_refresh(1, append_sid($this->u_action . '&action=delete&skip_rows=' . $post_counter . '&hash=' . generate_link_hash('acp_search'))); + $lang_str_ary = [ + $user->lang('DELETING_INDEX_IN_PROGRESS'), + $user->lang('DELETING_INDEX_IN_PROGRESS_EXPLAIN'), + $this->get_post_index_progress($post_counter) + ]; + trigger_error(implode('
', $lang_str_ary)); + } else { $starttime = microtime(true); $row_count = 0; - while (still_on_time() && $post_counter <= $this->max_post_id) + while (still_on_time() && $post_counter < $this->max_post_id) { $sql = 'SELECT post_id, poster_id, forum_id FROM ' . POSTS_TABLE . ' @@ -350,7 +355,14 @@ class acp_search $totaltime = microtime(true) - $starttime; $rows_per_second = $row_count / $totaltime; meta_refresh(1, append_sid($this->u_action . '&action=delete&skip_rows=' . $post_counter . '&hash=' . generate_link_hash('acp_search'))); - trigger_error($user->lang('SEARCH_INDEX_DELETE_REDIRECT', (int) $row_count, $post_counter) . $user->lang('SEARCH_INDEX_DELETE_REDIRECT_RATE', $rows_per_second)); + $lang_str_ary = [ + $user->lang('DELETING_INDEX_IN_PROGRESS'), + $user->lang('DELETING_INDEX_IN_PROGRESS_EXPLAIN'), + $user->lang('SEARCH_INDEX_DELETE_REDIRECT', (int) $row_count, $post_counter), + $user->lang('SEARCH_INDEX_DELETE_REDIRECT_RATE', $rows_per_second), + $this->get_post_index_progress($post_counter) + ]; + trigger_error(implode('
', $lang_str_ary)); } } @@ -360,7 +372,7 @@ class acp_search $this->save_state(); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_SEARCH_INDEX_REMOVED', false, array($name)); - trigger_error($user->lang['SEARCH_INDEX_REMOVED'] . adm_back_link($this->u_action) . $this->close_popup_js()); + trigger_error($user->lang['SEARCH_INDEX_REMOVED'] . adm_back_link($this->u_action)); break; case 'create': @@ -371,9 +383,19 @@ class acp_search { $this->state = array(''); $this->save_state(); - trigger_error($error . adm_back_link($this->u_action) . $this->close_popup_js(), E_USER_WARNING); + trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING); } } + else if ($submit) + { + meta_refresh(1, append_sid($this->u_action . '&action=create&skip_rows=' . $post_counter . '&hash=' . generate_link_hash('acp_search'))); + $lang_str_ary = [ + $user->lang('INDEXING_IN_PROGRESS'), + $user->lang('INDEXING_IN_PROGRESS_EXPLAIN'), + $this->get_post_index_progress($post_counter) + ]; + trigger_error(implode('
', $lang_str_ary)); + } else { $sql = 'SELECT forum_id, enable_indexing @@ -388,7 +410,7 @@ class acp_search $starttime = microtime(true); $row_count = 0; - while (still_on_time() && $post_counter <= $this->max_post_id) + while (still_on_time() && $post_counter < $this->max_post_id) { $sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id FROM ' . POSTS_TABLE . ' @@ -437,7 +459,14 @@ class acp_search $totaltime = microtime(true) - $starttime; $rows_per_second = $row_count / $totaltime; meta_refresh(1, append_sid($this->u_action . '&action=create&skip_rows=' . $post_counter . '&hash=' . generate_link_hash('acp_search'))); - trigger_error($user->lang('SEARCH_INDEX_CREATE_REDIRECT', (int) $row_count, $post_counter) . $user->lang('SEARCH_INDEX_CREATE_REDIRECT_RATE', $rows_per_second)); + $lang_str_ary = [ + $user->lang('INDEXING_IN_PROGRESS'), + $user->lang('INDEXING_IN_PROGRESS_EXPLAIN'), + $user->lang('SEARCH_INDEX_CREATE_REDIRECT', (int) $row_count, $post_counter), + $user->lang('SEARCH_INDEX_CREATE_REDIRECT_RATE', $rows_per_second), + $this->get_post_index_progress($post_counter) + ]; + trigger_error(implode('
', $lang_str_ary)); } } @@ -447,7 +476,7 @@ class acp_search $this->save_state(); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_SEARCH_INDEX_CREATED', false, array($name)); - trigger_error($user->lang['SEARCH_INDEX_CREATED'] . adm_back_link($this->u_action) . $this->close_popup_js()); + trigger_error($user->lang['SEARCH_INDEX_CREATED'] . adm_back_link($this->u_action)); break; } } @@ -516,8 +545,6 @@ class acp_search $template->assign_vars(array( 'S_INDEX' => true, 'U_ACTION' => $this->u_action . '&hash=' . generate_link_hash('acp_search'), - 'U_PROGRESS_BAR' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&mode=$mode&action=progress_bar"), - 'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&mode=$mode&action=progress_bar")), )); if (isset($this->state[1])) @@ -526,40 +553,12 @@ class acp_search 'S_CONTINUE_INDEXING' => $this->state[1], 'U_CONTINUE_INDEXING' => $this->u_action . '&action=' . $this->state[1] . '&hash=' . generate_link_hash('acp_search'), 'L_CONTINUE' => ($this->state[1] == 'create') ? $user->lang['CONTINUE_INDEXING'] : $user->lang['CONTINUE_DELETING_INDEX'], - 'L_CONTINUE_EXPLAIN' => ($this->state[1] == 'create') ? $user->lang['CONTINUE_INDEXING_EXPLAIN'] : $user->lang['CONTINUE_DELETING_INDEX_EXPLAIN']) - ); + 'L_CONTINUE_EXPLAIN' => ($this->state[1] == 'create') ? $user->lang['CONTINUE_INDEXING_EXPLAIN'] : $user->lang['CONTINUE_DELETING_INDEX_EXPLAIN'], + 'L_CONTINUE_PROGRESS' => (isset($this->state[2]) && $this->state[2] > 0) ? $this->get_post_index_progress($this->state[2]) : $this->get_post_index_progress(0) + )); } } - function display_progress_bar($type) - { - global $template, $user; - - $l_type = ($type == 'create') ? 'INDEXING_IN_PROGRESS' : 'DELETING_INDEX_IN_PROGRESS'; - - adm_page_header($user->lang[$l_type]); - - $template->set_filenames(array( - 'body' => 'progress_bar.html') - ); - - $template->assign_vars(array( - 'L_PROGRESS' => $user->lang[$l_type], - 'L_PROGRESS_EXPLAIN' => $user->lang[$l_type . '_EXPLAIN']) - ); - - adm_page_footer(); - } - - function close_popup_js() - { - return "\n"; - } - function get_search_types() { global $phpbb_extension_manager; @@ -586,6 +585,39 @@ class acp_search return $max_post_id; } + /** + * Get progress stats of search index with HTML progress bar. + * + * @param int $post_counter Post ID of last post indexed. + * @return string Returns string with HTML progress bar and stats. + */ + function get_post_index_progress(int $post_counter) + { + global $db, $language; + + $sql = 'SELECT COUNT(post_id) as done_count + FROM ' . POSTS_TABLE . ' + WHERE post_id <= ' . (int) $post_counter; + $result = $db->sql_query($sql); + $done_count = (int) $db->sql_fetchfield('done_count'); + $db->sql_freeresult($result); + + $sql = 'SELECT COUNT(post_id) as remain_count + FROM ' . POSTS_TABLE . ' + WHERE post_id > ' . (int) $post_counter; + $result = $db->sql_query($sql); + $remain_count = (int) $db->sql_fetchfield('remain_count'); + $db->sql_freeresult($result); + + $total_count = $done_count + $remain_count; + $percent = ($done_count / $total_count) * 100; + + $progress = sprintf('
%3$.2f %%
', $done_count, $total_count, $percent); + $progress .= $language->lang('SEARCH_INDEX_PROGRESS', $done_count, $remain_count, $total_count); + + return $progress; + } + function save_state($state = false) { global $config; diff --git a/phpBB/language/en/acp/search.php b/phpBB/language/en/acp/search.php index a79c67fd8e..51cef39d47 100644 --- a/phpBB/language/en/acp/search.php +++ b/phpBB/language/en/acp/search.php @@ -52,7 +52,7 @@ $lang = array_merge($lang, array( 'DEFAULT_SEARCH_RETURN_CHARS' => 'Default number of returned characters', 'DEFAULT_SEARCH_RETURN_CHARS_EXPLAIN' => 'The default number of characters that will be returned while searching. A value of 0 will return the entire post.', 'DELETE_INDEX' => 'Delete index', - 'DELETING_INDEX_IN_PROGRESS' => 'Deleting the index in progress', + 'DELETING_INDEX_IN_PROGRESS' => 'Deletion of index is in progress…', 'DELETING_INDEX_IN_PROGRESS_EXPLAIN' => 'The search backend is currently cleaning its index. This can take a few minutes.', 'FULLTEXT_MYSQL_INCOMPATIBLE_DATABASE' => 'The MySQL fulltext backend can only be used with MySQL4 and above.', @@ -92,7 +92,7 @@ $lang = array_merge($lang, array( 'GO_TO_SEARCH_INDEX' => 'Go to search index page', 'INDEX_STATS' => 'Index statistics', - 'INDEXING_IN_PROGRESS' => 'Indexing in progress', + 'INDEXING_IN_PROGRESS' => 'Indexing in progress…', 'INDEXING_IN_PROGRESS_EXPLAIN' => 'The search backend is currently indexing all posts on the board. This can take from a few minutes to a few hours depending on your board’s size.', 'LIMIT_SEARCH_LOAD' => 'Search page system load limit', @@ -112,18 +112,19 @@ $lang = array_merge($lang, array( 'SEARCH_GUEST_INTERVAL' => 'Guest search flood interval', 'SEARCH_GUEST_INTERVAL_EXPLAIN' => 'Number of seconds guests must wait between searches. If one guest searches all others have to wait until the time interval passed.', 'SEARCH_INDEX_CREATE_REDIRECT' => array( - 2 => 'All posts up to post id %2$d have now been indexed, of which %1$d posts were within this step.
', + 2 => 'All posts up to post id %2$d have now been indexed, of which %1$d posts were within this step.', ), 'SEARCH_INDEX_CREATE_REDIRECT_RATE' => array( - 2 => 'The current rate of indexing is approximately %1$.1f posts per second.
Indexing in progress…', + 2 => 'The current rate of indexing is approximately %1$.1f posts per second.', ), 'SEARCH_INDEX_DELETE_REDIRECT' => array( - 2 => 'All posts up to post id %2$d have been removed from the search index, of which %1$d posts were within this step.
', + 2 => 'All posts up to post id %2$d have been removed from the search index, of which %1$d posts were within this step.', ), 'SEARCH_INDEX_DELETE_REDIRECT_RATE' => array( - 2 => 'The current rate of deleting is approximately %1$.1f posts per second.
Deleting in progress…', + 2 => 'The current rate of deleting is approximately %1$.1f posts per second.', ), 'SEARCH_INDEX_CREATED' => 'Successfully indexed all posts in the board database.', + 'SEARCH_INDEX_PROGRESS' => 'Done: %1$d | Pending: %2$d | Total: %3$d', 'SEARCH_INDEX_REMOVED' => 'Successfully deleted the search index for this backend.', 'SEARCH_INTERVAL' => 'User search flood interval', 'SEARCH_INTERVAL_EXPLAIN' => 'Number of seconds users must wait between searches. This interval is checked independently for each user.', diff --git a/tests/functional/search/base.php b/tests/functional/search/base.php index 582ff917f5..41a14a8113 100644 --- a/tests/functional/search/base.php +++ b/tests/functional/search/base.php @@ -191,6 +191,21 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case ); $form->setValues($form_values); $crawler = self::submit($form); + + $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]'); + + if ($meta_refresh->count() > 0) + { + // Wait for posts to be fully indexed + while ($meta_refresh->count() > 0) + { + preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match); + $url = $match[1]; + $crawler = self::request('POST', $url); + $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]'); + } + } + $this->assertContainsLang('SEARCH_INDEX_CREATED', $crawler->text()); // Ensure search index has been actually created @@ -213,6 +228,21 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case ); $form->setValues($form_values); $crawler = self::submit($form); + + $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]'); + + if ($meta_refresh->count() > 0) + { + // Wait for index to be fully deleted + while ($meta_refresh->count() > 0) + { + preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match); + $url = $match[1]; + $crawler = self::request('POST', $url); + $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]'); + } + } + $this->assertContainsLang('SEARCH_INDEX_REMOVED', $crawler->text()); // Ensure search index has been actually removed From 3db6cc98f55e1b0c2b8a606d2d21bd534b2fb686 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Nov 2022 22:23:56 +0100 Subject: [PATCH 2/2] [ticket/16913] Move progress bar HTML to acp_search.html PHPBB3-16913 --- phpBB/adm/style/acp_search.html | 44 ++++++++++++-- phpBB/includes/acp/acp_search.php | 96 +++++++++++++++++++------------ 2 files changed, 98 insertions(+), 42 deletions(-) diff --git a/phpBB/adm/style/acp_search.html b/phpBB/adm/style/acp_search.html index cba7660e1e..039091c45d 100644 --- a/phpBB/adm/style/acp_search.html +++ b/phpBB/adm/style/acp_search.html @@ -81,12 +81,28 @@

{L_ACP_SEARCH_INDEX}

-

{L_CONTINUE_EXPLAIN}

- {% if L_CONTINUE_PROGRESS %}
{{ L_CONTINUE_PROGRESS }}
{% endif %} +

+ {% if S_CONTINUE_INDEXING == 'create' %} + {{ lang('CONTINUE_INDEXING_EXPLAIN') }} + {% else %} + {{ lang('CONTINUE_DELETING_INDEX_EXPLAIN') }} + {% endif %} +

- {L_ACP_SUBMIT_CHANGES} + {{ lang('CONTINUE_INDEXING') }} + {% if CONTINUE_PROGRESS %} +
+
+
+ {{ CONTINUE_PROGRESS.PERCENTAGE|number_format(2) ~ ' %' }}
+ {{ lang('SEARCH_INDEX_PROGRESS', CONTINUE_PROGRESS.VALUE, CONTINUE_PROGRESS.REMAINING, CONTINUE_PROGRESS.TOTAL) }} +
+ {% endif %}

  @@ -138,10 +154,10 @@

- + - +

{S_FORM_TOKEN} @@ -152,6 +168,24 @@ + +
+

{{ INDEXING_TITLE }}

+

+ {{ INDEXING_EXPLAIN }} + {% if INDEXING_PROGRESS %}
{{ INDEXING_PROGRESS }}{% endif %} + {% if INDEXING_RATE %}
{{ INDEXING_RATE }}{% endif %} + {% if INDEXING_PROGRESS_BAR %} +
+
+ {{ INDEXING_PROGRESS_BAR.PERCENTAGE|number_format(2) ~ ' %' }}
+ {{ lang('SEARCH_INDEX_PROGRESS', INDEXING_PROGRESS_BAR.VALUE, INDEXING_PROGRESS_BAR.REMAINING, INDEXING_PROGRESS_BAR.TOTAL) }} + {% endif %} +

+
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index 151e3b95ca..8e195e2cf3 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -239,7 +239,7 @@ class acp_search function index($id, $mode) { - global $db, $user, $template, $phpbb_log, $request; + global $db, $language, $user, $template, $phpbb_log, $request; global $config, $phpbb_admin_path, $phpEx; $action = $request->variable('action', ''); @@ -312,12 +312,17 @@ class acp_search else if ($submit) { meta_refresh(1, append_sid($this->u_action . '&action=delete&skip_rows=' . $post_counter . '&hash=' . generate_link_hash('acp_search'))); - $lang_str_ary = [ - $user->lang('DELETING_INDEX_IN_PROGRESS'), - $user->lang('DELETING_INDEX_IN_PROGRESS_EXPLAIN'), - $this->get_post_index_progress($post_counter) - ]; - trigger_error(implode('
', $lang_str_ary)); + $template->assign_vars([ + 'S_INDEX_PROGRESS' => true, + 'INDEXING_TITLE' => $language->lang('DELETING_INDEX_IN_PROGRESS'), + 'INDEXING_EXPLAIN' => $language->lang('DELETING_INDEX_IN_PROGRESS_EXPLAIN'), + 'INDEXING_PROGRESS_BAR' => $this->get_post_index_progress($post_counter), + ]); + + $this->tpl_name = 'acp_search'; + $this->page_title = 'ACP_SEARCH_INDEX'; + + return; } else { @@ -355,14 +360,20 @@ class acp_search $totaltime = microtime(true) - $starttime; $rows_per_second = $row_count / $totaltime; meta_refresh(1, append_sid($this->u_action . '&action=delete&skip_rows=' . $post_counter . '&hash=' . generate_link_hash('acp_search'))); - $lang_str_ary = [ - $user->lang('DELETING_INDEX_IN_PROGRESS'), - $user->lang('DELETING_INDEX_IN_PROGRESS_EXPLAIN'), - $user->lang('SEARCH_INDEX_DELETE_REDIRECT', (int) $row_count, $post_counter), - $user->lang('SEARCH_INDEX_DELETE_REDIRECT_RATE', $rows_per_second), - $this->get_post_index_progress($post_counter) - ]; - trigger_error(implode('
', $lang_str_ary)); + + $template->assign_vars([ + 'S_INDEX_PROGRESS' => true, + 'INDEXING_TITLE' => $language->lang('DELETING_INDEX_IN_PROGRESS'), + 'INDEXING_EXPLAIN' => $language->lang('DELETING_INDEX_IN_PROGRESS_EXPLAIN'), + 'INDEXING_PROGRESS' => $language->lang('SEARCH_INDEX_DELETE_REDIRECT', $row_count, $post_counter), + 'INDEXING_RATE' => $language->lang('SEARCH_INDEX_DELETE_REDIRECT_RATE', $rows_per_second), + 'INDEXING_PROGRESS_BAR' => $this->get_post_index_progress($post_counter), + ]); + + $this->tpl_name = 'acp_search'; + $this->page_title = 'ACP_SEARCH_INDEX'; + + return; } } @@ -389,12 +400,18 @@ class acp_search else if ($submit) { meta_refresh(1, append_sid($this->u_action . '&action=create&skip_rows=' . $post_counter . '&hash=' . generate_link_hash('acp_search'))); - $lang_str_ary = [ - $user->lang('INDEXING_IN_PROGRESS'), - $user->lang('INDEXING_IN_PROGRESS_EXPLAIN'), - $this->get_post_index_progress($post_counter) - ]; - trigger_error(implode('
', $lang_str_ary)); + + $template->assign_vars([ + 'S_INDEX_PROGRESS' => true, + 'INDEXING_TITLE' => $language->lang('INDEXING_IN_PROGRESS'), + 'INDEXING_EXPLAIN' => $language->lang('INDEXING_IN_PROGRESS_EXPLAIN'), + 'INDEXING_PROGRESS_BAR' => $this->get_post_index_progress($post_counter), + ]); + + $this->tpl_name = 'acp_search'; + $this->page_title = 'ACP_SEARCH_INDEX'; + + return; } else { @@ -459,14 +476,19 @@ class acp_search $totaltime = microtime(true) - $starttime; $rows_per_second = $row_count / $totaltime; meta_refresh(1, append_sid($this->u_action . '&action=create&skip_rows=' . $post_counter . '&hash=' . generate_link_hash('acp_search'))); - $lang_str_ary = [ - $user->lang('INDEXING_IN_PROGRESS'), - $user->lang('INDEXING_IN_PROGRESS_EXPLAIN'), - $user->lang('SEARCH_INDEX_CREATE_REDIRECT', (int) $row_count, $post_counter), - $user->lang('SEARCH_INDEX_CREATE_REDIRECT_RATE', $rows_per_second), - $this->get_post_index_progress($post_counter) - ]; - trigger_error(implode('
', $lang_str_ary)); + $template->assign_vars([ + 'S_INDEX_PROGRESS' => true, + 'INDEXING_TITLE' => $language->lang('INDEXING_IN_PROGRESS'), + 'INDEXING_EXPLAIN' => $language->lang('INDEXING_IN_PROGRESS_EXPLAIN'), + 'INDEXING_PROGRESS' => $language->lang('SEARCH_INDEX_CREATE_REDIRECT', $row_count, $post_counter), + 'INDEXING_RATE' => $language->lang('SEARCH_INDEX_CREATE_REDIRECT_RATE', $rows_per_second), + 'INDEXING_PROGRESS_BAR' => $this->get_post_index_progress($post_counter), + ]); + + $this->tpl_name = 'acp_search'; + $this->page_title = 'ACP_SEARCH_INDEX'; + + return; } } @@ -552,9 +574,7 @@ class acp_search $template->assign_vars(array( 'S_CONTINUE_INDEXING' => $this->state[1], 'U_CONTINUE_INDEXING' => $this->u_action . '&action=' . $this->state[1] . '&hash=' . generate_link_hash('acp_search'), - 'L_CONTINUE' => ($this->state[1] == 'create') ? $user->lang['CONTINUE_INDEXING'] : $user->lang['CONTINUE_DELETING_INDEX'], - 'L_CONTINUE_EXPLAIN' => ($this->state[1] == 'create') ? $user->lang['CONTINUE_INDEXING_EXPLAIN'] : $user->lang['CONTINUE_DELETING_INDEX_EXPLAIN'], - 'L_CONTINUE_PROGRESS' => (isset($this->state[2]) && $this->state[2] > 0) ? $this->get_post_index_progress($this->state[2]) : $this->get_post_index_progress(0) + 'CONTINUE_PROGRESS' => (isset($this->state[2]) && $this->state[2] > 0) ? $this->get_post_index_progress($this->state[2]) : $this->get_post_index_progress(0) )); } } @@ -589,7 +609,7 @@ class acp_search * Get progress stats of search index with HTML progress bar. * * @param int $post_counter Post ID of last post indexed. - * @return string Returns string with HTML progress bar and stats. + * @return array Returns array with progress bar data. */ function get_post_index_progress(int $post_counter) { @@ -612,10 +632,12 @@ class acp_search $total_count = $done_count + $remain_count; $percent = ($done_count / $total_count) * 100; - $progress = sprintf('
%3$.2f %%
', $done_count, $total_count, $percent); - $progress .= $language->lang('SEARCH_INDEX_PROGRESS', $done_count, $remain_count, $total_count); - - return $progress; + return [ + 'VALUE' => $done_count, + 'TOTAL' => $total_count, + 'PERCENTAGE' => $percent, + 'REMAINING' => $remain_count, + ]; } function save_state($state = false)