diff options
Diffstat (limited to 'phpBB/includes/acp/acp_search.php')
| -rw-r--r-- | phpBB/includes/acp/acp_search.php | 93 | 
1 files changed, 32 insertions, 61 deletions
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index 0cd67b1c34..abb8301507 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 . '&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 +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 . '&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));  						}  					} @@ -455,7 +449,6 @@ class acp_search  		$search = null;  		$error = false; -		$search_options = '';  		foreach ($search_types as $type)  		{  			if ($this->init_search($type, $search, $error) || !method_exists($search, 'index_created')) @@ -463,7 +456,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 +555,15 @@ class acp_search  	function get_search_types()  	{ -		global $phpbb_root_path, $phpEx; - -		$search_types = array(); - -		$dp = @opendir($phpbb_root_path . 'includes/search'); - -		if ($dp) -		{ -			while (($file = readdir($dp)) !== false) -			{ -				if ((preg_match('#\.' . $phpEx . '$#', $file)) && ($file != "search.$phpEx")) -				{ -					$search_types[] = preg_replace('#^(.*?)\.' . $phpEx . '$#', '\1', $file); -				} -			} -			closedir($dp); +		global $phpbb_root_path, $phpEx, $phpbb_extension_manager; -			sort($search_types); -		} +		$finder = $phpbb_extension_manager->get_finder(); -		return $search_types; +		return $finder +			->extension_suffix('_backend') +			->extension_directory('/search') +			->core_path('phpbb/search/') +			->get_classes();  	}  	function get_max_post_id() @@ -617,27 +598,17 @@ class acp_search  	*/  	function init_search($type, &$search, &$error)  	{ -		global $phpbb_root_path, $phpEx, $user; +		global $phpbb_root_path, $phpEx, $user, $auth, $config, $db, $phpbb_dispatcher; -		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"); - -		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, $phpbb_dispatcher);  		return $error;  	}  } - -?>
\ No newline at end of file  | 
