* (bug 6061) Improper escaping in some html forms
[mediawiki.git] / includes / SpecialMostlinkedcategories.php
blob6951e457ea7d97332863782f6d181833db882855
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 require_once 'QueryPage.php';
16 /**
17 * @package MediaWiki
18 * @subpackage SpecialPage
20 class MostlinkedCategoriesPage extends QueryPage {
22 function getName() { return 'Mostlinkedcategories'; }
23 function isExpensive() { return true; }
24 function isSyndicated() { return false; }
26 function getSQL() {
27 $dbr =& wfGetDB( DB_SLAVE );
28 extract( $dbr->tableNames( 'categorylinks', 'page' ) );
29 $name = $dbr->addQuotes( $this->getName() );
30 return
32 SELECT
33 $name as type,
34 " . NS_CATEGORY . " as namespace,
35 cl_to as title,
36 COUNT(*) as value
37 FROM $categorylinks
38 GROUP BY cl_to
42 function sortDescending() { return true; }
44 /**
45 * Fetch user page links and cache their existence
47 function preprocessResults( &$db, &$res ) {
48 $batch = new LinkBatch;
49 while ( $row = $db->fetchObject( $res ) )
50 $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) );
51 $batch->execute();
53 // Back to start for display
54 if ( $db->numRows( $res ) > 0 )
55 // If there are no rows we get an error seeking.
56 $db->dataSeek( $res, 0 );
59 function formatResult( $skin, $result ) {
60 global $wgLang, $wgContLang;
62 $nt = Title::makeTitle( $result->namespace, $result->title );
63 $text = $wgContLang->convert( $nt->getText() );
65 $plink = $skin->makeLinkObj( $nt, htmlspecialchars( $text ) );
67 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
68 $wgLang->formatNum( $result->value ) );
69 return wfSpecialList($plink, $nlinks);
73 /**
74 * constructor
76 function wfSpecialMostlinkedCategories() {
77 list( $limit, $offset ) = wfCheckLimits();
79 $wpp = new MostlinkedCategoriesPage();
81 $wpp->doQuery( $offset, $limit );