]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/specials/SpecialUnusedtemplates.php
MediaWiki 1.16.1-scripts
[autoinstallsdev/mediawiki.git] / includes / specials / SpecialUnusedtemplates.php
1 <?php
2 /**
3  * @file
4  * @ingroup SpecialPage
5  */
6
7 /**
8  * implements Special:Unusedtemplates
9  * @author Rob Church <robchur@gmail.com>
10  * @copyright © 2006 Rob Church
11  * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
12  * @ingroup SpecialPage
13  */
14 class UnusedtemplatesPage extends QueryPage {
15
16         function getName() { return( 'Unusedtemplates' ); }
17         function isExpensive() { return true; }
18         function isSyndicated() { return false; }
19         function sortDescending() { return false; }
20
21         function getSQL() {
22                 $dbr = wfGetDB( DB_SLAVE );
23                 list( $page, $templatelinks) = $dbr->tableNamesN( 'page', 'templatelinks' );
24                 $sql = "SELECT 'Unusedtemplates' AS type, page_title AS title,
25                         page_namespace AS namespace, 0 AS value
26                         FROM $page
27                         LEFT JOIN $templatelinks
28                         ON page_namespace = tl_namespace AND page_title = tl_title
29                         WHERE page_namespace = 10 AND tl_from IS NULL
30                         AND page_is_redirect = 0";
31                 return $sql;
32         }
33
34         function formatResult( $skin, $result ) {
35                 $title = Title::makeTitle( NS_TEMPLATE, $result->title );
36                 $pageLink = $skin->linkKnown(
37                         $title,
38                         null,
39                         array(),
40                         array( 'redirect' => 'no' )
41                 );
42                 $wlhLink = $skin->linkKnown(
43                         SpecialPage::getTitleFor( 'Whatlinkshere' ),
44                         wfMsgHtml( 'unusedtemplateswlh' ),
45                         array(),
46                         array( 'target' => $title->getPrefixedText() )
47                 );
48                 return wfSpecialList( $pageLink, $wlhLink );
49         }
50
51         function getPageHeader() {
52                 return wfMsgExt( 'unusedtemplatestext', array( 'parse' ) );
53         }
54
55 }
56
57 function wfSpecialUnusedtemplates() {
58         list( $limit, $offset ) = wfCheckLimits();
59         $utp = new UnusedtemplatesPage();
60         $utp->doQuery( $offset, $limit );
61 }