SpecialUnusedcategories.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * @file
  4. * @ingroup SpecialPage
  5. */
  6. /**
  7. * @ingroup SpecialPage
  8. */
  9. class UnusedCategoriesPage extends QueryPage {
  10. function isExpensive() { return true; }
  11. function getName() {
  12. return 'Unusedcategories';
  13. }
  14. function getPageHeader() {
  15. return wfMsgExt( 'unusedcategoriestext', array( 'parse' ) );
  16. }
  17. function getSQL() {
  18. $NScat = NS_CATEGORY;
  19. $dbr = wfGetDB( DB_SLAVE );
  20. list( $categorylinks, $page ) = $dbr->tableNamesN( 'categorylinks', 'page' );
  21. return "SELECT 'Unusedcategories' as type,
  22. {$NScat} as namespace, page_title as title, page_title as value
  23. FROM $page
  24. LEFT JOIN $categorylinks ON page_title=cl_to
  25. WHERE cl_from IS NULL
  26. AND page_namespace = {$NScat}
  27. AND page_is_redirect = 0";
  28. }
  29. function formatResult( $skin, $result ) {
  30. $title = Title::makeTitle( NS_CATEGORY, $result->title );
  31. return $skin->makeLinkObj( $title, $title->getText() );
  32. }
  33. }
  34. /** constructor */
  35. function wfSpecialUnusedCategories() {
  36. list( $limit, $offset ) = wfCheckLimits();
  37. $uc = new UnusedCategoriesPage();
  38. return $uc->doQuery( $offset, $limit );
  39. }