]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/BackLinks.php
PageList cleanup. Move the Plugin::_init functionality into the
[SourceForge/phpwiki.git] / lib / plugin / BackLinks.php
1 <?php // -*-php-*-
2 rcs_id('$Id: BackLinks.php,v 1.18 2002-01-31 01:14:14 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         return array('exclude'          => '',
21                      'include_self'     => 0,
22                      'noheader'         => 0,
23                      'page'             => '[pagename]',
24                      'info'             => false
25                      );
26     }
27     // info arg allows multiple columns info=mtime,hits,summary,version,author,locked,minor
28     // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
29  
30     function run($dbi, $argstr, $request) {
31         $this->_args = $this->getArgs($argstr, $request);
32         extract($this->_args);
33         if (!$page)
34             return '';
35         
36         $exclude = $exclude ? explode(",", $exclude) : array();
37         if (!$include_self)
38             $exclude[] = $page;
39
40         $pagelist = new PageList($info, $exclude);
41
42         $p = $dbi->getPage($page);
43         $pagelist->addPages($p->getLinks());
44
45         if (!$noheader) {
46             $pagelink = WikiLink($page, 'auto');
47
48             if ($pagelist->isEmpty())
49                 return HTML::p(fmt("No pages link to %s.", $pagelink));
50
51             if ($pagelist->getTotal() == 1)
52                 $pagelist->setCaption(fmt("One page links to %s:",
53                                           $pagelink));
54             else
55                 $pagelist->setCaption(fmt("%s pages link to %s:",
56                                           $pagelist->getTotal(), $pagelink));
57         }
58
59         return $pagelist;
60     }
61
62 };
63
64 // For emacs users
65 // Local Variables:
66 // mode: php
67 // tab-width: 8
68 // c-basic-offset: 4
69 // c-hanging-comment-ender-p: nil
70 // indent-tabs-mode: nil
71 // End:
72         
73 ?>