]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/MostPopular.php
Converted to use new PageList class.
[SourceForge/phpwiki.git] / lib / plugin / MostPopular.php
1 <?php // -*-php-*-
2 rcs_id('$Id: MostPopular.php,v 1.11 2002-01-21 16:31:53 carstenklapp Exp $');
3 /**
4  */
5
6 require_once('lib/PageList.php');
7
8 class WikiPlugin_MostPopular
9 extends WikiPlugin
10 {
11     function getName () {
12         return _("MostPopular");
13     }
14
15     function getDescription () {
16         return _("List the most popular pages");
17     }
18
19     function getDefaultArguments() {
20         return array('limit'    => 20,
21                      'noheader' => 0);
22     }
23
24     function run($dbi, $argstr, $request) {
25         extract($this->getArgs($argstr, $request));
26
27         $pages = $dbi->mostPopular($limit);
28
29         $list = new PageList();
30         $list->insertColumn(_("Hits"));
31         //$list->addcolumn(_("Last Modified"));
32
33         while ($page = $pages->next()) {
34             $hits = $page->get('hits');
35             if ($hits == 0)
36                 break;
37             $list->addPage($page);
38         }
39         $pages->free();
40         
41         if (! $noheader) {
42             if ($limit > 0) {
43                 $list->setCaption(_("The %d most popular pages of this wiki:"));
44             } else {
45                 $list->setCaption(_("Visited pages on this wiki, ordered by popularity:"));
46             }
47         }
48         return $list->getHTML();
49         
50     }
51 };
52
53 // Local Variables:
54 // mode: php
55 // tab-width: 8
56 // c-basic-offset: 4
57 // c-hanging-comment-ender-p: nil
58 // indent-tabs-mode: nil
59 // End:
60 ?>