From c4a55e4dc254189dc80bfcefdc8c5b72f05eab49 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Tue, 18 Apr 2006 03:49:13 +0000 Subject: [PATCH] (bug 5250) Introduce Special:Unusedtemplates --- RELEASE-NOTES | 1 + includes/QueryPage.php | 1 + includes/SpecialPage.php | 1 + includes/SpecialUnusedtemplates.php | 53 +++++++++++++++++++++++++++++ languages/Messages.php | 5 +++ 5 files changed, 61 insertions(+) create mode 100644 includes/SpecialUnusedtemplates.php diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b9143018d1..804f8e9c7e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -94,6 +94,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 5595) Localisation for Bosnian language (bs) * (bug 2910) Default view preferences for watchlists * Add "hide bot edits from the watchlist" user preference +* (bug 5250) Introduce Special:Unusedtemplates == Compatibility == diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 79ce0ba667..eb1a02848d 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -40,6 +40,7 @@ $wgQueryPages = array( array( 'WantedCategoriesPage', 'Wantedcategories' ), array( 'WantedPagesPage', 'Wantedpages' ), array( 'UnwatchedPagesPage', 'Unwatchedpages' ), + array( 'UnusedtemplatesPage', 'Unusedtemplates' ), ); wfRunHooks( 'wgQueryPages', array( &$wgQueryPages ) ); diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index eb643411d2..72ce4dcdf8 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -79,6 +79,7 @@ $wgSpecialPages = array( 'Unwatchedpages' => new SpecialPage( 'Unwatchedpages', 'unwatchedpages' ), 'Listredirects' => new SpecialPage( 'Listredirects' ), 'Revisiondelete' => new SpecialPage( 'Revisiondelete', 'deleterevision' ), + 'Unusedtemplates' => new SpecialPage( 'Unusedtemplates' ), ); if( !$wgDisableCounters ) { diff --git a/includes/SpecialUnusedtemplates.php b/includes/SpecialUnusedtemplates.php new file mode 100644 index 0000000000..428a5a9cb8 --- /dev/null +++ b/includes/SpecialUnusedtemplates.php @@ -0,0 +1,53 @@ + + * @copyright © 2006 Rob Church + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ + +/* */ +require_once 'QueryPage.php'; + +/** + * @package MediaWiki + * @subpackage SpecialPage + */ + +class UnusedtemplatesPage extends QueryPage { + + function getName() { return( 'Unusedtemplates' ); } + function isExpensive() { return( true ); } + function isSyndicated() { return( false ); } + function sortDescending() { return( false ); } + + function getSQL() { + $dbr =& wfGetDB( DB_SLAVE ); + extract( $dbr->tableNames( 'page', 'templatelinks' ) ); + $sql = "SELECT 'Unusedtemplates' AS type, page_title AS title, page_namespace AS namespace, 0 AS value FROM $page LEFT JOIN $templatelinks ON page_namespace = tl_namespace AND page_title = tl_title WHERE page_namespace = 10 AND tl_from IS NULL"; + return( $sql ); + } + + function formatResult( $skin, $result ) { + $title = Title::makeTitle( NS_TEMPLATE, $result->title ); + $pageLink = $skin->makeKnownLinkObj( $title, '', 'redirect=no' ); + $wlhLink = $skin->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Whatlinkshere' ), wfMsgHtml( 'unusedtemplateswlh' ), 'target=' . $title->getPrefixedUrl() ); + return( $pageLink . ' (' . $wlhLink . ')' ); + } + + function getPageHeader() { + return( wfMsgHtml( 'unusedtemplatestext' ) ); + } + +} + +function wfSpecialUnusedtemplates() { + list( $limit, $offset ) = wfCheckLimits(); + $utp = new UnusedtemplatesPage(); + $utp->doQuery( $offset, $limit ); +} + +?> \ No newline at end of file diff --git a/languages/Messages.php b/languages/Messages.php index 3404f6a157..babcae73ee 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -919,6 +919,11 @@ this old version, (rev) = revert to this old version. # List redirects 'listredirects' => 'List redirects', +# Unused templates +'unusedtemplates' => 'Unused templates', +'unusedtemplatestext' => 'This page lists all pages in the template namespace which are not included in another page. Remember to check for other links to the templates before deleting them.', +'unusedtemplateswlh' => 'other links', + # Statistics # 'statistics' => 'Statistics', -- 2.20.1