Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 31 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| SpecialMostLinkedCategories | |
0.00% |
0 / 30 |
|
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 / 8 |
|
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 | * Copyright © 2005, Ævar Arnfjörð Bjarmason |
| 4 | * |
| 5 | * @license GPL-2.0-or-later |
| 6 | * @file |
| 7 | */ |
| 8 | |
| 9 | namespace MediaWiki\Specials; |
| 10 | |
| 11 | use MediaWiki\Cache\LinkBatchFactory; |
| 12 | use MediaWiki\Html\Html; |
| 13 | use MediaWiki\Language\ILanguageConverter; |
| 14 | use MediaWiki\Languages\LanguageConverterFactory; |
| 15 | use MediaWiki\Linker\Linker; |
| 16 | use MediaWiki\Skin\Skin; |
| 17 | use MediaWiki\SpecialPage\QueryPage; |
| 18 | use MediaWiki\Title\Title; |
| 19 | use stdClass; |
| 20 | use Wikimedia\HtmlArmor\HtmlArmor; |
| 21 | use Wikimedia\Rdbms\IConnectionProvider; |
| 22 | use Wikimedia\Rdbms\IReadableDatabase; |
| 23 | use Wikimedia\Rdbms\IResultWrapper; |
| 24 | |
| 25 | /** |
| 26 | * List of categories with the most pages in them |
| 27 | * |
| 28 | * @ingroup SpecialPage |
| 29 | * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com> |
| 30 | */ |
| 31 | class SpecialMostLinkedCategories extends QueryPage { |
| 32 | |
| 33 | private ILanguageConverter $languageConverter; |
| 34 | |
| 35 | public function __construct( |
| 36 | IConnectionProvider $dbProvider, |
| 37 | LinkBatchFactory $linkBatchFactory, |
| 38 | LanguageConverterFactory $languageConverterFactory |
| 39 | ) { |
| 40 | parent::__construct( 'Mostlinkedcategories' ); |
| 41 | $this->setDatabaseProvider( $dbProvider ); |
| 42 | $this->setLinkBatchFactory( $linkBatchFactory ); |
| 43 | $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ); |
| 44 | } |
| 45 | |
| 46 | /** @inheritDoc */ |
| 47 | public function isSyndicated() { |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | /** @inheritDoc */ |
| 52 | public function getQueryInfo() { |
| 53 | $dbr = $this->getDatabaseProvider()->getReplicaDatabase(); |
| 54 | return [ |
| 55 | 'tables' => [ 'category' ], |
| 56 | 'fields' => [ 'title' => 'cat_title', |
| 57 | 'namespace' => NS_CATEGORY, |
| 58 | 'value' => 'cat_pages' ], |
| 59 | 'conds' => [ $dbr->expr( 'cat_pages', '>', 0 ) ], |
| 60 | ]; |
| 61 | } |
| 62 | |
| 63 | /** @inheritDoc */ |
| 64 | protected function sortDescending() { |
| 65 | return true; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Fetch user page links and cache their existence |
| 70 | * |
| 71 | * @param IReadableDatabase $db |
| 72 | * @param IResultWrapper $res |
| 73 | */ |
| 74 | public function preprocessResults( $db, $res ) { |
| 75 | $this->executeLBFromResultWrapper( $res ); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * @param Skin $skin |
| 80 | * @param stdClass $result Result row |
| 81 | * @return string |
| 82 | */ |
| 83 | public function formatResult( $skin, $result ) { |
| 84 | $nt = Title::makeTitleSafe( NS_CATEGORY, $result->title ); |
| 85 | if ( !$nt ) { |
| 86 | return Html::element( |
| 87 | 'span', |
| 88 | [ 'class' => 'mw-invalidtitle' ], |
| 89 | Linker::getInvalidTitleDescription( |
| 90 | $this->getContext(), |
| 91 | NS_CATEGORY, |
| 92 | $result->title ) |
| 93 | ); |
| 94 | } |
| 95 | |
| 96 | $text = $this->languageConverter->convertHtml( $nt->getText() ); |
| 97 | |
| 98 | $plink = $this->getLinkRenderer()->makeLink( $nt, new HtmlArmor( $text ) ); |
| 99 | $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped(); |
| 100 | |
| 101 | return $this->getLanguage()->specialList( $plink, $nlinks ); |
| 102 | } |
| 103 | |
| 104 | /** @inheritDoc */ |
| 105 | protected function getGroupName() { |
| 106 | return 'highuse'; |
| 107 | } |
| 108 | } |
| 109 | /** |
| 110 | * Retain the old class name for backwards compatibility. |
| 111 | * @deprecated since 1.41 |
| 112 | */ |
| 113 | class_alias( SpecialMostLinkedCategories::class, 'SpecialMostLinkedCategories' ); |