SpecialUnwatchedpages.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * @file
  4. * @ingroup SpecialPage
  5. */
  6. /**
  7. * A special page that displays a list of pages that are not on anyones watchlist.
  8. * Implements Special:Unwatchedpages
  9. *
  10. * @ingroup SpecialPage
  11. * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
  12. * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
  13. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
  14. */
  15. class UnwatchedpagesPage extends QueryPage {
  16. function getName() { return 'Unwatchedpages'; }
  17. function isExpensive() { return true; }
  18. function isSyndicated() { return false; }
  19. function getSQL() {
  20. $dbr = wfGetDB( DB_SLAVE );
  21. list( $page, $watchlist ) = $dbr->tableNamesN( 'page', 'watchlist' );
  22. $mwns = NS_MEDIAWIKI;
  23. return
  24. "
  25. SELECT
  26. 'Unwatchedpages' as type,
  27. page_namespace as namespace,
  28. page_title as title,
  29. page_namespace as value
  30. FROM $page
  31. LEFT JOIN $watchlist ON wl_namespace = page_namespace AND page_title = wl_title
  32. WHERE wl_title IS NULL AND page_is_redirect = 0 AND page_namespace<>$mwns
  33. ";
  34. }
  35. function sortDescending() { return false; }
  36. function formatResult( $skin, $result ) {
  37. global $wgContLang;
  38. $nt = Title::makeTitle( $result->namespace, $result->title );
  39. $text = $wgContLang->convert( $nt->getPrefixedText() );
  40. $plink = $skin->makeKnownLinkObj( $nt, htmlspecialchars( $text ) );
  41. $wlink = $skin->makeKnownLinkObj( $nt, wfMsgHtml( 'watch' ), 'action=watch' );
  42. return wfSpecialList( $plink, $wlink );
  43. }
  44. }
  45. /**
  46. * constructor
  47. */
  48. function wfSpecialUnwatchedpages() {
  49. global $wgUser, $wgOut;
  50. if ( ! $wgUser->isAllowed( 'unwatchedpages' ) )
  51. return $wgOut->permissionRequired( 'unwatchedpages' );
  52. list( $limit, $offset ) = wfCheckLimits();
  53. $wpp = new UnwatchedpagesPage();
  54. $wpp->doQuery( $offset, $limit );
  55. }