Rename all the special page class files back to their proper names.
[lhc/web/wiklou.git] / includes / specials / SpecialMostlinkedcategories.php
1 <?php
2 /**
3 * @file
4 * @ingroup SpecialPage
5 */
6
7 /**
8 * A querypage to show categories ordered in descending order by the pages in them
9 *
10 * @ingroup SpecialPage
11 *
12 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
13 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
14 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
15 */
16 class MostlinkedCategoriesPage extends QueryPage {
17
18 function getName() { return 'Mostlinkedcategories'; }
19 function isExpensive() { return true; }
20 function isSyndicated() { return false; }
21
22 function getSQL() {
23 $dbr = wfGetDB( DB_SLAVE );
24 $categorylinks = $dbr->tableName( 'categorylinks' );
25 $name = $dbr->addQuotes( $this->getName() );
26 return
27 "
28 SELECT
29 $name as type,
30 " . NS_CATEGORY . " as namespace,
31 cl_to as title,
32 COUNT(*) as value
33 FROM $categorylinks
34 GROUP BY 1,2,3
35 ";
36 }
37
38 function sortDescending() { return true; }
39
40 /**
41 * Fetch user page links and cache their existence
42 */
43 function preprocessResults( $db, $res ) {
44 $batch = new LinkBatch;
45 while ( $row = $db->fetchObject( $res ) )
46 $batch->add( $row->namespace, $row->title );
47 $batch->execute();
48
49 // Back to start for display
50 if ( $db->numRows( $res ) > 0 )
51 // If there are no rows we get an error seeking.
52 $db->dataSeek( $res, 0 );
53 }
54
55 function formatResult( $skin, $result ) {
56 global $wgLang, $wgContLang;
57
58 $nt = Title::makeTitle( $result->namespace, $result->title );
59 $text = $wgContLang->convert( $nt->getText() );
60
61 $plink = $skin->makeLinkObj( $nt, htmlspecialchars( $text ) );
62
63 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
64 $wgLang->formatNum( $result->value ) );
65 return wfSpecialList($plink, $nlinks);
66 }
67 }
68
69 /**
70 * constructor
71 */
72 function wfSpecialMostlinkedCategories() {
73 list( $limit, $offset ) = wfCheckLimits();
74
75 $wpp = new MostlinkedCategoriesPage();
76
77 $wpp->doQuery( $offset, $limit );
78 }