> */ require_once 'lib/PageList.php'; class WikiPlugin_PopularTags extends WikiPlugin { // get list of categories sorted by number of backlinks private function cmp_by_count($a, $b) { if ($a['count'] == $b['count']) return 0; return $a['count'] < $b['count'] ? 1 : -1; } function getDescription() { return _("List the most popular tags."); } function getDefaultArguments() { return array('pagename' => '[pagename]', 'limit' => 10, 'mincount' => 5, 'noheader' => 0, ); } function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); extract($args); $maincat = $dbi->getPage(_("CategoryCategory")); $bi = $maincat->getBackLinks(false); $bl = array(); while ($b = $bi->next()) { $name = $b->getName(); if (preg_match("/^" . _("Template") . "/", $name)) continue; $pages = $b->getBackLinks(false); $bl[] = array('name' => $name, 'count' => $pages->count()); } usort($bl, array($this, 'cmp_by_count')); $html = HTML::ul(); $i = 0; foreach ($bl as $b) { $i++; $name = $b['name']; $count = $b['count']; if ($count < $mincount) break; if ($i > $limit) break; $wo = preg_replace("/^(" . _("Category") . "|" . _("Topic") . ")/", "", $name); $wo = HTML(HTML::span($wo), HTML::raw(" "), HTML::small("(" . $count . ")")); $link = WikiLink($name, 'auto', $wo); $html->pushContent(HTML::li($link)); } return $html; } } // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: