MediaWiki master
SpecialWithoutInterwiki.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Specials;
22
32
40 private $prefix = '';
41
42 private NamespaceInfo $namespaceInfo;
43
50 public function __construct(
51 NamespaceInfo $namespaceInfo,
52 IConnectionProvider $dbProvider,
53 LinkBatchFactory $linkBatchFactory,
54 LanguageConverterFactory $languageConverterFactory
55 ) {
56 parent::__construct( 'Withoutinterwiki' );
57 $this->namespaceInfo = $namespaceInfo;
58 $this->setDatabaseProvider( $dbProvider );
59 $this->setLinkBatchFactory( $linkBatchFactory );
60 $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) );
61 }
62
63 public function execute( $par ) {
64 $prefix = $this->getRequest()->getVal( 'prefix', $par );
65 $this->prefix = $prefix !== null ? Title::capitalize( $prefix, NS_MAIN ) : '';
66 parent::execute( $par );
67 }
68
69 protected function getPageHeader() {
70 # Do not show useless input form if special page is cached
71 if ( $this->isCached() ) {
72 return '';
73 }
74
75 $formDescriptor = [
76 'prefix' => [
77 'label-message' => 'allpagesprefix',
78 'name' => 'prefix',
79 'id' => 'wiprefix',
80 'type' => 'text',
81 'size' => 20,
82 'default' => $this->prefix
83 ]
84 ];
85
86 HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
87 ->setWrapperLegend( '' )
88 ->setSubmitTextMsg( 'withoutinterwiki-submit' )
89 ->setMethod( 'get' )
90 ->prepareForm()
91 ->displayForm( false );
92 return '';
93 }
94
95 protected function sortDescending() {
96 return false;
97 }
98
99 protected function getOrderFields() {
100 return [ 'page_namespace', 'page_title' ];
101 }
102
103 public function isExpensive() {
104 return true;
105 }
106
107 public function isSyndicated() {
108 return false;
109 }
110
111 public function getQueryInfo() {
112 $query = [
113 'tables' => [ 'page', 'langlinks' ],
114 'fields' => [
115 'namespace' => 'page_namespace',
116 'title' => 'page_title',
117 ],
118 'conds' => [
119 'll_title' => null,
120 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
121 'page_is_redirect' => 0
122 ],
123 'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ]
124 ];
125 if ( $this->prefix ) {
126 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
127 $query['conds'][] = $dbr->expr(
128 'page_title',
129 IExpression::LIKE,
130 new LikeValue( $this->prefix, $dbr->anyString() )
131 );
132 }
133
134 return $query;
135 }
136
137 protected function getGroupName() {
138 return 'maintenance';
139 }
140}
141
146class_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:208
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:79
Content of like value.
Definition LikeValue.php:14
Provide primary and replica IDatabase connections.