MediaWiki REL1_40
SpecialWithoutInterwiki.php
Go to the documentation of this file.
1<?php
29
36 private $prefix = '';
37
39 private $namespaceInfo;
40
47 public function __construct(
48 NamespaceInfo $namespaceInfo,
49 ILoadBalancer $loadBalancer,
50 LinkBatchFactory $linkBatchFactory,
51 LanguageConverterFactory $languageConverterFactory
52 ) {
53 parent::__construct( 'Withoutinterwiki' );
54 $this->namespaceInfo = $namespaceInfo;
55 $this->setDBLoadBalancer( $loadBalancer );
56 $this->setLinkBatchFactory( $linkBatchFactory );
57 $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) );
58 }
59
60 public function execute( $par ) {
61 $prefix = $this->getRequest()->getVal( 'prefix', $par );
62 $this->prefix = $prefix !== null ? Title::capitalize( $prefix, NS_MAIN ) : '';
63 parent::execute( $par );
64 }
65
66 protected function getPageHeader() {
67 # Do not show useless input form if special page is cached
68 if ( $this->isCached() ) {
69 return '';
70 }
71
72 $formDescriptor = [
73 'prefix' => [
74 'label-message' => 'allpagesprefix',
75 'name' => 'prefix',
76 'id' => 'wiprefix',
77 'type' => 'text',
78 'size' => 20,
79 'default' => $this->prefix
80 ]
81 ];
82
83 HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
84 ->setWrapperLegend( '' )
85 ->setSubmitTextMsg( 'withoutinterwiki-submit' )
86 ->setMethod( 'get' )
87 ->prepareForm()
88 ->displayForm( false );
89 return '';
90 }
91
92 protected function sortDescending() {
93 return false;
94 }
95
96 protected function getOrderFields() {
97 return [ 'page_namespace', 'page_title' ];
98 }
99
100 public function isExpensive() {
101 return true;
102 }
103
104 public function isSyndicated() {
105 return false;
106 }
107
108 public function getQueryInfo() {
109 $query = [
110 'tables' => [ 'page', 'langlinks' ],
111 'fields' => [
112 'namespace' => 'page_namespace',
113 'title' => 'page_title',
114 ],
115 'conds' => [
116 'll_title IS NULL',
117 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
118 'page_is_redirect' => 0
119 ],
120 'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ]
121 ];
122 if ( $this->prefix ) {
123 $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
124 $query['conds'][] = 'page_title ' . $dbr->buildLike( $this->prefix, $dbr->anyString() );
125 }
126
127 return $query;
128 }
129
130 protected function getGroupName() {
131 return 'maintenance';
132 }
133}
const NS_MAIN
Definition Defines.php:64
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Represents a title within MediaWiki.
Definition Title.php:82
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.
This class is a delegate to ILBFactory for a given database cluster.