Debian Codegraph @

includes/specials/SpecialWithoutInterwiki.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 namespace MediaWiki\Specials;
22
23 use MediaWiki\Cache\LinkBatchFactory;
24 use MediaWiki\HTMLForm\HTMLForm;
25 use MediaWiki\Languages\LanguageConverterFactory;
26 use MediaWiki\SpecialPage\PageQueryPage;
27 use MediaWiki\Title\NamespaceInfo;
28 use MediaWiki\Title\Title;
29 use Wikimedia\Rdbms\IConnectionProvider;
30 use Wikimedia\Rdbms\IExpression;
31 use Wikimedia\Rdbms\LikeValue;
32
33 /**
34 * List of pages without any language links
35 *
36 * @ingroup SpecialPage
37 * @author Rob Church <[email protected]>
38 */
39 class SpecialWithoutInterwiki extends PageQueryPage {
40 /** @var string */
41 private $prefix = '';
42
43 private NamespaceInfo $namespaceInfo;
44
45 /**
46 * @param NamespaceInfo $namespaceInfo
47 * @param IConnectionProvider $dbProvider
48 * @param LinkBatchFactory $linkBatchFactory
49 * @param LanguageConverterFactory $languageConverterFactory
50 */
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'][] = $dbr->expr(
129 'page_title',
130 IExpression::LIKE,
131 new LikeValue( $this->prefix, $dbr->anyString() )
132 );
133 }
134
135 return $query;
136 }
137
138 protected function getGroupName() {
139 return 'maintenance';
140 }
141 }
142
143 /**
144 * Retain the old class name for backwards compatibility.
145 * @deprecated since 1.41
146 */
147 class_alias( SpecialWithoutInterwiki::class, 'SpecialWithoutInterwiki' );