| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 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 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
class SpecialMostInterwikis extends QueryPage { |
| 42 |
|
| 43 |
private NamespaceInfo $namespaceInfo; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 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 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
public function preprocessResults( $db, $res ) { |
| 102 |
$this->executeLBFromResultWrapper( $res ); |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 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 |
|
| 143 |
|
| 144 |
|
| 145 |
class_alias( SpecialMostInterwikis::class, 'SpecialMostInterwikis' ); |