Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.inc |
— | — | @@ -5,6 +5,7 @@ |
6 | 6 | * @author Yaron Koren |
7 | 7 | * @author Jeffrey Stuckman |
8 | 8 | * @author Matt Williamson |
| 9 | + * @author Patrick Nagel |
9 | 10 | */ |
10 | 11 | |
11 | 12 | class SFFormInputs { |
— | — | @@ -465,7 +466,7 @@ |
466 | 467 | } |
467 | 468 | |
468 | 469 | function dateEntryHTML($date, $input_name, $is_mandatory, $is_disabled, $other_args) { |
469 | | - global $sfgTabIndex, $sfgFieldNum, $sfgJSValidationCalls; |
| 470 | + global $sfgTabIndex, $sfgFieldNum, $sfgJSValidationCalls, $wgAmericanDates; |
470 | 471 | |
471 | 472 | $input_id = "input_$sfgFieldNum"; |
472 | 473 | $info_id = "info_$sfgFieldNum"; |
— | — | @@ -495,16 +496,22 @@ |
496 | 497 | $month = $cur_date['month']; |
497 | 498 | $day = null; // no need for day |
498 | 499 | } |
| 500 | + $text = ""; |
499 | 501 | $disabled_text = ($is_disabled) ? "disabled" : ""; |
500 | | - $text = SFFormInputs::monthDropdownHTML($month, $input_name, $is_disabled); |
501 | | - $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_day" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>' . "\n"; |
| 502 | + if ($wgAmericanDates) { |
| 503 | + $text .= SFFormInputs::monthDropdownHTML($month, $input_name, $is_disabled); |
| 504 | + $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_day" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>' . "\n"; |
| 505 | + } else { |
| 506 | + $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_day" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>' . "\n"; |
| 507 | + $text .= SFFormInputs::monthDropdownHTML($month, $input_name, $is_disabled); |
| 508 | + } |
502 | 509 | $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_year" name="' . $input_name . '[year]" type="text" value="' . $year . '" size="4" ' . $disabled_text . '/>' . "\n"; |
503 | 510 | $text .= " <span id=\"$info_id\" class=\"errorMessage\"></span>"; |
504 | 511 | return array($text, null); |
505 | 512 | } |
506 | 513 | |
507 | 514 | function dateTimeEntryHTML($datetime, $input_name, $is_mandatory, $is_disabled, $other_args) { |
508 | | - global $sfgTabIndex; |
| 515 | + global $sfgTabIndex, $sfg24HourTime; |
509 | 516 | |
510 | 517 | $include_timezone = $other_args['include_timezone']; |
511 | 518 | |
— | — | @@ -515,14 +522,22 @@ |
516 | 523 | if (isset($datetime['hour'])) $hour = $cur_value['hour']; |
517 | 524 | if (isset($datetime['minute'])) $minute = $cur_value['minute']; |
518 | 525 | if (isset($datetime['second'])) $second = $cur_value['second']; |
519 | | - if (isset($datetime['ampm24h'])) $ampm24h = $cur_value['ampm24h']; |
| 526 | + if (! $sfg24HourTime) { |
| 527 | + if (isset($datetime['ampm24h'])) $ampm24h = $cur_value['ampm24h']; |
| 528 | + } |
520 | 529 | if (isset($datetime['timezone'])) $timezone = $cur_value['timezone']; |
521 | 530 | } else { |
522 | 531 | $actual_date = strtotime($datetime); |
523 | | - $hour = date("g", $actual_date); |
| 532 | + if ($sfg24HourTime) { |
| 533 | + $hour = date("G", $actual_date); |
| 534 | + } else { |
| 535 | + $hour = date("g", $actual_date); |
| 536 | + } |
524 | 537 | $minute = date("i", $actual_date); |
525 | 538 | $second = date("s", $actual_date); |
526 | | - $ampm24h = date("A", $actual_date); |
| 539 | + if (! $sfg24HourTime) { |
| 540 | + $ampm24h = date("A", $actual_date); |
| 541 | + } |
527 | 542 | $timezone = date("T", $actual_date); |
528 | 543 | } |
529 | 544 | } else { |
— | — | @@ -541,15 +556,17 @@ |
542 | 557 | $sfgTabIndex++; |
543 | 558 | $text .= ':<input tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[second]" type="text" value="' . $second . '" size="2"/ ' . $disabled_text . '>' . "\n"; |
544 | 559 | |
545 | | - $sfgTabIndex++; |
546 | | - $text .= ' <select tabindex="' . $sfgTabIndex . '" name="' . $input_name . "[ampm24h]\" $disabled_text>\n"; |
547 | | - $ampm24h_options = array('', 'AM', 'PM'); |
548 | | - foreach ($ampm24h_options as $value) { |
549 | | - $text .= " <option value=\"$value\""; |
550 | | - if ($value == $ampm24h) {$text .= " selected=\"selected\""; } |
551 | | - $text .= ">$value</option>\n"; |
| 560 | + if (! $sfg24HourTime) { |
| 561 | + $sfgTabIndex++; |
| 562 | + $text .= ' <select tabindex="' . $sfgTabIndex . '" name="' . $input_name . "[ampm24h]\" $disabled_text>\n"; |
| 563 | + $ampm24h_options = array('', 'AM', 'PM'); |
| 564 | + foreach ($ampm24h_options as $value) { |
| 565 | + $text .= " <option value=\"$value\""; |
| 566 | + if ($value == $ampm24h) {$text .= " selected=\"selected\""; } |
| 567 | + $text .= ">$value</option>\n"; |
| 568 | + } |
| 569 | + $text .= " </select>\n"; |
552 | 570 | } |
553 | | - $text .= " </select>\n"; |
554 | 571 | |
555 | 572 | if ($include_timezone) { |
556 | 573 | $sfgTabIndex++; |