summaryrefslogtreecommitdiff
path: root/includes/SpecialCategories.php
blob: 346eac633da75f9b769c12c28e0ff9fdb9320fb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
 *
 * @package MediaWiki
 * @subpackage SpecialPage
 */

/**
 *
 * @package MediaWiki
 * @subpackage SpecialPage
 */
class CategoriesPage extends QueryPage {

	function getName() {
		return "Categories";
	}

	function isExpensive() {
		return false;
	}

	function isSyndicated() { return false; }

	function getPageHeader() {
		return wfMsgWikiHtml( 'categoriespagetext' );
	}
	
	function getSQL() {
		$NScat = NS_CATEGORY;
		$dbr =& wfGetDB( DB_SLAVE );
		$categorylinks = $dbr->tableName( 'categorylinks' );
		$implicit_groupby = $dbr->implicitGroupby() ? '1' : 'cl_to';
		$s= "SELECT 'Categories' as type,
				{$NScat} as namespace,
				cl_to as title,
				$implicit_groupby as value,
				COUNT(*) as count
			   FROM $categorylinks
			   GROUP BY 1,2,3,4";
		return $s;
	}

	function sortDescending() {
		return false;
	}

	function formatResult( $skin, $result ) {
		global $wgLang;
		$title = Title::makeTitle( NS_CATEGORY, $result->title );
		$plink = $skin->makeLinkObj( $title, $title->getText() );
		$nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
			$wgLang->formatNum( $result->count ) );
		return wfSpecialList($plink, $nlinks);
	}
}

/**
 *
 */
function wfSpecialCategories() {
	list( $limit, $offset ) = wfCheckLimits();

	$cap = new CategoriesPage();

	return $cap->doQuery( $offset, $limit );
}

?>