GPL Headers for all!
[lhc/web/wiklou.git] / includes / specials / SpecialUnusedtemplates.php
1 <?php
2 /**
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 */
19
20 /**
21 * @file
22 * @ingroup SpecialPage
23 */
24
25 /**
26 * implements Special:Unusedtemplates
27 * @author Rob Church <robchur@gmail.com>
28 * @copyright © 2006 Rob Church
29 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
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 }