The war on redundant ampersand usage!
[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 * @addtogroup SpecialPage
12 */
13 class MostcategoriesPage extends QueryPage {
14
15 function getName() { return 'Mostcategories'; }
16 function isExpensive() { return true; }
17 function isSyndicated() { return false; }
18
19 function getSQL() {
20 $dbr = wfGetDB( DB_SLAVE );
21 list( $categorylinks, $page) = $dbr->tableNamesN( 'categorylinks', 'page' );
22 return
23 "
24 SELECT
25 'Mostcategories' as type,
26 page_namespace as namespace,
27 page_title as title,
28 COUNT(*) as value
29 FROM $categorylinks
30 LEFT JOIN $page ON cl_from = page_id
31 WHERE page_namespace = " . NS_MAIN . "
32 GROUP BY 1,2,3
33 HAVING COUNT(*) > 1
34 ";
35 }
36
37 function formatResult( $skin, $result ) {
38 global $wgLang;
39 $title = Title::makeTitleSafe( $result->namespace, $result->title );
40 $count = wfMsgExt( 'ncategories', array( 'parsemag', 'escape' ), $wgLang->formatNum( $result->value ) );
41 $link = $skin->makeKnownLinkObj( $title, $title->getText() );
42 return wfSpecialList( $link, $count );
43 }
44 }
45
46 /**
47 * constructor
48 */
49 function wfSpecialMostcategories() {
50 list( $limit, $offset ) = wfCheckLimits();
51
52 $wpp = new MostcategoriesPage();
53
54 $wpp->doQuery( $offset, $limit );
55 }
56
57 ?>