From 1ec227d651fc56141b161d7d4bdab44baf2d3939 Mon Sep 17 00:00:00 2001 From: Prateek Saxena Date: Fri, 29 Dec 2017 09:40:41 +0530 Subject: [PATCH] Special:ProtectedPages: Add fields directly in $formDescriptor MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit …instead of having separate functions. Change-Id: Ife9ca83b97b24e4372d1b43b0eea41c3ac5c0fe2 --- includes/specials/SpecialProtectedpages.php | 116 ++++++-------------- 1 file changed, 34 insertions(+), 82 deletions(-) diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php index 987bcdda79..2ef9eafffb 100644 --- a/includes/specials/SpecialProtectedpages.php +++ b/includes/specials/SpecialProtectedpages.php @@ -96,15 +96,42 @@ class SpecialProtectedpages extends SpecialPage { $size, $indefOnly, $cascadeOnly, $noRedirect ) { $formDescriptor = [ - 'namespace' => $this->getNamespaceMenu( $namespace ), + 'namespace' => [ + 'class' => 'HTMLSelectNamespace', + 'name' => 'namespace', + 'id' => 'namespace', + 'cssclass' => 'namespaceselector', + 'selected' => $namespace, + 'all' => '', + 'label' => $this->msg( 'namespace' )->text(), + ], 'typemenu' => $this->getTypeMenu( $type ), 'levelmenu' => $this->getLevelMenu( $level ), - - 'expirycheck' => $this->getExpiryCheck( $indefOnly ), - 'cascadecheck' => $this->getCascadeCheck( $cascadeOnly ), - 'redirectcheck' => $this->getRedirectCheck( $noRedirect ), - - 'sizelimit' => $this->getSizeLimit( $sizetype, $size ), + 'expirycheck' => [ + 'type' => 'check', + 'label' => $this->msg( 'protectedpages-indef' )->text(), + 'name' => 'indefonly', + 'id' => 'indefonly', + 'value' => $indefOnly + ], + 'cascadecheck' => [ + 'type' => 'check', + 'label' => $this->msg( 'protectedpages-cascade' )->text(), + 'name' => 'cascadeonly', + 'id' => 'cascadeonly', + 'value' => $cascadeOnly + ], + 'redirectcheck' => [ + 'type' => 'check', + 'label' => $this->msg( 'protectedpages-noredirect' )->text(), + 'name' => 'noredirect', + 'id' => 'noredirect', + 'value' => $noRedirect, + ], + 'sizelimit' => [ + 'class' => 'HTMLSizeFilterField', + 'name' => 'size', + ] ]; $htmlForm = new HTMLForm( $formDescriptor, $this->getContext() ); $htmlForm @@ -115,81 +142,6 @@ class SpecialProtectedpages extends SpecialPage { return $htmlForm->prepareForm()->getHTML( false ); } - /** - * Prepare the namespace filter drop-down; standard namespace - * selector, sans the MediaWiki namespace - * - * @param string|null $namespace Pre-select namespace - * @return array - */ - protected function getNamespaceMenu( $namespace = null ) { - return [ - 'class' => 'HTMLSelectNamespace', - 'name' => 'namespace', - 'id' => 'namespace', - 'cssclass' => 'namespaceselector', - 'selected' => $namespace, - 'all' => '', - 'label' => $this->msg( 'namespace' )->text(), - ]; - } - - /** - * @param bool $indefOnly - * @return array - */ - protected function getExpiryCheck( $indefOnly ) { - return [ - 'type' => 'check', - 'label' => $this->msg( 'protectedpages-indef' )->text(), - 'name' => 'indefonly', - 'id' => 'indefonly', - 'value' => $indefOnly - ]; - } - - /** - * @param bool $cascadeOnly - * @return array - */ - protected function getCascadeCheck( $cascadeOnly ) { - return [ - 'type' => 'check', - 'label' => $this->msg( 'protectedpages-cascade' )->text(), - 'name' => 'cascadeonly', - 'id' => 'cascadeonly', - 'value' => $cascadeOnly - ]; - } - - /** - * @param bool $noRedirect - * @return array - */ - protected function getRedirectCheck( $noRedirect ) { - return [ - 'type' => 'check', - 'label' => $this->msg( 'protectedpages-noredirect' )->text(), - 'name' => 'noredirect', - 'id' => 'noredirect', - 'value' => $noRedirect, - ]; - } - - /** - * @param string $sizetype "min" or "max" - * @param mixed $size - * @return array - */ - protected function getSizeLimit( $sizetype, $size ) { - $max = $sizetype === 'max'; - - return [ - 'class' => 'HTMLSizeFilterField', - 'name' => 'size', - ]; - } - /** * Creates the input label of the restriction type * @param string $pr_type Protection type -- 2.20.1