From: Prateek Saxena Date: Mon, 1 Jan 2018 05:43:27 +0000 (+0530) Subject: Special:ProtectedTitles: Use HTMLForm X-Git-Tag: 1.31.0-rc.0~208^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22calendrier%22%2C%22type=semaine%22%29%20.%20%22?a=commitdiff_plain;h=b77e185a7140c1f967c4269136b6b1d952146128;p=lhc%2Fweb%2Fwiklou.git Special:ProtectedTitles: Use HTMLForm Bug: T117723 Change-Id: Idbf924a2a0e6348a32ab48a0e39b812400a6c9af --- diff --git a/includes/specials/SpecialProtectedtitles.php b/includes/specials/SpecialProtectedtitles.php index af2b81f152..fa12f507f9 100644 --- a/includes/specials/SpecialProtectedtitles.php +++ b/includes/specials/SpecialProtectedtitles.php @@ -113,39 +113,25 @@ class SpecialProtectedtitles extends SpecialPage { * @private */ function showOptions( $namespace, $type = 'edit', $level ) { - $action = htmlspecialchars( wfScript() ); - $title = $this->getPageTitle(); - $special = htmlspecialchars( $title->getPrefixedDBkey() ); - - return "
\n" . - '
' . - Xml::element( 'legend', [], $this->msg( 'protectedtitles' )->text() ) . - Html::hidden( 'title', $special ) . " \n" . - $this->getNamespaceMenu( $namespace ) . " \n" . - $this->getLevelMenu( $level ) . " \n" . - " " . Xml::submitButton( $this->msg( 'protectedtitles-submit' )->text() ) . "\n" . - "
"; - } - - /** - * Prepare the namespace filter drop-down; standard namespace - * selector, sans the MediaWiki namespace - * - * @param string|null $namespace Pre-select namespace - * @return string - */ - function getNamespaceMenu( $namespace = null ) { - return Html::namespaceSelector( - [ - 'selected' => $namespace, - 'all' => '', - 'label' => $this->msg( 'namespace' )->text() - ], [ + $formDescriptor = [ + 'namespace' => [ + 'class' => 'HTMLSelectNamespace', 'name' => 'namespace', 'id' => 'namespace', - 'class' => 'namespaceselector', - ] - ); + 'cssclass' => 'namespaceselector', + 'all' => '', + 'label' => $this->msg( 'namespace' )->text() + ], + 'levelmenu' => $this->getLevelMenu( $level ) + ]; + + $htmlForm = new HTMLForm( $formDescriptor, $this->getContext() ); + $htmlForm + ->setMethod( 'get' ) + ->setWrapperLegendMsg( 'protectedtitles' ) + ->setSubmitText( $this->msg( 'protectedtitles-submit' )->text() ); + + return $htmlForm->prepareForm()->getHTML( false ); } /** @@ -173,14 +159,16 @@ class SpecialProtectedtitles extends SpecialPage { } // Third pass generates sorted XHTML content foreach ( $m as $text => $type ) { - $selected = ( $type == $pr_level ); - $options[] = Xml::option( $text, $type, $selected ); + $options[ $text ] = $type; } - return Xml::label( $this->msg( 'restriction-level' )->text(), $this->IdLevel ) . ' ' . - Xml::tags( 'select', - [ 'id' => $this->IdLevel, 'name' => $this->IdLevel ], - implode( "\n", $options ) ); + return [ + 'type' => 'select', + 'options' => $options, + 'label' => $this->msg( 'restriction-level' )->text(), + 'name' => $this->IdLevel, + 'id' => $this->IdLevel + ]; } protected function getGroupName() {