5 * -------------------------------------------------------------
7 * Name: html_select_time
8 * Purpose: Prints the dropdowns for time selection
9 * Taken from the original Smarty
10 * http://smarty.php.net
11 * -------------------------------------------------------------
13 function tpl_function_html_select_time($params, &$template_object)
15 require_once("shared.make_timestamp.php");
16 require_once("function.html_options.php");
21 $display_hours = true;
22 $display_minutes = true;
23 $display_seconds = true;
24 $display_meridian = true;
28 /* Should the select boxes be part of an array when returned from PHP?
29 e.g. setting it to "birthday", would create "birthday[Hour]",
30 "birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]".
31 Can be combined with prefix. */
37 $meridian_extra = null;
41 $time = tpl_make_timestamp($time);
47 $hours = $use_24_hours ?
range(0, 23) : range(1, 12);
48 $hour_fmt = $use_24_hours ?
'%H' : '%I';
49 for ($i = 0, $for_max = count($hours); $i < $for_max; $i++
)
51 $hours[$i] = sprintf('%02d', $hours[$i]);
53 $html_result .= '<select name=';
54 if (null !== $field_array)
56 $html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"';
60 $html_result .= '"' . $prefix . 'Hour"';
62 if (null !== $hour_extra)
64 $html_result .= ' ' . $hour_extra;
66 if (null !== $all_extra)
68 $html_result .= ' ' . $all_extra;
70 $html_result .= '>'."\n";
71 $html_result .= tpl_function_html_options(array('output' => $hours,
73 'selected' => strftime($hour_fmt, $time),
74 'print_result' => false),
76 $html_result .= "</select>\n";
81 $all_minutes = range(0, 59);
82 for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+
= $minute_interval)
84 $minutes[] = sprintf('%02d', $all_minutes[$i]);
86 $selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
87 $html_result .= '<select name=';
88 if (null !== $field_array)
90 $html_result .= '"' . $field_array . '[' . $prefix . 'Minute]"';
94 $html_result .= '"' . $prefix . 'Minute"';
96 if (null !== $minute_extra)
98 $html_result .= ' ' . $minute_extra;
100 if (null !== $all_extra)
102 $html_result .= ' ' . $all_extra;
104 $html_result .= '>'."\n";
105 $html_result .= tpl_function_html_options(array('output' => $minutes,
106 'values' => $minutes,
107 'selected' => $selected,
108 'print_result' => false),
110 $html_result .= "</select>\n";
113 if ($display_seconds)
115 $all_seconds = range(0, 59);
116 for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+
= $second_interval)
118 $seconds[] = sprintf('%02d', $all_seconds[$i]);
120 $selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
121 $html_result .= '<select name=';
122 if (null !== $field_array)
124 $html_result .= '"' . $field_array . '[' . $prefix . 'Second]"';
128 $html_result .= '"' . $prefix . 'Second"';
130 if (null !== $second_extra)
132 $html_result .= ' ' . $second_extra;
134 if (null !== $all_extra)
136 $html_result .= ' ' . $all_extra;
138 $html_result .= '>'."\n";
139 $html_result .= tpl_function_html_options(array('output' => $seconds,
140 'values' => $seconds,
141 'selected' => $selected,
142 'print_result' => false),
144 $html_result .= "</select>\n";
147 if ($display_meridian && !$use_24_hours)
149 $html_result .= '<select name=';
150 if (null !== $field_array)
152 $html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]"';
156 $html_result .= '"' . $prefix . 'Meridian"';
158 if (null !== $meridian_extra)
160 $html_result .= ' ' . $meridian_extra;
162 if (null !== $all_extra)
164 $html_result .= ' ' . $all_extra;
166 $html_result .= '>'."\n";
167 $html_result .= tpl_function_html_options(array('output' => array('AM', 'PM'),
168 'values' => array('am', 'pm'),
169 'selected' => strtolower(strftime('%p', $time)),
170 'print_result' => false),
172 $html_result .= "</select>\n";