MediaWiki REL1_39
SpecialWithoutInterwiki.php
Go to the documentation of this file.
1<?php
28
35 private $prefix = '';
36
38 private $namespaceInfo;
39
46 public function __construct(
47 NamespaceInfo $namespaceInfo,
48 ILoadBalancer $loadBalancer,
49 LinkBatchFactory $linkBatchFactory,
50 LanguageConverterFactory $languageConverterFactory
51 ) {
52 parent::__construct( 'Withoutinterwiki' );
53 $this->namespaceInfo = $namespaceInfo;
54 $this->setDBLoadBalancer( $loadBalancer );
55 $this->setLinkBatchFactory( $linkBatchFactory );
56 $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) );
57 }
58
59 public function execute( $par ) {
60 $prefix = $this->getRequest()->getVal( 'prefix', $par );
61 $this->prefix = $prefix !== null ? Title::capitalize( $prefix, NS_MAIN ) : '';
62 parent::execute( $par );
63 }
64
65 protected function getPageHeader() {
66 # Do not show useless input form if special page is cached
67 if ( $this->isCached() ) {
68 return '';
69 }
70
71 $formDescriptor = [
72 'prefix' => [
73 'label-message' => 'allpagesprefix',
74 'name' => 'prefix',
75 'id' => 'wiprefix',
76 'type' => 'text',
77 'size' => 20,
78 'default' => $this->prefix
79 ]
80 ];
81
82 HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
83 ->setWrapperLegend( '' )
84 ->setSubmitTextMsg( 'withoutinterwiki-submit' )
85 ->setMethod( 'get' )
86 ->prepareForm()
87 ->displayForm( false );
88 return '';
89 }
90
91 protected function sortDescending() {
92 return false;
93 }
94
95 protected function getOrderFields() {
96 return [ 'page_namespace', 'page_title' ];
97 }
98
99 public function isExpensive() {
100 return true;
101 }
102
103 public function isSyndicated() {
104 return false;
105 }
106
107 public function getQueryInfo() {
108 $query = [
109 'tables' => [ 'page', 'langlinks' ],
110 'fields' => [
111 'namespace' => 'page_namespace',
112 'title' => 'page_title',
113 ],
114 'conds' => [
115 'll_title IS NULL',
116 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
117 'page_is_redirect' => 0
118 ],
119 'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ]
120 ];
121 if ( $this->prefix ) {
122 $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
123 $query['conds'][] = 'page_title ' . $dbr->buildLike( $this->prefix, $dbr->anyString() );
124 }
125
126 return $query;
127 }
128
129 protected function getGroupName() {
130 return 'maintenance';
131 }
132}
const NS_MAIN
Definition Defines.php:64
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Variant of QueryPage which formats the result as a simple link to the page.
setLanguageConverter(ILanguageConverter $languageConverter)
setDBLoadBalancer(ILoadBalancer $loadBalancer)
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
getDBLoadBalancer()
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.
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
sortDescending()
Override to sort by increasing values.
getOrderFields()
Subclasses return an array of fields to order by here.
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.
execute( $par)
This is the actual workhorse.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
Create and track the database connections and transactions for a given database cluster.