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