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