Skip to content
Snippets Groups Projects
Commit d0ab54f6 authored by Michael Klier chi@chimeric.de's avatar Michael Klier chi@chimeric.de
Browse files

namespace restricted fulltext-search

    - The fulltext-search can now be restricted to a given
      namespace seperated by an "@"

darcs-hash:20060518161855-484ab-1617b6d2c3593525f4d29a789b0a32ebf414b9ae.gz
parent 77b98903
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,15 @@ function ft_pageSearch($query,&$poswords){
$hidden = array_filter(array_keys($docs),'isHiddenPage');
$not = array_merge($not,$hidden);
// filter unmatched namespaces
if(!empty($q['ns'])) {
foreach($docs as $key => $val) {
if(!preg_match('/^'.$q['ns'].'/',$key)) {
unset($docs[$key]);
}
}
}
// remove negative matches
foreach($not as $n){
unset($docs[$n]);
......@@ -254,10 +263,17 @@ function ft_queryParser($query){
$q = array();
$q['query'] = $query;
$q['ns'] = '';
$q['phrases'] = array();
$q['and'] = array();
$q['not'] = array();
// strip namespace from query
if(preg_match('/([^@]*)@([^@]*)/',$query,$match)) {
$query = $match[1];
$q['ns'] = $match[2];
}
// handle phrase searches
while(preg_match('/"(.*?)"/',$query,$match)){
$q['phrases'][] = $match[1];
......
......@@ -365,6 +365,18 @@ function html_search(){
print p_locale_xhtml('searchpage');
flush();
//check if search is restricted to namespace
if(preg_match('/([^@]*)@([^@]*)/',$QUERY,$match)) {
$id = cleanID($match[1]);
if(empty($id)) {
print '<div class="nothing">'.$lang['nothingfound'].'</div>';
flush();
return;
}
} else {
$id = cleanID($QUERY);
}
//show progressbar
print '<div class="centeralign" id="dw__loading">';
print '<br /></div>';
......@@ -375,7 +387,8 @@ function html_search(){
//do quick pagesearch
$data = array();
$data = ft_pageLookup(cleanID($QUERY));
$data = ft_pageLookup($id);
if(count($data)){
sort($data);
print '<div class="search_quickresult">';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment