diff options
Diffstat (limited to 'phpBB/includes/acp/acp_search.php')
-rw-r--r-- | phpBB/includes/acp/acp_search.php | 71 |
1 files changed, 20 insertions, 51 deletions
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index 0cd67b1c34..11a2511aee 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -2,9 +2,8 @@ /** * * @package acp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -77,7 +76,8 @@ 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>'; @@ -232,15 +232,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 +275,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 +337,7 @@ class acp_search $totaltime = $mtime[0] + $mtime[1] - $starttime; $rows_per_second = $row_count / $totaltime; meta_refresh(1, append_sid($this->u_action . '&action=delete&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 +397,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 +427,7 @@ class acp_search $totaltime = $mtime[0] + $mtime[1] - $starttime; $rows_per_second = $row_count / $totaltime; meta_refresh(1, append_sid($this->u_action . '&action=create&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 +454,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 +553,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 +596,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; - } + global $phpbb_root_path, $phpEx, $user, $auth, $config, $db; - include_once("{$phpbb_root_path}includes/search/$type.$phpEx"); - - 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 |