Changeset 1434
- Timestamp:
- 06/13/06 14:27:05 (2 years ago)
- Files:
-
- trunk/lib/helper/FormHelper.php (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/helper/FormHelper.php
r1433 r1434 562 562 } 563 563 564 function select_day_tag($name, $value, $options = array(), $html_options = array()) 565 { 564 function select_day_tag($name, $value = null, $options = array(), $html_options = array()) 565 { 566 if ($value === null) 567 { 568 $value = date('j'); 569 } 570 566 571 $options = _parse_attributes($options); 567 572 … … 578 583 for ($x = 1; $x < 32; $x++) 579 584 { 580 $select_options[$x] = _ add_zeros($x, 2);585 $select_options[$x] = _prepend_zeros($x, 2); 581 586 } 582 587 … … 584 589 } 585 590 586 function select_month_tag($name, $value, $options = array(), $html_options = array()) 587 { 591 function select_month_tag($name, $value = null, $options = array(), $html_options = array()) 592 { 593 if ($value === null) 594 { 595 $value = date('n'); 596 } 597 588 598 $options = _parse_attributes($options); 589 599 … … 605 615 for ($k = 1; $k < 13; $k++) 606 616 { 607 $select_options[$k] = _ add_zeros($k, 2);617 $select_options[$k] = _prepend_zeros($k, 2); 608 618 } 609 619 } … … 629 639 } 630 640 631 function select_year_tag($name, $value, $options = array(), $html_options = array()) 632 { 641 function select_year_tag($name, $value = null, $options = array(), $html_options = array()) 642 { 643 if ($value === null) 644 { 645 $value = date('Y'); 646 } 647 633 648 $options = _parse_attributes($options); 634 649 … … 675 690 * @return string 676 691 */ 677 function select_date_tag($name, $value , $options = array(), $html_options = array())692 function select_date_tag($name, $value = null, $options = array(), $html_options = array()) 678 693 { 679 694 $options = _parse_attributes($options); … … 733 748 } 734 749 735 $html_options['id'] = $name . '_month'; 736 $m = (!$discard_month) ? select_month_tag($name . '[month]', _parse_value_for_date($value, 'month', 'm'), $options + $include_custom_month, $html_options) : ''; 737 738 $html_options['id'] = $name . '_day'; 739 $d = (!$discard_day) ? select_day_tag($name . '[day]', _parse_value_for_date($value, 'day', 'd'), $options + $include_custom_day, $html_options) : ''; 740 741 $html_options['id'] = $name . '_year'; 742 $y = (!$discard_year) ? select_year_tag($name . '[year]', _parse_value_for_date($value, 'year', 'Y'), $options + $include_custom_year, $html_options) : ''; 750 $month_name = $name . '[month]'; 751 $m = (!$discard_month) ? select_month_tag($month_name, _parse_value_for_date($value, 'month', 'm'), $options + $include_custom_month, $html_options) : ''; 752 753 754 $day_name = $name . '[day]'; 755 $d = (!$discard_day) ? select_day_tag($day_name, _parse_value_for_date($value, 'day', 'd'), $options + $include_custom_day, $html_options) : ''; 756 757 $year_name = $name . '[year]'; 758 $y = (!$discard_year) ? select_year_tag($year_name, _parse_value_for_date($value, 'year', 'Y'), $options + $include_custom_year, $html_options) : ''; 743 759 744 760 // we have $tags = array ('m','d','y') … … 752 768 } 753 769 754 function select_second_tag($name, $value, $options = array(), $html_options = array()) 755 { 770 function select_second_tag($name, $value = null, $options = array(), $html_options = array()) 771 { 772 if ($value === null) 773 { 774 $value = date('s'); 775 } 776 756 777 $options = _parse_attributes($options); 757 778 $select_options = array(); … … 769 790 for ($x = 0; $x < 60; $x += $second_step) 770 791 { 771 $select_options[$x] = _ add_zeros($x, 2);792 $select_options[$x] = _prepend_zeros($x, 2); 772 793 } 773 794 … … 775 796 } 776 797 777 function select_minute_tag($name, $value, $options = array(), $html_options = array()) 778 { 798 function select_minute_tag($name, $value = null, $options = array(), $html_options = array()) 799 { 800 if ($value === null) 801 { 802 $value = date('i'); 803 } 804 779 805 $options = _parse_attributes($options); 780 806 $select_options = array(); … … 792 818 for ($x = 0; $x < 60; $x += $minute_step) 793 819 { 794 $select_options[$x] = _ add_zeros($x, 2);820 $select_options[$x] = _prepend_zeros($x, 2); 795 821 } 796 822 … … 798 824 } 799 825 800 function select_hour_tag($name, $value, $options = array(), $html_options = array()) 801 { 826 function select_hour_tag($name, $value = null, $options = array(), $html_options = array()) 827 { 828 if ($value === null) 829 { 830 $value = date('h'); 831 } 832 802 833 $options = _parse_attributes($options); 803 834 $select_options = array(); … … 819 850 for ($x = $start_hour; $x <= $end_hour; $x++) 820 851 { 821 $select_options[$x] = _ add_zeros($x, 2);852 $select_options[$x] = _prepend_zeros($x, 2); 822 853 } 823 854 … … 825 856 } 826 857 827 function select_ampm_tag($name, $value, $options = array(), $html_options = array()) 828 { 858 function select_ampm_tag($name, $value = null, $options = array(), $html_options = array()) 859 { 860 if ($value === null) 861 { 862 $value = date('A'); 863 } 864 829 865 $options = _parse_attributes($options); 830 866 $select_options = array(); … … 854 890 * @return string 855 891 */ 856 function select_time_tag($name, $value , $options = array(), $html_options = array())892 function select_time_tag($name, $value = null, $options = array(), $html_options = array()) 857 893 { 858 894 $options = _parse_attributes($options); … … 893 929 $tags = array(); 894 930 895 $h tml_options['id'] = $name . '_hour';896 $tags[] = select_hour_tag($ name . '[hour]', _parse_value_for_date($value, 'hour', ($_12hour_time) ? 'h' : 'H'), $options + $include_custom_hour, $html_options);897 898 $ html_options['id'] = $name . '_minute';899 $tags[] = select_minute_tag($ name . '[minute]', _parse_value_for_date($value, 'minute', 'i'), $options + $include_custom_minute, $html_options);931 $hour_name = $name . '[hour]'; 932 $tags[] = select_hour_tag($hour_name, _parse_value_for_date($value, 'hour', ($_12hour_time) ? 'h' : 'H'), $options + $include_custom_hour, $html_options); 933 934 $minute_name = $name . '[minute]'; 935 $tags[] = select_minute_tag($minute_name, _parse_value_for_date($value, 'minute', 'i'), $options + $include_custom_minute, $html_options); 900 936 901 937 if ($include_second) 902 938 { 903 $ html_options['id'] = $name . '_second';904 $tags[] = select_second_tag($ name . "[second]", _parse_value_for_date($value, 'second', 's'), $options + $include_custom_second, $html_options);939 $second_name = $name . '[second]'; 940 $tags[] = select_second_tag($second_name, _parse_value_for_date($value, 'second', 's'), $options + $include_custom_second, $html_options); 905 941 } 906 942 … … 909 945 if ($_12hour_time) 910 946 { 911 $ html_options['id'] = $name . '_ampm';912 $time .= $ampm_seperator . select_ampm_tag($ name . "[ampm]", _parse_value_for_date($value, 'ampm', 'A'), $options + $include_custom_ampm, $html_options);947 $ampm_name = $name . "[ampm]"; 948 $time .= $ampm_seperator . select_ampm_tag($ampm_name, _parse_value_for_date($value, 'ampm', 'A'), $options + $include_custom_ampm, $html_options); 913 949 } 914 950 … … 924 960 * @return string 925 961 */ 926 function select_datetime_tag($name, $value , $options = array(), $html_options = array())962 function select_datetime_tag($name, $value = null, $options = array(), $html_options = array()) 927 963 { 928 964 $options = _parse_attributes($options); … … 957 993 } 958 994 959 function _ add_zeros($string, $strlen)995 function _prepend_zeros($string, $strlen) 960 996 { 961 997 if ($strlen > strlen($string)) … … 1026 1062 return $value; 1027 1063 } 1064 else if (empty($value)) 1065 { 1066 $value = date('Y-m-d H:i:s'); 1067 } 1028 1068 1029 1069 // english text presentation