MediaWiki master
SpecialWithoutInterwiki.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
19
28 private $prefix = '';
29
30 public function __construct(
31 private readonly NamespaceInfo $namespaceInfo,
32 IConnectionProvider $dbProvider,
33 LinkBatchFactory $linkBatchFactory,
34 LanguageConverterFactory $languageConverterFactory
35 ) {
36 parent::__construct( 'Withoutinterwiki' );
37 $this->setDatabaseProvider( $dbProvider );
38 $this->setLinkBatchFactory( $linkBatchFactory );
39 $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) );
40 }
41
43 public function execute( $par ) {
44 $prefix = $this->getRequest()->getVal( 'prefix', $par );
45 $this->prefix = $prefix !== null ? Title::capitalize( $prefix, NS_MAIN ) : '';
46 parent::execute( $par );
47 }
48
50 protected function getPageHeader() {
51 # Do not show useless input form if special page is cached
52 if ( $this->isCached() ) {
53 return '';
54 }
55
56 $formDescriptor = [
57 'prefix' => [
58 'label-message' => 'allpagesprefix',
59 'name' => 'prefix',
60 'id' => 'wiprefix',
61 'type' => 'text',
62 'size' => 20,
63 'default' => $this->prefix
64 ]
65 ];
66
67 HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
68 ->setWrapperLegend( '' )
69 ->setSubmitTextMsg( 'withoutinterwiki-submit' )
70 ->setMethod( 'get' )
71 ->prepareForm()
72 ->displayForm( false );
73 return '';
74 }
75
77 protected function sortDescending() {
78 return false;
79 }
80
82 protected function getOrderFields() {
83 return [ 'page_namespace', 'page_title' ];
84 }
85
87 public function isExpensive() {
88 return true;
89 }
90
92 public function isSyndicated() {
93 return false;
94 }
95
97 public function getQueryInfo() {
98 $query = [
99 'tables' => [ 'page', 'langlinks' ],
100 'fields' => [
101 'namespace' => 'page_namespace',
102 'title' => 'page_title',
103 ],
104 'conds' => [
105 'll_title' => null,
106 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
107 'page_is_redirect' => 0
108 ],
109 'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ]
110 ];
111
112 if ( $this->prefix ) {
113 $dbr = $this->getRecacheDB();
114 $query['conds'][] = $dbr->expr(
115 'page_title',
116 IExpression::LIKE,
117 new LikeValue( $this->prefix, $dbr->anyString() )
118 );
119 }
120
121 return $query;
122 }
123
125 protected function getRecacheDB() {
126 return $this->getDatabaseProvider()->getReplicaDatabase(
127 LangLinksTable::VIRTUAL_DOMAIN,
128 'vslow'
129 );
130 }
131
133 protected function getGroupName() {
134 return 'maintenance';
135 }
136}
137
142class_alias( SpecialWithoutInterwiki::class, 'SpecialWithoutInterwiki' );
const NS_MAIN
Definition Defines.php:51
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.
Factory for LinkBatch objects to batch query page metadata.
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.Don't append DESC to the field names,...
sortDescending()
Override to sort by increasing values.to override bool
getRecacheDB()
Get a DB connection to be used for slow recache queries.to override IReadableDatabase
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
__construct(private readonly NamespaceInfo $namespaceInfo, IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
isExpensive()
Should this query page only be updated offline on large wikis?If the query for this page is considere...
getPageHeader()
The content returned by this function will be output before any result.to override string
isSyndicated()
Sometimes we don't want to build rss / atom feeds.to override bool
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
execute( $par)
This is the actual workhorse.It does everything needed to make a real, honest-to-gosh query page....
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:69
Content of like value.
Definition LikeValue.php:14
Provide primary and replica IDatabase connections.