Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 54 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
| SpecialWithoutInterwiki | |
0.00% |
0 / 53 |
|
0.00% |
0 / 9 |
156 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| execute | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| getPageHeader | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
6 | |||
| sortDescending | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getOrderFields | |
0.00% |
0 / 1 |
|
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 / 21 |
|
0.00% |
0 / 1 |
6 | |||
| getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\Specials; |
| 8 | |
| 9 | use MediaWiki\Cache\LinkBatchFactory; |
| 10 | use MediaWiki\HTMLForm\HTMLForm; |
| 11 | use MediaWiki\Languages\LanguageConverterFactory; |
| 12 | use MediaWiki\SpecialPage\PageQueryPage; |
| 13 | use MediaWiki\Title\NamespaceInfo; |
| 14 | use MediaWiki\Title\Title; |
| 15 | use Wikimedia\Rdbms\IConnectionProvider; |
| 16 | use Wikimedia\Rdbms\IExpression; |
| 17 | use Wikimedia\Rdbms\LikeValue; |
| 18 | |
| 19 | /** |
| 20 | * List of pages without any language links |
| 21 | * |
| 22 | * @ingroup SpecialPage |
| 23 | * @author Rob Church <robchur@gmail.com> |
| 24 | */ |
| 25 | class SpecialWithoutInterwiki extends PageQueryPage { |
| 26 | /** @var string */ |
| 27 | private $prefix = ''; |
| 28 | |
| 29 | private NamespaceInfo $namespaceInfo; |
| 30 | |
| 31 | public function __construct( |
| 32 | NamespaceInfo $namespaceInfo, |
| 33 | IConnectionProvider $dbProvider, |
| 34 | LinkBatchFactory $linkBatchFactory, |
| 35 | LanguageConverterFactory $languageConverterFactory |
| 36 | ) { |
| 37 | parent::__construct( 'Withoutinterwiki' ); |
| 38 | $this->namespaceInfo = $namespaceInfo; |
| 39 | $this->setDatabaseProvider( $dbProvider ); |
| 40 | $this->setLinkBatchFactory( $linkBatchFactory ); |
| 41 | $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) ); |
| 42 | } |
| 43 | |
| 44 | /** @inheritDoc */ |
| 45 | public function execute( $par ) { |
| 46 | $prefix = $this->getRequest()->getVal( 'prefix', $par ); |
| 47 | $this->prefix = $prefix !== null ? Title::capitalize( $prefix, NS_MAIN ) : ''; |
| 48 | parent::execute( $par ); |
| 49 | } |
| 50 | |
| 51 | /** @inheritDoc */ |
| 52 | protected function getPageHeader() { |
| 53 | # Do not show useless input form if special page is cached |
| 54 | if ( $this->isCached() ) { |
| 55 | return ''; |
| 56 | } |
| 57 | |
| 58 | $formDescriptor = [ |
| 59 | 'prefix' => [ |
| 60 | 'label-message' => 'allpagesprefix', |
| 61 | 'name' => 'prefix', |
| 62 | 'id' => 'wiprefix', |
| 63 | 'type' => 'text', |
| 64 | 'size' => 20, |
| 65 | 'default' => $this->prefix |
| 66 | ] |
| 67 | ]; |
| 68 | |
| 69 | HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() ) |
| 70 | ->setWrapperLegend( '' ) |
| 71 | ->setSubmitTextMsg( 'withoutinterwiki-submit' ) |
| 72 | ->setMethod( 'get' ) |
| 73 | ->prepareForm() |
| 74 | ->displayForm( false ); |
| 75 | return ''; |
| 76 | } |
| 77 | |
| 78 | /** @inheritDoc */ |
| 79 | protected function sortDescending() { |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | /** @inheritDoc */ |
| 84 | protected function getOrderFields() { |
| 85 | return [ 'page_namespace', 'page_title' ]; |
| 86 | } |
| 87 | |
| 88 | /** @inheritDoc */ |
| 89 | public function isExpensive() { |
| 90 | return true; |
| 91 | } |
| 92 | |
| 93 | /** @inheritDoc */ |
| 94 | public function isSyndicated() { |
| 95 | return false; |
| 96 | } |
| 97 | |
| 98 | /** @inheritDoc */ |
| 99 | public function getQueryInfo() { |
| 100 | $query = [ |
| 101 | 'tables' => [ 'page', 'langlinks' ], |
| 102 | 'fields' => [ |
| 103 | 'namespace' => 'page_namespace', |
| 104 | 'title' => 'page_title', |
| 105 | ], |
| 106 | 'conds' => [ |
| 107 | 'll_title' => null, |
| 108 | 'page_namespace' => $this->namespaceInfo->getContentNamespaces(), |
| 109 | 'page_is_redirect' => 0 |
| 110 | ], |
| 111 | 'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ] |
| 112 | ]; |
| 113 | if ( $this->prefix ) { |
| 114 | $dbr = $this->getDatabaseProvider()->getReplicaDatabase(); |
| 115 | $query['conds'][] = $dbr->expr( |
| 116 | 'page_title', |
| 117 | IExpression::LIKE, |
| 118 | new LikeValue( $this->prefix, $dbr->anyString() ) |
| 119 | ); |
| 120 | } |
| 121 | |
| 122 | return $query; |
| 123 | } |
| 124 | |
| 125 | /** @inheritDoc */ |
| 126 | protected function getGroupName() { |
| 127 | return 'maintenance'; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Retain the old class name for backwards compatibility. |
| 133 | * @deprecated since 1.41 |
| 134 | */ |
| 135 | class_alias( SpecialWithoutInterwiki::class, 'SpecialWithoutInterwiki' ); |