Added default values for parameters.

This commit is contained in:
Trevor Parscal 2008-10-27 22:52:05 +00:00
parent fe52f15a5b
commit 97020945cb

View file

@ -353,36 +353,38 @@ class InputBox {
$values[ strtolower( trim( $name ) ) ] = trim( $value ); $values[ strtolower( trim( $name ) ) ] = trim( $value );
} }
// Go through and set all the options we found // Build list of options, with local member names and deafults
$options = array( $options = array(
'type' => 'mType', 'type' => array( 'mType', '' ),
'width' => 'mWidth', 'width' => array( 'mWidth', 50 ),
'preload' => 'mPreload', 'preload' => array( 'mPreload', '' ),
'editintro' => 'mEditIntro', 'editintro' => array( 'mEditIntro', '' ),
'break' => 'mBR', 'break' => array( 'mBR', 'yes' ),
'default' => 'mDefaultText', 'default' => array( 'mDefaultText', '' ),
'bgcolor' => 'mBGColor', 'bgcolor' => array( 'mBGColor', 'transparent' ),
'buttonlabel' => 'mButtonLabel', 'buttonlabel' => array( 'mButtonLabel', '' ),
'searchbuttonlabel' => 'mSearchButtonLabel', 'searchbuttonlabel' => array( 'mSearchButtonLabel', '' ),
'fulltextbutton' => 'mFullTextButton', 'fulltextbutton' => array( 'mFullTextButton', '' ),
'namespaces' => '_namespaces', 'namespaces' => array( '_namespaces', '' ),
'labeltext' => 'mLabelText', 'labeltext' => array( 'mLabelText', '' ),
'hidden' => 'mHidden', 'hidden' => array( 'mHidden', '' ),
'id' => 'mID', 'id' => array( 'mID', '' ),
'inline' => 'mInline' 'inline' => array( 'mInline', false )
); );
foreach ( $options as $name => $var ) { foreach ( $options as $name => $var ) {
if ( isset( $values[$name] ) ) { if ( isset( $values[$name] ) ) {
$this->$var = $values[$name]; $this->$var[0] = $values[$name];
} else {
$this->$var[0] = $var[1];
} }
} }
// Insert a line break if configured to do so // Insert a line break if configured to do so
$this->mBR = ( strtolower( $this->mBR ) == "no" ) ? '' : '<br />'; $this->mBR = ( strtolower( $this->mBR ) == "no" ) ? '' : '<br />';
// Validate the width; make sure it's a valid, positive integer // Validate the width; make sure it's a valid, positive integer
$this->mWidth = intval( $this->mWidth <= 0 ? 50 : $this->mWidth ); $this->mWidth = intval( $this->mWidth <= 0 ? 50 : $this->mWidth );
wfProfileOut( __METHOD__ ); wfProfileOut( __METHOD__ );
} }