]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/BackLinks.php
Moved ucfirst into PageList until a better solution comes up.
[SourceForge/phpwiki.git] / lib / plugin / BackLinks.php
1 <?php // -*-php-*-
2 rcs_id('$Id: BackLinks.php,v 1.9 2002-01-21 19:18:16 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     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     // Currently only info="Last Modified" or info=hits works (I don't think
40     // anything else would be useful anyway).
41
42         if ($info)
43             $pagelist->insertColumn(_($info));
44
45         $n = false;
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             $pagelist->addPage($backlink);
53             $n = true;
54         }
55
56         
57         if ($noheader)
58             return $pagelist->getContent();
59
60 //        global $Theme;
61 //        $pagelink = $Theme->linkExistingWikiWord($page);
62         $pagelink = LinkExistingWikiWord($page);
63
64         if ($n)
65             //FIXME: use __sprintf
66             //$head = sprintf("These %s pages link to %s:", '%d', $pagelink);
67             $head = sprintf("These pages link to %s:", $pagelink);
68         else
69             $head = sprintf("No pages link to %s.", $pagelink);
70
71 //        $head = new RawXML($pagelist->setCaption($head));
72 //        $head = HTML::p(new RawXML($pagelist->setCaption($head)));
73 //        $head = HTML::p($pagelist->setCaption($head));
74         return array($head, $pagelist->getContent());
75     }
76
77
78 };
79
80 // For emacs users
81 // Local Variables:
82 // mode: php
83 // tab-width: 8
84 // c-basic-offset: 4
85 // c-hanging-comment-ender-p: nil
86 // indent-tabs-mode: nil
87 // End:
88         
89 ?>