setHeaders(); $this->outputHeader(); $this->getOutput()->addModuleStyles( 'mediawiki.special' ); $this->addHelpLink( 'Help:Protected_pages' ); $request = $this->getRequest(); $type = $request->getVal( $this->IdType ); $level = $request->getVal( $this->IdLevel ); $sizetype = $request->getVal( 'size-mode' ); $size = $request->getIntOrNull( 'size' ); $ns = $request->getIntOrNull( 'namespace' ); $filters = $request->getArray( 'wpfilters', [] ); $indefOnly = in_array( 'indefonly', $filters ); $cascadeOnly = in_array( 'cascadeonly', $filters ); $noRedirect = in_array( 'noredirect', $filters ); $pager = new ProtectedPagesPager( $this, [], $type, $level, $ns, $sizetype, $size, $indefOnly, $cascadeOnly, $noRedirect, $this->getLinkRenderer() ); $this->getOutput()->addHTML( $this->showOptions( $ns, $type, $level, $sizetype, $size, $filters ) ); if ( $pager->getNumRows() ) { $this->getOutput()->addParserOutputContent( $pager->getFullOutput() ); } else { $this->getOutput()->addWikiMsg( 'protectedpagesempty' ); } } /** * @param int $namespace * @param string $type Restriction type * @param string $level Restriction level * @param string $sizetype "min" or "max" * @param int $size * @param array $filters Filters set for the pager: indefOnly, * cascadeOnly, noRedirect * @return string Input form */ protected function showOptions( $namespace, $type, $level, $sizetype, $size, $filters ) { $formDescriptor = [ 'namespace' => [ 'class' => HTMLSelectNamespace::class, 'name' => 'namespace', 'id' => 'namespace', 'cssclass' => 'namespaceselector', 'all' => '', 'label' => $this->msg( 'namespace' )->text(), ], 'typemenu' => $this->getTypeMenu( $type ), 'levelmenu' => $this->getLevelMenu( $level ), 'filters' => [ 'class' => 'HTMLMultiSelectField', 'label' => $this->msg( 'protectedpages-filters' )->text(), 'flatlist' => true, 'options-messages' => [ 'protectedpages-indef' => 'indefonly', 'protectedpages-cascade' => 'cascadeonly', 'protectedpages-noredirect' => 'noredirect', ], 'default' => $filters, ], 'sizelimit' => [ 'class' => HTMLSizeFilterField::class, 'name' => 'size', ] ]; $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() ); $htmlForm ->setMethod( 'get' ) ->setWrapperLegendMsg( 'protectedpages' ) ->setSubmitText( $this->msg( 'protectedpages-submit' )->text() ); return $htmlForm->prepareForm()->getHTML( false ); } /** * Creates the input label of the restriction type * @param string $pr_type Protection type * @return array */ protected function getTypeMenu( $pr_type ) { $m = []; // Temporary array $options = []; // First pass to load the log names foreach ( Title::getFilteredRestrictionTypes( true ) as $type ) { // Messages: restriction-edit, restriction-move, restriction-create, restriction-upload $text = $this->msg( "restriction-$type" )->text(); $m[$text] = $type; } // Third pass generates sorted XHTML content foreach ( $m as $text => $type ) { $options[$text] = $type; } return [ 'type' => 'select', 'options' => $options, 'label' => $this->msg( 'restriction-type' )->text(), 'name' => $this->IdType, 'id' => $this->IdType, ]; } /** * Creates the input label of the restriction level * @param string $pr_level Protection level * @return array */ protected function getLevelMenu( $pr_level ) { // Temporary array $m = [ $this->msg( 'restriction-level-all' )->text() => 0 ]; $options = []; // First pass to load the log names foreach ( $this->getConfig()->get( 'RestrictionLevels' ) as $type ) { // Messages used can be 'restriction-level-sysop' and 'restriction-level-autoconfirmed' if ( $type != '' && $type != '*' ) { $text = $this->msg( "restriction-level-$type" )->text(); $m[$text] = $type; } } // Third pass generates sorted XHTML content foreach ( $m as $text => $type ) { $options[$text] = $type; } return [ 'type' => 'select', 'options' => $options, 'label' => $this->msg( 'restriction-level' )->text(), 'name' => $this->IdLevel, 'id' => $this->IdLevel ]; } protected function getGroupName() { return 'maintenance'; } }