]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/backend/dumb/BackLinkIter.php
trailing_spaces
[SourceForge/phpwiki.git] / lib / WikiDB / backend / dumb / BackLinkIter.php
1 <?php // -*-php-*-
2 // $Id$
3
4 require_once('lib/WikiDB/backend.php');
5
6 /**
7  * This backlink iterator will work with any WikiDB_backend
8  * which has a working get_links(,'links_from') method.
9  *
10  * This is mostly here for testing, 'cause it's slow,slow,slow.
11  */
12 class WikiDB_backend_dumb_BackLinkIter
13 extends WikiDB_backend_iterator
14 {
15     function WikiDB_backend_dumb_BackLinkIter(&$backend, &$all_pages, $pagename) {
16         $this->_pages = $all_pages;
17         $this->_backend = &$backend;
18         $this->_target = $pagename;
19     }
20
21     function next() {
22         while ($page = $this->_pages->next()) {
23             $pagename = $page['pagename'];
24             $links = $this->_backend->get_links($pagename, false);
25             while ($link = $links->next()) {
26                 if ($link['pagename'] == $this->_target) {
27                     $links->free();
28                     return $page;
29                 }
30             }
31         }
32     }
33
34     function free() {
35         $this->_pages->free();
36     }
37 }
38
39 // Local Variables:
40 // mode: php
41 // tab-width: 8
42 // c-basic-offset: 4
43 // c-hanging-comment-ender-p: nil
44 // indent-tabs-mode: nil
45 // End:
46
47 ?>