SpecialUnusedtemplates.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @file
  4. * @ingroup SpecialPage
  5. */
  6. /**
  7. * implements Special:Unusedtemplates
  8. * @author Rob Church <robchur@gmail.com>
  9. * @copyright © 2006 Rob Church
  10. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
  11. * @ingroup SpecialPage
  12. */
  13. class UnusedtemplatesPage extends QueryPage {
  14. function getName() { return( 'Unusedtemplates' ); }
  15. function isExpensive() { return true; }
  16. function isSyndicated() { return false; }
  17. function sortDescending() { return false; }
  18. function getSQL() {
  19. $dbr = wfGetDB( DB_SLAVE );
  20. list( $page, $templatelinks) = $dbr->tableNamesN( 'page', 'templatelinks' );
  21. $sql = "SELECT 'Unusedtemplates' AS type, page_title AS title,
  22. page_namespace AS namespace, 0 AS value
  23. FROM $page
  24. LEFT JOIN $templatelinks
  25. ON page_namespace = tl_namespace AND page_title = tl_title
  26. WHERE page_namespace = 10 AND tl_from IS NULL
  27. AND page_is_redirect = 0";
  28. return $sql;
  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. function getPageHeader() {
  40. return wfMsgExt( 'unusedtemplatestext', array( 'parse' ) );
  41. }
  42. }
  43. function wfSpecialUnusedtemplates() {
  44. list( $limit, $offset ) = wfCheckLimits();
  45. $utp = new UnusedtemplatesPage();
  46. $utp->doQuery( $offset, $limit );
  47. }