Merge "Add namespace restrictions to `meta=siteinfo&siprop=namespaces` API result"
[lhc/web/wiklou.git] / includes / specials / SpecialWithoutInterwiki.php
1 <?php
2 /**
3 * Implements Special:Withoutinterwiki
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup SpecialPage
22 * @author Rob Church <robchur@gmail.com>
23 */
24
25 use MediaWiki\MediaWikiServices;
26
27 /**
28 * Special page lists pages without language links
29 *
30 * @ingroup SpecialPage
31 */
32 class SpecialWithoutInterwiki extends PageQueryPage {
33 private $prefix = '';
34
35 function __construct( $name = 'Withoutinterwiki' ) {
36 parent::__construct( $name );
37 }
38
39 function execute( $par ) {
40 $this->prefix = Title::capitalize(
41 $this->getRequest()->getVal( 'prefix', $par ), NS_MAIN );
42 parent::execute( $par );
43 }
44
45 function getPageHeader() {
46 # Do not show useless input form if special page is cached
47 if ( $this->isCached() ) {
48 return '';
49 }
50
51 $formDescriptor = [
52 'prefix' => [
53 'label-message' => 'allpagesprefix',
54 'name' => 'prefix',
55 'id' => 'wiprefix',
56 'type' => 'text',
57 'size' => 20,
58 'default' => $this->prefix
59 ]
60 ];
61
62 $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
63 $htmlForm->setWrapperLegend( '' )
64 ->setSubmitTextMsg( 'withoutinterwiki-submit' )
65 ->setMethod( 'get' )
66 ->prepareForm()
67 ->displayForm( false );
68 }
69
70 function sortDescending() {
71 return false;
72 }
73
74 function getOrderFields() {
75 return [ 'page_namespace', 'page_title' ];
76 }
77
78 function isExpensive() {
79 return true;
80 }
81
82 function isSyndicated() {
83 return false;
84 }
85
86 function getQueryInfo() {
87 $query = [
88 'tables' => [ 'page', 'langlinks' ],
89 'fields' => [
90 'namespace' => 'page_namespace',
91 'title' => 'page_title',
92 'value' => 'page_title'
93 ],
94 'conds' => [
95 'll_title IS NULL',
96 'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
97 getContentNamespaces(),
98 'page_is_redirect' => 0
99 ],
100 'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ]
101 ];
102 if ( $this->prefix ) {
103 $dbr = wfGetDB( DB_REPLICA );
104 $query['conds'][] = 'page_title ' . $dbr->buildLike( $this->prefix, $dbr->anyString() );
105 }
106
107 return $query;
108 }
109
110 protected function getGroupName() {
111 return 'maintenance';
112 }
113 }