https://www.mediawiki.org/wiki/Special:Code/MediaWiki/115374
Revision: 115374
Author: yaron
Date: 2012-05-14 14:38:27 +0000 (Mon, 14 May 2012)
Log Message:
-----------
Changed code to fully use new structure for form inputs, making use of
getHtmlText() instead of getHTML(), thanks to patch from Yury Katkov (this
should eventually be done for all the SF form inputs)
Modified Paths:
--------------
trunk/extensions/SemanticForms/includes/forminputs/SF_ListBoxInput.php
Modified: trunk/extensions/SemanticForms/includes/forminputs/SF_ListBoxInput.php
===================================================================
--- trunk/extensions/SemanticForms/includes/forminputs/SF_ListBoxInput.php
2012-05-14 14:24:47 UTC (rev 115373)
+++ trunk/extensions/SemanticForms/includes/forminputs/SF_ListBoxInput.php
2012-05-14 14:38:27 UTC (rev 115374)
@@ -17,35 +17,48 @@
return 'listbox';
}
- public static function getHTML( $cur_value, $input_name, $is_mandatory,
$is_disabled, $other_args ) {
+ public static function getParameters() {
+ $params = parent::getParameters();
+ $params[] = array(
+ 'name' => 'size',
+ 'type' => 'int',
+ 'description' => wfMsg( 'sf_forminputs_listboxsize' )
+ );
+ return $params;
+ }
+
+ /**
+ * Returns the HTML code to be included in the output page for this
input.
+ */
+ public function getHtmlText() {
global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect;
- $className = ( $is_mandatory ) ? 'mandatoryField' :
'createboxInput';
- if ( array_key_exists( 'class', $other_args ) ) {
- $className .= ' ' . $other_args['class'];
+ $className = ( $this->mIsMandatory ) ? 'mandatoryField' :
'createboxInput';
+ if ( array_key_exists( 'class', $this->mOtherArgs ) ) {
+ $className .= ' ' . $this->mOtherArgs['class'];
}
$input_id = "input_$sfgFieldNum";
// get list delimiter - default is comma
- if ( array_key_exists( 'delimiter', $other_args ) ) {
- $delimiter = $other_args['delimiter'];
+ if ( array_key_exists( 'delimiter', $this->mOtherArgs ) ) {
+ $delimiter = $this->mOtherArgs['delimiter'];
} else {
$delimiter = ',';
}
$cur_values = SFUtils::getValuesArray( $cur_value, $delimiter );
$className .= ' sfShowIfSelected';
- if ( ( $possible_values = $other_args['possible_values'] ) ==
null ) {
+ if ( ( $possible_values = $this->mOtherArgs['possible_values']
) == null ) {
$possible_values = array();
}
$optionsText = '';
foreach ( $possible_values as $possible_value ) {
if (
- array_key_exists( 'value_labels', $other_args )
&&
- is_array( $other_args['value_labels'] ) &&
- array_key_exists( $possible_value,
$other_args['value_labels'] )
+ array_key_exists( 'value_labels',
$this->mOtherArgs ) &&
+ is_array( $this->mOtherArgs['value_labels'] ) &&
+ array_key_exists( $possible_value,
$this->mOtherArgs['value_labels'] )
)
{
- $optionLabel =
$other_args['value_labels'][$possible_value];
+ $optionLabel =
$this->mOtherArgs['value_labels'][$possible_value];
} else {
$optionLabel = $possible_value;
}
@@ -58,24 +71,24 @@
$selectAttrs = array(
'id' => $input_id,
'tabindex' => $sfgTabIndex,
- 'name' => $input_name . '[]',
+ 'name' => $this->mInputName . '[]',
'class' => $className,
'multiple' => 'multiple'
);
- if ( array_key_exists( 'size', $other_args ) ) {
- $selectAttrs['size'] = $other_args['size'];
+ if ( array_key_exists( 'size', $this->mOtherArgs ) ) {
+ $selectAttrs['size'] = $this->mOtherArgs['size'];
}
- if ( $is_disabled ) {
+ if ( $this->mIsDisabled ) {
$selectAttrs['disabled'] = 'disabled';
}
$text = Html::rawElement( 'select', $selectAttrs, $optionsText
);
- $text .= Html::hidden( $input_name . '[is_list]', 1 );
- if ( $is_mandatory ) {
+ $text .= Html::hidden( $this->mInputName . '[is_list]', 1 );
+ if ( $this->mIsMandatory ) {
$text = Html::rawElement( 'span', array( 'class' =>
'inputSpan mandatoryFieldSpan' ), $text );
}
- if ( array_key_exists( 'show on select', $other_args ) ) {
- foreach ( $other_args['show on select'] as $div_id =>
$options ) {
+ if ( array_key_exists( 'show on select', $this->mOtherArgs ) ) {
+ foreach ( $this->mOtherArgs['show on select'] as
$div_id => $options ) {
if ( array_key_exists( $input_id,
$sfgShowOnSelect ) ) {
$sfgShowOnSelect[$input_id][] = array(
$options, $div_id );
} else {
@@ -86,27 +99,4 @@
return $text;
}
-
- public static function getParameters() {
- $params = parent::getParameters();
- $params[] = array(
- 'name' => 'size',
- 'type' => 'int',
- 'description' => wfMsg( 'sf_forminputs_listboxsize' )
- );
- return $params;
- }
-
- /**
- * Returns the HTML code to be included in the output page for this
input.
- */
- public function getHtmlText() {
- return self::getHTML(
- $this->mCurrentValue,
- $this->mInputName,
- $this->mIsMandatory,
- $this->mIsDisabled,
- $this->mOtherArgs
- );
- }
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs