From: Brion Vibber Date: Tue, 6 Dec 2011 19:32:29 +0000 (+0000) Subject: Revert r104353, r104354, r104356, r104358, r104383: changes to pagers breaking... X-Git-Tag: 1.31.0-rc.0~26154 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=1200ae7daef88a06cf985700234a94d4c0bd7482;p=lhc%2Fweb%2Fwiklou.git Revert r104353, r104354, r104356, r104358, r104383: changes to pagers breaking existing links as noted in CR. --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index f53d9a177c..ff76e9ae1f 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -104,7 +104,6 @@ $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', @@ -747,6 +746,7 @@ $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', diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 85b5038a19..ec2486c2ab 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -72,8 +72,6 @@ class HTMLForm extends ContextSource { 'submit' => 'HTMLSubmitField', 'hidden' => 'HTMLHiddenField', 'edittools' => 'HTMLEditTools', - 'namespaces' => 'HTMLNamespacesField', - 'restrictionlevels' => 'HTMLRestrictionLevelsField', # HTMLTextField will output the correct type="" attribute automagically. # There are about four zillion other HTML5 input types, like url, but @@ -847,25 +845,6 @@ 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; - } - - /** - * Returns a value of a field - * - * @param $field string Field name - * @return mixed - */ - public function getVal( $field ) { - return $this->mFieldData[$field]; - } } /** @@ -1092,15 +1071,6 @@ 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; } @@ -2016,84 +1986,3 @@ class HTMLEditTools extends HTMLFormField { . "\n"; } } - -/** - * Dropdown for namespaces - */ -class HTMLNamespacesField extends HTMLSelectField { - function __construct( $params ) { - global $wgContLang; - parent::__construct( $params ); - - $namespaces = $wgContLang->getFormattedNamespaces(); - - $options = array(); - $options[ wfMessage( 'namespacesall' )->escaped() ] = ''; // TODO: Make an option - - foreach ( $namespaces as $index => $name ) { - // Don't include things like SpecialPages - if ( $index < NS_MAIN ) { - continue; - } - - if ( $index === 0 ) { - $name = wfMessage( 'blanknamespace' )->escaped(); - } - - $options[$name] = $index; - } - - $this->mParams['options'] = $options; - } -} - -/** - * Dropdown for protection levels - */ -class HTMLRestrictionLevelsField extends HTMLSelectField { - - /** - * Should this field be displayed? If it hits a condition where it should - * be hidden, set this to false. - * - * @var bool - */ - protected $enabled = true; - - function __construct( $params ) { - global $wgRestrictionLevels; - parent::__construct( $params ); - - $options = array( wfMsg('restriction-level-all') => 0 ); // Temporary array - - // First pass to load the level names - foreach( $wgRestrictionLevels as $type ) { - if ( $type != '' && $type != '*' ) { - $text = wfMsg("restriction-level-$type"); - $options[$text] = $type; - } - } - - // Is there only one level (aside from "all")? - if( count($options) <= 2 ) { - $this->enabled = false; - return; - } - - $this->mParams['options'] = $options; - } - - /** - * Returns false where - * - * @param $value - * @return String - */ - function getTableRow( $value ) { - if ( $this->enabled ) { - return parent::getTableRow( $value ); - } - - return ''; - } -} \ No newline at end of file diff --git a/includes/Pager.php b/includes/Pager.php index 375040d7cc..a03a1d1d4c 100644 --- a/includes/Pager.php +++ b/includes/Pager.php @@ -99,13 +99,6 @@ abstract class IndexPager extends ContextSource implements Pager { protected $mLastShown, $mFirstShown, $mPastTheEndIndex, $mDefaultQuery, $mNavigationBar; - /** - * HTMLForm object - * - * @var HTMLForm - */ - protected $mHTMLForm; - /** * Result object for the query. Warning: seek before use. * @@ -566,46 +559,6 @@ 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" ); - } - - $this->mHTMLForm = new HTMLForm( $this->getHTMLFormFields(), $this->getContext() ); - $this->mHTMLForm->setMethod( 'get' ); - $this->mHTMLForm->setWrapperLegendMsg( $this->getHTMLFormLegend() ); - $this->mHTMLForm->setSubmitTextMsg( $this->getHTMLFormSubmit() ); - $this->addHiddenFields(); - $this->modifyHTMLForm( $this->mHTMLForm ); - $this->mHTMLForm->prepareForm(); - - return $this->mHTMLForm->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 - */ - protected function addHiddenFields() { - $query = $this->getRequest()->getQueryValues(); - $fieldsBlacklist = array( 'title' ); - $fields = $this->mHTMLForm->getFlatFields(); - foreach ( $fields as $name => $field ) { - $fieldsBlacklist[] = $field->getName(); - } - foreach ( $query as $name => $value ) { - if ( in_array( $name, $fieldsBlacklist ) ) { - continue; - } - $this->mHTMLForm->addHiddenField( $name, $value ); - } - } - /** * Abstract formatting function. This should return an HTML string * representing the result row $row. Rows will be concatenated and @@ -682,43 +635,6 @@ 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 ) {} } @@ -1155,27 +1071,6 @@ 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 elements for use in a method="get" form. * Resubmits all defined elements of the query string, except for a @@ -1263,30 +1158,3 @@ 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 diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index 4ff3e0b0af..617a802690 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -53,7 +53,7 @@ class ActiveUsersPager extends UsersPager { parent::__construct( $context ); $this->RCMaxAge = $wgActiveUserDays; - $un = $this->getRequest()->getText( 'wpUsername', $par ); + $un = $this->getRequest()->getText( 'username', $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( 'wpHideBots', false, FormOptions::BOOL ); - $this->opts->add( 'wpHideSysops', false, FormOptions::BOOL ); + $this->opts->add( 'hidebots', false, FormOptions::BOOL ); + $this->opts->add( 'hidesysops', false, FormOptions::BOOL ); $this->opts->fetchValuesFromRequest( $this->getRequest() ); $this->groups = array(); - if ( $this->opts->getValue( 'wpHideBots' ) == 1 ) { + if ( $this->opts->getValue( 'hidebots' ) == 1 ) { $this->groups['bot'] = true; } - if ( $this->opts->getValue( 'wpHideSysops' ) == 1 ) { + if ( $this->opts->getValue( 'hidesysops' ) == 1 ) { $this->groups['sysop'] = true; } } @@ -143,32 +143,30 @@ class ActiveUsersPager extends UsersPager { return Html::rawElement( 'li', array(), "{$item} [{$count}]{$blocked}" ); } - 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', - ), - ); + function getPageHeader() { + global $wgScript; - return $f; - } + $self = $this->getTitle(); + $limit = $this->mLimit ? Html::hidden( 'limit', $this->mLimit ) : ''; - protected function getHTMLFormLegend() { - return 'activeusers'; - } + $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 ) . '
';# Username field + + $out .= Xml::checkLabel( $this->msg( 'activeusers-hidebots' )->text(), + 'hidebots', 'hidebots', $this->opts->getValue( 'hidebots' ) ); + + $out .= Xml::checkLabel( $this->msg( 'activeusers-hidesysops' )->text(), + 'hidesysops', 'hidesysops', $this->opts->getValue( 'hidesysops' ) ) . '
'; + + $out .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "\n";# Submit button and form bottom + $out .= Xml::closeElement( 'fieldset' ); + $out .= Xml::closeElement( 'form' ); - protected function getHTMLFormSubmit() { - return 'allpagessubmit'; + return $out; } } @@ -204,7 +202,7 @@ class SpecialActiveUsers extends SpecialPage { # getBody() first to check, if empty $usersbody = $up->getBody(); - $out->addHTML( $up->buildHTMLForm() ); + $out->addHTML( $up->getPageHeader() ); if ( $usersbody ) { $out->addHTML( $up->getNavigationBar() . diff --git a/includes/specials/SpecialAllmessages.php b/includes/specials/SpecialAllmessages.php index 55316df012..45ba4066ba 100644 --- a/includes/specials/SpecialAllmessages.php +++ b/includes/specials/SpecialAllmessages.php @@ -62,18 +62,18 @@ class SpecialAllmessages extends SpecialPage { $out->addModuleStyles( 'mediawiki.special' ); - $this->filter = $request->getVal( 'wpFilter', 'all' ); - $this->prefix = $request->getVal( 'wpPrefix', '' ); + $this->filter = $request->getVal( 'filter', 'all' ); + $this->prefix = $request->getVal( 'prefix', '' ); $this->table = new AllmessagesTablePager( $this, array(), - wfGetLangObj( $request->getVal( 'wpLanguage', $par ) ) + wfGetLangObj( $request->getVal( 'lang', $par ) ) ); $this->langcode = $this->table->lang->getCode(); - $out->addHTML( $this->table->buildHTMLForm() . + $out->addHTML( $this->table->buildForm() . $this->table->getNavigationBar() . $this->table->getBody() . $this->table->getNavigationBar() ); @@ -120,14 +120,14 @@ class AllmessagesTablePager extends TablePager { $request = $this->getRequest(); - if( $request->getVal( 'wpFilter', 'all' ) === 'all' ){ + if( $request->getVal( 'filter', 'all' ) === 'all' ){ $this->custom = null; // So won't match in either case } else { - $this->custom = ($request->getVal( 'wpFilter' ) == 'unmodified'); + $this->custom = ($request->getVal( 'filter' ) == 'unmodified'); } - $prefix = $this->getLanguage()->ucfirst( $request->getVal( 'wpPrefix', '' ) ); - $prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $request->getVal( 'wpPrefix', null ) ) : null; + $prefix = $this->getLanguage()->ucfirst( $request->getVal( 'prefix', '' ) ); + $prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $request->getVal( 'prefix', null ) ) : null; if( $prefix !== null ){ $this->displayPrefix = $prefix->getDBkey(); $this->prefix = '/^' . preg_quote( $this->displayPrefix ) . '/i'; @@ -145,48 +145,83 @@ class AllmessagesTablePager extends TablePager { } } - 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(), - ); + function buildForm() { + global $wgScript; $languages = Language::getLanguageNames( false ); ksort( $languages ); - foreach( $languages as $code => $name ) { - $f['Language']['options'][ "$code - $name" ] = $code; + $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" . + ' + ' . + Xml::label( $this->msg( 'allmessages-prefix' )->text(), 'mw-allmessages-form-prefix' ) . + "\n + " . + Xml::input( 'prefix', 20, str_replace( '_', ' ', $this->displayPrefix ), array( 'id' => 'mw-allmessages-form-prefix' ) ) . + "\n + + \n + " . + $this->msg( 'allmessages-filter' )->escaped() . + "\n + " . + 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' ) + ) . + "\n + + \n + " . + Xml::label( $this->msg( 'allmessages-language' )->text(), 'mw-allmessages-form-lang' ) . + "\n + " . + 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"; } - - return $f; - } - - protected function getHTMLFormLegend() { - return 'allmessages-filter-legend'; - } - - protected function getHTMLFormSubmit() { - return 'allmessages-filter-submit'; + $out .= Xml::closeElement( 'select' ) . + "\n + " . + + ' + ' . + Xml::label( $this->msg( 'table_pager_limit_label' )->text(), 'mw-table_pager_limit_label' ) . + ' + ' . + $this->getLimitSelect() . + ' + + + ' . + Xml::submitButton( $this->msg( 'allmessages-filter-submit' )->text() ) . + "\n + " . + + Xml::closeElement( 'table' ) . + $this->getHiddenFields( array( 'title', 'prefix', 'filter', 'lang', 'limit' ) ) . + Xml::closeElement( 'fieldset' ) . + Xml::closeElement( 'form' ); + return $out; } function getAllMessages( $descending ) { diff --git a/includes/specials/SpecialBlockList.php b/includes/specials/SpecialBlockList.php index 8334c99748..719a3381b9 100644 --- a/includes/specials/SpecialBlockList.php +++ b/includes/specials/SpecialBlockList.php @@ -43,13 +43,13 @@ class SpecialBlockList extends SpecialPage { $this->setHeaders(); $this->outputHeader(); $out = $this->getOutput(); + $lang = $this->getLanguage(); $out->setPageTitle( $this->msg( 'ipblocklist' ) ); $out->addModuleStyles( 'mediawiki.special' ); $request = $this->getRequest(); $par = $request->getVal( 'ip', $par ); $this->target = trim( $request->getVal( 'wpTarget', $par ) ); - $request->setVal( 'wpTarget', $this->target ); $this->options = $request->getArray( 'wpOptions', array() ); @@ -62,6 +62,46 @@ 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(); } @@ -136,7 +176,6 @@ class SpecialBlockList extends SpecialPage { } $pager = new BlockListPager( $this, $conds ); - $out->addHTML( $pager->buildHTMLForm() ); if ( $pager->getNumRows() ) { $out->addHTML( $pager->getNavigationBar() . @@ -360,37 +399,6 @@ 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'; } @@ -439,4 +447,33 @@ class BlockListPager extends TablePager { $lb->execute(); wfProfileOut( __METHOD__ ); } -} \ No newline at end of file +} + +/** + * 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; + } + +} diff --git a/includes/specials/SpecialCategories.php b/includes/specials/SpecialCategories.php index ee973c02aa..6d2831c7b0 100644 --- a/includes/specials/SpecialCategories.php +++ b/includes/specials/SpecialCategories.php @@ -35,7 +35,7 @@ class SpecialCategories extends SpecialPage { $this->outputHeader(); $this->getOutput()->allowClickjacking(); - $from = $this->getRequest()->getText( 'wpFrom', $par ); + $from = $this->getRequest()->getText( 'from', $par ); $cap = new CategoryPager( $this->getContext(), $from ); $cap->doQuery(); @@ -43,7 +43,7 @@ class SpecialCategories extends SpecialPage { $this->getOutput()->addHTML( Html::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) . $this->msg( 'categoriespagetext', $cap->getNumRows() )->parseAsBlock() . - $cap->buildHTMLForm() . + $cap->getStartForm( $from ) . $cap->getNavigationBar() . '' . $cap->getNavigationBar() . @@ -118,21 +118,16 @@ class CategoryPager extends AlphabeticPager { return Xml::tags( 'li', null, $this->getLanguage()->specialList( $titleText, $count ) ) . "\n"; } - protected function getHTMLFormFields() { - return array( - 'From' => array( - 'type' => 'text', - 'label-message' => 'categoriesfrom', - 'size' => '20', - ), - ); - } - - protected function getHTMLFormLegend() { - return 'categories'; - } - - protected function getHTMLFormSubmit() { - return 'allpagessubmit'; + public function getStartForm( $from ) { + global $wgScript; + + return + Xml::tags( 'form', array( 'method' => 'get', 'action' => $wgScript ), + Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . + Xml::fieldset( $this->msg( 'categories' )->text(), + Xml::inputLabel( $this->msg( 'categoriesfrom' )->text(), + 'from', 'from', 20, $from ) . + ' ' . + Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) ) ); } } diff --git a/includes/specials/SpecialListfiles.php b/includes/specials/SpecialListfiles.php index 5fb199c4c7..b57549919e 100644 --- a/includes/specials/SpecialListfiles.php +++ b/includes/specials/SpecialListfiles.php @@ -35,8 +35,8 @@ class SpecialListFiles extends IncludableSpecialPage { $userName = $par; $search = ''; } else { - $userName = $this->getRequest()->getText( 'wpUsername', $par ); - $search = $this->getRequest()->getText( 'wpSearch', '' ); + $userName = $this->getRequest()->getText( 'user', $par ); + $search = $this->getRequest()->getText( 'ilsearch', '' ); } $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->buildHTMLForm(); + $form = $pager->getForm(); $body = $pager->getBody(); $nav = $pager->getNavigationBar(); $html = "$form
\n$body
\n$nav"; @@ -234,35 +234,30 @@ class ImageListPager extends TablePager { } } - protected function getHTMLFormFields() { - global $wgMiserMode; - $f = array( - 'Limit' => $this->getHTMLFormLimitSelect(), - ); - + function getForm() { + global $wgScript, $wgMiserMode; + $inputForm = array(); + $inputForm['table_pager_limit_label'] = $this->getLimitSelect(); if ( !$wgMiserMode ) { - $f['Search'] = array( - 'type' => 'text', - 'label-message' => 'listfiles_search_for', - 'maxlength' => 255, - ); + $inputForm['listfiles_search_for'] = Html::input( 'ilsearch', $this->mSearch, 'text', + array( + 'size' => '40', + 'maxlength' => '255', + 'id' => 'mw-ilsearch', + ) ); } - - $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'; + $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"; } function getTableClass() { diff --git a/includes/specials/SpecialListusers.php b/includes/specials/SpecialListusers.php index 431e6c8d56..b1ff6ea705 100644 --- a/includes/specials/SpecialListusers.php +++ b/includes/specials/SpecialListusers.php @@ -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( 'wpUsername' ); + $un = $request->getText( 'username' ); } elseif ( count( $parms ) == 2 ) { $this->requestedGroup = $parms[0]; $un = $parms[1]; } else { - $this->requestedGroup = $request->getVal( 'wpGroup' ); - $un = ( $par != '' ) ? $par : $request->getText( 'wpUsername' ); + $this->requestedGroup = $request->getVal( 'group' ); + $un = ( $par != '' ) ? $par : $request->getText( 'username' ); } if ( in_array( $this->requestedGroup, $symsForAll ) ) { $this->requestedGroup = ''; } - $this->editsOnly = $request->getBool( 'wpEditsOnly' ); - $this->creationSort = $request->getBool( 'wpCreationSort' ); + $this->editsOnly = $request->getBool( 'editsOnly' ); + $this->creationSort = $request->getBool( 'creationSort' ); $this->requestedUser = ''; if ( $un != '' ) { @@ -182,43 +182,41 @@ class UsersPager extends AlphabeticPager { return parent::getBody(); } - 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'; + 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' ) . '
'; + $out .= Xml::checkLabel( wfMsg('listusers-editsonly'), 'editsOnly', 'editsOnly', $this->editsOnly ); + $out .= ' '; + $out .= Xml::checkLabel( wfMsg('listusers-creationsort'), 'creationSort', 'creationSort', $this->creationSort ); + $out .= '
'; + + 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; } /** @@ -297,7 +295,7 @@ class SpecialListUsers extends SpecialPage { # getBody() first to check, if empty $usersbody = $up->getBody(); - $s = $up->buildHTMLForm(); + $s = $up->getPageHeader(); if( $usersbody ) { $s .= $up->getNavigationBar(); $s .= Html::rawElement( 'ul', array(), $usersbody ); diff --git a/includes/specials/SpecialNewimages.php b/includes/specials/SpecialNewimages.php index f95748a58c..dbf354d5f6 100644 --- a/includes/specials/SpecialNewimages.php +++ b/includes/specials/SpecialNewimages.php @@ -30,15 +30,16 @@ class SpecialNewFiles extends IncludableSpecialPage { $this->setHeaders(); $this->outputHeader(); - $out = $this->getOutput(); $pager = new NewFilesPager( $this->getContext(), $par ); if ( !$this->including() ) { - $out->addHTML( $pager->buildHTMLForm() ); + $form = $pager->getForm(); + $form->prepareForm(); + $form->displayForm( '' ); } - $out->addHTML( $pager->getBody() ); + $this->getOutput()->addHTML( $pager->getBody() ); if ( !$this->including() ) { - $out->addHTML( $pager->getNavigationBar() ); + $this->getOutput()->addHTML( $pager->getNavigationBar() ); } } } @@ -124,7 +125,7 @@ class NewFilesPager extends ReverseChronologicalPager { ); } - protected function getHTMLFormFields() { + function getForm() { global $wgMiserMode; $fields = array( @@ -137,6 +138,17 @@ class NewFilesPager extends ReverseChronologicalPager { 'type' => 'check', 'label' => wfMessage( 'showhidebots', wfMsg( 'show' ) ), 'name' => 'showbots', + # 'default' => $this->getRequest()->getBool( 'showbots', 0 ), + ), + 'limit' => array( + 'type' => 'hidden', + 'default' => $this->getRequest()->getText( 'limit' ), + 'name' => 'limit', + ), + 'offset' => array( + 'type' => 'hidden', + 'default' => $this->getRequest()->getText( 'offset' ), + 'name' => 'offset', ), ); @@ -144,14 +156,12 @@ class NewFilesPager extends ReverseChronologicalPager { unset( $fields['like'] ); } - return $fields; - } - - protected function getHTMLFormLegend() { - return 'newimages-legend'; - } + $form = new HTMLForm( $fields, $this->getContext() ); + $form->setTitle( $this->getTitle() ); + $form->setSubmitText( wfMsg( 'ilsubmit' ) ); + $form->setMethod( 'get' ); + $form->setWrapperLegend( wfMsg( 'newimages-legend' ) ); - protected function getHTMLFormSubmit() { - return 'ilsubmit'; + return $form; } } diff --git a/includes/specials/SpecialProtectedtitles.php b/includes/specials/SpecialProtectedtitles.php index 17d3016cb7..982feb661b 100644 --- a/includes/specials/SpecialProtectedtitles.php +++ b/includes/specials/SpecialProtectedtitles.php @@ -28,6 +28,9 @@ */ class SpecialProtectedtitles extends SpecialPage { + protected $IdLevel = 'level'; + protected $IdType = 'type'; + public function __construct() { parent::__construct( 'Protectedtitles' ); } @@ -41,8 +44,16 @@ class SpecialProtectedtitles extends SpecialPage { Title::purgeExpiredRestrictions(); } - $pager = new ProtectedTitlesPager( $this ); - $this->getOutput()->addHTML( $pager->buildHTMLForm() ); + $request = $this->getRequest(); + $type = $request->getVal( $this->IdType ); + $level = $request->getVal( $this->IdLevel ); + $sizetype = $request->getVal( 'sizetype' ); + $size = $request->getIntOrNull( 'size' ); + $NS = $request->getIntOrNull( 'namespace' ); + + $pager = new ProtectedTitlesPager( $this, array(), $type, $level, $NS, $sizetype, $size ); + + $this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level ) ); if ( $pager->getNumRows() ) { $s = $pager->getNavigationBar(); @@ -59,7 +70,6 @@ class SpecialProtectedtitles extends SpecialPage { /** * Callback function to output a restriction * - * @param $row * @return string */ function formatRow( $row ) { @@ -97,30 +107,89 @@ class SpecialProtectedtitles extends SpecialPage { return '
  • ' . $lang->specialList( $link, implode( $description_items, ', ' ) ) . "
  • \n"; } -} -/** - * @todo document - * @ingroup Pager - */ -class ProtectedTitlesPager extends AlphabeticPager { /** - * @var SpecialProtectedtitles + * @param $namespace Integer: + * @param $type string + * @param $level string + * @private */ - public $mForm; + function showOptions( $namespace, $type='edit', $level ) { + global $wgScript; + $action = htmlspecialchars( $wgScript ); + $title = $this->getTitle(); + $special = htmlspecialchars( $title->getPrefixedDBkey() ); + return "
    \n" . + '
    ' . + Xml::element( 'legend', array(), wfMsg( 'protectedtitles' ) ) . + Html::hidden( 'title', $special ) . " \n" . + $this->getNamespaceMenu( $namespace ) . " \n" . + $this->getLevelMenu( $level ) . " \n" . + " " . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . + "
    "; + } /** - * @var array + * Prepare the namespace filter drop-down; standard namespace + * selector, sans the MediaWiki namespace + * + * @param $namespace Mixed: pre-select namespace + * @return string */ - public $mConds; + function getNamespaceMenu( $namespace = null ) { + return Xml::label( wfMsg( 'namespace' ), 'namespace' ) + . ' ' + . Xml::namespaceSelector( $namespace, '' ); + } /** - * @param $form SpecialProtectedtitles - * @param $conds array + * @return string Formatted HTML + * @private */ - function __construct( $form, $conds = array() ) { + function getLevelMenu( $pr_level ) { + global $wgRestrictionLevels; + + $m = array( wfMsg('restriction-level-all') => 0 ); // Temporary array + $options = array(); + + // First pass to load the log names + foreach( $wgRestrictionLevels as $type ) { + if ( $type !='' && $type !='*') { + $text = wfMsg("restriction-level-$type"); + $m[$text] = $type; + } + } + // Is there only one level (aside from "all")? + if( count($m) <= 2 ) { + return ''; + } + // Third pass generates sorted XHTML content + foreach( $m as $text => $type ) { + $selected = ($type == $pr_level ); + $options[] = Xml::option( $text, $type, $selected ); + } + + return + Xml::label( wfMsg('restriction-level') , $this->IdLevel ) . ' ' . + Xml::tags( 'select', + array( 'id' => $this->IdLevel, 'name' => $this->IdLevel ), + implode( "\n", $options ) ); + } +} + +/** + * @todo document + * @ingroup Pager + */ +class ProtectedTitlesPager extends AlphabeticPager { + public $mForm, $mConds; + + function __construct( $form, $conds = array(), $type, $level, $namespace, $sizetype='', $size=0 ) { $this->mForm = $form; $this->mConds = $conds; + $this->level = $level; + $this->namespace = $namespace; + $this->size = intval($size); parent::__construct( $form->getContext() ); } @@ -156,14 +225,10 @@ class ProtectedTitlesPager extends AlphabeticPager { function getQueryInfo() { $conds = $this->mConds; $conds[] = 'pt_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() ); - - if ( $this->mHTMLForm->getVal( 'Level' ) ) { - $conds['pt_create_perm'] = $this->mHTMLForm->getVal( 'Level' ); - } - if ( $this->mHTMLForm->getVal( 'Namespace' ) !== '' ) { - $conds['pt_namespace'] = $this->mHTMLForm->getVal( 'Namespace' ); - } - + if( $this->level ) + $conds['pt_create_perm'] = $this->level; + if( !is_null($this->namespace) ) + $conds[] = 'pt_namespace=' . $this->mDb->addQuotes( $this->namespace ); return array( 'tables' => 'protected_titles', 'fields' => 'pt_namespace,pt_title,pt_create_perm,pt_expiry,pt_timestamp', @@ -174,28 +239,5 @@ class ProtectedTitlesPager extends AlphabeticPager { function getIndexField() { return 'pt_timestamp'; } - - protected function getHTMLFormFields() { - return array( - 'Namespace' => array( - 'type' => 'namespaces', - 'label-message' => 'namespace', - ), - 'Level' => array( - 'type' => 'restrictionlevels', - 'label-message' => 'restriction-level', - ), - ); - } - - protected function getHTMLFormSubmit() { - return 'allpagessubmit'; - } - - protected function getHTMLFormLegend() { - return 'protectedtitles'; - } - - }