Got rid of the MagicWord indexing constants (MAG_xxx), replaced them by string indexi...
[lhc/web/wiklou.git] / includes / SpecialMostcategories.php
1 <?php
2 /**
3 * @package MediaWiki
4 * @subpackage SpecialPage
5 *
6 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
7 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
8 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
9 */
10
11 /**
12 * @package MediaWiki
13 * @subpackage SpecialPage
14 */
15 class MostcategoriesPage extends QueryPage {
16
17 function getName() { return 'Mostcategories'; }
18 function isExpensive() { return true; }
19 function isSyndicated() { return false; }
20
21 function getSQL() {
22 $dbr =& wfGetDB( DB_SLAVE );
23 extract( $dbr->tableNames( 'categorylinks', 'page' ) );
24 return
25 "
26 SELECT
27 'Mostcategories' as type,
28 page_namespace as namespace,
29 page_title as title,
30 COUNT(*) as value
31 FROM $categorylinks
32 LEFT JOIN $page ON cl_from = page_id
33 WHERE page_namespace = " . NS_MAIN . "
34 GROUP BY cl_from
35 HAVING COUNT(*) > 1
36 ";
37 }
38
39 function formatResult( $skin, $result ) {
40 global $wgContLang, $wgLang;
41
42 $nt = Title::makeTitle( $result->namespace, $result->title );
43 $text = $wgContLang->convert( $nt->getPrefixedText() );
44
45 $plink = $skin->makeKnownLink( $nt->getPrefixedText(), $text );
46
47 $nl = wfMsgExt( 'ncategories', array( 'parsemag', 'escape' ),
48 $wgLang->formatNum( $result->value ) );
49
50 $nlink = $skin->makeKnownLink( $wgContLang->specialPage( 'Categories' ),
51 $nl, 'article=' . $nt->getPrefixedURL() );
52
53 return wfSpecialList($plink, $nlink);
54 }
55 }
56
57 /**
58 * constructor
59 */
60 function wfSpecialMostcategories() {
61 list( $limit, $offset ) = wfCheckLimits();
62
63 $wpp = new MostcategoriesPage();
64
65 $wpp->doQuery( $offset, $limit );
66 }
67
68 ?>