Merge "Convert SpecialPrefixIndex to class HTMLForm"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 10 Apr 2018 05:32:04 +0000 (05:32 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 10 Apr 2018 05:32:04 +0000 (05:32 +0000)
includes/specials/SpecialPrefixindex.php

index 34ffa07..afd626b 100644 (file)
@@ -98,56 +98,36 @@ class SpecialPrefixindex extends SpecialAllPages {
         * @return string
         */
        protected function namespacePrefixForm( $namespace = NS_MAIN, $from = '' ) {
-               $out = Xml::openElement( 'div', [ 'class' => 'namespaceoptions' ] );
-               $out .= Xml::openElement(
-                       'form',
-                       [ 'method' => 'get', 'action' => $this->getConfig()->get( 'Script' ) ]
-               );
-               $out .= Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
-               $out .= Xml::openElement( 'fieldset' );
-               $out .= Xml::element( 'legend', null, $this->msg( 'allpages' )->text() );
-               $out .= Xml::openElement( 'table', [ 'id' => 'nsselect', 'class' => 'allpages' ] );
-               $out .= "<tr>
-                               <td class='mw-label'>" .
-                       Xml::label( $this->msg( 'allpagesprefix' )->text(), 'nsfrom' ) .
-                       "</td>
-                               <td class='mw-input'>" .
-                       Xml::input( 'prefix', 30, str_replace( '_', ' ', $from ), [ 'id' => 'nsfrom' ] ) .
-                       "</td>
-                       </tr>
-                       <tr>
-                       <td class='mw-label'>" .
-                       Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) .
-                       "</td>
-                               <td class='mw-input'>" .
-                       Html::namespaceSelector( [
-                               'selected' => $namespace,
-                       ], [
+               $fields = [
+                       'prefix' => [
+                               'label-message' => 'allpagesprefix',
+                               'type' => 'text',
+                               'size' => '30',
+                       ],
+                       'namespace' => [
+                               'type' => 'namespaceselect',
                                'name' => 'namespace',
                                'id' => 'namespace',
-                               'class' => 'namespaceselector',
-                       ] ) .
-                       Xml::checkLabel(
-                               $this->msg( 'allpages-hide-redirects' )->text(),
-                               'hideredirects',
-                               'hideredirects',
-                               $this->hideRedirects
-                       ) . ' ' .
-                       Xml::checkLabel(
-                               $this->msg( 'prefixindex-strip' )->text(),
-                               'stripprefix',
-                               'stripprefix',
-                               $this->stripPrefix
-                       ) . ' ' .
-                       Xml::submitButton( $this->msg( 'prefixindex-submit' )->text() ) .
-                       "</td>
-                       </tr>";
-               $out .= Xml::closeElement( 'table' );
-               $out .= Xml::closeElement( 'fieldset' );
-               $out .= Xml::closeElement( 'form' );
-               $out .= Xml::closeElement( 'div' );
-
-               return $out;
+                               'label-message' => 'namespace',
+                               'all' => null,
+                               'value' => $namespace,
+                       ],
+                       'hidedirects' => [
+                               'class' => 'HTMLCheckField',
+                               'label-message' => 'allpages-hide-redirects',
+                       ],
+                       'stripprefix' => [
+                               'class' => 'HTMLCheckField',
+                               'label-message' => 'prefixindex-strip',
+                       ],
+               ];
+               $form = new HTMLForm( $fields, $this->getContext() );
+               $form
+                       ->setMethod( 'get' )
+                       ->setWrapperLegendMsg( 'allpages' )
+                       ->setSubmitTextMsg( 'prefixindex-submit' )
+                       ->prepareForm()
+                       ->displayForm( false );
        }
 
        /**