1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-19 15:17:16 +01:00

[feature/postgresql-fulltext-search] remove phrase search code

Unused Code for phrase search removed as pgsql doesnt support it. An added
message is displayed if user tries to perform exact phrase search.

PHPBB3-9730
This commit is contained in:
Dhruv Goel 2012-07-01 12:45:18 +05:30
parent f2dfaa73ff
commit 19d76f76dc
4 changed files with 13 additions and 33 deletions

View File

@ -30,6 +30,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
public $search_query;
public $common_words = array();
public $word_length = array();
public $phrase_search = false;
public function __construct(&$error)
{
@ -110,39 +111,6 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
preg_match_all('#(?:[^\p{L}\p{N}*"()]|^)([+\-|]?(?:[\p{L}\p{N}*"()]+\'?)*[\p{L}\p{N}*"()])(?:[^\p{L}\p{N}*"()]|$)#u', $split_keywords, $matches);
$this->split_words = $matches[1];
// to allow phrase search, we need to concatenate quoted words
$tmp_split_words = array();
$phrase = '';
foreach ($this->split_words as $word)
{
if ($phrase)
{
$phrase .= ' ' . $word;
if (strpos($word, '"') !== false && substr_count($word, '"') % 2 == 1)
{
$tmp_split_words[] = $phrase;
$phrase = '';
}
}
else if (strpos($word, '"') !== false && substr_count($word, '"') % 2 == 1)
{
$phrase = $word;
}
else
{
$tmp_split_words[] = $word . ' ';
}
}
if ($phrase)
{
$tmp_split_words[] = $phrase;
}
$this->split_words = $tmp_split_words;
unset($tmp_split_words);
unset($phrase);
foreach ($this->split_words as $i => $word)
{
$clean_word = preg_replace('#^[+\-|"]#', '', $word);

View File

@ -72,6 +72,7 @@ $lang = array_merge($lang, array(
'WORDS_IN_NO_POST' => 'No posts were found because the words <strong>%s</strong> are not contained in any post.',
'POST_CHARACTERS' => 'characters of posts',
'PHRASE_SEARCH_DISABLED' => 'Searching by exact phrase is not supported on this board.',
'RECENT_SEARCHES' => 'Recent searches',
'RESULT_DAYS' => 'Limit results to previous',

View File

@ -596,6 +596,13 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$u_search .= ($search_fields != 'all') ? '&amp;sf=' . $search_fields : '';
$u_search .= ($return_chars != 300) ? '&amp;ch=' . $return_chars : '';
//check if search backend supports phrase search or not
$l_phrase_search_disabled = '';
if (strpos(html_entity_decode($keywords), '"') !== false && isset($search->phrase_search))
{
$l_phrase_search_disabled = $search->phrase_search ? false : true;
}
$template->assign_vars(array(
'SEARCH_TITLE' => $l_search_title,
'SEARCH_MATCHES' => $l_search_matches,
@ -603,6 +610,9 @@ if ($keywords || $author || $author_id || $search_id || $submit)
'IGNORED_WORDS' => (sizeof($search->common_words)) ? implode(' ', $search->common_words) : '',
'PAGINATION' => generate_pagination($u_search, $total_match_count, $per_page, $start),
'PAGE_NUMBER' => on_page($total_match_count, $per_page, $start),
'PHRASE_SEARCH_DISABLED' => $l_phrase_search_disabled,
'TOTAL_MATCHES' => $total_match_count,
'SEARCH_IN_RESULTS' => ($search_id) ? false : true,

View File

@ -2,6 +2,7 @@
<h2><!-- IF SEARCH_TITLE -->{SEARCH_TITLE}<!-- ELSE -->{SEARCH_MATCHES}<!-- ENDIF --><!-- IF SEARCH_WORDS -->: <a href="{U_SEARCH_WORDS}">{SEARCH_WORDS}</a><!-- ENDIF --></h2>
<!-- IF IGNORED_WORDS --> <p>{L_IGNORED_TERMS}: <strong>{IGNORED_WORDS}</strong></p><!-- ENDIF -->
<!-- IF PHRASE_SEARCH_DISABLED --> <p><strong>{L_PHRASE_SEARCH_DISABLED}</strong></p><!-- ENDIF -->
<!-- IF SEARCH_TOPIC -->
<p><a class="{S_CONTENT_FLOW_BEGIN}" href="{U_SEARCH_TOPIC}">{L_RETURN_TO}: {SEARCH_TOPIC}</a></p>