2 rcs_id('$Id: MostPopular.php,v 1.26 2004-04-18 01:34:21 rurban Exp $');
4 Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
6 This file is part of PhpWiki.
8 PhpWiki is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 PhpWiki is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with PhpWiki; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 require_once('lib/PageList.php');
28 class WikiPlugin_MostPopular
32 return _("MostPopular");
35 function getDescription () {
36 return _("List the most popular pages.");
39 function getVersion() {
40 return preg_replace("/[Revision: $]/", '',
41 "\$Revision: 1.26 $");
44 function getDefaultArguments() {
45 return array('pagename' => '[pagename]', // hackish
47 'limit' => 20, // limit <0 returns least popular pages
54 // info arg allows multiple columns
55 // info=mtime,hits,summary,version,author,locked,minor
56 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
57 // sortby: only pagename or hits. mtime not!
59 function run($dbi, $argstr, &$request, $basepage) {
60 //$request->setArg('nocache','1');
61 extract($this->getArgs($argstr, $request));
62 if (strstr($sortby,'mtime')) {
63 trigger_error(_("sortby=mtime not supported with MostPopular"),
67 $columns = $info ? explode(",", $info) : array();
68 array_unshift($columns, 'hits');
70 $pagelist = new PageList($columns, $exclude);
72 $pages = $dbi->mostPopular($limit,$sortby);
73 while ($page = $pages->next()) {
74 $hits = $page->get('hits');
75 // don't show pages with no hits if most popular pages
77 if ($hits == 0 && $limit > 0)
79 $pagelist->addPage($page);
85 $pagelist->setCaption(_("The %d most popular pages of this wiki:"));
88 $pagelist->setCaption(_("The %d least popular pages of this wiki:"));
90 $pagelist->setCaption(_("Visited pages on this wiki, ordered by popularity:"));
98 // $Log: not supported by cvs2svn $
99 // Revision 1.25 2004/03/30 02:38:06 rurban
100 // RateIt support (currently no recommendation engine yet)
102 // Revision 1.24 2004/03/01 13:48:46 rurban
104 // p[] consistency fix
106 // Revision 1.23 2004/02/17 12:11:36 rurban
107 // added missing 4th basepage arg at plugin->run() to almost all plugins. This caused no harm so far, because it was silently dropped on normal usage. However on plugin internal ->run invocations it failed. (InterWikiSearch, IncludeSiteMap, ...)
109 // Revision 1.22 2003/01/18 21:48:56 carstenklapp
111 // Reformatting & tabs to spaces;
112 // Added copyleft, getVersion, getDescription, rcs_id.
119 // c-hanging-comment-ender-p: nil
120 // indent-tabs-mode: nil