Fix last commit, was broken
[lhc/web/wiklou.git] / includes / specials / SpecialUnusedcategories.php
1 <?php
2 /**
3 * @file
4 * @ingroup SpecialPage
5 */
6
7 /**
8 * @ingroup SpecialPage
9 */
10 class UnusedCategoriesPage extends QueryPage {
11
12 function isExpensive() { return true; }
13
14 function getName() {
15 return 'Unusedcategories';
16 }
17
18 function getPageHeader() {
19 return wfMsgExt( 'unusedcategoriestext', array( 'parse' ) );
20 }
21
22 function getSQL() {
23 $NScat = NS_CATEGORY;
24 $dbr = wfGetDB( DB_SLAVE );
25 list( $categorylinks, $page, $page_props ) = $dbr->tableNamesN( 'categorylinks', 'page', 'page_props' );
26 return "SELECT 'Unusedcategories' as type,
27 {$NScat} as namespace, page_title as title, page_title as value
28 FROM $page
29 LEFT JOIN $categorylinks ON page_title=cl_to
30 LEFT JOIN $page_props ON (pp_page=page_id AND pp_propname = 'ignoreunused')
31 WHERE cl_from IS NULL
32 AND page_namespace = {$NScat}
33 AND page_is_redirect = 0
34 AND pp_propname IS NULL";
35 }
36
37 function formatResult( $skin, $result ) {
38 $title = Title::makeTitle( NS_CATEGORY, $result->title );
39 return $skin->makeLinkObj( $title, $title->getText() );
40 }
41 }
42
43 /** constructor */
44 function wfSpecialUnusedCategories() {
45 list( $limit, $offset ) = wfCheckLimits();
46 $uc = new UnusedCategoriesPage();
47 return $uc->doQuery( $offset, $limit );
48 }