4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
22 * @ingroup SpecialPage
26 * A querypage to show categories ordered in descending order by the pages in them
28 * @ingroup SpecialPage
30 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
31 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
32 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
34 class MostlinkedCategoriesPage
extends QueryPage
{
36 function getName() { return 'Mostlinkedcategories'; }
37 function isExpensive() { return true; }
38 function isSyndicated() { return false; }
41 $dbr = wfGetDB( DB_SLAVE
);
42 $categorylinks = $dbr->tableName( 'categorylinks' );
43 $name = $dbr->addQuotes( $this->getName() );
48 " . NS_CATEGORY
. " as namespace,
56 function sortDescending() { return true; }
59 * Fetch user page links and cache their existence
61 function preprocessResults( $db, $res ) {
62 $batch = new LinkBatch
;
63 while ( $row = $db->fetchObject( $res ) )
64 $batch->add( $row->namespace, $row->title
);
67 // Back to start for display
68 if ( $db->numRows( $res ) > 0 )
69 // If there are no rows we get an error seeking.
70 $db->dataSeek( $res, 0 );
73 function formatResult( $skin, $result ) {
74 global $wgLang, $wgContLang;
76 $nt = Title
::makeTitle( $result->namespace, $result->title
);
77 $text = $wgContLang->convert( $nt->getText() );
79 $plink = $skin->link( $nt, htmlspecialchars( $text ) );
81 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
82 $wgLang->formatNum( $result->value
) );
83 return wfSpecialList($plink, $nlinks);
90 function wfSpecialMostlinkedCategories() {
91 list( $limit, $offset ) = wfCheckLimits();
93 $wpp = new MostlinkedCategoriesPage();
95 $wpp->doQuery( $offset, $limit );