26 require_once $smarty->_get_plugin_filepath(
'shared',
'make_timestamp');
27 require_once $smarty->_get_plugin_filepath(
'function',
'html_options');
31 $display_hours =
true;
32 $display_minutes =
true;
33 $display_seconds =
true;
34 $display_meridian =
true;
47 $meridian_extra = null;
49 foreach ($params as $_key=>$_value) {
58 case 'meridian_extra':
59 $$_key = (string)$_value;
63 case 'display_minutes':
64 case 'display_seconds':
65 case 'display_meridian':
67 $$_key = (bool)$_value;
70 case 'minute_interval':
71 case 'second_interval':
72 $$_key = (int)$_value;
76 $smarty->trigger_error(
"[html_select_time] unknown parameter $_key", E_USER_WARNING);
85 $hours = $use_24_hours ? range(0, 23) : range(1, 12);
86 $hour_fmt = $use_24_hours ?
'%H' :
'%I';
87 for (
$i = 0, $for_max = count($hours);
$i < $for_max;
$i++)
88 $hours[
$i] = sprintf(
'%02d', $hours[
$i]);
89 $html_result .=
'<select name=';
90 if (null !== $field_array) {
91 $html_result .=
'"' . $field_array .
'[' . $prefix .
'Hour]"';
93 $html_result .=
'"' . $prefix .
'Hour"';
95 if (null !== $hour_extra){
96 $html_result .=
' ' . $hour_extra;
98 if (null !== $all_extra){
99 $html_result .=
' ' . $all_extra;
101 $html_result .=
'>'.
"\n";
104 'selected' => strftime($hour_fmt,
$time),
105 'print_result' =>
false),
107 $html_result .=
"</select>\n";
110 if ($display_minutes) {
111 $all_minutes = range(0, 59);
112 for (
$i = 0, $for_max = count($all_minutes);
$i < $for_max;
$i+= $minute_interval)
113 $minutes[] = sprintf(
'%02d', $all_minutes[
$i]);
114 $selected = intval(floor(strftime(
'%M',
$time) / $minute_interval) * $minute_interval);
115 $html_result .=
'<select name=';
116 if (null !== $field_array) {
117 $html_result .=
'"' . $field_array .
'[' . $prefix .
'Minute]"';
119 $html_result .=
'"' . $prefix .
'Minute"';
121 if (null !== $minute_extra){
122 $html_result .=
' ' . $minute_extra;
124 if (null !== $all_extra){
125 $html_result .=
' ' . $all_extra;
127 $html_result .=
'>'.
"\n";
130 'values' => $minutes,
131 'selected' => $selected,
132 'print_result' =>
false),
134 $html_result .=
"</select>\n";
137 if ($display_seconds) {
138 $all_seconds = range(0, 59);
139 for (
$i = 0, $for_max = count($all_seconds);
$i < $for_max;
$i+= $second_interval)
140 $seconds[] = sprintf(
'%02d', $all_seconds[
$i]);
141 $selected = intval(floor(strftime(
'%S',
$time) / $second_interval) * $second_interval);
142 $html_result .=
'<select name=';
143 if (null !== $field_array) {
144 $html_result .=
'"' . $field_array .
'[' . $prefix .
'Second]"';
146 $html_result .=
'"' . $prefix .
'Second"';
149 if (null !== $second_extra){
150 $html_result .=
' ' . $second_extra;
152 if (null !== $all_extra){
153 $html_result .=
' ' . $all_extra;
155 $html_result .=
'>'.
"\n";
158 'values' => $seconds,
159 'selected' => $selected,
160 'print_result' =>
false),
162 $html_result .=
"</select>\n";
165 if ($display_meridian && !$use_24_hours) {
166 $html_result .=
'<select name=';
167 if (null !== $field_array) {
168 $html_result .=
'"' . $field_array .
'[' . $prefix .
'Meridian]"';
170 $html_result .=
'"' . $prefix .
'Meridian"';
173 if (null !== $meridian_extra){
174 $html_result .=
' ' . $meridian_extra;
176 if (null !== $all_extra){
177 $html_result .=
' ' . $all_extra;
179 $html_result .=
'>'.
"\n";
182 'values' => array(
'am',
'pm'),
183 'selected' => strtolower(strftime(
'%p',
$time)),
184 'print_result' =>
false),
186 $html_result .=
"</select>\n";