2 rcs_id('$Id: TextSearchIter.php,v 1.5 2005-09-11 13:20:52 rurban Exp $');
4 class WikiDB_backend_dumb_TextSearchIter
5 extends WikiDB_backend_iterator
7 function WikiDB_backend_dumb_TextSearchIter(&$backend, &$pages, $search, $fulltext=false,
10 $this->_backend = &$backend;
11 $this->_pages = $pages;
12 $this->_fulltext = $fulltext;
13 $this->_search = $search;
16 if (isset($options['limit'])) $this->_limit = $options['limit'];
17 else $this->_limit = 0;
18 if (isset($options['exclude'])) $this->_exclude = $options['exclude'];
19 else $this->_exclude = false;
22 function _get_content(&$page) {
23 $backend = &$this->_backend;
24 $pagename = $page['pagename'];
26 if (!isset($page['versiondata'])) {
27 $version = $backend->get_latest_version($pagename);
28 $page['versiondata'] = $backend->get_versiondata($pagename, $version, true);
30 return $page['versiondata']['%content'];
33 function _match(&$page) {
34 $text = $page['pagename'];
35 if ($result = $this->_search->match($text)) // first match the pagename only
38 if ($this->_fulltext) {
39 $text .= "\n" . $this->_get_content($page);
40 return $this->_search->match($text);
46 $pages = &$this->_pages;
47 while ($page = $pages->next()) {
48 if ($this->_match($page)) {
49 if ($this->_limit and ($this->_index++ >= $this->_limit))
58 $this->_pages->free();
62 // (c-file-style: "gnu")
67 // c-hanging-comment-ender-p: nil
68 // indent-tabs-mode: nil