r104318 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104317‎ | r104318 | r104319 >
Date:22:15, 26 November 2011
Author:johnduhart
Status:resolved (Comments)
Tags:
Comment:
Bug 32603 - limit option is missing on Special:BlockList

Okay so essentially this is a workaround for a 1.18 release blocker, and is not a real solution. The real solution is to rework the Pager class to work with HTMLForm and then move the form for BlockList into the BlockListPager. I'll have that done before 1.19.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialBlockList.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialBlockList.php
@@ -43,6 +43,7 @@
4444 $this->setHeaders();
4545 $this->outputHeader();
4646 $out = $this->getOutput();
 47+ $lang = $this->getLanguage();
4748 $out->setPageTitle( $this->msg( 'ipblocklist' ) );
4849 $out->addModuleStyles( 'mediawiki.special' );
4950
@@ -80,6 +81,19 @@
8182 ),
8283 'flatlist' => true,
8384 ),
 85+ 'Limit' => array(
 86+ 'class' => 'HTMLBlockedUsersItemSelect',
 87+ 'label-message' => 'table_pager_limit_label',
 88+ 'options' => array(
 89+ $lang->formatNum( 20 ) => 20,
 90+ $lang->formatNum( 50 ) => 50,
 91+ $lang->formatNum( 100 ) => 100,
 92+ $lang->formatNum( 250 ) => 250,
 93+ $lang->formatNum( 500 ) => 500,
 94+ ),
 95+ 'name' => 'limit',
 96+ 'default' => 50,
 97+ ),
8498 );
8599 $form = new HTMLForm( $fields, $this->getContext() );
86100 $form->setMethod( 'get' );
@@ -434,3 +448,31 @@
435449 wfProfileOut( __METHOD__ );
436450 }
437451 }
 452+
 453+/**
 454+ * Items per page dropdown. Essentially a crap workaround for bug 32603.
 455+ *
 456+ * @todo Do not release 1.19 with this.
 457+ */
 458+class HTMLBlockedUsersItemSelect extends HTMLSelectField {
 459+ /**
 460+ * Basically don't do any validation. If it's a number that's fine. Also,
 461+ * add it to the list if it's not there already
 462+ *
 463+ * @param $value
 464+ * @param $alldata
 465+ * @return bool
 466+ */
 467+ function validate( $value, $alldata ) {
 468+ if ( $value == '' ) {
 469+ return true;
 470+ }
 471+
 472+ if ( !in_array( $value, $this->mParams['options'] ) ) {
 473+ $this->mParams['options'][ $this->mParent->getLanguage()->formatNum( $value ) ] = intval($value);
 474+ }
 475+
 476+ return true;
 477+ }
 478+
 479+}
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r104322Followup r104318, add the new class to the Autoloaderjohnduhart23:05, 26 November 2011
r104350Followup r104318, sort the options in the limit dropdownjohnduhart17:31, 27 November 2011
r104353This is the rework I was talking about in r104318 for 1.19. Instead of having...johnduhart18:23, 27 November 2011
r104486MFT r104318, r104322, r104350reedy21:03, 28 November 2011
r104487MFT r104486, Merges r104318, r104322, r104350reedy21:05, 28 November 2011
r105341Followup r104350, r104318: only allow custom limits through if they're valid ...brion19:45, 6 December 2011

Comments

#Comment by Reedy (talk | contribs)   22:38, 26 November 2011

Best practises suggest to add everything to the AutoLoader :)

#Comment by Johnduhart (talk | contribs)   23:02, 26 November 2011

True.

#Comment by Duplicatebug (talk | contribs)   17:05, 27 November 2011

Using something like TablePager::getLimitSelect is better, yes. It is possible to sort that array, so the user specifiy limit is not at the end? Thanks.

#Comment by Johnduhart (talk | contribs)   17:21, 27 November 2011

The reason I didn't use that is because that returns raw HTML, and doesn't work with HTMLForm. This is a temporary workaround so 1.18 can be shipped. As for the the userspecified limit, I'll follow up on that.

#Comment by Brion VIBBER (talk | contribs)   19:55, 6 December 2011

Seems to work for now; poked a little followup in r105341 to improve validation.

Status & tagging log