update relnotes
[lhc/web/wiklou.git] / includes / SpecialMostlinkedcategories.php
1 <?php
2 /**
3 * A querypage to show categories ordered in descending order by the pages in them
4 *
5 * @addtogroup SpecialPage
6 *
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
10 */
11
12 /**
13 * @addtogroup SpecialPage
14 */
15 class MostlinkedCategoriesPage extends QueryPage {
16
17 function getName() { return 'Mostlinkedcategories'; }
18 function isExpensive() { return true; }
19 function isSyndicated() { return false; }
20
21 function getSQL() {
22 $dbr = wfGetDB( DB_SLAVE );
23 $categorylinks = $dbr->tableName( 'categorylinks' );
24 $name = $dbr->addQuotes( $this->getName() );
25 return
26 "
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
34 ";
35 }
36
37 function sortDescending() { return true; }
38
39 /**
40 * Fetch user page links and cache their existence
41 */
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();
47
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 );
52 }
53
54 function formatResult( $skin, $result ) {
55 global $wgLang, $wgContLang;
56
57 $nt = Title::makeTitle( $result->namespace, $result->title );
58 $text = $wgContLang->convert( $nt->getText() );
59
60 $plink = $skin->makeLinkObj( $nt, htmlspecialchars( $text ) );
61
62 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
63 $wgLang->formatNum( $result->value ) );
64 return wfSpecialList($plink, $nlinks);
65 }
66 }
67
68 /**
69 * constructor
70 */
71 function wfSpecialMostlinkedCategories() {
72 list( $limit, $offset ) = wfCheckLimits();
73
74 $wpp = new MostlinkedCategoriesPage();
75
76 $wpp->doQuery( $offset, $limit );
77 }
78
79 ?>