]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/MostPopular.php
Minor reindenting & rewrapping.
[SourceForge/phpwiki.git] / lib / plugin / MostPopular.php
1 <?php // -*-php-*-
2 rcs_id('$Id: MostPopular.php,v 1.5 2002-01-09 18:06:49 carstenklapp Exp $');
3 /**
4  */
5 class WikiPlugin_MostPopular
6 extends WikiPlugin
7 {
8     function getName () {
9         return _("MostPopular");
10     }
11
12     function getDescription () {
13         return _("List the most popular pages");
14     }
15
16     function getDefaultArguments() {
17         // FIXME: how to exclude multiple pages?
18         return array('limit'    => 20,
19                      'noheader' => 0);
20     }
21
22     function run($dbi, $argstr, $request) {
23         extract($this->getArgs($argstr, $request));
24
25         $pages = $dbi->mostPopular($limit);
26
27         $lines[] = $this->_tr(QElement('u', _("Hits")),
28                               QElement('u', _("Page Name")));
29
30         while ($page = $pages->next()) {
31             $hits = $page->get('hits');
32             if ($hits == 0)
33                 break;
34             $lines[] = $this->_tr($hits,
35                                   LinkWikiWord($page->getName()));
36         }
37         $pages->free();
38
39         $html = '';
40         if (!$noheader) {
41             $html .= QElement('p',
42                              sprintf(_("The %s most popular pages of this wiki:"),
43                                      $limit ? $limit : ''));
44         }
45
46
47         $html .= Element('blockquote',
48                          Element('table', array('cellpadding' => 0,
49                                                 'cellspacing' => 1,
50                                                 'border' => 0),
51                                  join("\n", $lines)));
52         return $html;
53     }
54
55     function _tr ($col1, $col2) {
56         return "<tr><td align='right'>$col1&nbsp;&nbsp;</td>"
57             . "<td>&nbsp;&nbsp;$col2</td></tr>\n";
58     }
59 };
60
61 // Local Variables:
62 // mode: php
63 // tab-width: 8
64 // c-basic-offset: 4
65 // c-hanging-comment-ender-p: nil
66 // indent-tabs-mode: nil
67 // End:
68 ?>