2 rcs_id('$Id: PopularTags.php,v 1.2 2007-05-01 16:05:29 rurban Exp $');
4 Copyright 2007 Reini Urban
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
25 * <?plugin PopularTags ?>
28 require_once('lib/PageList.php');
30 class WikiPlugin_PopularTags
34 return _("PopularTags");
37 function getDescription () {
38 return _("List the most popular tags.");
41 function getVersion() {
42 return preg_replace("/[Revision: $]/", '',
46 function getDefaultArguments() {
47 return array('pagename' => '[pagename]',
55 function run($dbi, $argstr, &$request, $basepage) {
56 $args = $this->getArgs($argstr, $request);
59 $maincat = $dbi->getPage(_("CategoryCategory"));
60 $bi = $maincat->getBackLinks(false);
62 while ($b = $bi->next()) {
63 $name = $b->getName();
64 if (preg_match("/^"._("Template")."/", $name)) continue;
65 $pages = $b->getBackLinks(false);
66 $bl[] = array('name' => $name,
67 'count' => $pages->count());
70 usort($bl, 'cmp_by_count');
71 $html = HTML::ul(); $i = 0;
76 if ($count < $mincount) break;
77 if ($i > $limit) break;
78 $wo = preg_replace("/^("._("Category")."|"
79 ._("Topic").")/", "", $name);
80 $wo = HTML(HTML::span($wo),HTML::raw(" "),HTML::small("(".$count.")"));
81 $link = WikiLink($name, 'auto', $wo);
82 $html->pushContent(HTML::li($link));
88 // get list of categories sorted by number of backlinks
89 function cmp_by_count($a, $b) {
90 if ($a['count'] == $b['count']) return 0;
91 return $a['count'] < $b['count'] ? 1 : -1;
95 // $Log: not supported by cvs2svn $
96 // Revision 1.1 2007/03/10 18:30:51 rurban
97 // Most popular list of Categories
104 // c-hanging-comment-ender-p: nil
105 // indent-tabs-mode: nil