]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - wiki_search.php3
initial commit for 1.1.4
[SourceForge/phpwiki.git] / wiki_search.php3
1 <?
2 /*
3    Title search:
4    This file will return the results of the search. It will: display 
5    the logo, the title "Search Results," then a list of all Wiki 
6    pages that match seperated by five dots and the text that matched;
7    an HR tag, and then a statement:
8       32 pages match your query.
9    where the number is correct.
10
11    The online classic Wiki has both full search and title search.
12    Title search is a good idea; it doesn't come with the script you 
13    download from c2.com.
14 */
15
16    echo WikiHeader("Search Results");
17    echo "<h1>$LogoImage Search Results</h1>\n";
18
19    $found = 0;
20
21    // from classic wiki: $pat =~ s/[+?.*()[\]{}|\\]/\\$&/g;
22    // disallow _'_ and _%_ too, _\_ have to be doubled
23    $search = preg_replace("/[+?.*()'%[\\]{}|\\\\]/", "", $search);
24
25    // search matching pages
26    $query = InitTitleSearch($dbi, $search);
27    while ($page = TitleSearchNextMatch($dbi, $query)) {
28       $found++;
29       echo LinkExistingWikiWord($page), "<br>\n";
30    }
31
32    echo "<hr>\n";
33    echo "$found pages match your query.\n";
34    echo WikiFooter();
35
36 ?>