MediaWiki master
SpecialWithoutInterwiki.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Specials;
22
32
41 private $prefix = '';
42
43 private NamespaceInfo $namespaceInfo;
44
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 # Do not show useless input form if special page is cached
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
147class_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
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
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.