r63520 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63519‎ | r63520 | r63521 >
Date:23:06, 9 March 2010
Author:yaron
Status:deferred
Tags:
Comment:
Various fixes - some unused field parameters are no longer passed in, to avoid complaints from Semantic Maps form inputs
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.inc
@@ -96,7 +96,7 @@
9797 $size = 35;
9898 }
9999 if ($validation_type_str != '') {
100 - if ($other_args['part_of_multiple']) {
 100+ if (array_key_exists('part_of_multiple', $other_args)) {
101101 $sfgJSValidationCalls[] = "validate_type_of_multiple_fields($sfgFieldNum, '$validation_type_str')";
102102 } else {
103103 $sfgJSValidationCalls[] = "validate_field_type('$input_id', '$validation_type_str', '$info_id')";
@@ -150,8 +150,8 @@
151151 $info_id = "info_$sfgFieldNum";
152152 $disabled_text = ($is_disabled) ? "disabled" : "";
153153 $javascript_text = '';
154 - $return_js_text;
155 - if (count($other_args['show on select']) > 0 ) {
 154+ $return_js_text = '';
 155+ if (array_key_exists('show on select', $other_args)) {
156156 $javascript_text = 'onChange="';
157157 foreach ($other_args['show on select'] as $div_id => $options) {
158158 $options_str = implode("', '", $options);
@@ -229,7 +229,7 @@
230230
231231 $javascript_text = '';
232232 $return_js_text;
233 - if (count($other_args['show on select']) > 0 ) {
 233+ if (array_key_exists('show on select', $other_args)) {
234234 $javascript_text = 'onChange="';
235235 foreach ($other_args['show on select'] as $div_id => $options) {
236236 $options_str = implode("', '", $options);
@@ -322,11 +322,13 @@
323323 END;
324324
325325 $return_js_text = '';
326 - if (count($other_args['show on select']) > 0) {
 326+ if (array_key_exists('show on select', $other_args)) {
327327 foreach ($other_args['show on select'] as $div_id => $options) {
328328 $cur_input_ids = array();
329329 foreach ($options as $option) {
330 - $cur_input_ids[] = $enum_input_ids[$option];
 330+ if (array_key_exists($option, $enum_input_ids)) {
 331+ $cur_input_ids[] = $enum_input_ids[$option];
 332+ }
331333 }
332334 $options_str = "['" . implode("', '", $cur_input_ids) . "']";
333335 $cur_js_text = "showIfChecked($options_str, '$div_id'); ";
@@ -533,7 +535,7 @@
534536 $input_id = "input_$sfgFieldNum";
535537 $info_id = "info_$sfgFieldNum";
536538 // add to validation calls
537 - if ($other_args['part_of_multiple']) {
 539+ if (array_key_exists('part_of_multiple', $other_args)) {
538540 $sfgJSValidationCalls[] = "validate_type_of_multiple_fields($sfgFieldNum, 'date')";
539541 } else {
540542 $sfgJSValidationCalls[] = "validate_field_type('$input_id', 'date', '$info_id')";
@@ -656,7 +658,7 @@
657659 $check_set = false;
658660 $javascript_text = '';
659661 $return_js_text = '';
660 - if (count($other_args['show on select']) > 0) {
 662+ if (array_key_exists('show on select', $other_args)) {
661663 $javascript_text = 'onClick="';
662664 foreach($other_args['show on select'] as $div_id => $options) {
663665 $options_str = implode("', '", $options);
@@ -718,7 +720,7 @@
719721 $input_id = "input_$sfgFieldNum";
720722 $disabled_text = ($is_disabled) ? "disabled" : "";
721723 $return_js_text = '';
722 - if (count($other_args['show on select'] > 0)) {
 724+ if (array_key_exists('show on select', $other_args)) {
723725 $div_id = key($other_args['show on select']);
724726 $this_js_text = "showIfChecked(['$input_id'], '$div_id');";
725727 // we use addClickHandler(), instead of adding the Javascript via
Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc
@@ -618,9 +618,11 @@
619619 }
620620 }
621621 }
622 - } // for
623 - $field_args['part_of_multiple'] = $allow_multiple;
624 - $field_args['show on select'] = $show_on_select;
 622+ } // end for
 623+ if ($allow_multiple)
 624+ $field_args['part_of_multiple'] = $allow_multiple;
 625+ if (count($show_on_select) > 0)
 626+ $field_args['show on select'] = $show_on_select;
625627 // get the value from the request, if it's there, and if it's not
626628 // an array
627629 $escaped_field_name = str_replace("'", "\'", $field_name);
@@ -847,7 +849,7 @@
848850 wfRunHooks('sfCreateFormField', array(&$form_field, &$cur_value, false));
849851 // if this is not part of a 'multiple' template, increment the
850852 // global tab index (used for correct tabbing)
851 - if (! $field_args['part_of_multiple'])
 853+ if (! array_key_exists('part_of_multiple', $field_args))
852854 $sfgTabIndex++;
853855 // increment the global field number regardless
854856 $sfgFieldNum++;

Status & tagging log