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 | * 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 | namespace MediaWiki\Specials; |
25 | |
26 | use HtmlArmor; |
27 | use ILanguageConverter; |
28 | use MediaWiki\Cache\LinkBatchFactory; |
29 | use MediaWiki\Languages\LanguageConverterFactory; |
30 | use MediaWiki\SpecialPage\QueryPage; |
31 | use MediaWiki\Title\NamespaceInfo; |
32 | use MediaWiki\Title\Title; |
33 | use Skin; |
34 | use Wikimedia\Rdbms\IConnectionProvider; |
35 | |
36 | /** |
37 | * Implements Special:Ancientpages |
38 | * |
39 | * @ingroup SpecialPage |
40 | */ |
41 | class SpecialAncientPages extends QueryPage { |
42 | |
43 | private NamespaceInfo $namespaceInfo; |
44 | private ILanguageConverter $languageConverter; |
45 | |
46 | /** |
47 | * @param NamespaceInfo $namespaceInfo |
48 | * @param IConnectionProvider $dbProvider |
49 | * @param LinkBatchFactory $linkBatchFactory |
50 | * @param LanguageConverterFactory $languageConverterFactory |
51 | */ |
52 | public function __construct( |
53 | NamespaceInfo $namespaceInfo, |
54 | IConnectionProvider $dbProvider, |
55 | LinkBatchFactory $linkBatchFactory, |
56 | LanguageConverterFactory $languageConverterFactory |
57 | ) { |
58 | parent::__construct( 'Ancientpages' ); |
59 | $this->namespaceInfo = $namespaceInfo; |
60 | $this->setDatabaseProvider( $dbProvider ); |
61 | $this->setLinkBatchFactory( $linkBatchFactory ); |
62 | $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ); |
63 | } |
64 | |
65 | public function isExpensive() { |
66 | return true; |
67 | } |
68 | |
69 | public function isSyndicated() { |
70 | return false; |
71 | } |
72 | |
73 | public function getQueryInfo() { |
74 | $tables = [ 'page', 'revision' ]; |
75 | $conds = [ |
76 | 'page_namespace' => $this->namespaceInfo->getContentNamespaces(), |
77 | 'page_is_redirect' => 0 |
78 | ]; |
79 | $joinConds = [ |
80 | 'revision' => [ |
81 | 'JOIN', [ |
82 | 'page_latest = rev_id' |
83 | ] |
84 | ], |
85 | ]; |
86 | |
87 | // Allow extensions to modify the query |
88 | $this->getHookRunner()->onAncientPagesQuery( $tables, $conds, $joinConds ); |
89 | |
90 | return [ |
91 | 'tables' => $tables, |
92 | 'fields' => [ |
93 | 'namespace' => 'page_namespace', |
94 | 'title' => 'page_title', |
95 | 'value' => 'rev_timestamp' |
96 | ], |
97 | 'conds' => $conds, |
98 | 'join_conds' => $joinConds |
99 | ]; |
100 | } |
101 | |
102 | public function usesTimestamps() { |
103 | return true; |
104 | } |
105 | |
106 | protected function sortDescending() { |
107 | return false; |
108 | } |
109 | |
110 | public function preprocessResults( $db, $res ) { |
111 | $this->executeLBFromResultWrapper( $res ); |
112 | } |
113 | |
114 | /** |
115 | * @param Skin $skin |
116 | * @param \stdClass $result Result row |
117 | * @return string |
118 | */ |
119 | public function formatResult( $skin, $result ) { |
120 | $d = $this->getLanguage()->userTimeAndDate( $result->value, $this->getUser() ); |
121 | $title = Title::makeTitle( $result->namespace, $result->title ); |
122 | $linkRenderer = $this->getLinkRenderer(); |
123 | |
124 | $link = $linkRenderer->makeKnownLink( |
125 | $title, |
126 | new HtmlArmor( $this->languageConverter->convertHtml( $title->getPrefixedText() ) ) |
127 | ); |
128 | |
129 | return $this->getLanguage()->specialList( $link, htmlspecialchars( $d ) ); |
130 | } |
131 | |
132 | protected function getGroupName() { |
133 | return 'maintenance'; |
134 | } |
135 | } |
136 | |
137 | /** @deprecated class alias since 1.41 */ |
138 | class_alias( SpecialAncientPages::class, 'SpecialAncientPages' ); |