Removing leecruft. No, you sure as hell couldn't defer it.
[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 require_once 'QueryPage.php';
13
14 /**
15 * @package MediaWiki
16 * @subpackage SpecialPage
17 */
18 class MostcategoriesPage extends QueryPage {
19
20 function getName() { return 'Mostcategories'; }
21 function isExpensive() { return true; }
22 function isSyndicated() { return false; }
23
24 function getSQL() {
25 $dbr =& wfGetDB( DB_SLAVE );
26 extract( $dbr->tableNames( 'categorylinks', 'page' ) );
27 return
28 "
29 SELECT
30 'Mostcategories' as type,
31 page_namespace as namespace,
32 page_title as title,
33 COUNT(*) as value
34 FROM $categorylinks
35 LEFT JOIN $page ON cl_from = page_id
36 WHERE page_namespace = " . NS_MAIN . "
37 GROUP BY cl_from
38 HAVING COUNT(*) > 1
39 ";
40 }
41
42 function formatResult( $skin, $result ) {
43 global $wgContLang;
44
45 $nt = Title::makeTitle( $result->namespace, $result->title );
46 $text = $wgContLang->convert( $nt->getPrefixedText() );
47
48 $plink = $skin->makeKnownLink( $nt->getPrefixedText(), $text );
49
50 $nl = wfMsg( 'ncategories', $result->value );
51 $nlink = $skin->makeKnownLink( $wgContLang->specialPage( 'Categories' ), $nl, 'article=' . $nt->getPrefixedURL() );
52
53 return "{$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 ?>