]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/BackLinks.php
Finish conversion to new OO HTML generation scheme.
[SourceForge/phpwiki.git] / lib / plugin / BackLinks.php
1 <?php // -*-php-*-
2 rcs_id('$Id: BackLinks.php,v 1.10 2002-01-22 03:17:47 dairiki Exp $');
3 /**
4  */
5
6 require_once('lib/PageList.php');
7
8 class WikiPlugin_BackLinks
9 extends WikiPlugin
10 {
11     function getName () {
12         return _("BackLinks");
13     }
14
15     function getDescription () {
16         return sprintf(_("Get BackLinks for %s"),'[pagename]');
17     }
18   
19     function getDefaultArguments() {
20         // FIXME: how to exclude multiple pages?
21         return array('exclude'          => '',
22                      'include_self'     => 0,
23                      'noheader'         => 0,
24                      'page'             => false,
25                      'info'             => false);
26     }
27
28     function run($dbi, $argstr, $request) {
29         $this->_args = $this->getArgs($argstr, $request);
30         extract($this->_args);
31         if (!$page)
32             return '';
33
34         $p = $dbi->getPage($page);
35         $backlinks = $p->getLinks();
36
37         $pagelist = new PageList();
38
39
40         // Currently only info="Last Modified" or info=hits works (I
41         // don't think anything else would be useful anyway).
42
43         if ($info)
44             $pagelist->insertColumn(_($info));
45
46         while ($backlink = $backlinks->next()) {
47             $name = $backlink->getName();
48             if ($exclude && $name == $exclude)
49                 continue;
50             if (!$include_self && $name == $page)
51                 continue;
52
53             $pagelist->addPage($backlink);
54         }
55
56         if (!$noheader) {
57             $pagelink = LinkWikiWord($page);
58             
59             if ($pagelist->isEmpty())
60                 return HTML::p(fmt("No pages link to %s.", $pagelink));
61
62             $pagelist->setCaption(fmt("%d pages link to %s:",
63                                       $pagelist->getTotal(), $pagelink));
64             $pagelist->setMessageIfEmpty('');
65         }
66
67         return $pagelist;
68     }
69 };
70
71 // For emacs users
72 // Local Variables:
73 // mode: php
74 // tab-width: 8
75 // c-basic-offset: 4
76 // c-hanging-comment-ender-p: nil
77 // indent-tabs-mode: nil
78 // End:
79         
80 ?>