MediaWiki master
SpecialWithoutInterwiki.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Specials;
22
25use MediaWiki\Languages\LanguageConverterFactory;
32
41 private $prefix = '';
42
43 private NamespaceInfo $namespaceInfo;
44
45 public function __construct(
46 NamespaceInfo $namespaceInfo,
47 IConnectionProvider $dbProvider,
48 LinkBatchFactory $linkBatchFactory,
49 LanguageConverterFactory $languageConverterFactory
50 ) {
51 parent::__construct( 'Withoutinterwiki' );
52 $this->namespaceInfo = $namespaceInfo;
53 $this->setDatabaseProvider( $dbProvider );
54 $this->setLinkBatchFactory( $linkBatchFactory );
55 $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) );
56 }
57
58 public function execute( $par ) {
59 $prefix = $this->getRequest()->getVal( 'prefix', $par );
60 $this->prefix = $prefix !== null ? Title::capitalize( $prefix, NS_MAIN ) : '';
61 parent::execute( $par );
62 }
63
64 protected function getPageHeader() {
65 # Do not show useless input form if special page is cached
66 if ( $this->isCached() ) {
67 return '';
68 }
69
70 $formDescriptor = [
71 'prefix' => [
72 'label-message' => 'allpagesprefix',
73 'name' => 'prefix',
74 'id' => 'wiprefix',
75 'type' => 'text',
76 'size' => 20,
77 'default' => $this->prefix
78 ]
79 ];
80
81 HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
82 ->setWrapperLegend( '' )
83 ->setSubmitTextMsg( 'withoutinterwiki-submit' )
84 ->setMethod( 'get' )
85 ->prepareForm()
86 ->displayForm( false );
87 return '';
88 }
89
90 protected function sortDescending() {
91 return false;
92 }
93
94 protected function getOrderFields() {
95 return [ 'page_namespace', 'page_title' ];
96 }
97
98 public function isExpensive() {
99 return true;
100 }
101
102 public function isSyndicated() {
103 return false;
104 }
105
106 public function getQueryInfo() {
107 $query = [
108 'tables' => [ 'page', 'langlinks' ],
109 'fields' => [
110 'namespace' => 'page_namespace',
111 'title' => 'page_title',
112 ],
113 'conds' => [
114 'll_title' => null,
115 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
116 'page_is_redirect' => 0
117 ],
118 'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ]
119 ];
120 if ( $this->prefix ) {
121 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
122 $query['conds'][] = $dbr->expr(
123 'page_title',
124 IExpression::LIKE,
125 new LikeValue( $this->prefix, $dbr->anyString() )
126 );
127 }
128
129 return $query;
130 }
131
132 protected function getGroupName() {
133 return 'maintenance';
134 }
135}
136
141class_alias( SpecialWithoutInterwiki::class, 'SpecialWithoutInterwiki' );
const NS_MAIN
Definition Defines.php:65
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:209
Variant of QueryPage which formats the result as a simple link to the page.
setLanguageConverter(ILanguageConverter $languageConverter)
setDatabaseProvider(IConnectionProvider $databaseProvider)
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
getContext()
Gets the context this SpecialPage is executed in.
getRequest()
Get the WebRequest being used for this instance.
List of pages without any language links.
getOrderFields()
Subclasses return an array of fields to order by here.
sortDescending()
Override to sort by increasing values.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
isExpensive()
Should this query page only be updated offline on large wikis?
getPageHeader()
The content returned by this function will be output before any result.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
__construct(NamespaceInfo $namespaceInfo, IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
execute( $par)
This is the actual workhorse.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Represents a title within MediaWiki.
Definition Title.php:78
Content of like value.
Definition LikeValue.php:14
Provide primary and replica IDatabase connections.