summaryrefslogtreecommitdiff
path: root/inc/search.php
diff options
context:
space:
mode:
authormatthiasgrimm <matthiasgrimm@users.sourceforge.net>2005-06-05 10:58:54 +0200
committermatthiasgrimm <matthiasgrimm@users.sourceforge.net>2005-06-05 10:58:54 +0200
commit5a5d942d429ee5f4b6c1c0b80774007c7bfbf4c8 (patch)
tree2a0ce7737d5af506d8fbd41d56a64091cc795ca2 /inc/search.php
parentf62ea8a1d1cf10eddeae777b11420624e111b7ea (diff)
downloadrpg-5a5d942d429ee5f4b6c1c0b80774007c7bfbf4c8.tar.gz
rpg-5a5d942d429ee5f4b6c1c0b80774007c7bfbf4c8.tar.bz2
extended search fix no. 2
The last patches confused darcs so we get a mixed up code. This patch corrected the mess hopefully. darcs-hash:20050605085854-7ef76-83d86fd24ce667f7cb506466ef2aef39ccc38cea.gz
Diffstat (limited to 'inc/search.php')
-rw-r--r--inc/search.php8
1 files changed, 3 insertions, 5 deletions
diff --git a/inc/search.php b/inc/search.php
index b96f2444d..4b1973e98 100644
--- a/inc/search.php
+++ b/inc/search.php
@@ -321,17 +321,14 @@ function search_fulltext(&$data,$base,$file,$type,$lvl,$opts){
// a search without any posword is useless
if (!count($poswords)) return true;
- $req = count($poswords) ? $reg .= '^(?=.*?'.join(')(?=.*?',$poswords).')' : '^';
+ $reg = '^(?=.*?'.join(')(?=.*?',$poswords).')';
$reg .= count($negwords) ? '((?!'.join('|',$negwords).').)*$' : '.*$';
- $mark = '('.join('|',$poswords).')';
//do the fulltext search
$matches = array();
if($cnt = preg_match_all('#'.$reg.'#usi',$lctext,$matches)){
//this is not the best way for snippet generation but the fastest I could find
- //split query and only use the first token
- $q = preg_split('/\s+/',$opts['query'],2);
- $q = $q[0];
+ $q = $poswords[0]; //use first posword for snippet
$p = utf8_strpos($lctext,$q);
$f = $p - 100;
$l = utf8_strlen($q) + 200;
@@ -339,6 +336,7 @@ function search_fulltext(&$data,$base,$file,$type,$lvl,$opts){
$snippet = '<span class="search_sep"> ... </span>'.
htmlspecialchars(utf8_substr($text,$f,$l)).
'<span class="search_sep"> ... </span>';
+ $mark = '('.join('|',$poswords).')';
$snippet = preg_replace('#'.$mark.'#si','<span class="search_hit">\\1</span>',$snippet);
$data[] = array(