00001 <?php
00016 class MostlinkedCategoriesPage extends QueryPage {
00017
00018 function getName() { return 'Mostlinkedcategories'; }
00019 function isExpensive() { return true; }
00020 function isSyndicated() { return false; }
00021
00022 function getSQL() {
00023 $dbr = wfGetDB( DB_SLAVE );
00024 $categorylinks = $dbr->tableName( 'categorylinks' );
00025 $name = $dbr->addQuotes( $this->getName() );
00026 return
00027 "
00028 SELECT
00029 $name as type,
00030 " . NS_CATEGORY . " as namespace,
00031 cl_to as title,
00032 COUNT(*) as value
00033 FROM $categorylinks
00034 GROUP BY cl_to
00035 ";
00036 }
00037
00038 function sortDescending() { return true; }
00039
00043 function preprocessResults( $db, $res ) {
00044 $batch = new LinkBatch;
00045 while ( $row = $db->fetchObject( $res ) )
00046 $batch->add( $row->namespace, $row->title );
00047 $batch->execute();
00048
00049
00050 if ( $db->numRows( $res ) > 0 )
00051
00052 $db->dataSeek( $res, 0 );
00053 }
00054
00055 function formatResult( $skin, $result ) {
00056 global $wgLang, $wgContLang;
00057
00058 $nt = Title::makeTitle( $result->namespace, $result->title );
00059 $text = $wgContLang->convert( $nt->getText() );
00060
00061 $plink = $skin->makeLinkObj( $nt, htmlspecialchars( $text ) );
00062
00063 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
00064 $wgLang->formatNum( $result->value ) );
00065 return wfSpecialList($plink, $nlinks);
00066 }
00067 }
00068
00072 function wfSpecialMostlinkedCategories() {
00073 list( $limit, $offset ) = wfCheckLimits();
00074
00075 $wpp = new MostlinkedCategoriesPage();
00076
00077 $wpp->doQuery( $offset, $limit );
00078 }