SpecialFewestrevisions.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * @file
  4. * @ingroup SpecialPage
  5. */
  6. /**
  7. * Special page for listing the articles with the fewest revisions.
  8. *
  9. * @ingroup SpecialPage
  10. * @author Martin Drashkov
  11. */
  12. class FewestrevisionsPage extends QueryPage {
  13. function getName() {
  14. return 'Fewestrevisions';
  15. }
  16. function isExpensive() {
  17. return true;
  18. }
  19. function isSyndicated() {
  20. return false;
  21. }
  22. function getSql() {
  23. $dbr = wfGetDB( DB_SLAVE );
  24. list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' );
  25. return "SELECT 'Fewestrevisions' as type,
  26. page_namespace as namespace,
  27. page_title as title,
  28. page_is_redirect as redirect,
  29. COUNT(*) as value
  30. FROM $revision
  31. JOIN $page ON page_id = rev_page
  32. WHERE page_namespace = " . NS_MAIN . "
  33. GROUP BY page_namespace, page_title, page_is_redirect
  34. HAVING COUNT(*) > 1";
  35. // ^^^ This was probably here to weed out redirects.
  36. // Since we mark them as such now, it might be
  37. // useful to remove this. People _do_ create pages
  38. // and never revise them, they aren't necessarily
  39. // redirects.
  40. }
  41. function sortDescending() {
  42. return false;
  43. }
  44. function formatResult( $skin, $result ) {
  45. global $wgLang, $wgContLang;
  46. $nt = Title::makeTitleSafe( $result->namespace, $result->title );
  47. $text = $wgContLang->convert( $nt->getPrefixedText() );
  48. $plink = $skin->makeKnownLinkObj( $nt, $text );
  49. $nl = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape'),
  50. $wgLang->formatNum( $result->value ) );
  51. $redirect = $result->redirect ? ' - ' . wfMsg( 'isredirect' ) : '';
  52. $nlink = $skin->makeKnownLinkObj( $nt, $nl, 'action=history' ) . $redirect;
  53. return wfSpecialList( $plink, $nlink );
  54. }
  55. }
  56. function wfSpecialFewestrevisions() {
  57. list( $limit, $offset ) = wfCheckLimits();
  58. $frp = new FewestrevisionsPage();
  59. $frp->doQuery( $offset, $limit );
  60. }