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: $]/", '',
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, $sortby);
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) {
91 $pagelist->addPage($page);
97 $pagelist->setCaption(_("The %d most popular pages of this wiki:"));
100 $pagelist->setCaption(_("The %d least popular pages of this wiki:"));
102 $pagelist->setCaption(_("Visited pages on this wiki, ordered by popularity:"));
110 // $Log: not supported by cvs2svn $
111 // Revision 1.31 2004/11/23 15:17:19 rurban
112 // better support for case_exact search (not caseexact for consistency),
113 // plugin args simplification:
114 // handle and explode exclude and pages argument in WikiPlugin::getArgs
115 // and exclude in advance (at the sql level if possible)
116 // handle sortby and limit from request override in WikiPlugin::getArgs
117 // ListSubpages: renamed pages to maxpages
119 // Revision 1.30 2004/10/14 19:19:34 rurban
120 // loadsave: check if the dumped file will be accessible from outside.
121 // and some other minor fixes. (cvsclient native not yet ready)
123 // Revision 1.29 2004/09/25 16:33:52 rurban
124 // add support for all PageList options
126 // Revision 1.28 2004/04/20 18:10:55 rurban
127 // config refactoring:
128 // FileFinder is needed for WikiFarm scripts calling index.php
129 // config run-time calls moved to lib/IniConfig.php:fix_configs()
130 // added PHPWIKI_DIR smart-detection code (Theme finder)
131 // moved FileFind to lib/FileFinder.php
132 // cleaned lib/config.php
134 // Revision 1.27 2004/04/20 00:06:53 rurban
137 // Revision 1.26 2004/04/18 01:34:21 rurban
138 // protect most_popular from sortby=mtime
140 // Revision 1.25 2004/03/30 02:38:06 rurban
141 // RateIt support (currently no recommendation engine yet)
143 // Revision 1.24 2004/03/01 13:48:46 rurban
145 // p[] consistency fix
147 // Revision 1.23 2004/02/17 12:11:36 rurban
148 // 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, ...)
150 // Revision 1.22 2003/01/18 21:48:56 carstenklapp
152 // Reformatting & tabs to spaces;
153 // Added copyleft, getVersion, getDescription, rcs_id.
160 // c-hanging-comment-ender-p: nil
161 // indent-tabs-mode: nil