Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 30 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
SpecialMostLinkedCategories | |
0.00% |
0 / 29 |
|
0.00% |
0 / 7 |
72 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
isSyndicated | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getQueryInfo | |
0.00% |
0 / 7 |
|
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 / 14 |
|
0.00% |
0 / 1 |
6 | |||
getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Implements Special:Mostlinkedcategories |
4 | * |
5 | * Copyright © 2005, Ævar Arnfjörð Bjarmason |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License along |
18 | * with this program; if not, write to the Free Software Foundation, Inc., |
19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
20 | * http://www.gnu.org/copyleft/gpl.html |
21 | * |
22 | * @file |
23 | * @ingroup SpecialPage |
24 | * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com> |
25 | */ |
26 | |
27 | namespace MediaWiki\Specials; |
28 | |
29 | use HtmlArmor; |
30 | use ILanguageConverter; |
31 | use MediaWiki\Cache\LinkBatchFactory; |
32 | use MediaWiki\Html\Html; |
33 | use MediaWiki\Languages\LanguageConverterFactory; |
34 | use MediaWiki\Linker\Linker; |
35 | use MediaWiki\SpecialPage\QueryPage; |
36 | use MediaWiki\Title\Title; |
37 | use Skin; |
38 | use stdClass; |
39 | use Wikimedia\Rdbms\IConnectionProvider; |
40 | use Wikimedia\Rdbms\IDatabase; |
41 | use Wikimedia\Rdbms\IResultWrapper; |
42 | |
43 | /** |
44 | * A querypage to show categories ordered in descending order by the pages in them |
45 | * |
46 | * @ingroup SpecialPage |
47 | */ |
48 | class SpecialMostLinkedCategories extends QueryPage { |
49 | |
50 | private ILanguageConverter $languageConverter; |
51 | |
52 | /** |
53 | * @param IConnectionProvider $dbProvider |
54 | * @param LinkBatchFactory $linkBatchFactory |
55 | * @param LanguageConverterFactory $languageConverterFactory |
56 | */ |
57 | public function __construct( |
58 | IConnectionProvider $dbProvider, |
59 | LinkBatchFactory $linkBatchFactory, |
60 | LanguageConverterFactory $languageConverterFactory |
61 | ) { |
62 | parent::__construct( 'Mostlinkedcategories' ); |
63 | $this->setDatabaseProvider( $dbProvider ); |
64 | $this->setLinkBatchFactory( $linkBatchFactory ); |
65 | $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ); |
66 | } |
67 | |
68 | public function isSyndicated() { |
69 | return false; |
70 | } |
71 | |
72 | public function getQueryInfo() { |
73 | return [ |
74 | 'tables' => [ 'category' ], |
75 | 'fields' => [ 'title' => 'cat_title', |
76 | 'namespace' => NS_CATEGORY, |
77 | 'value' => 'cat_pages' ], |
78 | 'conds' => [ 'cat_pages > 0' ], |
79 | ]; |
80 | } |
81 | |
82 | protected function sortDescending() { |
83 | return true; |
84 | } |
85 | |
86 | /** |
87 | * Fetch user page links and cache their existence |
88 | * |
89 | * @param IDatabase $db |
90 | * @param IResultWrapper $res |
91 | */ |
92 | public function preprocessResults( $db, $res ) { |
93 | $this->executeLBFromResultWrapper( $res ); |
94 | } |
95 | |
96 | /** |
97 | * @param Skin $skin |
98 | * @param stdClass $result Result row |
99 | * @return string |
100 | */ |
101 | public function formatResult( $skin, $result ) { |
102 | $nt = Title::makeTitleSafe( NS_CATEGORY, $result->title ); |
103 | if ( !$nt ) { |
104 | return Html::element( |
105 | 'span', |
106 | [ 'class' => 'mw-invalidtitle' ], |
107 | Linker::getInvalidTitleDescription( |
108 | $this->getContext(), |
109 | NS_CATEGORY, |
110 | $result->title ) |
111 | ); |
112 | } |
113 | |
114 | $text = $this->languageConverter->convertHtml( $nt->getText() ); |
115 | |
116 | $plink = $this->getLinkRenderer()->makeLink( $nt, new HtmlArmor( $text ) ); |
117 | $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped(); |
118 | |
119 | return $this->getLanguage()->specialList( $plink, $nlinks ); |
120 | } |
121 | |
122 | protected function getGroupName() { |
123 | return 'highuse'; |
124 | } |
125 | } |
126 | /** |
127 | * Retain the old class name for backwards compatibility. |
128 | * @deprecated since 1.41 |
129 | */ |
130 | class_alias( SpecialMostLinkedCategories::class, 'SpecialMostLinkedCategories' ); |