This is the rework I was talking about in r104318 for 1.19. Instead of having Pager...
authorJohn Du Hart <johnduhart@users.mediawiki.org>
Sun, 27 Nov 2011 18:23:50 +0000 (18:23 +0000)
committerJohn Du Hart <johnduhart@users.mediawiki.org>
Sun, 27 Nov 2011 18:23:50 +0000 (18:23 +0000)
This is simply a first pass, there's many more classes to convert.

includes/AutoLoader.php
includes/HTMLForm.php
includes/Pager.php
includes/specials/SpecialActiveusers.php
includes/specials/SpecialAllmessages.php
includes/specials/SpecialBlockList.php
includes/specials/SpecialListfiles.php
includes/specials/SpecialListusers.php

index 4420b96..9d34c7d 100644 (file)
@@ -104,6 +104,7 @@ $wgAutoloadLocalClasses = array(
        'HTMLHiddenField' => 'includes/HTMLForm.php',
        'HTMLInfoField' => 'includes/HTMLForm.php',
        'HTMLIntField' => 'includes/HTMLForm.php',
+       'HTMLItemsPerPageField' => 'includes/Pager.php',
        'HTMLMultiSelectField' => 'includes/HTMLForm.php',
        'HTMLRadioField' => 'includes/HTMLForm.php',
        'HTMLSelectAndOtherField' => 'includes/HTMLForm.php',
@@ -743,7 +744,6 @@ $wgAutoloadLocalClasses = array(
        'EmailInvalidation' => 'includes/specials/SpecialConfirmemail.php',
        'FewestrevisionsPage' => 'includes/specials/SpecialFewestrevisions.php',
        'FileDuplicateSearchPage' => 'includes/specials/SpecialFileDuplicateSearch.php',
-       'HTMLBlockedUsersItemSelect' => 'includes/specials/SpecialBlockList.php',
        'ImportReporter' => 'includes/specials/SpecialImport.php',
        'IPBlockForm' => 'includes/specials/SpecialBlock.php',
        'LinkSearchPage' => 'includes/specials/SpecialLinkSearch.php',
index ec2486c..8baf2ca 100644 (file)
@@ -845,6 +845,15 @@ class HTMLForm extends ContextSource {
        public function getLegend( $key ) {
                return wfMsg( "{$this->mMessagePrefix}-$key" );
        }
+
+       /**
+        * Returns an array of fields in the form
+        *
+        * @return HTMLFormField[]
+        */
+       public function getFlatFields() {
+               return $this->mFlatFields;
+       }
 }
 
 /**
@@ -1071,6 +1080,15 @@ abstract class HTMLFormField {
                return $html;
        }
 
+       /**
+        * Returns the HTML name of the Field
+        *
+        * @return string
+        */
+       public function getName() {
+               return $this->mName;
+       }
+
        function getLabel() {
                return $this->mLabel;
        }
index a03a1d1..41e9501 100644 (file)
@@ -559,6 +559,48 @@ abstract class IndexPager extends ContextSource implements Pager {
                return $links;
        }
 
+       /**
+        * Assembles an HTMLForm for the Pager and returns the HTML
+        *
+        * @return string
+        */
+       public function buildHTMLForm() {
+               if ( $this->getHTMLFormFields() === null ) {
+                       throw new MWException( __METHOD__ . " was called without any form fields being defined" );
+               }
+
+               $form = new HTMLForm( $this->getHTMLFormFields(), $this->getContext() );
+               $form->setMethod( 'get' );
+               $form->setWrapperLegendMsg( $this->getHTMLFormLegend() );
+               $form->setSubmitTextMsg( $this->getHTMLFormSubmit() );
+               $this->addHiddenFields( $form );
+               $this->modifyHTMLForm( $form );
+               $form->prepareForm();
+
+               return $form->getHTML( '' );
+       }
+
+       /**
+        * Adds hidden elements to forms for things that are in the query string.
+        * This is so that parameters like offset stick through form submissions
+        *
+        * @param HTMLForm $form
+        */
+       protected function addHiddenFields( HTMLForm $form ) {
+               $query = $this->getRequest()->getQueryValues();
+               $fieldsBlacklist = array( 'title' );
+               $fields = $form->getFlatFields();
+               foreach ( $fields as $name => $field ) {
+                       $fieldsBlacklist[] = $field->getName();
+               }
+               foreach ( $query as $name => $value ) {
+                       if ( in_array( $name, $fieldsBlacklist ) ) {
+                               continue;
+                       }
+                       $form->addHiddenField( $name, $value );
+               }
+       }
+
        /**
         * Abstract formatting function. This should return an HTML string
         * representing the result row $row. Rows will be concatenated and
@@ -635,6 +677,43 @@ abstract class IndexPager extends ContextSource implements Pager {
         * @return Boolean
         */
        protected function getDefaultDirections() { return false; }
+
+       /**
+        * Returns an array for HTMLForm fields for the pager
+        *
+        * Only used if the pager makes use of HTMLForms
+        *
+        * @return array|null
+        */
+       protected function getHTMLFormFields() { return null; }
+
+       /**
+        * Message name for the fieldset legend text
+        *
+        * Only used if the pager makes use of HTMLForms
+        *
+        * @return string
+        */
+       protected function getHTMLFormLegend() { return ''; }
+
+       /**
+        * Message name for the submit button text
+        *
+        * Only used if the pager makes use of HTMLForms
+        *
+        * @return string
+        */
+       protected function getHTMLFormSubmit() { return ''; }
+
+       /**
+        * If the pager needs to do any modifications to the Form, override this
+        * function.
+        *
+        * Only used if the pager makes use of HTMLForms
+        *
+        * @param HTMLForm $form
+        */
+       protected function modifyHTMLForm( HTMLForm $form ) {}
 }
 
 
@@ -1071,6 +1150,27 @@ abstract class TablePager extends IndexPager {
                return $s;
        }
 
+       /**
+        * Returns an HTMLFormField definition for the "Items per page:" dropdown
+        *
+        * @return array
+        */
+       protected function getHTMLFormLimitSelect() {
+               $f = array(
+                       'class' => 'HTMLItemsPerPageField',
+                       'label-message' => 'table_pager_limit_label',
+                       'options' => array(),
+                       'default' => $this->mDefaultLimit,
+                       'name' => 'limit',
+               );
+
+               foreach( $this->mLimitsShown as $limit ) {
+                       $f['options'][$this->getLanguage()->formatNum( $limit )] = $limit;
+               }
+
+               return $f;
+       }
+
        /**
         * Get <input type="hidden"> elements for use in a method="get" form.
         * Resubmits all defined elements of the query string, except for a
@@ -1158,3 +1258,30 @@ abstract class TablePager extends IndexPager {
         */
        abstract function getFieldNames();
 }
