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