]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/backend/dumb/TextSearchIter.php
better support for case_exact search (not caseexact for consistency),
[SourceForge/phpwiki.git] / lib / WikiDB / backend / dumb / TextSearchIter.php
1 <?php // -*-php-*-
2 rcs_id('$Id: TextSearchIter.php,v 1.2 2004-11-23 15:17:19 rurban Exp $');
3
4 class WikiDB_backend_dumb_TextSearchIter
5 extends WikiDB_backend_iterator
6 {
7     function WikiDB_backend_dumb_TextSearchIter(&$backend, &$pages, $search, $fulltext=false, $case_exact=false) {
8         $this->_backend = &$backend;
9         $this->_pages = $pages;
10         $this->_fullsearch = $fulltext;
11         $this->_search = $search;
12         $this->_case_exact = $case_exact;
13     }
14
15     function _get_content(&$page) {
16         $backend = &$this->_backend;
17         $pagename = $page['pagename'];
18         
19         if (!isset($page['versiondata'])) {
20             $version = $backend->get_latest_version($pagename);
21             $page['versiondata'] = $backend->get_versiondata($pagename, $version, true);
22         }
23         return $page['versiondata']['%content'];
24     }
25         
26         
27     function _match(&$page) {
28         $text = $page['pagename'];
29         if ($this->_fullsearch)
30             $text .= "\n" . $this->_get_content($page);
31
32         return $this->_search->match($text);
33     }
34
35     function next() {
36         $pages = &$this->_pages;
37
38         while ($page = $pages->next()) {
39             if ($this->_match($page))
40                 return $page;
41         }
42         return false;
43     }
44
45     function free() {
46         $this->_pages->free();
47     }
48 };
49
50 // (c-file-style: "gnu")
51 // Local Variables:
52 // mode: php
53 // tab-width: 8
54 // c-basic-offset: 4
55 // c-hanging-comment-ender-p: nil
56 // indent-tabs-mode: nil
57 // End:   
58 ?>