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