Merge "RevisionStoreDbTestBase, remove redundant needsDB override"
[lhc/web/wiklou.git] / includes / specials / SpecialAncientpages.php
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
24 use MediaWiki\MediaWikiServices;
25
26 /**
27 * Implements Special:Ancientpages
28 *
29 * @ingroup SpecialPage
30 */
31 class AncientPagesPage extends QueryPage {
32
33 function __construct( $name = 'Ancientpages' ) {
34 parent::__construct( $name );
35 }
36
37 public function isExpensive() {
38 return true;
39 }
40
41 function isSyndicated() {
42 return false;
43 }
44
45 public function getQueryInfo() {
46 $tables = [ 'page', 'revision' ];
47 $conds = [
48 'page_namespace' => MWNamespace::getContentNamespaces(),
49 'page_is_redirect' => 0
50 ];
51 $joinConds = [
52 'revision' => [
53 'INNER JOIN', [
54 'page_latest = rev_id'
55 ]
56 ],
57 ];
58
59 // Allow extensions to modify the query
60 Hooks::run( 'AncientPagesQuery', [ &$tables, &$conds, &$joinConds ] );
61
62 return [
63 'tables' => $tables,
64 'fields' => [
65 'namespace' => 'page_namespace',
66 'title' => 'page_title',
67 'value' => 'rev_timestamp'
68 ],
69 'conds' => $conds,
70 'join_conds' => $joinConds
71 ];
72 }
73
74 public function usesTimestamps() {
75 return true;
76 }
77
78 function sortDescending() {
79 return false;
80 }
81
82 public function preprocessResults( $db, $res ) {
83 $this->executeLBFromResultWrapper( $res );
84 }
85
86 /**
87 * @param Skin $skin
88 * @param object $result Result row
89 * @return string
90 */
91 function formatResult( $skin, $result ) {
92 $d = $this->getLanguage()->userTimeAndDate( $result->value, $this->getUser() );
93 $title = Title::makeTitle( $result->namespace, $result->title );
94 $linkRenderer = $this->getLinkRenderer();
95 $link = $linkRenderer->makeKnownLink(
96 $title,
97 new HtmlArmor( MediaWikiServices::getInstance()->getContentLanguage()->
98 convert( htmlspecialchars( $title->getPrefixedText() ) ) )
99 );
100
101 return $this->getLanguage()->specialList( $link, htmlspecialchars( $d ) );
102 }
103
104 protected function getGroupName() {
105 return 'maintenance';
106 }
107 }