r83588 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83587‎ | r83588 | r83589 >
Date:15:33, 9 March 2011
Author:yaron
Status:deferred
Tags:
Comment:
Fixed autocompletion in regular text inputs, for both old and new syntax
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php
@@ -186,6 +186,11 @@
187187 public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
188188 global $sfgTabIndex, $sfgFieldNum;
189189
 190+ // For backward compatibility with pre-SF-2.1 forms
 191+ if ( array_key_exists( 'autocomplete field type', $other_args ) ) {
 192+ return SFTextWithAutocompleteInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args );
 193+ }
 194+
190195 $className = "createboxInput";
191196 if ( $is_mandatory ) {
192197 $className .= " mandatoryField";
@@ -772,7 +777,10 @@
773778 }
774779
775780 public static function getAutocompletionTypeAndSource( $field_args ) {
776 - if ( array_key_exists( 'values from property', $field_args ) ||
 781+ if ( array_key_exists( 'autocomplete field type', $field_args ) ) {
 782+ $autocompleteFieldType = $field_args['autocomplete field type'];
 783+ $autocompletionSource = $field_args['autocompletion source'];
 784+ } elseif ( array_key_exists( 'values from property', $field_args ) ||
777785 array_key_exists( 'semantic_property', $field_args ) ) {
778786 if ( array_key_exists( 'values from property', $field_args ) ) {
779787 $autocompletionSource = $field_args['values from property'];
@@ -804,9 +812,6 @@
805813 global $sfgFieldNum;
806814 $autocompleteFieldType = 'values';
807815 $autocompletionSource = "values-$sfgFieldNum";
808 - } elseif ( array_key_exists( 'autocomplete field type', $field_args ) ) {
809 - $autocompleteFieldType = $field_args['autocomplete field type'];
810 - $autocompletionSource = $field_args['autocompletion source'];
811816 } else {
812817 $autocompleteFieldType = null;
813818 $autocompletionSource = null;
@@ -846,7 +851,10 @@
847852 $field_args['remote autocompletion'] == true ) {
848853 $remoteDataType = $autocompleteFieldType;
849854 } elseif ( $autocompletionSource != '' ) {
850 - if ( $autocompleteFieldType == 'values' ) {
 855+ if ( array_key_exists( 'possible_values', $field_args ) &&
 856+ count( $field_args['possible_values'] ) > 0 ) {
 857+ $autocompleteValues = $field_args['possible_values'];
 858+ } elseif ( $autocompleteFieldType == 'values' ) {
851859 $autocompleteValues = explode( ',', $field_args['values'] );
852860 } else {
853861 $autocompleteValues = SFUtils::getAutocompleteValues( $autocompletionSource, $autocompleteFieldType );