MediaWiki  master
SpecialWithoutInterwiki.php
Go to the documentation of this file.
1 <?php
25 namespace MediaWiki\Specials;
26 
27 use HTMLForm;
34 
41  private $prefix = '';
42 
43  private NamespaceInfo $namespaceInfo;
44 
51  public function __construct(
52  NamespaceInfo $namespaceInfo,
53  IConnectionProvider $dbProvider,
54  LinkBatchFactory $linkBatchFactory,
55  LanguageConverterFactory $languageConverterFactory
56  ) {
57  parent::__construct( 'Withoutinterwiki' );
58  $this->namespaceInfo = $namespaceInfo;
59  $this->setDatabaseProvider( $dbProvider );
60  $this->setLinkBatchFactory( $linkBatchFactory );
61  $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) );
62  }
63 
64  public function execute( $par ) {
65  $prefix = $this->getRequest()->getVal( 'prefix', $par );
66  $this->prefix = $prefix !== null ? Title::capitalize( $prefix, NS_MAIN ) : '';
67  parent::execute( $par );
68  }
69 
70  protected function getPageHeader() {
71  # Do not show useless input form if special page is cached
72  if ( $this->isCached() ) {
73  return '';
74  }
75 
76  $formDescriptor = [
77  'prefix' => [
78  'label-message' => 'allpagesprefix',
79  'name' => 'prefix',
80  'id' => 'wiprefix',
81  'type' => 'text',
82  'size' => 20,
83  'default' => $this->prefix
84  ]
85  ];
86 
87  HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
88  ->setWrapperLegend( '' )
89  ->setSubmitTextMsg( 'withoutinterwiki-submit' )
90  ->setMethod( 'get' )
91  ->prepareForm()
92  ->displayForm( false );
93  return '';
94  }
95 
96  protected function sortDescending() {
97  return false;
98  }
99 
100  protected function getOrderFields() {
101  return [ 'page_namespace', 'page_title' ];
102  }
103 
104  public function isExpensive() {
105  return true;
106  }
107 
108  public function isSyndicated() {
109  return false;
110  }
111 
112  public function getQueryInfo() {
113  $query = [
114  'tables' => [ 'page', 'langlinks' ],
115  'fields' => [
116  'namespace' => 'page_namespace',
117  'title' => 'page_title',
118  ],
119  'conds' => [
120  'll_title' => null,
121  'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
122  'page_is_redirect' => 0
123  ],
124  'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ]
125  ];
126  if ( $this->prefix ) {
127  $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
128  $query['conds'][] = 'page_title ' . $dbr->buildLike( $this->prefix, $dbr->anyString() );
129  }
130 
131  return $query;
132  }
133 
134  protected function getGroupName() {
135  return 'maintenance';
136  }
137 }
138 
143 class_alias( SpecialWithoutInterwiki::class, 'SpecialWithoutInterwiki' );
const NS_MAIN
Definition: Defines.php:64
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition: HTMLForm.php:158
static factory( $displayFormat, $descriptor, IContextSource $context, $messagePrefix='')
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:360
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Variant of QueryPage which formats the result as a simple link to the page.
setLanguageConverter(ILanguageConverter $languageConverter)
setDatabaseProvider(IConnectionProvider $databaseProvider)
Definition: QueryPage.php:985
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:360
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:185
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.
getOrderFields()
Subclasses return an array of fields to order by here.
sortDescending()
Override to sort by increasing values.
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.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
__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.
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:76
static capitalize( $text, $ns=NS_MAIN)
Capitalize a text string for a title if it belongs to a namespace that capitalizes.
Definition: Title.php:2717
Provide primary and replica IDatabase connections.