* $wgDebugTidy feature
[lhc/web/wiklou.git] / includes / SpecialMostcategories.php
1 <?php
2 /**
3 * @addtogroup SpecialPage
4 *
5 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
6 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
7 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
8 */
9
10 /**
11 * implements Special:Mostcategories
12 * @addtogroup SpecialPage
13 */
14 class MostcategoriesPage extends QueryPage {
15
16 function getName() { return 'Mostcategories'; }
17 function isExpensive() { return true; }
18 function isSyndicated() { return false; }
19
20 function getSQL() {
21 $dbr = wfGetDB( DB_SLAVE );
22 list( $categorylinks, $page) = $dbr->tableNamesN( 'categorylinks', 'page' );
23 return
24 "
25 SELECT
26 'Mostcategories' as type,
27 page_namespace as namespace,
28 page_title as title,
29 COUNT(*) as value
30 FROM $categorylinks
31 LEFT JOIN $page ON cl_from = page_id
32 WHERE page_namespace = " . NS_MAIN . "
33 GROUP BY 1,2,3
34 HAVING COUNT(*) > 1
35 ";
36 }
37
38 function formatResult( $skin, $result ) {
39 global $wgLang;
40 $title = Title::makeTitleSafe( $result->namespace, $result->title );
41 if ( !$title instanceof Title ) { throw new MWException('Invalid title in database'); }
42 $count = wfMsgExt( 'ncategories', array( 'parsemag', 'escape' ), $wgLang->formatNum( $result->value ) );
43 $link = $skin->makeKnownLinkObj( $title, $title->getText() );
44 return wfSpecialList( $link, $count );
45 }
46 }
47
48 /**
49 * constructor
50 */
51 function wfSpecialMostcategories() {
52 list( $limit, $offset ) = wfCheckLimits();
53
54 $wpp = new MostcategoriesPage();
55
56 $wpp->doQuery( $offset, $limit );
57 }
58
59