r83613 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83612‎ | r83613 | r83614 >
Date:22:46, 9 March 2011
Author:yaron
Status:deferred
Tags:
Comment:
Another attempted fix for autocompletion
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php
@@ -777,23 +777,14 @@
778778 }
779779
780780 public static function getAutocompletionTypeAndSource( $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 ) ||
785 - array_key_exists( 'semantic_property', $field_args ) ) {
786 - if ( array_key_exists( 'values from property', $field_args ) ) {
787 - $autocompletionSource = $field_args['values from property'];
788 - } else { // if ( array_key_exists( 'semantic_property', $field_args ) ) {
789 - $autocompletionSource = $field_args['semantic_property'];
790 - }
 781+ if ( array_key_exists( 'values from property', $field_args ) ) {
 782+ $autocompletionSource = $field_args['values from property'];
791783 $propValue = SMWPropertyValue::makeUserProperty( $autocompletionSource );
792784 if ( $propValue->getPropertyTypeID() == '_wpg' ) {
793785 $autocompleteFieldType = 'relation';
794786 } else {
795787 $autocompleteFieldType = 'attribute';
796788 }
797 -
798789 } elseif ( array_key_exists( 'values from category', $field_args ) ) {
799790 $autocompleteFieldType = 'category';
800791 $autocompletionSource = $field_args['values from category'];
@@ -812,6 +803,17 @@
813804 global $sfgFieldNum;
814805 $autocompleteFieldType = 'values';
815806 $autocompletionSource = "values-$sfgFieldNum";
 807+ } elseif ( array_key_exists( 'autocomplete field type', $field_args ) ) {
 808+ $autocompleteFieldType = $field_args['autocomplete field type'];
 809+ $autocompletionSource = $field_args['autocompletion source'];
 810+ } elseif ( array_key_exists( 'semantic_property', $field_args ) ) {
 811+ $autocompletionSource = $field_args['semantic_property'];
 812+ $propValue = SMWPropertyValue::makeUserProperty( $autocompletionSource );
 813+ if ( $propValue->getPropertyTypeID() == '_wpg' ) {
 814+ $autocompleteFieldType = 'relation';
 815+ } else {
 816+ $autocompleteFieldType = 'attribute';
 817+ }
816818 } else {
817819 $autocompleteFieldType = null;
818820 $autocompletionSource = null;
@@ -851,6 +853,7 @@
852854 $field_args['remote autocompletion'] == true ) {
853855 $remoteDataType = $autocompleteFieldType;
854856 } elseif ( $autocompletionSource != '' ) {
 857+ // @TODO - that count() check shouldn't be necessary
855858 if ( array_key_exists( 'possible_values', $field_args ) &&
856859 count( $field_args['possible_values'] ) > 0 ) {
857860 $autocompleteValues = $field_args['possible_values'];