MediaWiki master
SpecialWithoutInterwiki.php
Go to the documentation of this file.
1<?php
25namespace MediaWiki\Specials;
26
36
43 private $prefix = '';
44
45 private NamespaceInfo $namespaceInfo;
46
53 public function __construct(
54 NamespaceInfo $namespaceInfo,
55 IConnectionProvider $dbProvider,
56 LinkBatchFactory $linkBatchFactory,
57 LanguageConverterFactory $languageConverterFactory
58 ) {
59 parent::__construct( 'Withoutinterwiki' );
60 $this->namespaceInfo = $namespaceInfo;
61 $this->setDatabaseProvider( $dbProvider );
62 $this->setLinkBatchFactory( $linkBatchFactory );
63 $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) );
64 }
65
66 public function execute( $par ) {
67 $prefix = $this->getRequest()->getVal( 'prefix', $par );
68 $this->prefix = $prefix !== null ? Title::capitalize( $prefix, NS_MAIN ) : '';
69 parent::execute( $par );
70 }
71
72 protected function getPageHeader() {
73 # Do not show useless input form if special page is cached
74 if ( $this->isCached() ) {
75 return '';
76 }
77
78 $formDescriptor = [
79 'prefix' => [
80 'label-message' => 'allpagesprefix',
81 'name' => 'prefix',
82 'id' => 'wiprefix',
83 'type' => 'text',
84 'size' => 20,
85 'default' => $this->prefix
86 ]
87 ];
88
89 HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
90 ->setWrapperLegend( '' )
91 ->setSubmitTextMsg( 'withoutinterwiki-submit' )
92 ->setMethod( 'get' )
93 ->prepareForm()
94 ->displayForm( false );
95 return '';
96 }
97
98 protected function sortDescending() {
99 return false;
100 }
101
102 protected function getOrderFields() {
103 return [ 'page_namespace', 'page_title' ];
104 }
105
106 public function isExpensive() {
107 return true;
108 }
109
110 public function isSyndicated() {
111 return false;
112 }
113
114 public function getQueryInfo() {
115 $query = [
116 'tables' => [ 'page', 'langlinks' ],
117 'fields' => [
118 'namespace' => 'page_namespace',
119 'title' => 'page_title',
120 ],
121 'conds' => [
122 'll_title' => null,
123 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
124 'page_is_redirect' => 0
125 ],
126 'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ]
127 ];
128 if ( $this->prefix ) {
129 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
130 $query['conds'][] = $dbr->expr(
131 'page_title',
132 IExpression::LIKE,
133 new LikeValue( $this->prefix, $dbr->anyString() )
134 );
135 }
136
137 return $query;
138 }
139
140 protected function getGroupName() {
141 return 'maintenance';
142 }
143}
144
149class_alias( SpecialWithoutInterwiki::class, 'SpecialWithoutInterwiki' );
const NS_MAIN
Definition Defines.php:64
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:206
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.
Special page lists pages without 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.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...