]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/BackLinks.php
Jeff's hacks II, continued:
[SourceForge/phpwiki.git] / lib / plugin / BackLinks.php
1 <?php // -*-php-*-
2 rcs_id('$Id: BackLinks.php,v 1.1 2001-09-18 19:19:05 dairiki Exp $');
3 /**
4  */
5 class WikiPlugin_BackLinks
6 extends WikiPlugin
7 {
8     var $name = 'BackLinks';
9   
10     function getDefaultArguments() {
11         // FIXME: how to exclude multiple pages?
12         return array('exclude'          => '',
13                      'include_self'     => 0,
14                      'noheader'         => 0,
15                      'page'             => false);
16     }
17
18     function run($dbi, $argstr, $request) {
19         $args = $this->getArgs($argstr, $request);
20         extract($args);
21         if (!$page)
22             return '';
23               
24         $p = $dbi->getPage($page);
25         $backlinks = $p->getLinks();
26         $lines = array();
27         while ($backlink = $backlinks->next()) {
28             $name = $backlink->getName();
29             if ($exclude && $name == $exclude)
30                 continue;
31             if (!$include_self && $name == $page)
32                 continue;
33             $lines[] = Element('li', LinkWikiWord($name));
34         }
35
36         $html = '';
37         if (!$noheader) {
38             $fs = $lines
39                  ? gettext("These pages link to %s:")
40                  : gettext("No pages link to %s.");
41             $header = sprintf(htmlspecialchars($fs),
42                               LinkExistingWikiWord($page));
43             $html = Element('p', $header) . "\n";
44         }
45         
46         return $html . Element('ul', join("\n", $lines));
47     }
48 };
49         
50 ?>