]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/BackLinks.php
Updated comments for new column version.
[SourceForge/phpwiki.git] / lib / plugin / BackLinks.php
1 <?php // -*-php-*-
2 rcs_id('$Id: BackLinks.php,v 1.13 2002-01-27 04:23:26 carstenklapp 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     // info arg allows multiple columns info=mtime,hits,summary,version,author,locked,minor
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         $p = $dbi->getPage($page);
37         $backlinks = $p->getLinks();
38
39         $pagelist = new PageList;
40
41         if ($info)
42             foreach (explode(",", $info) as $col)
43                 $pagelist->insertColumn($col);
44
45         while ($backlink = $backlinks->next()) {
46             $name = $backlink->getName();
47             if ($exclude && $name == $exclude)
48                 continue;
49             if (!$include_self && $name == $page)
50                 continue;
51
52             $pagelist->addPage($backlink);
53         }
54
55         if (!$noheader) {
56             $pagelink = LinkWikiWord($page);
57             
58             if ($pagelist->isEmpty())
59                 return HTML::p(fmt("No pages link to %s.", $pagelink));
60
61             $pagelist->setCaption(fmt("%d pages link to %s:",
62                                       $pagelist->getTotal(), $pagelink));
63             $pagelist->setMessageIfEmpty('');
64         }
65
66         return $pagelist;
67     }
68 };
69
70 // For emacs users
71 // Local Variables:
72 // mode: php
73 // tab-width: 8
74 // c-basic-offset: 4
75 // c-hanging-comment-ender-p: nil
76 // indent-tabs-mode: nil
77 // End:
78         
79 ?>