+
+/**
+ * Items per page dropdown for HTMLForm
+ */
+class HTMLItemsPerPageField extends HTMLSelectField {
+       /**
+        * Basically don't do any validation. If it's a number that's fine. Also,
+        * add it to the list if it's not there already
+        *
+        * @param $value
+        * @param $alldata
+        * @return bool
+        */
+       function validate( $value, $alldata ) {
+               if ( $value == '' ) {
+                       return true;
+               }
+
+               if ( !in_array( $value, $this->mParams['options'] ) ) {
+                       $this->mParams['options'][ $this->mParent->getLanguage()->formatNum( $value ) ] = intval($value);
+                       asort( $this->mParams['options'] );
+               }
+
+               return true;
+       }
+
+}
\ No newline at end of file
index 617a802..4ff3e0b 100644 (file)
@@ -53,7 +53,7 @@ class ActiveUsersPager extends UsersPager {
                parent::__construct( $context );
 
                $this->RCMaxAge = $wgActiveUserDays;
-               $un = $this->getRequest()->getText( 'username', $par );
+               $un = $this->getRequest()->getText( 'wpUsername', $par );
                $this->requestedUser = '';
                if ( $un != '' ) {
                        $username = Title::makeTitleSafe( NS_USER, $un );
@@ -68,16 +68,16 @@ class ActiveUsersPager extends UsersPager {
        public function setupOptions() {
                $this->opts = new FormOptions();
 
-               $this->opts->add( 'hidebots', false, FormOptions::BOOL );
-               $this->opts->add( 'hidesysops', false, FormOptions::BOOL );
+               $this->opts->add( 'wpHideBots', false, FormOptions::BOOL );
+               $this->opts->add( 'wpHideSysops', false, FormOptions::BOOL );
 
                $this->opts->fetchValuesFromRequest( $this->getRequest() );
 
                $this->groups = array();
-               if ( $this->opts->getValue( 'hidebots' ) == 1 ) {
+               if ( $this->opts->getValue( 'wpHideBots' ) == 1 ) {
                        $this->groups['bot'] = true;
                }
-               if ( $this->opts->getValue( 'hidesysops' ) == 1 ) {
+               if ( $this->opts->getValue( 'wpHideSysops' ) == 1 ) {
                        $this->groups['sysop'] = true;
                }
        }
@@ -143,30 +143,32 @@ class ActiveUsersPager extends UsersPager {
                return Html::rawElement( 'li', array(), "{$item} [{$count}]{$blocked}" );
        }
 
-       function getPageHeader() {
-               global $wgScript;
-
-               $self = $this->getTitle();
-               $limit = $this->mLimit ? Html::hidden( 'limit', $this->mLimit ) : '';
-
-               $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); # Form tag
-               $out .= Xml::fieldset( $this->msg( 'activeusers' )->text() ) . "\n";
-               $out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . "\n";
-
-               $out .= Xml::inputLabel( $this->msg( 'activeusers-from' )->text(),
-                       'username', 'offset', 20, $this->requestedUser ) . '<br />';# Username field
-
-               $out .= Xml::checkLabel( $this->msg( 'activeusers-hidebots' )->text(),
-                       'hidebots', 'hidebots', $this->opts->getValue( 'hidebots' ) );
+       protected function getHTMLFormFields() {
+               $f = array(
+                       'Username' => array(
+                               'type' => 'text',
+                               'label-message' => 'activeusers-from',
+                               'size' => 30,
+                       ),
+                       'HideBots' => array(
+                               'type' => 'check',
+                               'label-message' => 'activeusers-hidebots',
+                       ),
+                       'HideSysops' => array(
+                               'type' => 'check',
+                               'label-message' => 'activeusers-hidesysops',
+                       ),
+               );
 
-               $out .= Xml::checkLabel( $this->msg( 'activeusers-hidesysops' )->text(),
-                       'hidesysops', 'hidesysops', $this->opts->getValue( 'hidesysops' ) ) . '<br />';
+               return $f;
+       }
 
-               $out .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "\n";# Submit button and form bottom
-               $out .= Xml::closeElement( 'fieldset' );
-               $out .= Xml::closeElement( 'form' );
+       protected function getHTMLFormLegend() {
+               return 'activeusers';
+       }
 
-               return $out;
+       protected function getHTMLFormSubmit() {
+               return 'allpagessubmit';
        }
 }
 
@@ -202,7 +204,7 @@ class SpecialActiveUsers extends SpecialPage {
                # getBody() first to check, if empty
                $usersbody = $up->getBody();
 
-               $out->addHTML( $up->getPageHeader() );
+               $out->addHTML( $up->buildHTMLForm() );
                if ( $usersbody ) {
                        $out->addHTML(
                                $up->getNavigationBar() .
index 45ba406..55316df 100644 (file)
@@ -62,18 +62,18 @@ class SpecialAllmessages extends SpecialPage {
 
                $out->addModuleStyles( 'mediawiki.special' );
 
-               $this->filter = $request->getVal( 'filter', 'all' );
-               $this->prefix = $request->getVal( 'prefix', '' );
+               $this->filter = $request->getVal( 'wpFilter', 'all' );
+               $this->prefix = $request->getVal( 'wpPrefix', '' );
 
                $this->table = new AllmessagesTablePager(
                        $this,
                        array(),
-                       wfGetLangObj( $request->getVal( 'lang', $par ) )
+                       wfGetLangObj( $request->getVal( 'wpLanguage', $par ) )
                );
 
                $this->langcode = $this->table->lang->getCode();
 
-               $out->addHTML( $this->table->buildForm() .
+               $out->addHTML( $this->table->buildHTMLForm() .
                        $this->table->getNavigationBar() .
                        $this->table->getBody() .
                        $this->table->getNavigationBar() );
@@ -120,14 +120,14 @@ class AllmessagesTablePager extends TablePager {
 
                $request = $this->getRequest();
 
-               if( $request->getVal( 'filter', 'all' ) === 'all' ){
+               if( $request->getVal( 'wpFilter', 'all' ) === 'all' ){
                        $this->custom = null; // So won't match in either case
                } else {
-                       $this->custom = ($request->getVal( 'filter' ) == 'unmodified');
+                       $this->custom = ($request->getVal( 'wpFilter' ) == 'unmodified');
                }
 
-               $prefix = $this->getLanguage()->ucfirst( $request->getVal( 'prefix', '' ) );
-               $prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $request->getVal( 'prefix', null ) ) : null;
+               $prefix = $this->getLanguage()->ucfirst( $request->getVal( 'wpPrefix', '' ) );
+               $prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $request->getVal( 'wpPrefix', null ) ) : null;
                if( $prefix !== null ){
                        $this->displayPrefix = $prefix->getDBkey();
                        $this->prefix = '/^' . preg_quote( $this->displayPrefix ) . '/i';
@@ -145,83 +145,48 @@ class AllmessagesTablePager extends TablePager {
                }
        }
 
-       function buildForm() {
-               global $wgScript;
+       protected function getHTMLFormFields() {
+               $f = array(
+                       'Prefix' => array(
+                               'type' => 'text',
+                               'label-message' => 'allmessages-prefix',
+                               'size' => 20,
+                       ),
+                       'Filter' => array(
+                               'type' => 'radio',
+                               'label-message' => 'allmessages-filter',
+                               'options' => array(
+                                       $this->msg( 'allmessages-filter-unmodified' )->text() => 'unmodified',
+                                       $this->msg( 'allmessages-filter-all' )->text() => 'all',
+                                       $this->msg( 'allmessages-filter-modified' )->text() => 'modified',
+                               ),
+                               'flatlist' => true,
+                       ),
+                       'Language' => array(
+                               'type' => 'select',
+                               'label-message' => 'allmessages-language',
+                               'options' => array(), // This is filled in below
+                               'default' => $this->langcode,
+                       ),
+                       'Limit' => $this->getHTMLFormLimitSelect(),
+               );
 
                $languages = Language::getLanguageNames( false );
                ksort( $languages );
 
-               $out  = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-allmessages-form' ) ) .
-                       Xml::fieldset( $this->msg( 'allmessages-filter-legend' )->text() ) .
-                       Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
-                       Xml::openElement( 'table', array( 'class' => 'mw-allmessages-table' ) ) . "\n" .
-                       '<tr>
-                               <td class="mw-label">' .
-                                       Xml::label( $this->msg( 'allmessages-prefix' )->text(), 'mw-allmessages-form-prefix' ) .
-                               "</td>\n
-                               <td class=\"mw-input\">" .
-                                       Xml::input( 'prefix', 20, str_replace( '_', ' ', $this->displayPrefix ), array( 'id' => 'mw-allmessages-form-prefix' ) ) .
-                               "</td>\n
-                       </tr>
-                       <tr>\n
-                               <td class='mw-label'>" .
-                                       $this->msg( 'allmessages-filter' )->escaped() .
-                               "</td>\n
-                               <td class='mw-input'>" .
-                                       Xml::radioLabel( $this->msg( 'allmessages-filter-unmodified' )->text(),
-                                               'filter',
-                                               'unmodified',
-                                               'mw-allmessages-form-filter-unmodified',
-                                               ( $this->filter == 'unmodified' )
-                                       ) .
-                                       Xml::radioLabel( $this->msg( 'allmessages-filter-all' )->text(),
-                                               'filter',
-                                               'all',
-                                               'mw-allmessages-form-filter-all',
-                                               ( $this->filter == 'all' )
-                                       ) .
-                                       Xml::radioLabel( $this->msg( 'allmessages-filter-modified' )->text(),
-                                               'filter',
-                                               'modified',
-                                               'mw-allmessages-form-filter-modified',
-                                       ( $this->filter == 'modified' )
-                               ) .
-                               "</td>\n
-                       </tr>
-                       <tr>\n
-                               <td class=\"mw-label\">" .
-                                       Xml::label( $this->msg( 'allmessages-language' )->text(), 'mw-allmessages-form-lang' ) .
-                               "</td>\n
-                               <td class=\"mw-input\">" .
-                                       Xml::openElement( 'select', array( 'id' => 'mw-allmessages-form-lang', 'name' => 'lang' ) );
-
-               foreach( $languages as $lang => $name ) {
-                       $selected = $lang == $this->langcode;
-                       $out .= Xml::option( $lang . ' - ' . $name, $lang, $selected ) . "\n";
+               foreach( $languages as $code => $name ) {
+                       $f['Language']['options'][ "$code - $name" ] = $code;
                }
-               $out .= Xml::closeElement( 'select' ) .
-                               "</td>\n
-                       </tr>" .
-
-                       '<tr>
-                               <td class="mw-label">' .
-                                       Xml::label( $this->msg( 'table_pager_limit_label' )->text(), 'mw-table_pager_limit_label' ) .
-                               '</td>
-                               <td class="mw-input">' .
-                                       $this->getLimitSelect() .
-                               '</td>
-                       <tr>
-                               <td></td>
-                               <td>' .
-                                       Xml::submitButton( $this->msg( 'allmessages-filter-submit' )->text() ) .
-                               "</td>\n
-                       </tr>" .
-
-                       Xml::closeElement( 'table' ) .
-                       $this->getHiddenFields( array( 'title', 'prefix', 'filter', 'lang', 'limit' ) ) .
-                       Xml::closeElement( 'fieldset' ) .
-                       Xml::closeElement( 'form' );
-               return $out;
+
+               return $f;
+       }
+
+       protected function getHTMLFormLegend() {
+               return 'allmessages-filter-legend';
+       }
+
+       protected function getHTMLFormSubmit() {
+               return 'allmessages-filter-submit';
        }
 
        function getAllMessages( $descending ) {
index 719a338..a6dee57 100644 (file)
@@ -43,7 +43,6 @@ class SpecialBlockList extends SpecialPage {
                $this->setHeaders();
                $this->outputHeader();
                $out = $this->getOutput();
-               $lang = $this->getLanguage();
                $out->setPageTitle( $this->msg( 'ipblocklist' ) );
                $out->addModuleStyles( 'mediawiki.special' );
 
@@ -62,46 +61,6 @@ class SpecialBlockList extends SpecialPage {
                        return;
                }
 
-               # Just show the block list
-               $fields = array(
-                       'Target' => array(
-                               'type' => 'text',
-                               'label-message' => 'ipadressorusername',
-                               'tabindex' => '1',
-                               'size' => '45',
-                               'default' => $this->target,
-                       ),
-                       'Options' => array(
-                               'type' => 'multiselect',
-                               'options' => array(
-                                       wfMsg( 'blocklist-userblocks' ) => 'userblocks',
-                                       wfMsg( 'blocklist-tempblocks' ) => 'tempblocks',
-                                       wfMsg( 'blocklist-addressblocks' ) => 'addressblocks',
-                                       wfMsg( 'blocklist-rangeblocks' ) => 'rangeblocks',
-                               ),
-                               'flatlist' => true,
-                       ),
-                       'Limit' => array(
-                               'class' => 'HTMLBlockedUsersItemSelect',
-                               'label-message' => 'table_pager_limit_label',
-                               'options' => array(
-                                       $lang->formatNum( 20 ) => 20,
-                                       $lang->formatNum( 50 ) => 50,
-                                       $lang->formatNum( 100 ) => 100,
-                                       $lang->formatNum( 250 ) => 250,
-                                       $lang->formatNum( 500 ) => 500,
-                               ),
-                               'name' => 'limit',
-                               'default' => 50,
-                       ),
-               );
-               $form = new HTMLForm( $fields, $this->getContext() );
-               $form->setMethod( 'get' );
-               $form->setWrapperLegend( wfMsg( 'ipblocklist-legend' ) );
-               $form->setSubmitText( wfMsg( 'ipblocklist-submit' ) );
-               $form->prepareForm();
-
-               $form->displayForm( '' );
                $this->showList();
        }
 
@@ -176,6 +135,7 @@ class SpecialBlockList extends SpecialPage {
                }
 
                $pager = new BlockListPager( $this, $conds );
+               $out->addHTML( $pager->buildHTMLForm() );
                if ( $pager->getNumRows() ) {
                        $out->addHTML(
                                $pager->getNavigationBar() .
@@ -399,6 +359,37 @@ class BlockListPager extends TablePager {
                return $info;
        }
 
+       protected function getHTMLFormFields() {
+               return array(
+                       'Target' => array(
+                               'type' => 'text',
+                               'label-message' => 'ipadressorusername',
+                               'tabindex' => '1',
+                               'size' => '45',
+                               //'default' => $this->target,
+                       ),
+                       'Options' => array(
+                               'type' => 'multiselect',
+                               'options' => array(
+                                       wfMsg( 'blocklist-userblocks' ) => 'userblocks',
+                                       wfMsg( 'blocklist-tempblocks' ) => 'tempblocks',
+                                       wfMsg( 'blocklist-addressblocks' ) => 'addressblocks',
+                                       wfMsg( 'blocklist-rangeblocks' ) => 'rangeblocks',
+                               ),
+                               'flatlist' => true,
+                       ),
+                       'Limit' => $this->getHTMLFormLimitSelect(),
+               );
+       }
+
+       protected function getHTMLFormSubmit() {
+               return 'ipblocklist-submit';
+       }
+
+       protected function getHTMLFormLegend() {
+               return 'ipblocklist-legend';
+       }
+
        public function getTableClass(){
                return 'TablePager mw-blocklist';
        }
@@ -447,33 +438,4 @@ class BlockListPager extends TablePager {
                $lb->execute();
                wfProfileOut( __METHOD__ );
        }
-}
-
-/**
- * Items per page dropdown. Essentially a crap workaround for bug 32603.
- *
- * @todo Do not release 1.19 with this.
- */
-class HTMLBlockedUsersItemSelect extends HTMLSelectField {
-       /**
-        * Basically don't do any validation. If it's a number that's fine. Also,
-        * add it to the list if it's not there already
-        *
-        * @param $value
-        * @param $alldata
-        * @return bool
-        */
-       function validate( $value, $alldata ) {
-               if ( $value == '' ) {
-                       return true;
-               }
-
-               if ( !in_array( $value, $this->mParams['options'] ) ) {
-                       $this->mParams['options'][ $this->mParent->getLanguage()->formatNum( $value ) ] = intval($value);
-                       asort( $this->mParams['options'] );
-               }
-
-               return true;
-       }
-
-}
+}
\ No newline at end of file
index b575499..5fb199c 100644 (file)
@@ -35,8 +35,8 @@ class SpecialListFiles extends IncludableSpecialPage {
                        $userName = $par;
                        $search = '';
                } else {
-                       $userName = $this->getRequest()->getText( 'user', $par );
-                       $search = $this->getRequest()->getText( 'ilsearch', '' );
+                       $userName = $this->getRequest()->getText( 'wpUsername', $par );
+                       $search = $this->getRequest()->getText( 'wpSearch', '' );
                }
 
                $pager = new ImageListPager( $this->getContext(), $userName, $search, $this->including() );
@@ -44,7 +44,7 @@ class SpecialListFiles extends IncludableSpecialPage {
                if ( $this->including() ) {
                        $html = $pager->getBody();
                } else {
-                       $form = $pager->getForm();
+                       $form = $pager->buildHTMLForm();
                        $body = $pager->getBody();
                        $nav = $pager->getNavigationBar();
                        $html = "$form<br />\n$body<br />\n$nav";
@@ -234,30 +234,35 @@ class ImageListPager extends TablePager {
                }
        }
 
-       function getForm() {
-               global $wgScript, $wgMiserMode;
-               $inputForm = array();
-               $inputForm['table_pager_limit_label'] = $this->getLimitSelect();
+       protected function getHTMLFormFields() {
+               global $wgMiserMode;
+               $f = array(
+                       'Limit' => $this->getHTMLFormLimitSelect(),
+               );
+
                if ( !$wgMiserMode ) {
-                       $inputForm['listfiles_search_for'] = Html::input( 'ilsearch', $this->mSearch, 'text',
-                               array(
-                                       'size'          => '40',
-                                       'maxlength' => '255',
-                                       'id'            => 'mw-ilsearch',
-                       ) );
+                       $f['Search'] = array(
+                               'type' => 'text',
+                               'label-message' => 'listfiles_search_for',
+                               'maxlength' => 255,
+                       );
                }
-               $inputForm['username'] = Html::input( 'user', $this->mUserName, 'text', array(
-                       'size'          => '40',
-                       'maxlength' => '255',
-                       'id'            => 'mw-listfiles-user',
-               ) );
-               return Html::openElement( 'form',
-                               array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listfiles-form' ) ) .
-                       Xml::fieldset( wfMsg( 'listfiles' ) ) .
-                       Xml::buildForm( $inputForm, 'table_pager_limit_submit' ) .
-                       $this->getHiddenFields( array( 'limit', 'ilsearch', 'user' ) ) .
-                       Html::closeElement( 'fieldset' ) .
-                       Html::closeElement( 'form' ) . "\n";
+
+               $f['Username'] = array(
+                       'type' => 'text',
+                       'label-message' => 'username',
+                       'maxlength' => 255,
+               );
+
+               return $f;
+       }
+
+       protected function getHTMLFormLegend() {
+               return 'listfiles';
+       }
+
+       protected function getHTMLFormSubmit() {
+               return 'table_pager_limit_submit';
        }
 
        function getTableClass() {
index b1ff6ea..431e6c8 100644 (file)
@@ -44,19 +44,19 @@ class UsersPager extends AlphabeticPager {
                $symsForAll = array( '*', 'user' );
                if ( $parms[0] != '' && ( in_array( $par, User::getAllGroups() ) || in_array( $par, $symsForAll ) ) ) {
                        $this->requestedGroup = $par;
-                       $un = $request->getText( 'username' );
+                       $un = $request->getText( 'wpUsername' );
                } elseif ( count( $parms ) == 2 ) {
                        $this->requestedGroup = $parms[0];
                        $un = $parms[1];
                } else {
-                       $this->requestedGroup = $request->getVal( 'group' );
-                       $un = ( $par != '' ) ? $par : $request->getText( 'username' );
+                       $this->requestedGroup = $request->getVal( 'wpGroup' );
+                       $un = ( $par != '' ) ? $par : $request->getText( 'wpUsername' );
                }
                if ( in_array( $this->requestedGroup, $symsForAll ) ) {
                        $this->requestedGroup = '';
                }
-               $this->editsOnly = $request->getBool( 'editsOnly' );
-               $this->creationSort = $request->getBool( 'creationSort' );
+               $this->editsOnly = $request->getBool( 'wpEditsOnly' );
+               $this->creationSort = $request->getBool( 'wpCreationSort' );
 
                $this->requestedUser = '';
                if ( $un != '' ) {
@@ -182,41 +182,43 @@ class UsersPager extends AlphabeticPager {
                return parent::getBody();
        }
 
-       function getPageHeader( ) {
-               global $wgScript;
-               $self = $this->getTitle();
-
-               # Form tag
-               $out  = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listusers-form' ) ) .
-                       Xml::fieldset( wfMsg( 'listusers' ) ) .
-                       Html::hidden( 'title', $self->getPrefixedDbKey() );
-
-               # Username field
-               $out .= Xml::label( wfMsg( 'listusersfrom' ), 'offset' ) . ' ' .
-                       Xml::input( 'username', 20, $this->requestedUser, array( 'id' => 'offset' ) ) . ' ';
-
-               # Group drop-down list
-               $out .= Xml::label( wfMsg( 'group' ), 'group' ) . ' ' .
-                       Xml::openElement('select',  array( 'name' => 'group', 'id' => 'group' ) ) .
-                       Xml::option( wfMsg( 'group-all' ), '' );
-               foreach( $this->getAllGroups() as $group => $groupText )
-                       $out .= Xml::option( $groupText, $group, $group == $this->requestedGroup );
-               $out .= Xml::closeElement( 'select' ) . '<br />';
-               $out .= Xml::checkLabel( wfMsg('listusers-editsonly'), 'editsOnly', 'editsOnly', $this->editsOnly );
-               $out .= '&#160;';
-               $out .= Xml::checkLabel( wfMsg('listusers-creationsort'), 'creationSort', 'creationSort', $this->creationSort );
-               $out .= '<br />';
-
-               wfRunHooks( 'SpecialListusersHeaderForm', array( $this, &$out ) );
-
-               # Submit button and form bottom
-               $out .= Html::hidden( 'limit', $this->mLimit );
-               $out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
-               wfRunHooks( 'SpecialListusersHeader', array( $this, &$out ) );
-               $out .= Xml::closeElement( 'fieldset' ) .
-                       Xml::closeElement( 'form' );
-
-               return $out;
+       protected function getHTMLFormFields() {
+               $f = array(
+                       'Username' => array(
+                               'type' => 'text',
+                               'label-message' => 'listusersfrom',
+                               'size' => 30,
+                       ),
+                       'Group' => array(
+                               'type' => 'select',
+                               'label-message' => 'group',
+                               'options' => array(
+                                       $this->msg( 'group-all' )->escaped() => '',
+                               ),
+                       ),
+                       'EditsOnly' => array(
+                               'type' => 'check',
+                               'label-message' => 'listusers-editsonly',
+                       ),
+                       'CreationSort' => array(
+                               'type' => 'check',
+                               'label-message' => 'listusers-creationsort',
+                       ),
+               );
+
+               foreach( $this->getAllGroups() as $group => $groupText ) {
+                       $f['Group']['options'][$groupText] = $group;
+               }
+
+               return $f;
+       }
+
+       protected function getHTMLFormSubmit() {
+               return 'allpagessubmit';
+       }
+
+       protected function getHTMLFormLegend() {
+               return 'listusers';
        }
 
        /**
@@ -295,7 +297,7 @@ class SpecialListUsers extends SpecialPage {
                # getBody() first to check, if empty
                $usersbody = $up->getBody();
 
-               $s = $up->getPageHeader();
+               $s = $up->buildHTMLForm();
                if( $usersbody ) {
                        $s .= $up->getNavigationBar();
                        $s .= Html::rawElement( 'ul', array(), $usersbody );