SpecialAncientPages.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * Implements Special:Ancientpages
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. * http://www.gnu.org/copyleft/gpl.html
  19. *
  20. * @file
  21. * @ingroup SpecialPage
  22. */
  23. use MediaWiki\MediaWikiServices;
  24. /**
  25. * Implements Special:Ancientpages
  26. *
  27. * @ingroup SpecialPage
  28. */
  29. class SpecialAncientPages extends QueryPage {
  30. function __construct( $name = 'Ancientpages' ) {
  31. parent::__construct( $name );
  32. }
  33. public function isExpensive() {
  34. return true;
  35. }
  36. function isSyndicated() {
  37. return false;
  38. }
  39. public function getQueryInfo() {
  40. $tables = [ 'page', 'revision' ];
  41. $conds = [
  42. 'page_namespace' =>
  43. MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces(),
  44. 'page_is_redirect' => 0
  45. ];
  46. $joinConds = [
  47. 'revision' => [
  48. 'JOIN', [
  49. 'page_latest = rev_id'
  50. ]
  51. ],
  52. ];
  53. // Allow extensions to modify the query
  54. Hooks::run( 'AncientPagesQuery', [ &$tables, &$conds, &$joinConds ] );
  55. return [
  56. 'tables' => $tables,
  57. 'fields' => [
  58. 'namespace' => 'page_namespace',
  59. 'title' => 'page_title',
  60. 'value' => 'rev_timestamp'
  61. ],
  62. 'conds' => $conds,
  63. 'join_conds' => $joinConds
  64. ];
  65. }
  66. public function usesTimestamps() {
  67. return true;
  68. }
  69. function sortDescending() {
  70. return false;
  71. }
  72. public function preprocessResults( $db, $res ) {
  73. $this->executeLBFromResultWrapper( $res );
  74. }
  75. /**
  76. * @param Skin $skin
  77. * @param object $result Result row
  78. * @return string
  79. */
  80. function formatResult( $skin, $result ) {
  81. $d = $this->getLanguage()->userTimeAndDate( $result->value, $this->getUser() );
  82. $title = Title::makeTitle( $result->namespace, $result->title );
  83. $linkRenderer = $this->getLinkRenderer();
  84. $link = $linkRenderer->makeKnownLink(
  85. $title,
  86. new HtmlArmor( MediaWikiServices::getInstance()->getContentLanguage()->
  87. convert( htmlspecialchars( $title->getPrefixedText() ) ) )
  88. );
  89. return $this->getLanguage()->specialList( $link, htmlspecialchars( $d ) );
  90. }
  91. protected function getGroupName() {
  92. return 'maintenance';
  93. }
  94. }