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