12 require_once(SMARTY_PLUGINS_DIR .
'shared.escape_special_chars.php');
16 require_once(SMARTY_PLUGINS_DIR .
'shared.make_timestamp.php');
38 $field_separator =
"\n";
39 $option_separator =
"\n";
42 $display_hours =
true;
43 $display_minutes =
true;
44 $display_seconds =
true;
45 $display_meridian =
true;
47 $hour_format =
'%02d';
48 $hour_value_format =
'%02d';
49 $minute_format =
'%02d';
50 $minute_value_format =
'%02d';
51 $second_format =
'%02d';
52 $second_value_format =
'%02d';
57 $meridian_size = null;
63 $meridian_empty = null;
80 $meridian_extra = null;
82 foreach ($params as $_key => $_value) {
85 if (!is_array($_value) && $_value !== null) {
93 case 'field_separator':
94 case 'option_separator':
100 case 'meridian_extra':
106 case 'meridian_empty':
115 case 'hour_value_format':
116 case 'minute_format':
117 case 'minute_value_format':
118 case 'second_format':
119 case 'second_value_format':
120 $$_key = (string)$_value;
123 case 'display_hours':
124 case 'display_minutes':
125 case 'display_seconds':
126 case 'display_meridian':
128 $$_key = (bool)$_value;
131 case 'minute_interval':
132 case 'second_interval':
137 case 'meridian_size':
138 $$_key = (int)$_value;
142 if (!is_array($_value)) {
143 $extra_attrs .=
' ' . $_key .
'="' . smarty_function_escape_special_chars($_value) .
'"';
145 trigger_error(
"html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
151 if (isset($params[
'time']) && is_array($params[
'time'])) {
152 if (isset($params[
'time'][$prefix .
'Hour'])) {
154 foreach (array(
'H' =>
'Hour',
'i' =>
'Minute',
's' =>
'Second') as $_elementKey => $_elementName) {
155 $_variableName =
'_' . strtolower($_elementName);
156 $$_variableName = isset($params[
'time'][$prefix . $_elementName])
157 ? $params[
'time'][$prefix . $_elementName]
158 : date($_elementKey);
160 $_meridian = isset($params[
'time'][$prefix .
'Meridian'])
161 ? (
' ' . $params[
'time'][$prefix .
'Meridian'])
163 $time = strtotime( $_hour .
':' . $_minute .
':' . $_second . $_meridian );
164 list($_hour, $_minute, $_second) = $time = explode(
'-', date(
'H-i-s', $time));
165 }
elseif (isset($params[
'time'][$field_array][$prefix .
'Hour'])) {
167 foreach (array(
'H' =>
'Hour',
'i' =>
'Minute',
's' =>
'Second') as $_elementKey => $_elementName) {
168 $_variableName =
'_' . strtolower($_elementName);
169 $$_variableName = isset($params[
'time'][$field_array][$prefix . $_elementName])
170 ? $params[
'time'][$field_array][$prefix . $_elementName]
171 : date($_elementKey);
173 $_meridian = isset($params[
'time'][$field_array][$prefix .
'Meridian'])
174 ? (
' ' . $params[
'time'][$field_array][$prefix .
'Meridian'])
176 $time = strtotime( $_hour .
':' . $_minute .
':' . $_second . $_meridian );
177 list($_hour, $_minute, $_second) = $time = explode(
'-', date(
'H-i-s', $time));
180 list($_year, $_month, $_day) = $time = explode(
'-', date(
'Y-m-d'));
182 }
elseif ($time === null) {
183 if (array_key_exists(
'time', $params)) {
184 $_hour = $_minute = $_second = $time = null;
186 list($_hour, $_minute, $_second) = $time = explode(
'-', date(
'H-i-s'));
189 list($_hour, $_minute, $_second) = $time = explode(
'-', date(
'H-i-s', $time));
193 if ($display_hours) {
196 $_name = $field_array ? ($field_array .
'[' . $prefix .
'Hour]') : ($prefix .
'Hour');
198 $_extra .=
' ' . $all_extra;
201 $_extra .=
' ' . $hour_extra;
204 $_html_hours =
'<select name="' . $_name .
'"';
205 if ($hour_id !== null || $all_id !== null) {
206 $_html_hours .=
' id="' . smarty_function_escape_special_chars(
207 $hour_id !== null ? ( $hour_id ? $hour_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
211 $_html_hours .=
' size="' . $hour_size .
'"';
213 $_html_hours .= $_extra . $extra_attrs .
'>' . $option_separator;
215 if (isset($hour_empty) || isset($all_empty)) {
216 $_html_hours .=
'<option value="">' . ( isset($hour_empty) ? $hour_empty : $all_empty ) .
'</option>' . $option_separator;
219 $start = $use_24_hours ? 0 : 1;
220 $end = $use_24_hours ? 23 : 12;
222 $_val = sprintf(
'%02d',
$i);
223 $_text = $hour_format ==
'%02d' ? $_val : sprintf($hour_format,
$i);
224 $_value = $hour_value_format ==
'%02d' ? $_val : sprintf($hour_value_format,
$i);
226 if (!$use_24_hours) {
227 $_hour12 = $_hour == 0
229 : ($_hour <= 12 ? $_hour : $_hour -12);
232 $selected = $_hour !== null ? ($use_24_hours ? $_hour == $_val : $_hour12 == $_val) : null;
233 $_html_hours .=
'<option value="' . $_value .
'"'
234 . ($selected ?
' selected="selected"' :
'')
235 .
'>' . $_text .
'</option>' . $option_separator;
238 $_html_hours .=
'</select>';
242 if ($display_minutes) {
245 $_name = $field_array ? ($field_array .
'[' . $prefix .
'Minute]') : ($prefix .
'Minute');
247 $_extra .=
' ' . $all_extra;
250 $_extra .=
' ' . $minute_extra;
253 $_html_minutes =
'<select name="' . $_name .
'"';
254 if ($minute_id !== null || $all_id !== null) {
255 $_html_minutes .=
' id="' . smarty_function_escape_special_chars(
256 $minute_id !== null ? ( $minute_id ? $minute_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
260 $_html_minutes .=
' size="' . $minute_size .
'"';
262 $_html_minutes .= $_extra . $extra_attrs .
'>' . $option_separator;
264 if (isset($minute_empty) || isset($all_empty)) {
265 $_html_minutes .=
'<option value="">' . ( isset($minute_empty) ? $minute_empty : $all_empty ) .
'</option>' . $option_separator;
268 $selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
269 for (
$i=0;
$i <= 59;
$i += $minute_interval) {
270 $_val = sprintf(
'%02d',
$i);
271 $_text = $minute_format ==
'%02d' ? $_val : sprintf($minute_format,
$i);
272 $_value = $minute_value_format ==
'%02d' ? $_val : sprintf($minute_value_format,
$i);
273 $_html_minutes .=
'<option value="' . $_value .
'"'
274 . ($selected ===
$i ?
' selected="selected"' :
'')
275 .
'>' . $_text .
'</option>' . $option_separator;
278 $_html_minutes .=
'</select>';
282 if ($display_seconds) {
285 $_name = $field_array ? ($field_array .
'[' . $prefix .
'Second]') : ($prefix .
'Second');
287 $_extra .=
' ' . $all_extra;
290 $_extra .=
' ' . $second_extra;
293 $_html_seconds =
'<select name="' . $_name .
'"';
294 if ($second_id !== null || $all_id !== null) {
295 $_html_seconds .=
' id="' . smarty_function_escape_special_chars(
296 $second_id !== null ? ( $second_id ? $second_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
300 $_html_seconds .=
' size="' . $second_size .
'"';
302 $_html_seconds .= $_extra . $extra_attrs .
'>' . $option_separator;
304 if (isset($second_empty) || isset($all_empty)) {
305 $_html_seconds .=
'<option value="">' . ( isset($second_empty) ? $second_empty : $all_empty ) .
'</option>' . $option_separator;
308 $selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
309 for (
$i=0;
$i <= 59;
$i += $second_interval) {
310 $_val = sprintf(
'%02d',
$i);
311 $_text = $second_format ==
'%02d' ? $_val : sprintf($second_format,
$i);
312 $_value = $second_value_format ==
'%02d' ? $_val : sprintf($second_value_format,
$i);
313 $_html_seconds .=
'<option value="' . $_value .
'"'
314 . ($selected ===
$i ?
' selected="selected"' :
'')
315 .
'>' . $_text .
'</option>' . $option_separator;
318 $_html_seconds .=
'</select>';
322 if ($display_meridian && !$use_24_hours) {
323 $_html_meridian =
'';
325 $_name = $field_array ? ($field_array .
'[' . $prefix .
'Meridian]') : ($prefix .
'Meridian');
327 $_extra .=
' ' . $all_extra;
329 if ($meridian_extra) {
330 $_extra .=
' ' . $meridian_extra;
333 $_html_meridian =
'<select name="' . $_name .
'"';
334 if ($meridian_id !== null || $all_id !== null) {
335 $_html_meridian .=
' id="' . smarty_function_escape_special_chars(
336 $meridian_id !== null ? ( $meridian_id ? $meridian_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
339 if ($meridian_size) {
340 $_html_meridian .=
' size="' . $meridian_size .
'"';
342 $_html_meridian .= $_extra . $extra_attrs .
'>' . $option_separator;
344 if (isset($meridian_empty) || isset($all_empty)) {
345 $_html_meridian .=
'<option value="">' . ( isset($meridian_empty) ? $meridian_empty : $all_empty ) .
'</option>' . $option_separator;
348 $_html_meridian .=
'<option value="am"'. ($_hour < 12 ?
' selected="selected"' :
'') .
'>AM</option>' . $option_separator
349 .
'<option value="pm"'. ($_hour < 12 ?
'' :
' selected="selected"') .
'>PM</option>' . $option_separator
354 foreach (array(
'_html_hours',
'_html_minutes',
'_html_seconds',
'_html_meridian') as $k) {
357 $_html .= $field_separator;
smarty_make_timestamp($string)
Function: smarty_make_timestamp Purpose: used by other smarty functions to make a timestamp from a s...
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
smarty_function_html_select_time($params, $template)