* Reorganised the includes directory, creating subdirectories db, parser and specials
[lhc/web/wiklou.git] / includes / specials / Unusedtemplates.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->makeKnownLinkObj( $title, '', 'redirect=no' );
37 $wlhLink = $skin->makeKnownLinkObj(
38 SpecialPage::getTitleFor( 'Whatlinkshere' ),
39 wfMsgHtml( 'unusedtemplateswlh' ),
40 'target=' . $title->getPrefixedUrl() );
41 return wfSpecialList( $pageLink, $wlhLink );
42 }
43
44 function getPageHeader() {
45 return wfMsgExt( 'unusedtemplatestext', array( 'parse' ) );
46 }
47
48 }
49
50 function wfSpecialUnusedtemplates() {
51 list( $limit, $offset ) = wfCheckLimits();
52 $utp = new UnusedtemplatesPage();
53 $utp->doQuery( $offset, $limit );
54 }