aboutsummaryrefslogtreecommitdiffstats
path: root/include/smarty/libs/plugins/function.html_select_time.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/smarty/libs/plugins/function.html_select_time.php')
-rw-r--r--include/smarty/libs/plugins/function.html_select_time.php72
1 files changed, 35 insertions, 37 deletions
diff --git a/include/smarty/libs/plugins/function.html_select_time.php b/include/smarty/libs/plugins/function.html_select_time.php
index 9fb8038e4..9af6aad5b 100644
--- a/include/smarty/libs/plugins/function.html_select_time.php
+++ b/include/smarty/libs/plugins/function.html_select_time.php
@@ -2,7 +2,7 @@
/**
* Smarty plugin
*
- * @package Smarty
+ * @package Smarty
* @subpackage PluginsFunction
*/
@@ -17,21 +17,21 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
/**
* Smarty {html_select_time} function plugin
- *
* Type: function<br>
* Name: html_select_time<br>
* Purpose: Prints the dropdowns for time selection
*
- * @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
- * (Smarty online manual)
- * @author Roberto Berto <roberto@berto.net>
- * @author Monte Ohrt <monte AT ohrt DOT com>
- * @param array $params parameters
- * @param Smarty_Internal_Template $template template object
+ * @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
+ * (Smarty online manual)
+ * @author Roberto Berto <roberto@berto.net>
+ * @author Monte Ohrt <monte AT ohrt DOT com>
+ *
+ * @param array $params parameters
+ *
* @return string
- * @uses smarty_make_timestamp()
+ * @uses smarty_make_timestamp()
*/
-function smarty_function_html_select_time($params, $template)
+function smarty_function_html_select_time($params)
{
$prefix = "Time_";
$field_array = null;
@@ -117,7 +117,7 @@ function smarty_function_html_select_time($params, $template)
case 'minute_value_format':
case 'second_format':
case 'second_value_format':
- $$_key = (string)$_value;
+ $$_key = (string) $_value;
break;
case 'display_hours':
@@ -125,7 +125,7 @@ function smarty_function_html_select_time($params, $template)
case 'display_seconds':
case 'display_meridian':
case 'use_24_hours':
- $$_key = (bool)$_value;
+ $$_key = (bool) $_value;
break;
case 'minute_interval':
@@ -135,7 +135,7 @@ function smarty_function_html_select_time($params, $template)
case 'minute_size':
case 'second_size':
case 'meridian_size':
- $$_key = (int)$_value;
+ $$_key = (int) $_value;
break;
default:
@@ -151,7 +151,7 @@ function smarty_function_html_select_time($params, $template)
if (isset($params['time']) && is_array($params['time'])) {
if (isset($params['time'][$prefix . 'Hour'])) {
// $_REQUEST[$field_array] given
- foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
+ foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName);
$$_variableName = isset($params['time'][$prefix . $_elementName])
? $params['time'][$prefix . $_elementName]
@@ -160,11 +160,11 @@ function smarty_function_html_select_time($params, $template)
$_meridian = isset($params['time'][$prefix . 'Meridian'])
? (' ' . $params['time'][$prefix . 'Meridian'])
: '';
- $time = strtotime( $_hour . ':' . $_minute . ':' . $_second . $_meridian );
+ $time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian);
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
} elseif (isset($params['time'][$field_array][$prefix . 'Hour'])) {
// $_REQUEST given
- foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
+ foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName);
$$_variableName = isset($params['time'][$field_array][$prefix . $_elementName])
? $params['time'][$field_array][$prefix . $_elementName]
@@ -173,7 +173,7 @@ function smarty_function_html_select_time($params, $template)
$_meridian = isset($params['time'][$field_array][$prefix . 'Meridian'])
? (' ' . $params['time'][$field_array][$prefix . 'Meridian'])
: '';
- $time = strtotime( $_hour . ':' . $_minute . ':' . $_second . $_meridian );
+ $time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian);
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
} else {
// no date found, use NOW
@@ -204,8 +204,8 @@ function smarty_function_html_select_time($params, $template)
$_html_hours = '<select name="' . $_name . '"';
if ($hour_id !== null || $all_id !== null) {
$_html_hours .= ' id="' . smarty_function_escape_special_chars(
- $hour_id !== null ? ( $hour_id ? $hour_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
- ) . '"';
+ $hour_id !== null ? ($hour_id ? $hour_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
+ ) . '"';
}
if ($hour_size) {
$_html_hours .= ' size="' . $hour_size . '"';
@@ -213,12 +213,12 @@ function smarty_function_html_select_time($params, $template)
$_html_hours .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($hour_empty) || isset($all_empty)) {
- $_html_hours .= '<option value="">' . ( isset($hour_empty) ? $hour_empty : $all_empty ) . '</option>' . $option_separator;
+ $_html_hours .= '<option value="">' . (isset($hour_empty) ? $hour_empty : $all_empty) . '</option>' . $option_separator;
}
$start = $use_24_hours ? 0 : 1;
$end = $use_24_hours ? 23 : 12;
- for ($i=$start; $i <= $end; $i++) {
+ for ($i = $start; $i <= $end; $i ++) {
$_val = sprintf('%02d', $i);
$_text = $hour_format == '%02d' ? $_val : sprintf($hour_format, $i);
$_value = $hour_value_format == '%02d' ? $_val : sprintf($hour_value_format, $i);
@@ -226,7 +226,7 @@ function smarty_function_html_select_time($params, $template)
if (!$use_24_hours) {
$_hour12 = $_hour == 0
? 12
- : ($_hour <= 12 ? $_hour : $_hour -12);
+ : ($_hour <= 12 ? $_hour : $_hour - 12);
}
$selected = $_hour !== null ? ($use_24_hours ? $_hour == $_val : $_hour12 == $_val) : null;
@@ -253,8 +253,8 @@ function smarty_function_html_select_time($params, $template)
$_html_minutes = '<select name="' . $_name . '"';
if ($minute_id !== null || $all_id !== null) {
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
- $minute_id !== null ? ( $minute_id ? $minute_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
- ) . '"';
+ $minute_id !== null ? ($minute_id ? $minute_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
+ ) . '"';
}
if ($minute_size) {
$_html_minutes .= ' size="' . $minute_size . '"';
@@ -262,11 +262,11 @@ function smarty_function_html_select_time($params, $template)
$_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($minute_empty) || isset($all_empty)) {
- $_html_minutes .= '<option value="">' . ( isset($minute_empty) ? $minute_empty : $all_empty ) . '</option>' . $option_separator;
+ $_html_minutes .= '<option value="">' . (isset($minute_empty) ? $minute_empty : $all_empty) . '</option>' . $option_separator;
}
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
- for ($i=0; $i <= 59; $i += $minute_interval) {
+ for ($i = 0; $i <= 59; $i += $minute_interval) {
$_val = sprintf('%02d', $i);
$_text = $minute_format == '%02d' ? $_val : sprintf($minute_format, $i);
$_value = $minute_value_format == '%02d' ? $_val : sprintf($minute_value_format, $i);
@@ -293,8 +293,8 @@ function smarty_function_html_select_time($params, $template)
$_html_seconds = '<select name="' . $_name . '"';
if ($second_id !== null || $all_id !== null) {
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
- $second_id !== null ? ( $second_id ? $second_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
- ) . '"';
+ $second_id !== null ? ($second_id ? $second_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
+ ) . '"';
}
if ($second_size) {
$_html_seconds .= ' size="' . $second_size . '"';
@@ -302,11 +302,11 @@ function smarty_function_html_select_time($params, $template)
$_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($second_empty) || isset($all_empty)) {
- $_html_seconds .= '<option value="">' . ( isset($second_empty) ? $second_empty : $all_empty ) . '</option>' . $option_separator;
+ $_html_seconds .= '<option value="">' . (isset($second_empty) ? $second_empty : $all_empty) . '</option>' . $option_separator;
}
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
- for ($i=0; $i <= 59; $i += $second_interval) {
+ for ($i = 0; $i <= 59; $i += $second_interval) {
$_val = sprintf('%02d', $i);
$_text = $second_format == '%02d' ? $_val : sprintf($second_format, $i);
$_value = $second_value_format == '%02d' ? $_val : sprintf($second_value_format, $i);
@@ -333,8 +333,8 @@ function smarty_function_html_select_time($params, $template)
$_html_meridian = '<select name="' . $_name . '"';
if ($meridian_id !== null || $all_id !== null) {
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
- $meridian_id !== null ? ( $meridian_id ? $meridian_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
- ) . '"';
+ $meridian_id !== null ? ($meridian_id ? $meridian_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
+ ) . '"';
}
if ($meridian_size) {
$_html_meridian .= ' size="' . $meridian_size . '"';
@@ -342,11 +342,11 @@ function smarty_function_html_select_time($params, $template)
$_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($meridian_empty) || isset($all_empty)) {
- $_html_meridian .= '<option value="">' . ( isset($meridian_empty) ? $meridian_empty : $all_empty ) . '</option>' . $option_separator;
+ $_html_meridian .= '<option value="">' . (isset($meridian_empty) ? $meridian_empty : $all_empty) . '</option>' . $option_separator;
}
- $_html_meridian .= '<option value="am"'. ($_hour < 12 ? ' selected="selected"' : '') .'>AM</option>' . $option_separator
- . '<option value="pm"'. ($_hour < 12 ? '' : ' selected="selected"') .'>PM</option>' . $option_separator
+ $_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') . '>AM</option>' . $option_separator
+ . '<option value="pm"' . ($_hour < 12 ? '' : ' selected="selected"') . '>PM</option>' . $option_separator
. '</select>';
}
@@ -362,5 +362,3 @@ function smarty_function_html_select_time($params, $template)
return $_html;
}
-
-?> \ No newline at end of file