invert without namespace doesn't do anything, so ignore it
[lhc/web/wiklou.git] / includes / specials / SpecialUnusedtemplates.php
1 <?php
2 /**
3 * Implements Special:Unusedtemplates
4 *
5 * Copyright © 2006 Rob Church
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
21 *
22 * @file
23 * @ingroup SpecialPage
24 * @author Rob Church <robchur@gmail.com>
25 */
26
27 /**
28 * A special page that lists unused templates
29 *
30 * @ingroup SpecialPage
31 */
32 class UnusedtemplatesPage extends QueryPage {
33
34 function getName() { return( 'Unusedtemplates' ); }
35 function isExpensive() { return true; }
36 function isSyndicated() { return false; }
37 function sortDescending() { return false; }
38
39 function getSQL() {
40 $dbr = wfGetDB( DB_SLAVE );
41 list( $page, $templatelinks) = $dbr->tableNamesN( 'page', 'templatelinks' );
42 $sql = "SELECT 'Unusedtemplates' AS type, page_title AS title,
43 page_namespace AS namespace, 0 AS value
44 FROM $page
45 LEFT JOIN $templatelinks
46 ON page_namespace = tl_namespace AND page_title = tl_title
47 WHERE page_namespace = 10 AND tl_from IS NULL
48 AND page_is_redirect = 0";
49 return $sql;
50 }
51
52 function formatResult( $skin, $result ) {
53 $title = Title::makeTitle( NS_TEMPLATE, $result->title );
54 $pageLink = $skin->linkKnown(
55 $title,
56 null,
57 array(),
58 array( 'redirect' => 'no' )
59 );
60 $wlhLink = $skin->linkKnown(
61 SpecialPage::getTitleFor( 'Whatlinkshere' ),
62 wfMsgHtml( 'unusedtemplateswlh' ),
63 array(),
64 array( 'target' => $title->getPrefixedText() )
65 );
66 return wfSpecialList( $pageLink, $wlhLink );
67 }
68
69 function getPageHeader() {
70 return wfMsgExt( 'unusedtemplatestext', array( 'parse' ) );
71 }
72
73 }
74
75 function wfSpecialUnusedtemplates() {
76 list( $limit, $offset ) = wfCheckLimits();
77 $utp = new UnusedtemplatesPage();
78 $utp->doQuery( $offset, $limit );
79 }