Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php |
— | — | @@ -9,32 +9,109 @@ |
10 | 10 | * @author Sanyam Goyal |
11 | 11 | */ |
12 | 12 | |
| 13 | +/** |
| 14 | + * Parent class for all form input classes. |
| 15 | + */ |
13 | 16 | class SFFormInput { |
| 17 | + /** |
| 18 | + * Returns the set of input types, other than the main one, defined |
| 19 | + * by this class; with the set of additional field arguments to |
| 20 | + * be passed to each one. |
| 21 | + */ |
| 22 | + public static function getAlternateInputTypes() { |
| 23 | + return array(); |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * Returns the set of SMW property types for which this input is |
| 28 | + * meant to be the default one - ideally, no more than one input |
| 29 | + * should declare itself the default for any specific type. |
| 30 | + */ |
| 31 | + public static function getDefaultPropTypes() { |
| 32 | + return array(); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Returns the set of SMW property types which this input can |
| 37 | + * handle, but for which it isn't the default input. |
| 38 | + */ |
| 39 | + public static function getOtherPropTypesHandled() { |
| 40 | + return array(); |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Like getDefaultPropTypes(), but for a field which holds a |
| 45 | + * list of values instead of just one. |
| 46 | + */ |
| 47 | + public static function getDefaultPropTypeLists() { |
| 48 | + return array(); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * Like getOtherPropTypesHandled(), but for a field which holds a |
| 53 | + * list of values instead of just one. |
| 54 | + */ |
| 55 | + public static function getOtherPropTypeListsHandled() { |
| 56 | + return array(); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Returns the set of parameters that every form input will have |
| 61 | + * automatically, and that don't need to be declared. |
| 62 | + */ |
14 | 63 | public static function getStandardParameters() { |
15 | 64 | $params = array(); |
16 | 65 | $params[] = array( 'name' => 'restricted', 'type' => 'boolean' ); |
17 | 66 | $params[] = array( 'name' => 'mandatory', 'type' => 'boolean' ); |
18 | | - return array(); |
| 67 | + return $params; |
19 | 68 | } |
20 | 69 | |
| 70 | + /** |
| 71 | + * Returns the set of parameters for this form input. |
| 72 | + */ |
21 | 73 | public static function getParameters() { |
22 | 74 | $params = array(); |
23 | 75 | $params[] = array( 'name' => 'class', 'type' => 'string' ); |
24 | 76 | $params[] = array( 'name' => 'default', 'type' => 'string' ); |
25 | 77 | $params[] = array( 'name' => 'preload', 'type' => 'string' ); |
26 | | - return array(); |
| 78 | + return $params; |
27 | 79 | } |
28 | 80 | } |
29 | 81 | |
| 82 | +/** |
| 83 | + * The base class for every form input that holds a pre-set enumeration |
| 84 | + * of values. |
| 85 | + */ |
30 | 86 | class SFEnumInput extends SFFormInput { |
| 87 | + public static function getOtherPropTypesHandled() { |
| 88 | + return array( 'enumeration' ); |
| 89 | + } |
| 90 | + |
31 | 91 | public static function getParameters() { |
32 | 92 | $params = parent::getParameters(); |
| 93 | + $params[] = array( 'name' => 'values', 'type' => 'string' ); |
| 94 | + $params[] = array( 'name' => 'values from property', 'type' => 'string' ); |
| 95 | + $params[] = array( 'name' => 'values from category', 'type' => 'string' ); |
| 96 | + $params[] = array( 'name' => 'values from namespace', 'type' => 'string' ); |
| 97 | + $params[] = array( 'name' => 'values from concept', 'type' => 'string' ); |
33 | 98 | $params[] = array( 'name' => 'show on select', 'type' => 'string' ); |
34 | 99 | return $params; |
35 | 100 | } |
36 | 101 | } |
37 | 102 | |
| 103 | +/** |
| 104 | + * The base class for every form input that holds a list of elements, each |
| 105 | + * one from a pre-set enumeration of values. |
| 106 | + */ |
38 | 107 | class SFMultiEnumInput extends SFEnumInput { |
| 108 | + public static function getOtherPropTypesHandled() { |
| 109 | + return array(); |
| 110 | + } |
| 111 | + |
| 112 | + public static function getOtherPropTypeListsHandled() { |
| 113 | + return array( 'enumeration' ); |
| 114 | + } |
| 115 | + |
39 | 116 | public static function getParameters() { |
40 | 117 | $params = parent::getParameters(); |
41 | 118 | $params[] = array( 'name' => 'delimiter', 'type' => 'string' ); |
— | — | @@ -43,6 +120,42 @@ |
44 | 121 | } |
45 | 122 | |
46 | 123 | class SFTextInput extends SFFormInput { |
| 124 | + public static function getName() { |
| 125 | + return 'text'; |
| 126 | + } |
| 127 | + |
| 128 | + public static function getAlternateInputTypes() { |
| 129 | + return array( |
| 130 | + array( 'year', array( 'size' => 4 ) ) |
| 131 | + ); |
| 132 | + } |
| 133 | + |
| 134 | + public static function getDefaultPropTypes() { |
| 135 | + return array( |
| 136 | + '_str' => array( 'field_type' => 'string' ), |
| 137 | + '_num' => array( 'field_type' => 'number' ), |
| 138 | + '_uri' => array( 'field_type' => 'URL' ), |
| 139 | + '_ema' => array( 'field_type' => 'email' ) |
| 140 | + ); |
| 141 | + } |
| 142 | + |
| 143 | + public static function getOtherPropTypesHandled() { |
| 144 | + return array( '_wpg', '_geo' ); |
| 145 | + } |
| 146 | + |
| 147 | + public static function getDefaultPropTypeLists() { |
| 148 | + return array( |
| 149 | + '_str' => array( 'field_type' => 'string', 'is_list' => 'true', 'size' => '100' ), |
| 150 | + '_num' => array( 'field_type' => 'number', 'is_list' => 'true', 'size' => '100' ), |
| 151 | + '_uri' => array( 'field_type' => 'URL', 'is_list' => 'true' ), |
| 152 | + '_ema' => array( 'field_type' => 'email', 'is_list' => 'true' ) |
| 153 | + ); |
| 154 | + } |
| 155 | + |
| 156 | + public static function getOtherPropTypeListsHandled() { |
| 157 | + return array( '_wpg' ); |
| 158 | + } |
| 159 | + |
47 | 160 | static function uploadLinkHTML( $input_id, $delimiter = null, $default_filename = null ) { |
48 | 161 | $upload_window_page = SpecialPage::getPage( 'UploadWindow' ); |
49 | 162 | $query_string = "sfInputID=$input_id"; |
— | — | @@ -68,17 +181,17 @@ |
69 | 182 | return $text; |
70 | 183 | } |
71 | 184 | |
72 | | - static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 185 | + static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
73 | 186 | // If it's an autocomplete, call the with-autocomplete function |
74 | 187 | // instead. |
75 | 188 | if ( array_key_exists( 'autocompletion source', $other_args ) ) { |
76 | | - return SFTextWithAutocompleteInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
| 189 | + return SFTextWithAutocompleteInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
77 | 190 | } |
78 | 191 | |
79 | 192 | // If there are possible values specified, call the dropdown |
80 | 193 | // function. |
81 | 194 | if ( array_key_exists( 'possible_values', $other_args ) && $other_args['possible_values'] != null ) |
82 | | - return SFDropdownInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
| 195 | + return SFDropdownInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
83 | 196 | |
84 | 197 | global $sfgTabIndex, $sfgFieldNum; |
85 | 198 | |
— | — | @@ -164,7 +277,21 @@ |
165 | 278 | } |
166 | 279 | |
167 | 280 | class SFDropdownInput extends SFEnumInput { |
168 | | - static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 281 | + public static function getName() { |
| 282 | + return 'dropdown'; |
| 283 | + } |
| 284 | + |
| 285 | + public static function getDefaultPropTypes() { |
| 286 | + return array( |
| 287 | + 'enumeration' => array() |
| 288 | + ); |
| 289 | + } |
| 290 | + |
| 291 | + public static function getOtherPropTypesHandled() { |
| 292 | + return array(); |
| 293 | + } |
| 294 | + |
| 295 | + static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
169 | 296 | global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
170 | 297 | |
171 | 298 | $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
— | — | @@ -223,7 +350,11 @@ |
224 | 351 | } |
225 | 352 | |
226 | 353 | class SFListBoxInput extends SFMultiEnumInput { |
227 | | - static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 354 | + public static function getName() { |
| 355 | + return 'listbox'; |
| 356 | + } |
| 357 | + |
| 358 | + static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
228 | 359 | global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
229 | 360 | |
230 | 361 | $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
— | — | @@ -290,7 +421,21 @@ |
291 | 422 | } |
292 | 423 | |
293 | 424 | class SFCheckboxesInput extends SFMultiEnumInput { |
294 | | - static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 425 | + public static function getName() { |
| 426 | + return 'checkboxes'; |
| 427 | + } |
| 428 | + |
| 429 | + public static function getDefaultPropTypeLists() { |
| 430 | + return array( |
| 431 | + 'enumeration' => array() |
| 432 | + ); |
| 433 | + } |
| 434 | + |
| 435 | + public static function getOtherPropTypeListsHandled() { |
| 436 | + return array(); |
| 437 | + } |
| 438 | + |
| 439 | + static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
295 | 440 | global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
296 | 441 | |
297 | 442 | $checkbox_class = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
— | — | @@ -368,15 +513,20 @@ |
369 | 514 | } |
370 | 515 | |
371 | 516 | class SFComboBoxInput extends SFFormInput { |
372 | | - static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 517 | + public static function getName() { |
| 518 | + return 'combobox'; |
| 519 | + } |
| 520 | + |
| 521 | + public static function getOtherPropTypesHandled() { |
| 522 | + return array( '_wpg', '_str' ); |
| 523 | + } |
| 524 | + |
| 525 | + static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
373 | 526 | if ( array_key_exists( 'no autocomplete', $other_args ) && |
374 | 527 | $other_args['no autocomplete'] == true ) { |
375 | 528 | unset( $other_args['autocompletion source'] ); |
376 | | - return SFTextInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
| 529 | + return SFTextInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
377 | 530 | } |
378 | | - // If a set of values was specified, print a dropdown instead. |
379 | | - if ( array_key_exists( 'possible_values', $other_args ) && $other_args['possible_values'] != null ) |
380 | | - return SFDropdownInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
381 | 531 | |
382 | 532 | global $sfgTabIndex, $sfgFieldNum; |
383 | 533 | |
— | — | @@ -434,6 +584,30 @@ |
435 | 585 | } |
436 | 586 | |
437 | 587 | class SFTextWithAutocompleteInput extends SFTextInput { |
| 588 | + public static function getName() { |
| 589 | + return 'text with autocomplete'; |
| 590 | + } |
| 591 | + |
| 592 | + public static function getDefaultPropTypes() { |
| 593 | + return array( |
| 594 | + '_wpg' => array() |
| 595 | + ); |
| 596 | + } |
| 597 | + |
| 598 | + public static function getOtherPropTypesHandled() { |
| 599 | + return array( '_str' ); |
| 600 | + } |
| 601 | + |
| 602 | + public static function getDefaultPropTypeLists() { |
| 603 | + return array( |
| 604 | + '_wpg' => array( 'is_list' => true, 'size' => 100 ) |
| 605 | + ); |
| 606 | + } |
| 607 | + |
| 608 | + public static function getOtherPropTypeListsHandled() { |
| 609 | + return array( '_str' ); |
| 610 | + } |
| 611 | + |
438 | 612 | static function setAutocompleteValues( $field_args ) { |
439 | 613 | global $sfgAutocompleteValues; |
440 | 614 | |
— | — | @@ -473,17 +647,17 @@ |
474 | 648 | return array( $autocompleteSettings, $remoteDataType, $delimiter ); |
475 | 649 | } |
476 | 650 | |
477 | | - static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 651 | + static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
478 | 652 | // If 'no autocomplete' was specified, print a regular text |
479 | 653 | // entry instead. |
480 | 654 | if ( array_key_exists( 'no autocomplete', $other_args ) && |
481 | 655 | $other_args['no autocomplete'] == true ) { |
482 | 656 | unset( $other_args['autocompletion source'] ); |
483 | | - return SFTextInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
| 657 | + return SFTextInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
484 | 658 | } |
485 | 659 | // if a set of values was specified, print a dropdown instead |
486 | 660 | if ( array_key_exists( 'possible_values', $other_args ) && $other_args['possible_values'] != null ) |
487 | | - return SFDropdownInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
| 661 | + return SFDropdownInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
488 | 662 | |
489 | 663 | global $sfgTabIndex, $sfgFieldNum; |
490 | 664 | |
— | — | @@ -538,22 +712,38 @@ |
539 | 713 | } |
540 | 714 | |
541 | 715 | public static function getParameters() { |
542 | | - $params = array(); |
543 | | - $params[] = array( 'name' => 'maxlength', 'type' => 'int' ); |
| 716 | + $params = parent::getParameters(); |
| 717 | + $params[] = array( 'name' => 'values from property', 'type' => 'string' ); |
| 718 | + $params[] = array( 'name' => 'values from category', 'type' => 'string' ); |
| 719 | + $params[] = array( 'name' => 'values from namespace', 'type' => 'string' ); |
| 720 | + $params[] = array( 'name' => 'values from concept', 'type' => 'string' ); |
| 721 | + $params[] = array( 'name' => 'values', 'type' => 'string' ); |
544 | 722 | $params[] = array( 'name' => 'list', 'type' => 'boolean' ); |
545 | 723 | $params[] = array( 'name' => 'remote autocompletion', 'type' => 'boolean' ); |
546 | | - return array(); |
| 724 | + return $params; |
547 | 725 | } |
548 | 726 | } |
549 | 727 | |
550 | | -class SFTextAreaWithAutocompleteInput extends SFTextWithAutocompleteInput { |
551 | | - static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 728 | +class SFTextAreaWithAutocompleteInput extends SFTextAreaInput { |
| 729 | + public static function getName() { |
| 730 | + return 'textarea with autocomplete'; |
| 731 | + } |
| 732 | + |
| 733 | + public static function getOtherPropTypesHandled() { |
| 734 | + return array( '_wpg', '_str' ); |
| 735 | + } |
| 736 | + |
| 737 | + public static function getOtherPropTypeListsHandled() { |
| 738 | + return array( '_wpg', '_str' ); |
| 739 | + } |
| 740 | + |
| 741 | + static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
552 | 742 | // If 'no autocomplete' was specified, print a regular |
553 | 743 | // textarea instead. |
554 | 744 | if ( array_key_exists( 'no autocomplete', $other_args ) && |
555 | 745 | $other_args['no autocomplete'] == true ) { |
556 | 746 | unset( $other_args['autocompletion source'] ); |
557 | | - return SFTextAreaInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
| 747 | + return SFTextAreaInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
558 | 748 | } |
559 | 749 | |
560 | 750 | global $sfgTabIndex, $sfgFieldNum; |
— | — | @@ -589,15 +779,13 @@ |
590 | 780 | } |
591 | 781 | if ( array_key_exists( 'maxlength', $other_args ) ) { |
592 | 782 | $maxlength = $other_args['maxlength']; |
593 | | - // For every actual character pressed (i.e., |
594 | | - // excluding things like the Shift key), |
595 | | - // reduce the string to its allowed length if |
596 | | - // it's exceeded that. |
597 | | - // This JS code is complicated so that it'll |
598 | | - // work correctly in IE - IE moves the cursor |
599 | | - // to the end whenever this.value is reset, |
600 | | - // so we'll make sure to do that only when |
601 | | - // we need to. |
| 783 | + // For every actual character pressed (i.e., excluding |
| 784 | + // things like the Shift key), reduce the string to |
| 785 | + // its allowed length if it's exceeded that. |
| 786 | + // This JS code is complicated so that it'll work |
| 787 | + // correctly in IE - IE moves the cursor to the end |
| 788 | + // whenever this.value is reset, so we'll make sure |
| 789 | + // to do that only when we need to. |
602 | 790 | $maxLengthJSCheck = "if (window.event && window.event.keyCode < 48 && window.event.keyCode != 13) return; if (this.value.length > $maxlength) { this.value = this.value.substring(0, $maxlength); }"; |
603 | 791 | $textarea_attrs['onKeyDown'] = $maxLengthJSCheck; |
604 | 792 | $textarea_attrs['onKeyUp'] = $maxLengthJSCheck; |
— | — | @@ -622,19 +810,37 @@ |
623 | 811 | } |
624 | 812 | |
625 | 813 | public static function getParameters() { |
626 | | - $params = array(); |
627 | | - $params[] = array( 'name' => 'maxlength', 'type' => 'int' ); |
| 814 | + $params = parent::getParameters(); |
| 815 | + $params[] = array( 'name' => 'values from property', 'type' => 'string' ); |
| 816 | + $params[] = array( 'name' => 'values from category', 'type' => 'string' ); |
| 817 | + $params[] = array( 'name' => 'values from namespace', 'type' => 'string' ); |
| 818 | + $params[] = array( 'name' => 'values from concept', 'type' => 'string' ); |
| 819 | + $params[] = array( 'name' => 'values', 'type' => 'string' ); |
628 | 820 | $params[] = array( 'name' => 'list', 'type' => 'boolean' ); |
629 | 821 | $params[] = array( 'name' => 'remote autocompletion', 'type' => 'boolean' ); |
630 | | - $params[] = array( 'name' => 'autogrow', 'type' => 'boolean' ); |
631 | | - return array(); |
| 822 | + return $params; |
632 | 823 | } |
633 | 824 | } |
634 | 825 | |
635 | 826 | class SFTextAreaInput extends SFFormInput { |
636 | | - static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 827 | + public static function getName() { |
| 828 | + return 'textarea'; |
| 829 | + } |
| 830 | + |
| 831 | + public static function getDefaultPropTypes() { |
| 832 | + return array( '_txt' => array(), '_cod' => array() ); |
| 833 | + } |
| 834 | + |
| 835 | + public static function getOtherPropTypesHandled() { |
| 836 | + return array( '_wpg', '_str' ); |
| 837 | + } |
| 838 | + |
| 839 | + public static function getOtherPropTypeListsHandled() { |
| 840 | + return array( '_wpg', '_str' ); |
| 841 | + } |
| 842 | + |
| 843 | + static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
637 | 844 | // set size values |
638 | | - |
639 | 845 | if ( ! array_key_exists( 'rows', $other_args ) ) { |
640 | 846 | $other_args['rows'] = 5; |
641 | 847 | } |
— | — | @@ -645,7 +851,7 @@ |
646 | 852 | // If it's an autocomplete, call the with-autocomplete |
647 | 853 | // function instead. |
648 | 854 | if ( array_key_exists( 'autocompletion source', $other_args ) ) { |
649 | | - return SFTextAreaWithAutocompleteInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
| 855 | + return SFTextAreaWithAutocompleteInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
650 | 856 | } |
651 | 857 | |
652 | 858 | global $sfgTabIndex, $sfgFieldNum; |
— | — | @@ -654,7 +860,7 @@ |
655 | 861 | if ( array_key_exists( 'class', $other_args ) ) { |
656 | 862 | $className .= " " . $other_args['class']; |
657 | 863 | } |
658 | | - // use a special ID for the free text field, for FCK's needs |
| 864 | + // Use a special ID for the free text field, for FCK's needs. |
659 | 865 | $input_id = $input_name == "free_text" ? "free_text" : "input_$sfgFieldNum"; |
660 | 866 | |
661 | 867 | $rows = $other_args['rows']; |
— | — | @@ -699,12 +905,21 @@ |
700 | 906 | $params = parent::getParameters(); |
701 | 907 | $params[] = array( 'name' => 'rows', 'type' => 'int' ); |
702 | 908 | $params[] = array( 'name' => 'cols', 'type' => 'int' ); |
| 909 | + $params[] = array( 'name' => 'maxlength', 'type' => 'int' ); |
703 | 910 | $params[] = array( 'name' => 'autogrow', 'type' => 'boolean' ); |
704 | 911 | return $params; |
705 | 912 | } |
706 | 913 | } |
707 | 914 | |
708 | 915 | class SFDateInput extends SFFormInput { |
| 916 | + public static function getName() { |
| 917 | + return 'date'; |
| 918 | + } |
| 919 | + |
| 920 | + public static function getDefaultPropTypes() { |
| 921 | + return array( '_dat' => array() ); |
| 922 | + } |
| 923 | + |
709 | 924 | static function monthDropdownHTML( $cur_month, $input_name, $is_disabled ) { |
710 | 925 | global $sfgTabIndex, $wgAmericanDates; |
711 | 926 | |
— | — | @@ -785,7 +1000,7 @@ |
786 | 1001 | return $text; |
787 | 1002 | } |
788 | 1003 | |
789 | | - static function getText( $date, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1004 | + static function getHTML( $date, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
790 | 1005 | $text = self::getMainHTML( $date, $input_name, $is_mandatory, $is_disabled, $other_args ); |
791 | 1006 | $spanClass = "dateInput"; |
792 | 1007 | if ( $is_mandatory ) { $spanClass .= " mandatoryFieldSpan"; } |
— | — | @@ -795,7 +1010,25 @@ |
796 | 1011 | } |
797 | 1012 | |
798 | 1013 | class SFDateTimeInput extends SFDateInput { |
799 | | - static function getText( $datetime, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1014 | + public static function getName() { |
| 1015 | + return 'datetime'; |
| 1016 | + } |
| 1017 | + |
| 1018 | + public static function getAlternateInputTypes() { |
| 1019 | + return array( |
| 1020 | + array( 'datetime with timezone', array( 'include_timezone' => true ) ) |
| 1021 | + ); |
| 1022 | + } |
| 1023 | + |
| 1024 | + public static function getDefaultPropTypes() { |
| 1025 | + return array(); |
| 1026 | + } |
| 1027 | + |
| 1028 | + public static function getOtherPropTypesHandled() { |
| 1029 | + return array( '_dat' ); |
| 1030 | + } |
| 1031 | + |
| 1032 | + static function getHTML( $datetime, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
800 | 1033 | global $sfgTabIndex, $sfg24HourTime; |
801 | 1034 | |
802 | 1035 | $include_timezone = $other_args['include_timezone']; |
— | — | @@ -882,10 +1115,30 @@ |
883 | 1116 | |
884 | 1117 | return $text; |
885 | 1118 | } |
| 1119 | + |
| 1120 | + public static function getParameters() { |
| 1121 | + $params = parent::getParameters(); |
| 1122 | + $params[] = array( 'name' => 'include timezone', 'type' => 'boolean' ); |
| 1123 | + return $params; |
| 1124 | + } |
886 | 1125 | } |
887 | 1126 | |
888 | 1127 | class SFRadioButtonInput extends SFEnumInput { |
889 | | - static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1128 | + public static function getName() { |
| 1129 | + return 'radiobutton'; |
| 1130 | + } |
| 1131 | + |
| 1132 | + public static function getDefaultPropTypes() { |
| 1133 | + return array( |
| 1134 | + 'enumeration' => array() |
| 1135 | + ); |
| 1136 | + } |
| 1137 | + |
| 1138 | + public static function getOtherPropTypeListsHandled() { |
| 1139 | + return array(); |
| 1140 | + } |
| 1141 | + |
| 1142 | + static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
890 | 1143 | global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
891 | 1144 | |
892 | 1145 | if ( ( $possible_values = $other_args['possible_values'] ) == null ) |
— | — | @@ -970,7 +1223,15 @@ |
971 | 1224 | } |
972 | 1225 | |
973 | 1226 | class SFCheckboxInput extends SFFormInput { |
974 | | - static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1227 | + public static function getName() { |
| 1228 | + return 'checkbox'; |
| 1229 | + } |
| 1230 | + |
| 1231 | + public static function getDefaultPropTypes() { |
| 1232 | + return array( '_boo' => array() ); |
| 1233 | + } |
| 1234 | + |
| 1235 | + static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
975 | 1236 | global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
976 | 1237 | |
977 | 1238 | $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
— | — | @@ -1014,7 +1275,15 @@ |
1015 | 1276 | } |
1016 | 1277 | |
1017 | 1278 | class SFCategoryInput extends SFFormInput { |
1018 | | - static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1279 | + public static function getName() { |
| 1280 | + return 'category'; |
| 1281 | + } |
| 1282 | + |
| 1283 | + public static function getOtherPropTypesHandled() { |
| 1284 | + return array( '_wpg' ); |
| 1285 | + } |
| 1286 | + |
| 1287 | + static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
1019 | 1288 | // escape if CategoryTree extension isn't included |
1020 | 1289 | if ( ! function_exists( 'efCategoryTreeParserHook' ) ) |
1021 | 1290 | return null; |
— | — | @@ -1083,10 +1352,26 @@ |
1084 | 1353 | |
1085 | 1354 | return $text; |
1086 | 1355 | } |
| 1356 | + |
| 1357 | + public static function getParameters() { |
| 1358 | + $params = parent::getParameters(); |
| 1359 | + $params[] = array( 'name' => 'top category', 'type' => 'string' ); |
| 1360 | + $params[] = array( 'name' => 'height', 'type' => 'int' ); |
| 1361 | + $params[] = array( 'name' => 'width', 'type' => 'int' ); |
| 1362 | + return $params; |
| 1363 | + } |
1087 | 1364 | } |
1088 | 1365 | |
1089 | | -class SFCategoriesInput { |
1090 | | - static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 1366 | +class SFCategoriesInput extends SFCategoryInput { |
| 1367 | + public static function getName() { |
| 1368 | + return 'categories'; |
| 1369 | + } |
| 1370 | + |
| 1371 | + public static function getOtherPropTypeListsHandled() { |
| 1372 | + return array( '_wpg' ); |
| 1373 | + } |
| 1374 | + |
| 1375 | + static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
1091 | 1376 | // escape if CategoryTree extension isn't included |
1092 | 1377 | if ( ! function_exists( 'efCategoryTreeParserHook' ) ) |
1093 | 1378 | return null; |