r78334 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78333‎ | r78334 | r78335 >
Date:22:14, 13 December 2010
Author:yaron
Status:deferred
Tags:
Comment:
Global $sfgAutocompleteMappings variable removed, replaced by new 'autocompletesettings' attribute within form inputs themselves
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php
@@ -373,7 +373,6 @@
374374
375375 global $sfgTabIndex, $sfgFieldNum, $wgOut, $sfgScriptPath, $wgJsMimeType;
376376 global $smwgScriptPath, $smwgJqUIAutoIncluded;
377 - global $sfgAutocompleteMappings;
378377
379378 $autocomplete_field_type = "";
380379 $autocompletion_source = "";
@@ -401,10 +400,8 @@
402401
403402 $input_id = "input_" . $sfgFieldNum;
404403
405 - $options_str_key = str_replace( "'", "\'", $autocompletion_source );
406 - $sfgAutocompleteMappings[$sfgFieldNum] = $options_str_key;
407 -
408404 $values = SFUtils::getAutocompleteValues($autocompletion_source, $autocomplete_field_type );
 405+ $autocompletion_source = str_replace( "'", "\'", $autocompletion_source );
409406
410407 /*adding code for displaying dropdown of autocomplete values*/
411408
@@ -412,7 +409,7 @@
413410 if ($is_mandatory) { $divClass .= " mandatory"; }
414411 $text =<<<END
415412 <div class="$divClass">
416 - <select id="input_$sfgFieldNum" name="$input_name" class="$className" tabindex="$sfgTabIndex">
 413+ <select id="input_$sfgFieldNum" name="$input_name" class="$className" tabindex="$sfgTabIndex" autocompletesettings="$autocompletion_source">
417414 <option value="$cur_value"></option>
418415
419416 END;
@@ -450,7 +447,7 @@
451448 return SFDropdownInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args );
452449
453450 global $sfgTabIndex, $sfgFieldNum, $sfgScriptPath, $wgJsMimeType, $smwgScriptPath, $smwgJqUIAutoIncluded;
454 - global $sfgAutocompleteMappings, $sfgAutocompleteDataTypes, $sfgAutocompleteValues;
 451+ global $sfgAutocompleteDataTypes, $sfgAutocompleteValues;
455452
456453 $className = ( $is_mandatory ) ? "autocompleteInput mandatoryField" : "autocompleteInput createboxInput";
457454 if ( array_key_exists( 'class', $other_args ) )
@@ -464,6 +461,22 @@
465462 }
466463 }
467464 $input_id = "input_" . $sfgFieldNum;
 465+
 466+ // Set autocomplete-settings attribute, and delimiter value (it's needed
 467+ // also for the 'uploadable' link, if there is one).
 468+ $autocompleteSettings = $autocompletion_source;
 469+ $is_list = ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] == true );
 470+ if ( $is_list ) {
 471+ $autocompleteSettings .= ",list";
 472+ if ( array_key_exists( 'delimiter', $other_args ) ) {
 473+ $delimiter = $other_args['delimiter'];
 474+ $autocompleteSettings .= "," . $delimiter;
 475+ } else {
 476+ $delimiter = ",";
 477+ }
 478+ } else {
 479+ $delimiter = null;
 480+ }
468481 if ( array_key_exists( 'input_type', $other_args ) && $other_args['input_type'] == "textarea" ) {
469482
470483 $rows = $other_args['rows'];
@@ -480,6 +493,7 @@
481494 'rows' => $rows,
482495 'cols' => $cols,
483496 'class' => $className,
 497+ 'autocompletesettings' => $autocompleteSettings,
484498 );
485499 if ( $is_disabled ) {
486500 $textarea_attrs['disabled'] = 'disabled';
@@ -512,6 +526,7 @@
513527 'size' => $size,
514528 'class' => $className,
515529 'tabindex' => $sfgTabIndex,
 530+ 'autocompletesettings' => $autocompleteSettings,
516531 );
517532 if ( $is_disabled ) {
518533 $inputAttrs['disabled'] = 'disabled';
@@ -521,17 +536,6 @@
522537 }
523538 $text = "\n\t" . Xml::element( 'input', $inputAttrs ) . "\n";
524539 }
525 - // is_list and delimiter variables - needed later
526 - $is_list = ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] == true );
527 - if ( $is_list ) {
528 - if ( array_key_exists( 'delimiter', $other_args ) ) {
529 - $delimiter = $other_args['delimiter'];
530 - } else {
531 - $delimiter = ",";
532 - }
533 - } else {
534 - $delimiter = null;
535 - }
536540 if ( array_key_exists( 'is_uploadable', $other_args ) && $other_args['is_uploadable'] == true ) {
537541 if ( array_key_exists( 'default filename', $other_args ) ) {
538542 $default_filename = $other_args['default filename'];
@@ -545,20 +549,12 @@
546550 if ( $is_mandatory ) { $spanClass .= " mandatoryFieldSpan"; }
547551 $text = "\n" . Xml::tags( 'span', array( 'class' => $spanClass ), $text );
548552
549 - $options_str_key = $autocompletion_source;
550 - if ( $is_list ) {
551 - $options_str_key .= ",list";
552 - if ( $delimiter != "," ) {
553 - $options_str_key .= "," . $delimiter;
554 - }
555 - }
556 - $sfgAutocompleteMappings[$sfgFieldNum] = $options_str_key;
557553 if ( array_key_exists( 'remote autocompletion', $other_args ) &&
558554 $other_args['remote autocompletion'] == true ) {
559 - $sfgAutocompleteDataTypes[$options_str_key] = $autocomplete_field_type;
 555+ $sfgAutocompleteDataTypes[$autocompleteSettings] = $autocomplete_field_type;
560556 } elseif ( $autocompletion_source != '' ) {
561557 $autocomplete_values = SFUtils::getAutocompleteValues( $autocompletion_source, $autocomplete_field_type );
562 - $sfgAutocompleteValues[$options_str_key] = $autocomplete_values;
 558+ $sfgAutocompleteValues[$autocompleteSettings] = $autocomplete_values;
563559 }
564560 return $text;
565561 }

Status & tagging log