]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/BackLinks.php
Moved description from html template into plugins.
[SourceForge/phpwiki.git] / lib / plugin / BackLinks.php
1 <?php // -*-php-*-
2 rcs_id('$Id: BackLinks.php,v 1.3 2001-12-15 10:54:36 carstenklapp Exp $');
3 /**
4  */
5 class WikiPlugin_BackLinks
6 extends WikiPlugin
7 {
8     var $name = 'BackLinks';
9     var $description = "Get BackLinks for [pagename]";
10   
11     function getDefaultArguments() {
12         // FIXME: how to exclude multiple pages?
13         return array('exclude'          => '',
14                      'include_self'     => 0,
15                      'noheader'         => 0,
16                      'page'             => false);
17     }
18
19     function run($dbi, $argstr, $request) {
20         $args = $this->getArgs($argstr, $request);
21         extract($args);
22         if (!$page)
23             return '';
24               
25         $p = $dbi->getPage($page);
26         $backlinks = $p->getLinks();
27         $lines = array();
28         while ($backlink = $backlinks->next()) {
29             $name = $backlink->getName();
30             if ($exclude && $name == $exclude)
31                 continue;
32             if (!$include_self && $name == $page)
33                 continue;
34             $lines[] = Element('li', LinkWikiWord($name));
35         }
36
37         $html = '';
38         if (!$noheader) {
39             $fs = $lines
40                  ? gettext("These pages link to %s:")
41                  : gettext("No pages link to %s.");
42             $header = sprintf(htmlspecialchars($fs),
43                               LinkExistingWikiWord($page));
44             $html = Element('p', $header) . "\n";
45         }
46         
47         return $html . Element('ul', join("\n", $lines));
48     }
49 };
50
51 // For emacs users
52 // Local Variables:
53 // mode: php
54 // tab-width: 8
55 // c-basic-offset: 4
56 // c-hanging-comment-ender-p: nil
57 // indent-tabs-mode: nil
58 // End:
59         
60 ?>