2 rcs_id('$Id: MostPopular.php,v 1.20 2002-02-08 20:30:48 lakka Exp $');
6 require_once('lib/PageList.php');
8 class WikiPlugin_MostPopular
12 return _("MostPopular");
15 function getDescription () {
16 return _("List the most popular pages");
19 function getDefaultArguments() {
20 return array('pagename' => '[pagename]', // hackish
22 'limit' => 20, // limit <0 returns least popular pages
27 // info arg allows multiple columns info=mtime,hits,summary,version,author,locked,minor
28 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
30 function run($dbi, $argstr, $request) {
31 extract($this->getArgs($argstr, $request));
33 $columns = $info ? explode(",", $info) : array();
34 array_unshift($columns, 'hits');
36 $pagelist = new PageList($columns, $exclude);
38 $pages = $dbi->mostPopular($limit);
40 while ($page = $pages->next()) {
41 $hits = $page->get('hits');
42 if ($hits == 0 && $limit > 0) // don't show pages with no hits if most
43 // popular pages wanted
45 $pagelist->addPage($page);
51 $pagelist->setCaption(_("The %d most popular pages of this wiki:"));
54 $pagelist->setCaption(_("The %d least popular pages of this wiki:"));
56 $pagelist->setCaption(_("Visited pages on this wiki, ordered by popularity:"));
68 // c-hanging-comment-ender-p: nil
69 // indent-tabs-mode: nil