aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/acp/acp_search.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/acp/acp_search.php')
-rw-r--r--phpBB/includes/acp/acp_search.php92
1 files changed, 32 insertions, 60 deletions
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php
index 0cd67b1c34..eddc6871f8 100644
--- a/phpBB/includes/acp/acp_search.php
+++ b/phpBB/includes/acp/acp_search.php
@@ -1,10 +1,13 @@
<?php
/**
*
-* @package acp
-* @version $Id$
-* @copyright (c) 2005 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -16,9 +19,6 @@ if (!defined('IN_PHPBB'))
exit;
}
-/**
-* @package acp
-*/
class acp_search
{
var $u_action;
@@ -77,9 +77,11 @@ class acp_search
continue;
}
- $name = ucfirst(strtolower(str_replace('_', ' ', $type)));
+ $name = $search->get_name();
+
$selected = ($config['search_type'] == $type) ? ' selected="selected"' : '';
- $search_options .= '<option value="' . $type . '"' . $selected . '>' . $name . '</option>';
+ $identifier = substr($type, strrpos($type, '\\') + 1);
+ $search_options .= "<option value=\"$type\"$selected data-toggle-setting=\"#search_{$identifier}_settings\">$name</option>";
if (method_exists($search, 'acp'))
{
@@ -88,9 +90,10 @@ class acp_search
if (!$submit)
{
$template->assign_block_vars('backend', array(
- 'NAME' => $name,
- 'SETTINGS' => $vars['tpl'])
- );
+ 'NAME' => $name,
+ 'SETTINGS' => $vars['tpl'],
+ 'IDENTIFIER' => $identifier,
+ ));
}
else if (is_array($vars['config']))
{
@@ -232,15 +235,7 @@ class acp_search
global $db, $user, $auth, $template, $cache;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
- if (isset($_REQUEST['action']) && is_array($_REQUEST['action']))
- {
- $action = request_var('action', array('' => false));
- $action = key($action);
- }
- else
- {
- $action = request_var('action', '');
- }
+ $action = request_var('action', '');
$this->state = explode(',', $config['search_indexing_state']);
if (isset($_POST['cancel']))
@@ -283,7 +278,7 @@ class acp_search
{
trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
}
- $name = ucfirst(strtolower(str_replace('_', ' ', $this->state[0])));
+ $name = $this->search->get_name();
$action = &$this->state[1];
@@ -345,7 +340,7 @@ class acp_search
$totaltime = $mtime[0] + $mtime[1] - $starttime;
$rows_per_second = $row_count / $totaltime;
meta_refresh(1, append_sid($this->u_action . '&amp;action=delete&amp;skip_rows=' . $post_counter));
- trigger_error(sprintf($user->lang['SEARCH_INDEX_DELETE_REDIRECT'], $post_counter, $row_count, $rows_per_second));
+ trigger_error($user->lang('SEARCH_INDEX_DELETE_REDIRECT', (int) $row_count, $post_counter, $rows_per_second));
}
}
@@ -405,9 +400,8 @@ class acp_search
$i = 0;
while ($row = ($buffer ? $rows[$i++] : $db->sql_fetchrow($result)))
{
- // Indexing enabled for this forum or global announcement?
- // Global announcements get indexed by default.
- if (!$row['forum_id'] || (isset($forums[$row['forum_id']]) && $forums[$row['forum_id']]))
+ // Indexing enabled for this forum
+ if (isset($forums[$row['forum_id']]) && $forums[$row['forum_id']])
{
$this->search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
}
@@ -436,7 +430,7 @@ class acp_search
$totaltime = $mtime[0] + $mtime[1] - $starttime;
$rows_per_second = $row_count / $totaltime;
meta_refresh(1, append_sid($this->u_action . '&amp;action=create&amp;skip_rows=' . $post_counter));
- trigger_error(sprintf($user->lang['SEARCH_INDEX_CREATE_REDIRECT'], $post_counter, $row_count, $rows_per_second));
+ trigger_error($user->lang('SEARCH_INDEX_CREATE_REDIRECT', (int) $row_count, $post_counter) . $user->lang('SEARCH_INDEX_CREATE_REDIRECT_RATE', $rows_per_second));
}
}
@@ -463,7 +457,7 @@ class acp_search
continue;
}
- $name = ucfirst(strtolower(str_replace('_', ' ', $type)));
+ $name = $search->get_name();
$data = array();
if (method_exists($search, 'index_stats'))
@@ -562,27 +556,15 @@ class acp_search
function get_search_types()
{
- global $phpbb_root_path, $phpEx;
-
- $search_types = array();
+ global $phpbb_root_path, $phpEx, $phpbb_extension_manager;
- $dp = @opendir($phpbb_root_path . 'includes/search');
+ $finder = $phpbb_extension_manager->get_finder();
- if ($dp)
- {
- while (($file = readdir($dp)) !== false)
- {
- if ((preg_match('#\.' . $phpEx . '$#', $file)) && ($file != "search.$phpEx"))
- {
- $search_types[] = preg_replace('#^(.*?)\.' . $phpEx . '$#', '\1', $file);
- }
- }
- closedir($dp);
-
- sort($search_types);
- }
-
- return $search_types;
+ return $finder
+ ->extension_suffix('_backend')
+ ->extension_directory('/search')
+ ->core_path('phpbb/search/')
+ ->get_classes();
}
function get_max_post_id()
@@ -617,27 +599,17 @@ class acp_search
*/
function init_search($type, &$search, &$error)
{
- global $phpbb_root_path, $phpEx, $user;
-
- if (!preg_match('#^\w+$#', $type) || !file_exists("{$phpbb_root_path}includes/search/$type.$phpEx"))
- {
- $error = $user->lang['NO_SUCH_SEARCH_MODULE'];
- return $error;
- }
-
- include_once("{$phpbb_root_path}includes/search/$type.$phpEx");
+ global $phpbb_root_path, $phpEx, $user, $auth, $config, $db;
- if (!class_exists($type))
+ if (!class_exists($type) || !method_exists($type, 'keyword_search'))
{
$error = $user->lang['NO_SUCH_SEARCH_MODULE'];
return $error;
}
$error = false;
- $search = new $type($error);
+ $search = new $type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
return $error;
}
}
-
-?> \ No newline at end of file