MediaWiki master
SpecialWithoutInterwiki.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
9use MediaWiki\Cache\LinkBatchFactory;
11use MediaWiki\Languages\LanguageConverterFactory;
18
27 private $prefix = '';
28
29 private NamespaceInfo $namespaceInfo;
30
31 public function __construct(
32 NamespaceInfo $namespaceInfo,
33 IConnectionProvider $dbProvider,
34 LinkBatchFactory $linkBatchFactory,
35 LanguageConverterFactory $languageConverterFactory
36 ) {
37 parent::__construct( 'Withoutinterwiki' );
38 $this->namespaceInfo = $namespaceInfo;
39 $this->setDatabaseProvider( $dbProvider );
40 $this->setLinkBatchFactory( $linkBatchFactory );
41 $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) );
42 }
43
45 public function execute( $par ) {
46 $prefix = $this->getRequest()->getVal( 'prefix', $par );
47 $this->prefix = $prefix !== null ? Title::capitalize( $prefix, NS_MAIN ) : '';
48 parent::execute( $par );
49 }
50
52 protected function getPageHeader() {
53 # Do not show useless input form if special page is cached
54 if ( $this->isCached() ) {
55 return '';
56 }
57
58 $formDescriptor = [
59 'prefix' => [
60 'label-message' => 'allpagesprefix',
61 'name' => 'prefix',
62 'id' => 'wiprefix',
63 'type' => 'text',
64 'size' => 20,
65 'default' => $this->prefix
66 ]
67 ];
68
69 HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
70 ->setWrapperLegend( '' )
71 ->setSubmitTextMsg( 'withoutinterwiki-submit' )
72 ->setMethod( 'get' )
73 ->prepareForm()
74 ->displayForm( false );
75 return '';
76 }
77
79 protected function sortDescending() {
80 return false;
81 }
82
84 protected function getOrderFields() {
85 return [ 'page_namespace', 'page_title' ];
86 }
87
89 public function isExpensive() {
90 return true;
91 }
92
94 public function isSyndicated() {
95 return false;
96 }
97
99 public function getQueryInfo() {
100 $query = [
101 'tables' => [ 'page', 'langlinks' ],
102 'fields' => [
103 'namespace' => 'page_namespace',
104 'title' => 'page_title',
105 ],
106 'conds' => [
107 'll_title' => null,
108 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
109 'page_is_redirect' => 0
110 ],
111 'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ]
112 ];
113 if ( $this->prefix ) {
114 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
115 $query['conds'][] = $dbr->expr(
116 'page_title',
117 IExpression::LIKE,
118 new LikeValue( $this->prefix, $dbr->anyString() )
119 );
120 }
121
122 return $query;
123 }
124
126 protected function getGroupName() {
127 return 'maintenance';
128 }
129}
130
135class_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:195
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
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?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
__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.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.