Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 54 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
SpecialWithoutInterwiki | |
0.00% |
0 / 53 |
|
0.00% |
0 / 9 |
156 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getPageHeader | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
6 | |||
sortDescending | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getOrderFields | |
0.00% |
0 / 1 |
|
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 / 21 |
|
0.00% |
0 / 1 |
6 | |||
getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Implements Special:Withoutinterwiki |
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 | * @author Rob Church <robchur@gmail.com> |
23 | */ |
24 | |
25 | namespace MediaWiki\Specials; |
26 | |
27 | use MediaWiki\Cache\LinkBatchFactory; |
28 | use MediaWiki\HTMLForm\HTMLForm; |
29 | use MediaWiki\Languages\LanguageConverterFactory; |
30 | use MediaWiki\SpecialPage\PageQueryPage; |
31 | use MediaWiki\Title\NamespaceInfo; |
32 | use MediaWiki\Title\Title; |
33 | use Wikimedia\Rdbms\IConnectionProvider; |
34 | use Wikimedia\Rdbms\IExpression; |
35 | use Wikimedia\Rdbms\LikeValue; |
36 | |
37 | /** |
38 | * Special page lists pages without language links |
39 | * |
40 | * @ingroup SpecialPage |
41 | */ |
42 | class SpecialWithoutInterwiki extends PageQueryPage { |
43 | private $prefix = ''; |
44 | |
45 | private NamespaceInfo $namespaceInfo; |
46 | |
47 | /** |
48 | * @param NamespaceInfo $namespaceInfo |
49 | * @param IConnectionProvider $dbProvider |
50 | * @param LinkBatchFactory $linkBatchFactory |
51 | * @param LanguageConverterFactory $languageConverterFactory |
52 | */ |
53 | public function __construct( |
54 | NamespaceInfo $namespaceInfo, |
55 | IConnectionProvider $dbProvider, |
56 | LinkBatchFactory $linkBatchFactory, |
57 | LanguageConverterFactory $languageConverterFactory |
58 | ) { |
59 | parent::__construct( 'Withoutinterwiki' ); |
60 | $this->namespaceInfo = $namespaceInfo; |
61 | $this->setDatabaseProvider( $dbProvider ); |
62 | $this->setLinkBatchFactory( $linkBatchFactory ); |
63 | $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) ); |
64 | } |
65 | |
66 | public function execute( $par ) { |
67 | $prefix = $this->getRequest()->getVal( 'prefix', $par ); |
68 | $this->prefix = $prefix !== null ? Title::capitalize( $prefix, NS_MAIN ) : ''; |
69 | parent::execute( $par ); |
70 | } |
71 | |
72 | protected function getPageHeader() { |
73 | # Do not show useless input form if special page is cached |
74 | if ( $this->isCached() ) { |
75 | return ''; |
76 | } |
77 | |
78 | $formDescriptor = [ |
79 | 'prefix' => [ |
80 | 'label-message' => 'allpagesprefix', |
81 | 'name' => 'prefix', |
82 | 'id' => 'wiprefix', |
83 | 'type' => 'text', |
84 | 'size' => 20, |
85 | 'default' => $this->prefix |
86 | ] |
87 | ]; |
88 | |
89 | HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() ) |
90 | ->setWrapperLegend( '' ) |
91 | ->setSubmitTextMsg( 'withoutinterwiki-submit' ) |
92 | ->setMethod( 'get' ) |
93 | ->prepareForm() |
94 | ->displayForm( false ); |
95 | return ''; |
96 | } |
97 | |
98 | protected function sortDescending() { |
99 | return false; |
100 | } |
101 | |
102 | protected function getOrderFields() { |
103 | return [ 'page_namespace', 'page_title' ]; |
104 | } |
105 | |
106 | public function isExpensive() { |
107 | return true; |
108 | } |
109 | |
110 | public function isSyndicated() { |
111 | return false; |
112 | } |
113 | |
114 | public function getQueryInfo() { |
115 | $query = [ |
116 | 'tables' => [ 'page', 'langlinks' ], |
117 | 'fields' => [ |
118 | 'namespace' => 'page_namespace', |
119 | 'title' => 'page_title', |
120 | ], |
121 | 'conds' => [ |
122 | 'll_title' => null, |
123 | 'page_namespace' => $this->namespaceInfo->getContentNamespaces(), |
124 | 'page_is_redirect' => 0 |
125 | ], |
126 | 'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ] |
127 | ]; |
128 | if ( $this->prefix ) { |
129 | $dbr = $this->getDatabaseProvider()->getReplicaDatabase(); |
130 | $query['conds'][] = $dbr->expr( |
131 | 'page_title', |
132 | IExpression::LIKE, |
133 | new LikeValue( $this->prefix, $dbr->anyString() ) |
134 | ); |
135 | } |
136 | |
137 | return $query; |
138 | } |
139 | |
140 | protected function getGroupName() { |
141 | return 'maintenance'; |
142 | } |
143 | } |
144 | |
145 | /** |
146 | * Retain the old class name for backwards compatibility. |
147 | * @deprecated since 1.41 |
148 | */ |
149 | class_alias( SpecialWithoutInterwiki::class, 'SpecialWithoutInterwiki' ); |