5 Modification information for LGPL compliance
7 r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
9 r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
11 r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
13 r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3 tags and updated the build system
15 r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
17 r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
19 r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
21 r10971 - 2006-01-12 14:58:30 -0800 (Thu, 12 Jan 2006) - chris - Bug 4128: updating Smarty templates to 2.6.11, a version supposedly that plays better with PHP 5.1
23 r8230 - 2005-10-03 17:47:19 -0700 (Mon, 03 Oct 2005) - majed - Added Sugar_Smarty to the code tree.
37 * Smarty {html_select_time} function plugin
40 * Name: html_select_time<br>
41 * Purpose: Prints the dropdowns for time selection
42 * @link http://smarty.php.net/manual/en/language.function.html.select.time.php {html_select_time}
43 * (Smarty online manual)
44 * @author Roberto Berto <roberto@berto.net>
45 * @credits Monte Ohrt <monte AT ohrt DOT com>
49 * @uses smarty_make_timestamp()
51 function smarty_function_html_select_time($params, &$smarty)
53 require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
54 require_once $smarty->_get_plugin_filepath('function','html_options');
58 $display_hours = true;
59 $display_minutes = true;
60 $display_seconds = true;
61 $display_meridian = true;
65 /* Should the select boxes be part of an array when returned from PHP?
66 e.g. setting it to "birthday", would create "birthday[Hour]",
67 "birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]".
68 Can be combined with prefix. */
74 $meridian_extra = null;
76 foreach ($params as $_key=>$_value) {
85 case 'meridian_extra':
86 $$_key = (string)$_value;
90 case 'display_minutes':
91 case 'display_seconds':
92 case 'display_meridian':
94 $$_key = (bool)$_value;
97 case 'minute_interval':
98 case 'second_interval':
99 $$_key = (int)$_value;
103 $smarty->trigger_error("[html_select_time] unknown parameter $_key", E_USER_WARNING);
107 $time = smarty_make_timestamp($time);
111 if ($display_hours) {
112 $hours = $use_24_hours ? range(0, 23) : range(1, 12);
113 $hour_fmt = $use_24_hours ? '%H' : '%I';
114 for ($i = 0, $for_max = count($hours); $i < $for_max; $i++)
115 $hours[$i] = sprintf('%02d', $hours[$i]);
116 $html_result .= '<select name=';
117 if (null !== $field_array) {
118 $html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"';
120 $html_result .= '"' . $prefix . 'Hour"';
122 if (null !== $hour_extra){
123 $html_result .= ' ' . $hour_extra;
125 if (null !== $all_extra){
126 $html_result .= ' ' . $all_extra;
128 $html_result .= '>'."\n";
129 $html_result .= smarty_function_html_options(array('output' => $hours,
131 'selected' => strftime($hour_fmt, $time),
132 'print_result' => false),
134 $html_result .= "</select>\n";
137 if ($display_minutes) {
138 $all_minutes = range(0, 59);
139 for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval)
140 $minutes[] = sprintf('%02d', $all_minutes[$i]);
141 $selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
142 $html_result .= '<select name=';
143 if (null !== $field_array) {
144 $html_result .= '"' . $field_array . '[' . $prefix . 'Minute]"';
146 $html_result .= '"' . $prefix . 'Minute"';
148 if (null !== $minute_extra){
149 $html_result .= ' ' . $minute_extra;
151 if (null !== $all_extra){
152 $html_result .= ' ' . $all_extra;
154 $html_result .= '>'."\n";
156 $html_result .= smarty_function_html_options(array('output' => $minutes,
157 'values' => $minutes,
158 'selected' => $selected,
159 'print_result' => false),
161 $html_result .= "</select>\n";
164 if ($display_seconds) {
165 $all_seconds = range(0, 59);
166 for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval)
167 $seconds[] = sprintf('%02d', $all_seconds[$i]);
168 $selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
169 $html_result .= '<select name=';
170 if (null !== $field_array) {
171 $html_result .= '"' . $field_array . '[' . $prefix . 'Second]"';
173 $html_result .= '"' . $prefix . 'Second"';
176 if (null !== $second_extra){
177 $html_result .= ' ' . $second_extra;
179 if (null !== $all_extra){
180 $html_result .= ' ' . $all_extra;
182 $html_result .= '>'."\n";
184 $html_result .= smarty_function_html_options(array('output' => $seconds,
185 'values' => $seconds,
186 'selected' => $selected,
187 'print_result' => false),
189 $html_result .= "</select>\n";
192 if ($display_meridian && !$use_24_hours) {
193 $html_result .= '<select name=';
194 if (null !== $field_array) {
195 $html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]"';
197 $html_result .= '"' . $prefix . 'Meridian"';
200 if (null !== $meridian_extra){
201 $html_result .= ' ' . $meridian_extra;
203 if (null !== $all_extra){
204 $html_result .= ' ' . $all_extra;
206 $html_result .= '>'."\n";
208 $html_result .= smarty_function_html_options(array('output' => array('AM', 'PM'),
209 'values' => array('am', 'pm'),
210 'selected' => strtolower(strftime('%p', $time)),
211 'print_result' => false),
213 $html_result .= "</select>\n";
219 /* vim: set expandtab: */