diff options
author | Nils Adermann <naderman@naderman.de> | 2006-03-15 23:20:04 +0000 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2006-03-15 23:20:04 +0000 |
commit | 7fd17b8251879e6f4592d7c4b5ebdc9faa405429 (patch) | |
tree | a59e660e49183d63f2d1816c38952ad662bf2c88 /phpBB/includes/search/fulltext_phpbb.php | |
parent | e221b03b957e49cb2248b91af303c453c4d1e975 (diff) | |
download | forums-7fd17b8251879e6f4592d7c4b5ebdc9faa405429.tar forums-7fd17b8251879e6f4592d7c4b5ebdc9faa405429.tar.gz forums-7fd17b8251879e6f4592d7c4b5ebdc9faa405429.tar.bz2 forums-7fd17b8251879e6f4592d7c4b5ebdc9faa405429.tar.xz forums-7fd17b8251879e6f4592d7c4b5ebdc9faa405429.zip |
- removed search settings from load page
- no need to retrieve mysql information on every page => removed (fulltext_mysql)
- added init() method to search plugins which is called when the search backend is changed
- optional create/delete index functions for methods which don't need to loop through all posts (like fulltext_mysql)
- index statistic functions for search plugins, displayed on acp search index page
- only remove words above 60% (fulltext_phpbb)
- added acp method to search plugins so they can display config options specific to a certain search backend
- renamed fulltext_phpbb specific options to make clear that they are a part of the plugin
- reordered lang entries for the load settings section
added acp_search.php:
- settings: general options / search backend / backend specific options
- index: statistics / delete index / create index (progress popup while processing)
git-svn-id: file:///svn/phpbb/trunk@5636 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/search/fulltext_phpbb.php')
-rw-r--r-- | phpBB/includes/search/fulltext_phpbb.php | 96 |
1 files changed, 93 insertions, 3 deletions
diff --git a/phpBB/includes/search/fulltext_phpbb.php b/phpBB/includes/search/fulltext_phpbb.php index 6259e7b984..341e9abb87 100644 --- a/phpBB/includes/search/fulltext_phpbb.php +++ b/phpBB/includes/search/fulltext_phpbb.php @@ -11,7 +11,7 @@ /** * @ignore */ -include($phpbb_root_path . 'includes/search/search.' . $phpEx); +include_once($phpbb_root_path . 'includes/search/search.' . $phpEx); /** * @package search @@ -20,6 +20,8 @@ include($phpbb_root_path . 'includes/search/search.' . $phpEx); */ class fulltext_phpbb extends search_backend { + var $stats; + function fulltext_phpbb(&$error) { $error = false; @@ -887,13 +889,13 @@ class fulltext_phpbb extends search_backend $destroy_cache_words = array(); - // Remove common (> 50% of posts ) words + // Remove common (> 60% of posts ) words if ($config['num_posts'] >= 100) { $sql = 'SELECT word_id FROM ' . SEARCH_MATCH_TABLE . ' GROUP BY word_id - HAVING COUNT(word_id) > ' . floor($config['num_posts'] * 0.5); + HAVING COUNT(word_id) > ' . floor($config['num_posts'] * 0.6); $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) @@ -951,6 +953,94 @@ class fulltext_phpbb extends search_backend // destroy cached search results containing any of the words that are now common or were removed $this->destroy_cache(array_unique($destroy_cache_words)); } + + /** + * Deletes all words from the index + */ + function delete_index($acp_module, $u_action) + { + global $db; + + $db->sql_query(((SQL_LAYER != 'sqlite') ? 'TRUNCATE ' : 'DELETE FROM ') . SEARCH_WORD_TABLE); + $db->sql_query(((SQL_LAYER != 'sqlite') ? 'TRUNCATE ' : 'DELETE FROM ') . SEARCH_MATCH_TABLE); + $db->sql_query(((SQL_LAYER != 'sqlite') ? 'TRUNCATE ' : 'DELETE FROM ') . SEARCH_TABLE); + } + + /** + * Returns true if both FULLTEXT indexes exist + */ + function index_created() + { + if (!is_array($this->stats)) + { + $this->get_stats(); + } + + return ($this->stats['total_words'] && $this->stats['total_matches']) ? true : false; + } + + /** + * Returns an associative array containing information about the indexes + */ + function index_stats() + { + global $user; + + if (!is_array($this->stats)) + { + $this->get_stats(); + } + + return array( + $user->lang['TOTAL_WORDS'] => $this->stats['total_words'], + $user->lang['TOTAL_MATCHES'] => $this->stats['total_matches']); + } + + function get_stats() + { + global $db; + + $sql = 'SELECT COUNT(*) as total_words + FROM ' . SEARCH_WORD_TABLE; + $result = $db->sql_query($sql); + $this->stats['total_words'] = $db->sql_fetchfield('total_words', 0, $result); + $db->sql_freeresult($result); + + $sql = 'SELECT COUNT(*) as total_matches + FROM ' . SEARCH_MATCH_TABLE; + $result = $db->sql_query($sql); + $this->stats['total_matches'] = $db->sql_fetchfield('total_matches', 0, $result); + $db->sql_freeresult($result); + } + + /** + * Returns a list of options for the ACP to display + */ + function acp() + { + global $user, $config; + + $tpl = ' + <dl> + <dt><label for="fulltext_phpbb_load_search_upd">' . $user->lang['YES_SEARCH_UPDATE'] . ':</label><br /><span>' . $user->lang['YES_SEARCH_UPDATE_EXPLAIN'] . '</span></dt> + <dd><input type="radio" id="fulltext_phpbb_load_search_upd" name="config[fulltext_phpbb_load_search_upd]" value="1"' . (($config['fulltext_phpbb_load_search_upd']) ? ' checked="checked"' : '') . ' class="radio" /> ' . $user->lang['YES'] . ' <input type="radio" name="config[fulltext_phpbb_load_search_upd]" value="0"' . ((!$config['fulltext_phpbb_load_search_upd']) ? ' checked="checked"' : '') . ' class="radio" /> ' . $user->lang['NO'] . '</dd> + </dl> + <dl> + <dt><label for="fulltext_phpbb_min_search_chars">' . $user->lang['MIN_SEARCH_CHARS'] . ':</label><br /><span>' . $user->lang['MIN_SEARCH_CHARS_EXPLAIN'] . '</span></dt> + <dd><input id="fulltext_phpbb_min_search_chars" type="text" size="3" maxlength="3" name="config[fulltext_phpbb_min_search_chars]" value="' . $config['fulltext_phpbb_min_search_chars'] . '" /></dd> + </dl> + <dl> + <dt><label for="fulltext_phpbb_max_search_chars">' . $user->lang['MAX_SEARCH_CHARS'] . ':</label><br /><span>' . $user->lang['MAX_SEARCH_CHARS_EXPLAIN'] . '</span></dt> + <dd><input id="fulltext_phpbb_max_search_chars" type="text" size="3" maxlength="3" name="config[fulltext_phpbb_max_search_chars]" value="' . $config['fulltext_phpbb_max_search_chars'] . '" /></dd> + </dl> + '; + + // These are fields required in the config table + return array( + 'tpl' => $tpl, + 'config' => array('fulltext_phpbb_load_search_upd' => 'bool', 'fulltext_phpbb_min_search_chars' => 'integer', 'fulltext_phpbb_max_search_chars' => 'integer') + ); + } } ?>
\ No newline at end of file |