]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/specials/SpecialUnusedcategories.php
MediaWiki 1.16.1-scripts
[autoinstallsdev/mediawiki.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 ) = $dbr->tableNamesN( 'categorylinks', 'page' );
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                                 WHERE cl_from IS NULL
31                                 AND page_namespace = {$NScat}
32                                 AND page_is_redirect = 0";
33         }
34
35         function formatResult( $skin, $result ) {
36                 $title = Title::makeTitle( NS_CATEGORY, $result->title );
37                 return $skin->link( $title, $title->getText() );
38         }
39 }
40
41 /** constructor */
42 function wfSpecialUnusedCategories() {
43         list( $limit, $offset ) = wfCheckLimits();
44         $uc = new UnusedCategoriesPage();
45         return $uc->doQuery( $offset, $limit );
46 }