r42696 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42695‎ | r42696 | r42697 >
Date:22:52, 27 October 2008
Author:tparscal
Status:old (Comments)
Tags:
Comment:
Added default values for parameters.
Modified paths:
  • /trunk/extensions/InputBox/InputBox.classes.php (modified) (history)

Diff [purge]

Index: trunk/extensions/InputBox/InputBox.classes.php
@@ -353,36 +353,38 @@
354354 $values[ strtolower( trim( $name ) ) ] = trim( $value );
355355 }
356356
357 - // Go through and set all the options we found
 357+ // Build list of options, with local member names and deafults
358358 $options = array(
359 - 'type' => 'mType',
360 - 'width' => 'mWidth',
361 - 'preload' => 'mPreload',
362 - 'editintro' => 'mEditIntro',
363 - 'break' => 'mBR',
364 - 'default' => 'mDefaultText',
365 - 'bgcolor' => 'mBGColor',
366 - 'buttonlabel' => 'mButtonLabel',
367 - 'searchbuttonlabel' => 'mSearchButtonLabel',
368 - 'fulltextbutton' => 'mFullTextButton',
369 - 'namespaces' => '_namespaces',
370 - 'labeltext' => 'mLabelText',
371 - 'hidden' => 'mHidden',
372 - 'id' => 'mID',
373 - 'inline' => 'mInline'
 359+ 'type' => array( 'mType', '' ),
 360+ 'width' => array( 'mWidth', 50 ),
 361+ 'preload' => array( 'mPreload', '' ),
 362+ 'editintro' => array( 'mEditIntro', '' ),
 363+ 'break' => array( 'mBR', 'yes' ),
 364+ 'default' => array( 'mDefaultText', '' ),
 365+ 'bgcolor' => array( 'mBGColor', 'transparent' ),
 366+ 'buttonlabel' => array( 'mButtonLabel', '' ),
 367+ 'searchbuttonlabel' => array( 'mSearchButtonLabel', '' ),
 368+ 'fulltextbutton' => array( 'mFullTextButton', '' ),
 369+ 'namespaces' => array( '_namespaces', '' ),
 370+ 'labeltext' => array( 'mLabelText', '' ),
 371+ 'hidden' => array( 'mHidden', '' ),
 372+ 'id' => array( 'mID', '' ),
 373+ 'inline' => array( 'mInline', false )
374374 );
375375 foreach ( $options as $name => $var ) {
376376 if ( isset( $values[$name] ) ) {
377 - $this->$var = $values[$name];
 377+ $this->$var[0] = $values[$name];
 378+ } else {
 379+ $this->$var[0] = $var[1];
378380 }
379381 }
380 -
 382+
381383 // Insert a line break if configured to do so
382384 $this->mBR = ( strtolower( $this->mBR ) == "no" ) ? '' : '<br />';
383385
384386 // Validate the width; make sure it's a valid, positive integer
385387 $this->mWidth = intval( $this->mWidth <= 0 ? 50 : $this->mWidth );
386 -
 388+
387389 wfProfileOut( __METHOD__ );
388390 }
389391

Follow-up revisions

RevisionCommit summaryAuthorDate
r43439Cleanup for r42696: use class defaultsaaron08:50, 13 November 2008

Comments

#Comment by Aaron Schulz (talk | contribs)   21:11, 31 October 2008

This somehow looks cryptic.

#Comment by Tim Starling (talk | contribs)   01:21, 4 November 2008

Revert and use class variable defaults instead.

#Comment by Aaron Schulz (talk | contribs)   08:50, 13 November 2008

Should be OK by 43493

Status & tagging log