Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | return array( '_wpg' ); |
160 | 160 | } |
161 | 161 | |
162 | | - static function uploadLinkHTML( $input_id, $delimiter = null, $default_filename = null ) { |
| 162 | + public static function uploadLinkHTML( $input_id, $delimiter = null, $default_filename = null ) { |
163 | 163 | $upload_window_page = SpecialPage::getPage( 'UploadWindow' ); |
164 | 164 | $query_string = "sfInputID=$input_id"; |
165 | 165 | if ( $delimiter != null ) |
— | — | @@ -183,7 +183,7 @@ |
184 | 184 | return $text; |
185 | 185 | } |
186 | 186 | |
187 | | - static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 187 | + public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
188 | 188 | global $sfgTabIndex, $sfgFieldNum; |
189 | 189 | |
190 | 190 | $className = "createboxInput"; |
— | — | @@ -282,7 +282,7 @@ |
283 | 283 | return array(); |
284 | 284 | } |
285 | 285 | |
286 | | - static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 286 | + public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
287 | 287 | global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
288 | 288 | |
289 | 289 | $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
— | — | @@ -345,7 +345,7 @@ |
346 | 346 | return 'listbox'; |
347 | 347 | } |
348 | 348 | |
349 | | - static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 349 | + public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
350 | 350 | global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
351 | 351 | |
352 | 352 | $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
— | — | @@ -432,7 +432,7 @@ |
433 | 433 | return array(); |
434 | 434 | } |
435 | 435 | |
436 | | - static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 436 | + public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
437 | 437 | global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
438 | 438 | |
439 | 439 | $checkbox_class = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
— | — | @@ -518,7 +518,7 @@ |
519 | 519 | return array( '_wpg', '_str' ); |
520 | 520 | } |
521 | 521 | |
522 | | - static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 522 | + public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
523 | 523 | // For backward compatibility with pre-SF-2.1 forms |
524 | 524 | if ( array_key_exists( 'no autocomplete', $other_args ) && |
525 | 525 | $other_args['no autocomplete'] == true ) { |
— | — | @@ -528,9 +528,6 @@ |
529 | 529 | |
530 | 530 | global $sfgTabIndex, $sfgFieldNum; |
531 | 531 | |
532 | | - $autocomplete_field_type = ""; |
533 | | - $autocompletion_source = ""; |
534 | | - |
535 | 532 | $className = "sfComboBox"; |
536 | 533 | if ( $is_mandatory ) { |
537 | 534 | $className .= " mandatoryField"; |
— | — | @@ -539,14 +536,7 @@ |
540 | 537 | $className .= " " . $other_args['class']; |
541 | 538 | } |
542 | 539 | $disabled_text = ( $is_disabled ) ? "disabled" : ""; |
543 | | - if ( array_key_exists( 'autocomplete field type', $other_args ) ) { |
544 | | - $autocomplete_field_type = $other_args['autocomplete field type']; |
545 | | - $autocompletion_source = $other_args['autocompletion source']; |
546 | | - if ( $autocomplete_field_type != 'external_url' ) { |
547 | | - global $wgContLang; |
548 | | - $autocompletion_source = $wgContLang->ucfirst( $autocompletion_source ); |
549 | | - } |
550 | | - } |
| 540 | + |
551 | 541 | if ( array_key_exists( 'size', $other_args ) ) { |
552 | 542 | $size = $other_args['size']; |
553 | 543 | } else { |
— | — | @@ -558,8 +548,10 @@ |
559 | 549 | // browsers. |
560 | 550 | $pixel_width = $size * 6 . "px"; |
561 | 551 | |
562 | | - $values = SFUtils::getAutocompleteValues($autocompletion_source, $autocomplete_field_type ); |
563 | | - $autocompletion_source = str_replace( "'", "\'", $autocompletion_source ); |
| 552 | + list( $autocompleteFieldType, $autocompletionSource ) = |
| 553 | + SFTextWithAutocompleteInput::getAutocompletionTypeAndSource( $other_args ); |
| 554 | + $values = SFUtils::getAutocompleteValues($autocompletionSource, $autocompleteFieldType ); |
| 555 | + $autocompletionSource = str_replace( "'", "\'", $autocompletionSource ); |
564 | 556 | |
565 | 557 | $optionsText = Xml::element( 'option', array( 'value' => $cur_value ), null, false ) . "\n"; |
566 | 558 | foreach ( $values as $value ) { |
— | — | @@ -571,7 +563,7 @@ |
572 | 564 | 'name' => $input_name, |
573 | 565 | 'class' => $className, |
574 | 566 | 'tabindex' => $sfgTabIndex, |
575 | | - 'autocompletesettings' => $autocompletion_source, |
| 567 | + 'autocompletesettings' => $autocompletionSource, |
576 | 568 | 'comboboxwidth' => $pixel_width, |
577 | 569 | ); |
578 | 570 | if ( array_key_exists( 'existing values only', $other_args ) ) { |
— | — | @@ -619,9 +611,7 @@ |
620 | 612 | return array( '_str' ); |
621 | 613 | } |
622 | 614 | |
623 | | - static function setAutocompleteValues( $field_args ) { |
624 | | - global $sfgAutocompleteValues; |
625 | | - |
| 615 | + public static function getAutocompletionTypeAndSource( $field_args ) { |
626 | 616 | if ( array_key_exists( 'values from property', $field_args ) || |
627 | 617 | array_key_exists( 'semantic_property', $field_args ) ) { |
628 | 618 | if ( array_key_exists( 'values from property', $field_args ) ) { |
— | — | @@ -667,8 +657,16 @@ |
668 | 658 | $autocompletionSource = $wgContLang->ucfirst( $autocompletionSource ); |
669 | 659 | } |
670 | 660 | |
| 661 | + return array( $autocompleteFieldType, $autocompletionSource ); |
| 662 | + } |
| 663 | + |
| 664 | + public static function setAutocompleteValues( $field_args ) { |
| 665 | + global $sfgAutocompleteValues; |
| 666 | + |
671 | 667 | // Get all autocomplete-related values, plus delimiter value |
672 | 668 | // (it's needed also for the 'uploadable' link, if there is one). |
| 669 | + list( $autocompleteFieldType, $autocompletionSource ) = |
| 670 | + self::getAutocompletionTypeAndSource( $field_args ); |
673 | 671 | $autocompleteSettings = $autocompletionSource; |
674 | 672 | $is_list = ( array_key_exists( 'is_list', $field_args ) && $field_args['is_list'] == true ); |
675 | 673 | if ( $is_list ) { |
— | — | @@ -698,7 +696,7 @@ |
699 | 697 | return array( $autocompleteSettings, $remoteDataType, $delimiter ); |
700 | 698 | } |
701 | 699 | |
702 | | - static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 700 | + public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
703 | 701 | // Backwards compatibility, for pre-SF-2.1 forms: |
704 | 702 | // if 'no autocomplete' was specified, switch to SFTextInput. |
705 | 703 | if ( array_key_exists( 'no autocomplete', $other_args ) && |
— | — | @@ -794,7 +792,7 @@ |
795 | 793 | return array( '_wpg', '_str' ); |
796 | 794 | } |
797 | 795 | |
798 | | - static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 796 | + public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
799 | 797 | global $sfgTabIndex, $sfgFieldNum; |
800 | 798 | |
801 | 799 | $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
— | — | @@ -878,7 +876,7 @@ |
879 | 877 | return array( '_wpg', '_str' ); |
880 | 878 | } |
881 | 879 | |
882 | | - static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 880 | + public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
883 | 881 | // If 'no autocomplete' was specified, print a regular |
884 | 882 | // textarea instead. |
885 | 883 | if ( array_key_exists( 'no autocomplete', $other_args ) && |
— | — | @@ -974,7 +972,7 @@ |
975 | 973 | return array( '_dat' => array() ); |
976 | 974 | } |
977 | 975 | |
978 | | - static function monthDropdownHTML( $cur_month, $input_name, $is_disabled ) { |
| 976 | + public static function monthDropdownHTML( $cur_month, $input_name, $is_disabled ) { |
979 | 977 | global $sfgTabIndex, $wgAmericanDates; |
980 | 978 | |
981 | 979 | $optionsText = ""; |
— | — | @@ -1000,7 +998,7 @@ |
1001 | 999 | return $text; |
1002 | 1000 | } |
1003 | 1001 | |
1004 | | - static function getMainHTML( $date, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1002 | + public static function getMainHTML( $date, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
1005 | 1003 | global $sfgTabIndex, $sfgFieldNum, $wgAmericanDates; |
1006 | 1004 | |
1007 | 1005 | $input_id = "input_$sfgFieldNum"; |
— | — | @@ -1054,7 +1052,7 @@ |
1055 | 1053 | return $text; |
1056 | 1054 | } |
1057 | 1055 | |
1058 | | - static function getHTML( $date, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1056 | + public static function getHTML( $date, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
1059 | 1057 | $text = self::getMainHTML( $date, $input_name, $is_mandatory, $is_disabled, $other_args ); |
1060 | 1058 | $spanClass = "dateInput"; |
1061 | 1059 | if ( $is_mandatory ) { $spanClass .= " mandatoryFieldSpan"; } |
— | — | @@ -1076,7 +1074,7 @@ |
1077 | 1075 | return array( '_dat' ); |
1078 | 1076 | } |
1079 | 1077 | |
1080 | | - static function getHTML( $datetime, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1078 | + public static function getHTML( $datetime, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
1081 | 1079 | global $sfgTabIndex, $sfg24HourTime; |
1082 | 1080 | |
1083 | 1081 | $include_timezone = array_key_exists( 'include timezone', $other_args ); |
— | — | @@ -1205,7 +1203,7 @@ |
1206 | 1204 | return 'radiobutton'; |
1207 | 1205 | } |
1208 | 1206 | |
1209 | | - static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1207 | + public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
1210 | 1208 | global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
1211 | 1209 | |
1212 | 1210 | if ( ( $possible_values = $other_args['possible_values'] ) == null ) |
— | — | @@ -1298,7 +1296,7 @@ |
1299 | 1297 | return array( '_boo' => array() ); |
1300 | 1298 | } |
1301 | 1299 | |
1302 | | - static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1300 | + public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
1303 | 1301 | global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
1304 | 1302 | |
1305 | 1303 | $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
— | — | @@ -1362,7 +1360,7 @@ |
1363 | 1361 | return array( '_wpg' ); |
1364 | 1362 | } |
1365 | 1363 | |
1366 | | - static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1364 | + public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
1367 | 1365 | // escape if CategoryTree extension isn't included |
1368 | 1366 | if ( ! function_exists( 'efCategoryTreeParserHook' ) ) |
1369 | 1367 | return null; |
— | — | @@ -1450,7 +1448,7 @@ |
1451 | 1449 | return array( '_wpg' ); |
1452 | 1450 | } |
1453 | 1451 | |
1454 | | - static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1452 | + public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
1455 | 1453 | // escape if CategoryTree extension isn't included |
1456 | 1454 | if ( ! function_exists( 'efCategoryTreeParserHook' ) ) |
1457 | 1455 | return null; |