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