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