| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Specials; |
| 22 |
|
| 23 |
use MediaWiki\Cache\LinkBatchFactory; |
| 24 |
use MediaWiki\HTMLForm\HTMLForm; |
| 25 |
use MediaWiki\Languages\LanguageConverterFactory; |
| 26 |
use MediaWiki\SpecialPage\PageQueryPage; |
| 27 |
use MediaWiki\Title\NamespaceInfo; |
| 28 |
use MediaWiki\Title\Title; |
| 29 |
use Wikimedia\Rdbms\IConnectionProvider; |
| 30 |
use Wikimedia\Rdbms\IExpression; |
| 31 |
use Wikimedia\Rdbms\LikeValue; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
class SpecialWithoutInterwiki extends PageQueryPage { |
| 40 |
|
| 41 |
private $prefix = ''; |
| 42 |
|
| 43 |
private NamespaceInfo $namespaceInfo; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public function __construct( |
| 52 |
NamespaceInfo $namespaceInfo, |
| 53 |
IConnectionProvider $dbProvider, |
| 54 |
LinkBatchFactory $linkBatchFactory, |
| 55 |
LanguageConverterFactory $languageConverterFactory |
| 56 |
) { |
| 57 |
parent::__construct( 'Withoutinterwiki' ); |
| 58 |
$this->namespaceInfo = $namespaceInfo; |
| 59 |
$this->setDatabaseProvider( $dbProvider ); |
| 60 |
$this->setLinkBatchFactory( $linkBatchFactory ); |
| 61 |
$this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) ); |
| 62 |
} |
| 63 |
|
| 64 |
public function execute( $par ) { |
| 65 |
$prefix = $this->getRequest()->getVal( 'prefix', $par ); |
| 66 |
$this->prefix = $prefix !== null ? Title::capitalize( $prefix, NS_MAIN ) : ''; |
| 67 |
parent::execute( $par ); |
| 68 |
} |
| 69 |
|
| 70 |
protected function getPageHeader() { |
| 71 |
|
| 72 |
if ( $this->isCached() ) { |
| 73 |
return ''; |
| 74 |
} |
| 75 |
|
| 76 |
$formDescriptor = [ |
| 77 |
'prefix' => [ |
| 78 |
'label-message' => 'allpagesprefix', |
| 79 |
'name' => 'prefix', |
| 80 |
'id' => 'wiprefix', |
| 81 |
'type' => 'text', |
| 82 |
'size' => 20, |
| 83 |
'default' => $this->prefix |
| 84 |
] |
| 85 |
]; |
| 86 |
|
| 87 |
HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() ) |
| 88 |
->setWrapperLegend( '' ) |
| 89 |
->setSubmitTextMsg( 'withoutinterwiki-submit' ) |
| 90 |
->setMethod( 'get' ) |
| 91 |
->prepareForm() |
| 92 |
->displayForm( false ); |
| 93 |
return ''; |
| 94 |
} |
| 95 |
|
| 96 |
protected function sortDescending() { |
| 97 |
return false; |
| 98 |
} |
| 99 |
|
| 100 |
protected function getOrderFields() { |
| 101 |
return [ 'page_namespace', 'page_title' ]; |
| 102 |
} |
| 103 |
|
| 104 |
public function isExpensive() { |
| 105 |
return true; |
| 106 |
} |
| 107 |
|
| 108 |
public function isSyndicated() { |
| 109 |
return false; |
| 110 |
} |
| 111 |
|
| 112 |
public function getQueryInfo() { |
| 113 |
$query = [ |
| 114 |
'tables' => [ 'page', 'langlinks' ], |
| 115 |
'fields' => [ |
| 116 |
'namespace' => 'page_namespace', |
| 117 |
'title' => 'page_title', |
| 118 |
], |
| 119 |
'conds' => [ |
| 120 |
'll_title' => null, |
| 121 |
'page_namespace' => $this->namespaceInfo->getContentNamespaces(), |
| 122 |
'page_is_redirect' => 0 |
| 123 |
], |
| 124 |
'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ] |
| 125 |
]; |
| 126 |
if ( $this->prefix ) { |
| 127 |
$dbr = $this->getDatabaseProvider()->getReplicaDatabase(); |
| 128 |
$query['conds'][] = $dbr->expr( |
| 129 |
'page_title', |
| 130 |
IExpression::LIKE, |
| 131 |
new LikeValue( $this->prefix, $dbr->anyString() ) |
| 132 |
); |
| 133 |
} |
| 134 |
|
| 135 |
return $query; |
| 136 |
} |
| 137 |
|
| 138 |
protected function getGroupName() { |
| 139 |
return 'maintenance'; |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
class_alias( SpecialWithoutInterwiki::class, 'SpecialWithoutInterwiki' ); |