8 * A querypage to show categories ordered in descending order by the pages in them
10 * @ingroup SpecialPage
12 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
13 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
14 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
16 class MostlinkedCategoriesPage
extends QueryPage
{
18 function getName() { return 'Mostlinkedcategories'; }
19 function isExpensive() { return true; }
20 function isSyndicated() { return false; }
23 $dbr = wfGetDB( DB_SLAVE
);
24 $categorylinks = $dbr->tableName( 'categorylinks' );
25 $name = $dbr->addQuotes( $this->getName() );
30 " . NS_CATEGORY
. " as namespace,
38 function sortDescending() { return true; }
41 * Fetch user page links and cache their existence
43 function preprocessResults( $db, $res ) {
44 $batch = new LinkBatch
;
45 while ( $row = $db->fetchObject( $res ) )
46 $batch->add( $row->namespace, $row->title
);
49 // Back to start for display
50 if ( $db->numRows( $res ) > 0 )
51 // If there are no rows we get an error seeking.
52 $db->dataSeek( $res, 0 );
55 function formatResult( $skin, $result ) {
56 global $wgLang, $wgContLang;
58 $nt = Title
::makeTitle( $result->namespace, $result->title
);
59 $text = $wgContLang->convert( $nt->getText() );
61 $plink = $skin->link( $nt, htmlspecialchars( $text ) );
63 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
64 $wgLang->formatNum( $result->value
) );
65 return wfSpecialList($plink, $nlinks);
72 function wfSpecialMostlinkedCategories() {
73 list( $limit, $offset ) = wfCheckLimits();
75 $wpp = new MostlinkedCategoriesPage();
77 $wpp->doQuery( $offset, $limit );