hook point for injecting fields into edit form
[mediawiki.git] / includes / SpecialMostlinkedcategories.php
blob536a48a186449894535a84dfdcec99894f9a0d5f
1 <?php
2 /**
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
12 /**
13 * @addtogroup SpecialPage
15 class MostlinkedCategoriesPage extends QueryPage {
17 function getName() { return 'Mostlinkedcategories'; }
18 function isExpensive() { return true; }
19 function isSyndicated() { return false; }
21 function getSQL() {
22 $dbr = wfGetDB( DB_SLAVE );
23 $categorylinks = $dbr->tableName( 'categorylinks' );
24 $name = $dbr->addQuotes( $this->getName() );
25 return
27 SELECT
28 $name as type,
29 " . NS_CATEGORY . " as namespace,
30 cl_to as title,
31 COUNT(*) as value
32 FROM $categorylinks
33 GROUP BY 1,2,3
37 function sortDescending() { return true; }
39 /**
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 ) );
46 $batch->execute();
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);
68 /**
69 * constructor
71 function wfSpecialMostlinkedCategories() {
72 list( $limit, $offset ) = wfCheckLimits();
74 $wpp = new MostlinkedCategoriesPage();
76 $wpp->doQuery( $offset, $limit );