00001 <?php
00016 class WantedCategoriesPage extends QueryPage {
00017
00018 function getName() {
00019 return 'Wantedcategories';
00020 }
00021
00022 function isExpensive() {
00023 return true;
00024 }
00025
00026 function isSyndicated() {
00027 return false;
00028 }
00029
00030 function getSQL() {
00031 $dbr = wfGetDB( DB_SLAVE );
00032 list( $categorylinks, $page ) = $dbr->tableNamesN( 'categorylinks', 'page' );
00033 $name = $dbr->addQuotes( $this->getName() );
00034 return
00035 "
00036 SELECT
00037 $name as type,
00038 " . NS_CATEGORY . " as namespace,
00039 cl_to as title,
00040 COUNT(*) as value
00041 FROM $categorylinks
00042 LEFT JOIN $page ON cl_to = page_title AND page_namespace = ". NS_CATEGORY ."
00043 WHERE page_title IS NULL
00044 GROUP BY cl_to
00045 ";
00046 }
00047
00048 function sortDescending() { return true; }
00049
00053 function preprocessResults( $db, $res ) {
00054 $batch = new LinkBatch;
00055 while ( $row = $db->fetchObject( $res ) )
00056 $batch->add( $row->namespace, $row->title );
00057 $batch->execute();
00058
00059
00060 if ( $db->numRows( $res ) > 0 )
00061
00062 $db->dataSeek( $res, 0 );
00063 }
00064
00065 function formatResult( $skin, $result ) {
00066 global $wgLang, $wgContLang;
00067
00068 $nt = Title::makeTitle( $result->namespace, $result->title );
00069 $text = $wgContLang->convert( $nt->getText() );
00070
00071 $plink = $this->isCached() ?
00072 $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) :
00073 $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) );
00074
00075 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
00076 $wgLang->formatNum( $result->value ) );
00077 return wfSpecialList($plink, $nlinks);
00078 }
00079 }
00080
00084 function wfSpecialWantedCategories() {
00085 list( $limit, $offset ) = wfCheckLimits();
00086
00087 $wpp = new WantedCategoriesPage();
00088
00089 $wpp->doQuery( $offset, $limit );
00090 }