'Results of searching for $Needle:',
'SearchFound' =>
'$MatchCount pages found out of $MatchSearched pages searched.'
));
SDV($HandleActions['search'],'HandleSearch');
if (isset($EnablePathInfo) && !$EnablePathInfo)
SDV($SearchTagFmt,"
");
SDV($SearchTagFmt,"");
SDV($SearchResultsFmt,"$[SearchFor]
$HTMLVSpace\$MatchList
$HTMLVSpace$[SearchFound]$HTMLVSpace");
SDV($PageSearchFmt,
"$[Search Results]
\$SearchResults");
SDV($SearchListItemFmt,'$Title');
SDV($SearchListGroupFmt,'$Group /');
SDV($InlineReplacements['/\\[\\[\\$Search\\]\\]/e'],
"FmtPageName(\$GLOBALS['SearchTagFmt'],\$pagename)");
SDV($InlineReplacements['/\\[\\[\\$Searchresults\\]\\]/e'],
"Keep(SearchResults(\$pagename))");
foreach(array('group'=>'SearchGroup','text'=>'Needle') as $k=>$v) {
$Search[$k]='';
if (isset($_POST[$k])) $Search[$k]=stripmagic($_POST[$k]);
if (isset($_GET[$k])) $Search[$k]=stripmagic($_GET[$k]);
}
if (preg_match("!^($GroupNamePattern)?/!i",$Search['text'],$match))
$Search['group'] = $match[1];
if ($action!='edit') {
$Needle = str_replace('$','$',htmlentities($Search['text'],ENT_QUOTES));
$SearchGroup = htmlentities($Search['group'],ENT_QUOTES);
}
function SearchResults($pagename) {
global $Search,$WikiLibDirs,$GroupNamePattern,$SearchExcludePatterns,
$SearchListItemFmt,$SearchListGroupFmt,$SearchResultsFmt,
$GroupFreeLinkPattern,$PageNameSpace;
if (!$Search['text']) return "";
$matches = array(); $matchsearched = 0;
$group = $Search['group'];
$terms = preg_replace("!^($GroupNamePattern)?/!i","",$Search['text']);
$terms = preg_split('/((?0) {
$dir = array_shift($dirlist);
$dfp = opendir($dir); if (!$dfp) continue;
while (($pagefile=readdir($dfp))!=false) {
if (substr($pagefile,0,1)=='.') continue;
if (is_dir("$dir/$pagefile"))
{ array_push($dirlist,"$dir/$pagefile"); continue; }
if (@$seen[$pagefile]++) continue;
if ($group && strcasecmp(FmtPageName('$Group',$pagefile),$group)!=0)
continue;
if (isset($SearchExcludePatterns))
foreach((array)$SearchExcludePatterns as $t)
if (preg_match($t,$pagefile)) continue 2;
$page = ReadPage($pagefile); Lock(0); if (!$page) continue;
$matchsearched++;
$text = $pagefile."\n".preg_replace("/$GroupFreeLinkPattern/e","'$0'.preg_replace('/\\s+/','$PageNameSpace',ucwords('$3'.'$4')).' '.'$3'.'$5'",$page['text']);
foreach($excl as $t) if (stristr($text,$t)) continue 2;
foreach($incl as $t) if (!stristr($text,$t)) continue 2;
$matches[] = $pagefile;
}
closedir($dfp);
}
sort($matches); reset($matches);
$MatchList = array();
foreach($matches as $pagefile) {
$pgroup = FmtPageName($SearchListGroupFmt,$pagefile);
if ($pgroup!=@$lgroup) {
$MatchList[] = $pgroup;
$lgroup = $pgroup;
}
$MatchList[] = FmtPageName($SearchListItemFmt,$pagefile);
}
$GLOBALS['MatchList'] = join('',$MatchList);
$GLOBALS['MatchCount'] = count($matches);
$GLOBALS['MatchSearched'] = $matchsearched;
$GLOBALS['SearchIncl'] = $incl;
$GLOBALS['SearchExcl'] = $excl;
$GLOBALS['GCount'] = 0;
return FmtPageName($SearchResultsFmt,$pagename);
}
function HandleSearch($pagename) {
global $HandleSearchFmt,$SearchResults,$CurrentTime;
global $PageStartFmt,$PageSearchFmt,$PageEndFmt;
$SearchResults = SearchResults($pagename);
$GLOBALS['LastModified'] = $CurrentTime;
$GLOBALS['LastModifiedBy'] = @$Author;
$GLOBALS['HTMLTitle'] = 'Search Results';
$GLOBALS['GCount'] = 0;
SDV($HandleSearchFmt,array(&$PageStartFmt, &$PageSearchFmt, &$PageEndFmt));
PrintFmt($pagename,$HandleSearchFmt);
}
?>