3 * Implements Special:Protectedpages
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.
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.
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
21 * @ingroup SpecialPage
25 * A special page that lists protected pages
27 * @ingroup SpecialPage
29 class SpecialProtectedpages
extends SpecialPage
{
30 protected $IdLevel = 'level';
31 protected $IdType = 'type';
33 public function __construct() {
34 parent
::__construct( 'Protectedpages' );
37 public function execute( $par ) {
39 $this->outputHeader();
40 $this->getOutput()->addModuleStyles( 'mediawiki.special' );
41 $this->addHelpLink( 'Help:Protected_pages' );
43 $request = $this->getRequest();
44 $type = $request->getVal( $this->IdType
);
45 $level = $request->getVal( $this->IdLevel
);
46 $sizetype = $request->getVal( 'size-mode' );
47 $size = $request->getIntOrNull( 'size' );
48 $ns = $request->getIntOrNull( 'namespace' );
50 $filters = $request->getArray( 'wpfilters', [] );
51 $indefOnly = in_array( 'indefonly', $filters );
52 $cascadeOnly = in_array( 'cascadeonly', $filters );
53 $noRedirect = in_array( 'noredirect', $filters );
55 $pager = new ProtectedPagesPager(
66 $this->getLinkRenderer()
69 $this->getOutput()->addHTML( $this->showOptions(
78 if ( $pager->getNumRows() ) {
79 $this->getOutput()->addParserOutputContent( $pager->getFullOutput() );
81 $this->getOutput()->addWikiMsg( 'protectedpagesempty' );
86 * @param int $namespace
87 * @param string $type Restriction type
88 * @param string $level Restriction level
89 * @param string $sizetype "min" or "max"
91 * @param array $filters Filters set for the pager: indefOnly,
92 * cascadeOnly, noRedirect
93 * @return string Input form
95 protected function showOptions( $namespace, $type, $level, $sizetype,
100 'class' => HTMLSelectNamespace
::class,
101 'name' => 'namespace',
103 'cssclass' => 'namespaceselector',
105 'label' => $this->msg( 'namespace' )->text(),
107 'typemenu' => $this->getTypeMenu( $type ),
108 'levelmenu' => $this->getLevelMenu( $level ),
110 'class' => 'HTMLMultiSelectField',
111 'label' => $this->msg( 'protectedpages-filters' )->text(),
113 'options-messages' => [
114 'protectedpages-indef' => 'indefonly',
115 'protectedpages-cascade' => 'cascadeonly',
116 'protectedpages-noredirect' => 'noredirect',
118 'default' => $filters,
121 'class' => HTMLSizeFilterField
::class,
125 $htmlForm = HTMLForm
::factory( 'ooui', $formDescriptor, $this->getContext() );
128 ->setWrapperLegendMsg( 'protectedpages' )
129 ->setSubmitText( $this->msg( 'protectedpages-submit' )->text() );
131 return $htmlForm->prepareForm()->getHTML( false );
135 * Creates the input label of the restriction type
136 * @param string $pr_type Protection type
139 protected function getTypeMenu( $pr_type ) {
140 $m = []; // Temporary array
143 // First pass to load the log names
144 foreach ( Title
::getFilteredRestrictionTypes( true ) as $type ) {
145 // Messages: restriction-edit, restriction-move, restriction-create, restriction-upload
146 $text = $this->msg( "restriction-$type" )->text();
150 // Third pass generates sorted XHTML content
151 foreach ( $m as $text => $type ) {
152 $options[$text] = $type;
157 'options' => $options,
158 'label' => $this->msg( 'restriction-type' )->text(),
159 'name' => $this->IdType
,
160 'id' => $this->IdType
,
165 * Creates the input label of the restriction level
166 * @param string $pr_level Protection level
169 protected function getLevelMenu( $pr_level ) {
171 $m = [ $this->msg( 'restriction-level-all' )->text() => 0 ];
174 // First pass to load the log names
175 foreach ( $this->getConfig()->get( 'RestrictionLevels' ) as $type ) {
176 // Messages used can be 'restriction-level-sysop' and 'restriction-level-autoconfirmed'
177 if ( $type != '' && $type != '*' ) {
178 $text = $this->msg( "restriction-level-$type" )->text();
183 // Third pass generates sorted XHTML content
184 foreach ( $m as $text => $type ) {
185 $options[$text] = $type;
190 'options' => $options,
191 'label' => $this->msg( 'restriction-level' )->text(),
192 'name' => $this->IdLevel
,
193 'id' => $this->IdLevel
197 protected function getGroupName() {
198 return 'maintenance';