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' );
42 $request = $this->getRequest();
43 $type = $request->getVal( $this->IdType
);
44 $level = $request->getVal( $this->IdLevel
);
45 $sizetype = $request->getVal( 'size-mode' );
46 $size = $request->getIntOrNull( 'size' );
47 $ns = $request->getIntOrNull( 'namespace' );
48 $indefOnly = $request->getBool( 'indefonly' ) ?
1 : 0;
49 $cascadeOnly = $request->getBool( 'cascadeonly' ) ?
1 : 0;
50 $noRedirect = $request->getBool( 'noredirect' ) ?
1 : 0;
52 $pager = new ProtectedPagesPager(
63 $this->getLinkRenderer()
66 $this->getOutput()->addHTML( $this->showOptions(
77 if ( $pager->getNumRows() ) {
78 $this->getOutput()->addParserOutputContent( $pager->getFullOutput() );
80 $this->getOutput()->addWikiMsg( 'protectedpagesempty' );
85 * @param int $namespace
86 * @param string $type Restriction type
87 * @param string $level Restriction level
88 * @param string $sizetype "min" or "max"
90 * @param bool $indefOnly Only indefinite protection
91 * @param bool $cascadeOnly Only cascading protection
92 * @param bool $noRedirect Don't show redirects
93 * @return string Input form
95 protected function showOptions( $namespace, $type = 'edit', $level, $sizetype,
96 $size, $indefOnly, $cascadeOnly, $noRedirect
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 ),
111 'label' => $this->msg( 'protectedpages-indef' )->text(),
112 'name' => 'indefonly',
117 'label' => $this->msg( 'protectedpages-cascade' )->text(),
118 'name' => 'cascadeonly',
119 'id' => 'cascadeonly',
123 'label' => $this->msg( 'protectedpages-noredirect' )->text(),
124 'name' => 'noredirect',
125 'id' => 'noredirect',
128 'class' => HTMLSizeFilterField
::class,
132 $htmlForm = new HTMLForm( $formDescriptor, $this->getContext() );
135 ->setWrapperLegendMsg( 'protectedpages' )
136 ->setSubmitText( $this->msg( 'protectedpages-submit' )->text() );
138 return $htmlForm->prepareForm()->getHTML( false );
142 * Creates the input label of the restriction type
143 * @param string $pr_type Protection type
146 protected function getTypeMenu( $pr_type ) {
147 $m = []; // Temporary array
150 // First pass to load the log names
151 foreach ( Title
::getFilteredRestrictionTypes( true ) as $type ) {
152 // Messages: restriction-edit, restriction-move, restriction-create, restriction-upload
153 $text = $this->msg( "restriction-$type" )->text();
157 // Third pass generates sorted XHTML content
158 foreach ( $m as $text => $type ) {
159 $options[$text] = $type;
164 'options' => $options,
165 'label' => $this->msg( 'restriction-type' )->text(),
166 'name' => $this->IdType
,
167 'id' => $this->IdType
,
172 * Creates the input label of the restriction level
173 * @param string $pr_level Protection level
176 protected function getLevelMenu( $pr_level ) {
178 $m = [ $this->msg( 'restriction-level-all' )->text() => 0 ];
181 // First pass to load the log names
182 foreach ( $this->getConfig()->get( 'RestrictionLevels' ) as $type ) {
183 // Messages used can be 'restriction-level-sysop' and 'restriction-level-autoconfirmed'
184 if ( $type != '' && $type != '*' ) {
185 $text = $this->msg( "restriction-level-$type" )->text();
190 // Third pass generates sorted XHTML content
191 foreach ( $m as $text => $type ) {
192 $options[$text] = $type;
197 'options' => $options,
198 'label' => $this->msg( 'restriction-level' )->text(),
199 'name' => $this->IdLevel
,
200 'id' => $this->IdLevel
204 protected function getGroupName() {
205 return 'maintenance';