Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 49 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
SpecialMostInterwikis | |
0.00% |
0 / 48 |
|
0.00% |
0 / 7 |
90 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
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 | |||
preprocessResults | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
formatResult | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
12 | |||
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 | * @ingroup SpecialPage |
20 | */ |
21 | |
22 | namespace MediaWiki\Specials; |
23 | |
24 | use MediaWiki\Cache\LinkBatchFactory; |
25 | use MediaWiki\Html\Html; |
26 | use MediaWiki\Linker\Linker; |
27 | use MediaWiki\SpecialPage\QueryPage; |
28 | use MediaWiki\Title\NamespaceInfo; |
29 | use MediaWiki\Title\Title; |
30 | use Skin; |
31 | use stdClass; |
32 | use Wikimedia\Rdbms\IConnectionProvider; |
33 | use Wikimedia\Rdbms\IDatabase; |
34 | use Wikimedia\Rdbms\IResultWrapper; |
35 | |
36 | /** |
37 | * List of pages that have the highest interwiki count. |
38 | * |
39 | * @ingroup SpecialPage |
40 | */ |
41 | class SpecialMostInterwikis extends QueryPage { |
42 | |
43 | private NamespaceInfo $namespaceInfo; |
44 | |
45 | /** |
46 | * @param NamespaceInfo $namespaceInfo |
47 | * @param IConnectionProvider $dbProvider |
48 | * @param LinkBatchFactory $linkBatchFactory |
49 | */ |
50 | public function __construct( |
51 | NamespaceInfo $namespaceInfo, |
52 | IConnectionProvider $dbProvider, |
53 | LinkBatchFactory $linkBatchFactory |
54 | ) { |
55 | parent::__construct( 'Mostinterwikis' ); |
56 | $this->namespaceInfo = $namespaceInfo; |
57 | $this->setDatabaseProvider( $dbProvider ); |
58 | $this->setLinkBatchFactory( $linkBatchFactory ); |
59 | } |
60 | |
61 | public function isExpensive() { |
62 | return true; |
63 | } |
64 | |
65 | public function isSyndicated() { |
66 | return false; |
67 | } |
68 | |
69 | public function getQueryInfo() { |
70 | return [ |
71 | 'tables' => [ |
72 | 'langlinks', |
73 | 'page' |
74 | ], 'fields' => [ |
75 | 'namespace' => 'page_namespace', |
76 | 'title' => 'page_title', |
77 | 'value' => 'COUNT(*)' |
78 | ], 'conds' => [ |
79 | 'page_namespace' => $this->namespaceInfo->getContentNamespaces() |
80 | ], 'options' => [ |
81 | 'HAVING' => 'COUNT(*) > 1', |
82 | 'GROUP BY' => [ |
83 | 'page_namespace', |
84 | 'page_title' |
85 | ] |
86 | ], 'join_conds' => [ |
87 | 'page' => [ |
88 | 'LEFT JOIN', |
89 | 'page_id = ll_from' |
90 | ] |
91 | ] |
92 | ]; |
93 | } |
94 | |
95 | /** |
96 | * Pre-fill the link cache |
97 | * |
98 | * @param IDatabase $db |
99 | * @param IResultWrapper $res |
100 | */ |
101 | public function preprocessResults( $db, $res ) { |
102 | $this->executeLBFromResultWrapper( $res ); |
103 | } |
104 | |
105 | /** |
106 | * @param Skin $skin |
107 | * @param stdClass $result |
108 | * @return string |
109 | */ |
110 | public function formatResult( $skin, $result ) { |
111 | $title = Title::makeTitleSafe( $result->namespace, $result->title ); |
112 | if ( !$title ) { |
113 | return Html::element( |
114 | 'span', |
115 | [ 'class' => 'mw-invalidtitle' ], |
116 | Linker::getInvalidTitleDescription( |
117 | $this->getContext(), |
118 | $result->namespace, |
119 | $result->title |
120 | ) |
121 | ); |
122 | } |
123 | |
124 | $linkRenderer = $this->getLinkRenderer(); |
125 | if ( $this->isCached() ) { |
126 | $link = $linkRenderer->makeLink( $title ); |
127 | } else { |
128 | $link = $linkRenderer->makeKnownLink( $title ); |
129 | } |
130 | |
131 | $count = $this->msg( 'ninterwikis' )->numParams( $result->value )->escaped(); |
132 | |
133 | return $this->getLanguage()->specialList( $link, $count ); |
134 | } |
135 | |
136 | protected function getGroupName() { |
137 | return 'highuse'; |
138 | } |
139 | } |
140 | |
141 | /** |
142 | * Retain the old class name for backwards compatibility. |
143 | * @deprecated since 1.41 |
144 | */ |
145 | class_alias( SpecialMostInterwikis::class, 'SpecialMostInterwikis' ); |