Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php |
— | — | @@ -188,11 +188,6 @@ |
189 | 189 | return SFTextWithAutocompleteInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
190 | 190 | } |
191 | 191 | |
192 | | - // If there are possible values specified, call the dropdown |
193 | | - // function. |
194 | | - if ( array_key_exists( 'possible_values', $other_args ) && $other_args['possible_values'] != null ) |
195 | | - return SFDropdownInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
196 | | - |
197 | 192 | global $sfgTabIndex, $sfgFieldNum; |
198 | 193 | |
199 | 194 | $className = "createboxInput"; |
— | — | @@ -610,20 +605,50 @@ |
611 | 606 | |
612 | 607 | static function setAutocompleteValues( $field_args ) { |
613 | 608 | global $sfgAutocompleteValues; |
614 | | - |
615 | | - $autocompletion_source = null; |
616 | | - if ( array_key_exists( 'autocomplete field type', $field_args ) ) { |
617 | | - $autocomplete_field_type = $field_args['autocomplete field type']; |
618 | | - $autocompletion_source = $field_args['autocompletion source']; |
619 | | - if ( $autocomplete_field_type != 'external_url' ) { |
620 | | - global $wgContLang; |
621 | | - $autocompletion_source = $wgContLang->ucfirst( $autocompletion_source ); |
| 609 | + |
| 610 | + if ( array_key_exists( 'values from property', $field_args ) ) { |
| 611 | + $autocompletionSource = $field_args['values from property']; |
| 612 | + $propValue = SMWPropertyValue::makeUserProperty( $autocompletionSource ); |
| 613 | + if ( $propValue->getPropertyTypeID() == '_wpg' ) { |
| 614 | + $autocompleteFieldType = 'relation'; |
| 615 | + } else { |
| 616 | + $autocompleteFieldType = 'attribute'; |
622 | 617 | } |
| 618 | + |
| 619 | + } elseif ( array_key_exists( 'values from category', $field_args ) ) { |
| 620 | + $autocompleteFieldType = 'category'; |
| 621 | + $autocompletionSource = $field_args['values from category']; |
| 622 | + } elseif ( array_key_exists( 'values from concept', $field_args ) ) { |
| 623 | + $autocompleteFieldType = 'concept'; |
| 624 | + $autocompletionSource = $field_args['values from concept']; |
| 625 | + } elseif ( array_key_exists( 'values from namespace', $field_args ) ) { |
| 626 | + $autocompleteFieldType = 'namespace'; |
| 627 | + $autocompletionSource = $field_args['values from namespace']; |
| 628 | + } elseif ( array_key_exists( 'values from url', $field_args ) ) { |
| 629 | + $autocompleteFieldType = 'external_url'; |
| 630 | + $autocompletionSource = $field_args['values from namespace']; |
| 631 | + // Autocompletion from URL is always done remotely. |
| 632 | + $field_args['remote autocompletion'] == true; |
| 633 | + } elseif ( array_key_exists( 'values', $field_args ) ) { |
| 634 | + global $sfgFieldNum; |
| 635 | + $autocompleteFieldType = 'values'; |
| 636 | + $autocompletionSource = "values-$sfgFieldNum"; |
| 637 | + } elseif ( array_key_exists( 'autocomplete field type', $field_args ) ) { |
| 638 | + $autocompleteFieldType = $field_args['autocomplete field type']; |
| 639 | + $autocompletionSource = $field_args['autocompletion source']; |
| 640 | + } else { |
| 641 | + $autocompleteFieldType = null; |
| 642 | + $autocompletionSource = null; |
623 | 643 | } |
624 | 644 | |
| 645 | + if ( $autocompleteFieldType != 'external_url' ) { |
| 646 | + global $wgContLang; |
| 647 | + $autocompletionSource = $wgContLang->ucfirst( $autocompletionSource ); |
| 648 | + } |
| 649 | + |
625 | 650 | // Get all autocomplete-related values, plus delimiter value |
626 | 651 | // (it's needed also for the 'uploadable' link, if there is one). |
627 | | - $autocompleteSettings = $autocompletion_source; |
| 652 | + $autocompleteSettings = $autocompletionSource; |
628 | 653 | $is_list = ( array_key_exists( 'is_list', $field_args ) && $field_args['is_list'] == true ); |
629 | 654 | if ( $is_list ) { |
630 | 655 | $autocompleteSettings .= ",list"; |
— | — | @@ -640,25 +665,26 @@ |
641 | 666 | $remoteDataType = null; |
642 | 667 | if ( array_key_exists( 'remote autocompletion', $field_args ) && |
643 | 668 | $field_args['remote autocompletion'] == true ) { |
644 | | - $remoteDataType = $autocomplete_field_type; |
645 | | - } elseif ( $autocompletion_source != '' ) { |
646 | | - $autocomplete_values = SFUtils::getAutocompleteValues( $autocompletion_source, $autocomplete_field_type ); |
647 | | - $sfgAutocompleteValues[$autocompleteSettings] = $autocomplete_values; |
| 669 | + $remoteDataType = $autocompleteFieldType; |
| 670 | + } elseif ( $autocompletionSource != '' ) { |
| 671 | + if ( $autocompleteFieldType == 'values' ) { |
| 672 | + $autocompleteValues = explode( ',', $field_args['values'] ); |
| 673 | + } else { |
| 674 | + $autocompleteValues = SFUtils::getAutocompleteValues( $autocompletionSource, $autocompleteFieldType ); |
| 675 | + } |
| 676 | + $sfgAutocompleteValues[$autocompleteSettings] = $autocompleteValues; |
648 | 677 | } |
649 | 678 | return array( $autocompleteSettings, $remoteDataType, $delimiter ); |
650 | 679 | } |
651 | 680 | |
652 | 681 | static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
653 | | - // If 'no autocomplete' was specified, print a regular text |
654 | | - // entry instead. |
| 682 | + // Backwards compatibility, for pre-SF-2.1 forms: |
| 683 | + // if 'no autocomplete' was specified, switch to SFTextInput. |
655 | 684 | if ( array_key_exists( 'no autocomplete', $other_args ) && |
656 | 685 | $other_args['no autocomplete'] == true ) { |
657 | 686 | unset( $other_args['autocompletion source'] ); |
658 | 687 | return SFTextInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
659 | 688 | } |
660 | | - // if a set of values was specified, print a dropdown instead |
661 | | - if ( array_key_exists( 'possible_values', $other_args ) && $other_args['possible_values'] != null ) |
662 | | - return SFDropdownInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
663 | 689 | |
664 | 690 | global $sfgTabIndex, $sfgFieldNum; |
665 | 691 | |
— | — | @@ -669,11 +695,13 @@ |
670 | 696 | $className .= " " . $other_args['class']; |
671 | 697 | $input_id = "input_" . $sfgFieldNum; |
672 | 698 | |
673 | | - |
674 | | - if ( array_key_exists( 'size', $other_args ) ) |
| 699 | + if ( array_key_exists( 'size', $other_args ) ) { |
675 | 700 | $size = $other_args['size']; |
676 | | - else |
| 701 | + } elseif ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] ) { |
| 702 | + $size = "100"; |
| 703 | + } else { |
677 | 704 | $size = "35"; |
| 705 | + } |
678 | 706 | |
679 | 707 | $inputAttrs = array( |
680 | 708 | 'type' => 'text', |
— | — | @@ -718,6 +746,7 @@ |
719 | 747 | $params[] = array( 'name' => 'values from category', 'type' => 'string' ); |
720 | 748 | $params[] = array( 'name' => 'values from namespace', 'type' => 'string' ); |
721 | 749 | $params[] = array( 'name' => 'values from concept', 'type' => 'string' ); |
| 750 | + $params[] = array( 'name' => 'values from url', 'type' => 'string' ); |
722 | 751 | $params[] = array( 'name' => 'values', 'type' => 'string' ); |
723 | 752 | $params[] = array( 'name' => 'list', 'type' => 'boolean' ); |
724 | 753 | $params[] = array( 'name' => 'remote autocompletion', 'type' => 'boolean' ); |
— | — | @@ -824,6 +853,7 @@ |
825 | 854 | $params[] = array( 'name' => 'values from category', 'type' => 'string' ); |
826 | 855 | $params[] = array( 'name' => 'values from namespace', 'type' => 'string' ); |
827 | 856 | $params[] = array( 'name' => 'values from concept', 'type' => 'string' ); |
| 857 | + $params[] = array( 'name' => 'values from url', 'type' => 'string' ); |
828 | 858 | $params[] = array( 'name' => 'values', 'type' => 'string' ); |
829 | 859 | $params[] = array( 'name' => 'list', 'type' => 'boolean' ); |
830 | 860 | $params[] = array( 'name' => 'remote autocompletion', 'type' => 'boolean' ); |