Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 43 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
SpecialAncientPages | |
0.00% |
0 / 42 |
|
0.00% |
0 / 9 |
90 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
isExpensive | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isSyndicated | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getQueryInfo | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
2 | |||
usesTimestamps | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sortDescending | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
preprocessResults | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
formatResult | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @file |
19 | */ |
20 | |
21 | namespace MediaWiki\Specials; |
22 | |
23 | use MediaWiki\Cache\LinkBatchFactory; |
24 | use MediaWiki\Language\ILanguageConverter; |
25 | use MediaWiki\Languages\LanguageConverterFactory; |
26 | use MediaWiki\Skin\Skin; |
27 | use MediaWiki\SpecialPage\QueryPage; |
28 | use MediaWiki\Title\NamespaceInfo; |
29 | use MediaWiki\Title\Title; |
30 | use Wikimedia\HtmlArmor\HtmlArmor; |
31 | use Wikimedia\Rdbms\IConnectionProvider; |
32 | |
33 | /** |
34 | * Implements Special:Ancientpages |
35 | * |
36 | * @ingroup SpecialPage |
37 | */ |
38 | class SpecialAncientPages extends QueryPage { |
39 | |
40 | private NamespaceInfo $namespaceInfo; |
41 | private ILanguageConverter $languageConverter; |
42 | |
43 | public function __construct( |
44 | NamespaceInfo $namespaceInfo, |
45 | IConnectionProvider $dbProvider, |
46 | LinkBatchFactory $linkBatchFactory, |
47 | LanguageConverterFactory $languageConverterFactory |
48 | ) { |
49 | parent::__construct( 'Ancientpages' ); |
50 | $this->namespaceInfo = $namespaceInfo; |
51 | $this->setDatabaseProvider( $dbProvider ); |
52 | $this->setLinkBatchFactory( $linkBatchFactory ); |
53 | $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ); |
54 | } |
55 | |
56 | public function isExpensive() { |
57 | return true; |
58 | } |
59 | |
60 | public function isSyndicated() { |
61 | return false; |
62 | } |
63 | |
64 | public function getQueryInfo() { |
65 | $tables = [ 'page', 'revision' ]; |
66 | $conds = [ |
67 | 'page_namespace' => $this->namespaceInfo->getContentNamespaces(), |
68 | 'page_is_redirect' => 0 |
69 | ]; |
70 | $joinConds = [ |
71 | 'revision' => [ |
72 | 'JOIN', [ |
73 | 'page_latest = rev_id' |
74 | ] |
75 | ], |
76 | ]; |
77 | |
78 | // Allow extensions to modify the query |
79 | $this->getHookRunner()->onAncientPagesQuery( $tables, $conds, $joinConds ); |
80 | |
81 | return [ |
82 | 'tables' => $tables, |
83 | 'fields' => [ |
84 | 'namespace' => 'page_namespace', |
85 | 'title' => 'page_title', |
86 | 'value' => 'rev_timestamp' |
87 | ], |
88 | 'conds' => $conds, |
89 | 'join_conds' => $joinConds |
90 | ]; |
91 | } |
92 | |
93 | public function usesTimestamps() { |
94 | return true; |
95 | } |
96 | |
97 | protected function sortDescending() { |
98 | return false; |
99 | } |
100 | |
101 | public function preprocessResults( $db, $res ) { |
102 | $this->executeLBFromResultWrapper( $res ); |
103 | } |
104 | |
105 | /** |
106 | * @param Skin $skin |
107 | * @param \stdClass $result Result row |
108 | * @return string |
109 | */ |
110 | public function formatResult( $skin, $result ) { |
111 | $d = $this->getLanguage()->userTimeAndDate( $result->value, $this->getUser() ); |
112 | $title = Title::makeTitle( $result->namespace, $result->title ); |
113 | $linkRenderer = $this->getLinkRenderer(); |
114 | |
115 | $link = $linkRenderer->makeKnownLink( |
116 | $title, |
117 | new HtmlArmor( $this->languageConverter->convertHtml( $title->getPrefixedText() ) ) |
118 | ); |
119 | |
120 | return $this->getLanguage()->specialList( $link, htmlspecialchars( $d ) ); |
121 | } |
122 | |
123 | protected function getGroupName() { |
124 | return 'maintenance'; |
125 | } |
126 | } |
127 | |
128 | /** @deprecated class alias since 1.41 */ |
129 | class_alias( SpecialAncientPages::class, 'SpecialAncientPages' ); |