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