From c01c4f01b6d7e8970536680a7fb8a19eb5d0c24b Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sun, 29 Jun 2014 15:06:02 +0200 Subject: [PATCH] Use HTMLForm to generate the form on Special:ListFiles - Makes the code easier to read - This was actually the last usage of Xml::buildForm() in core - Removed tabindex; not needed since the navigation is already in DOM order Change-Id: Ie0a2819fdf28f734a8c68246be693de7259b8332 --- includes/specials/SpecialListfiles.php | 81 ++++++++++++++++---------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/includes/specials/SpecialListfiles.php b/includes/specials/SpecialListfiles.php index c62c1de781..ed7648d735 100644 --- a/includes/specials/SpecialListfiles.php +++ b/includes/specials/SpecialListfiles.php @@ -499,42 +499,61 @@ class ImageListPager extends TablePager { } function getForm() { - $inputForm = array(); - $inputForm['table_pager_limit_label'] = $this->getLimitSelect( array( 'tabindex' => 1 ) ); + $fields = array(); + $fields['limit'] = array( + 'type' => 'select', + 'name' => 'limit', + 'label-message' => 'table_pager_limit_label', + 'options' => $this->getLimitSelectList(), + 'default' => $this->mLimit, + ); + if ( !$this->getConfig()->get( 'MiserMode' ) ) { - $inputForm['listfiles_search_for'] = Html::input( - 'ilsearch', - $this->mSearch, - 'text', - array( - 'size' => '40', - 'maxlength' => '255', - 'id' => 'mw-ilsearch', - 'tabindex' => 2, - ) + $fields['ilsearch'] = array( + 'type' => 'text', + 'name' => 'ilsearch', + 'id' => 'mw-ilsearch', + 'label-message' => 'listfiles_search_for', + 'default' => $this->mSearch, + 'size' => '40', + 'maxlength' => '255', ); } - $inputForm['username'] = Html::input( 'user', $this->mUserName, 'text', array( + + $fields['user'] = array( + 'type' => 'text', + 'name' => 'user', + 'id' => 'mw-listfiles-user', + 'label-message' => 'username', + 'default' => $this->mUserName, 'size' => '40', 'maxlength' => '255', - 'id' => 'mw-listfiles-user', - 'tabindex' => 3, - ) ); - - $inputForm['listfiles-show-all'] = Html::input( 'ilshowall', 1, 'checkbox', array( - 'checked' => $this->mShowAll, - 'tabindex' => 4, - ) ); - - return Html::openElement( 'form', - array( 'method' => 'get', 'action' => wfScript(), 'id' => 'mw-listfiles-form' ) - ) . - Xml::fieldset( $this->msg( 'listfiles' )->text() ) . - Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . - Xml::buildForm( $inputForm, 'table_pager_limit_submit', array( 'tabindex' => 5 ) ) . - $this->getHiddenFields( array( 'limit', 'ilsearch', 'user', 'title', 'ilshowall' ) ) . - Html::closeElement( 'fieldset' ) . - Html::closeElement( 'form' ) . "\n"; + ); + + $fields['ilshowall'] = array( + 'type' => 'check', + 'name' => 'ilshowall', + 'id' => 'mw-listfiles-show-all', + 'label-message' => 'listfiles-show-all', + 'default' => $this->mShowAll, + ); + + $query = $this->getRequest()->getQueryValues(); + unset( $query['title'] ); + unset( $query['limit'] ); + unset( $query['ilsearch'] ); + unset( $query['user'] ); + + $form = new HTMLForm( $fields, $this->getContext() ); + + $form->setMethod( 'get' ); + $form->setId( 'mw-listfiles-form' ); + $form->setWrapperLegendMsg( 'listfiles' ); + $form->setSubmitTextMsg( 'table_pager_limit_submit' ); + $form->addHiddenFields( $query ); + + $form->prepareForm(); + $form->displayForm( '' ); } function getTableClass() { -- 2.20.1