2 rcs_id('$Id: MostPopular.php,v 1.31 2004-11-23 15:17:19 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.31 $");
44 function getDefaultArguments() {
47 PageList::supportedArgs(),
48 array('pagename' => '[pagename]', // hackish
50 'limit' => 20, // limit <0 returns least popular pages
58 // info arg allows multiple columns
59 // info=mtime,hits,summary,version,author,locked,minor
60 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
61 // sortby: only pagename or hits. mtime not!
63 function run($dbi, $argstr, &$request, $basepage) {
64 $args = $this->getArgs($argstr, $request);
66 if (strstr($sortby,'mtime')) {
67 trigger_error(_("sortby=mtime not supported with MostPopular"),
71 $columns = $info ? explode(",", $info) : array();
72 array_unshift($columns, 'hits');
74 if (! $request->getArg('count')) {
75 //$args['count'] = $dbi->numPages(false,$exclude);
76 $allpages = $dbi->mostPopular(0);
77 $args['count'] = $allpages->count();
79 $args['count'] = $request->getArg('count');
82 $pages = $dbi->mostPopular($limit, $sortby);
83 $pagelist = new PageList($columns, $exclude, $args);
84 while ($page = $pages->next()) {
85 $hits = $page->get('hits');
86 // don't show pages with no hits if most popular pages
88 if ($hits == 0 && $limit > 0)
90 $pagelist->addPage($page);
96 $pagelist->setCaption(_("The %d most popular pages of this wiki:"));
99 $pagelist->setCaption(_("The %d least popular pages of this wiki:"));
101 $pagelist->setCaption(_("Visited pages on this wiki, ordered by popularity:"));
109 // $Log: not supported by cvs2svn $
110 // Revision 1.30 2004/10/14 19:19:34 rurban
111 // loadsave: check if the dumped file will be accessible from outside.
112 // and some other minor fixes. (cvsclient native not yet ready)
114 // Revision 1.29 2004/09/25 16:33:52 rurban
115 // add support for all PageList options
117 // Revision 1.28 2004/04/20 18:10:55 rurban
118 // config refactoring:
119 // FileFinder is needed for WikiFarm scripts calling index.php
120 // config run-time calls moved to lib/IniConfig.php:fix_configs()
121 // added PHPWIKI_DIR smart-detection code (Theme finder)
122 // moved FileFind to lib/FileFinder.php
123 // cleaned lib/config.php
125 // Revision 1.27 2004/04/20 00:06:53 rurban
128 // Revision 1.26 2004/04/18 01:34:21 rurban
129 // protect most_popular from sortby=mtime
131 // Revision 1.25 2004/03/30 02:38:06 rurban
132 // RateIt support (currently no recommendation engine yet)
134 // Revision 1.24 2004/03/01 13:48:46 rurban
136 // p[] consistency fix
138 // Revision 1.23 2004/02/17 12:11:36 rurban
139 // 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, ...)
141 // Revision 1.22 2003/01/18 21:48:56 carstenklapp
143 // Reformatting & tabs to spaces;
144 // Added copyleft, getVersion, getDescription, rcs_id.
151 // c-hanging-comment-ender-p: nil
152 // indent-tabs-mode: nil