Added description for two new tables
[mediawiki.git] / includes / SpecialMostlinkedcategories.php
blob5942b3f4ea6e345535843c9f4a09d99130e1e200
1 <?php
2 /**
3 * A querypage to show categories ordered in descending order by the pages in them
5 * @package MediaWiki
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
13 /**
14 * @package MediaWiki
15 * @subpackage SpecialPage
17 class MostlinkedCategoriesPage extends QueryPage {
19 function getName() { return 'Mostlinkedcategories'; }
20 function isExpensive() { return true; }
21 function isSyndicated() { return false; }
23 function getSQL() {
24 $dbr =& wfGetDB( DB_SLAVE );
25 extract( $dbr->tableNames( 'categorylinks', 'page' ) );
26 $name = $dbr->addQuotes( $this->getName() );
27 return
29 SELECT
30 $name as type,
31 " . NS_CATEGORY . " as namespace,
32 cl_to as title,
33 COUNT(*) as value
34 FROM $categorylinks
35 GROUP BY 1,2,3
39 function sortDescending() { return true; }
41 /**
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 ) );
48 $batch->execute();
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);
70 /**
71 * constructor
73 function wfSpecialMostlinkedCategories() {
74 list( $limit, $offset ) = wfCheckLimits();
76 $wpp = new MostlinkedCategoriesPage();
78 $wpp->doQuery( $offset, $limit );