3 * A querypage to show categories ordered in descending order by the pages in them
6 * @subpackage SpecialPage
8 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
9 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
10 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
15 * @subpackage SpecialPage
17 class MostlinkedCategoriesPage
extends QueryPage
{
19 function getName() { return 'Mostlinkedcategories'; }
20 function isExpensive() { return true; }
21 function isSyndicated() { return false; }
24 $dbr =& wfGetDB( DB_SLAVE
);
25 extract( $dbr->tableNames( 'categorylinks', 'page' ) );
26 $name = $dbr->addQuotes( $this->getName() );
31 " . NS_CATEGORY
. " as namespace,
39 function sortDescending() { return true; }
42 * Fetch user page links and cache their existence
44 function preprocessResults( &$db, &$res ) {
45 $batch = new LinkBatch
;
46 while ( $row = $db->fetchObject( $res ) )
47 $batch->addObj( Title
::makeTitleSafe( $row->namespace, $row->title
) );
50 // Back to start for display
51 if ( $db->numRows( $res ) > 0 )
52 // If there are no rows we get an error seeking.
53 $db->dataSeek( $res, 0 );
56 function formatResult( $skin, $result ) {
57 global $wgLang, $wgContLang;
59 $nt = Title
::makeTitle( $result->namespace, $result->title
);
60 $text = $wgContLang->convert( $nt->getText() );
62 $plink = $skin->makeLinkObj( $nt, htmlspecialchars( $text ) );
64 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
65 $wgLang->formatNum( $result->value
) );
66 return wfSpecialList($plink, $nlinks);
73 function wfSpecialMostlinkedCategories() {
74 list( $limit, $offset ) = wfCheckLimits();
76 $wpp = new MostlinkedCategoriesPage();
78 $wpp->doQuery( $offset, $limit );