MediaWiki  master
SpecialWithoutInterwiki.php
Go to the documentation of this file.
1 <?php
28 
35  private $prefix = '';
36 
38  private $namespaceInfo;
39 
46  public function __construct(
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  $this->prefix = Title::capitalize(
61  $this->getRequest()->getVal( 'prefix', $par ), 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 }
SpecialWithoutInterwiki\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialWithoutInterwiki.php:129
SpecialWithoutInterwiki\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: SpecialWithoutInterwiki.php:99
QueryPage\getDBLoadBalancer
getDBLoadBalancer()
Definition: QueryPage.php:900
SpecialWithoutInterwiki\$namespaceInfo
NamespaceInfo $namespaceInfo
Definition: SpecialWithoutInterwiki.php:38
SpecialWithoutInterwiki\__construct
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
Definition: SpecialWithoutInterwiki.php:46
MediaWiki\Languages\LanguageConverterFactory
An interface for creating language converters.
Definition: LanguageConverterFactory.php:46
NS_MAIN
const NS_MAIN
Definition: Defines.php:64
PageQueryPage
Variant of QueryPage which formats the result as a simple link to the page.
Definition: PageQueryPage.php:34
$dbr
$dbr
Definition: testCompression.php:54
QueryPage\setLinkBatchFactory
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:135
MediaWiki\Languages\LanguageConverterFactory\getLanguageConverter
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Definition: LanguageConverterFactory.php:125
QueryPage\isCached
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:297
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:39
SpecialWithoutInterwiki\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: SpecialWithoutInterwiki.php:91
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:764
PageQueryPage\setLanguageConverter
setLanguageConverter(ILanguageConverter $languageConverter)
Definition: PageQueryPage.php:57
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:780
QueryPage\setDBLoadBalancer
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:892
SpecialWithoutInterwiki\$prefix
$prefix
Definition: SpecialWithoutInterwiki.php:35
QueryPage\$linkBatchFactory
LinkBatchFactory null $linkBatchFactory
Definition: QueryPage.php:74
Title\capitalize
static capitalize( $text, $ns=NS_MAIN)
Capitalize a text string for a title if it belongs to a namespace that capitalizes.
Definition: Title.php:2999
SpecialWithoutInterwiki\isSyndicated
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
Definition: SpecialWithoutInterwiki.php:103
SpecialWithoutInterwiki\getPageHeader
getPageHeader()
The content returned by this function will be output before any result.
Definition: SpecialWithoutInterwiki.php:65
SpecialWithoutInterwiki\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialWithoutInterwiki.php:107
SpecialWithoutInterwiki\execute
execute( $par)
This is the actual workhorse.
Definition: SpecialWithoutInterwiki.php:59
SpecialWithoutInterwiki\getOrderFields
getOrderFields()
Subclasses return an array of fields to order by here.
Definition: SpecialWithoutInterwiki.php:95
SpecialWithoutInterwiki
Special page lists pages without language links.
Definition: SpecialWithoutInterwiki.php:34
QueryPage\$loadBalancer
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:71
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:35
HTMLForm\factory
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:326
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81