diff options
Diffstat (limited to 'vendor/smarty/smarty/libs/plugins/function.html_select_date.php')
-rw-r--r-- | vendor/smarty/smarty/libs/plugins/function.html_select_date.php | 69 |
1 files changed, 31 insertions, 38 deletions
diff --git a/vendor/smarty/smarty/libs/plugins/function.html_select_date.php b/vendor/smarty/smarty/libs/plugins/function.html_select_date.php index a396046b2..763fc60f9 100644 --- a/vendor/smarty/smarty/libs/plugins/function.html_select_date.php +++ b/vendor/smarty/smarty/libs/plugins/function.html_select_date.php @@ -101,7 +101,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem $field_separator = "\n"; $option_separator = "\n"; $time = null; - // $all_empty = null; // $day_empty = null; // $month_empty = null; @@ -114,7 +113,17 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem foreach ($params as $_key => $_value) { switch ($_key) { case 'time': - $$_key = $_value; // we'll handle conversion below + if (!is_array($_value) && $_value !== null) { + $template->_checkPlugins( + array( + array( + 'function' => 'smarty_make_timestamp', + 'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php' + ) + ) + ); + $time = smarty_make_timestamp($_value); + } break; case 'month_names': if (is_array($_value) && count($_value) === 12) { @@ -169,59 +178,43 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem } // Note: date() is faster than strftime() // Note: explode(date()) is faster than date() date() date() - - if (isset($time) && is_array($time)) { - if (isset($time[$prefix . 'Year'])) { + if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) { + if (isset($params[ 'time' ][ $prefix . 'Year' ])) { // $_REQUEST[$field_array] given - foreach ([ - 'Y' => 'Year', - 'm' => 'Month', - 'd' => 'Day' - ] as $_elementKey => $_elementName) { + foreach (array( + 'Y' => 'Year', + 'm' => 'Month', + 'd' => 'Day' + ) as $_elementKey => $_elementName) { $_variableName = '_' . strtolower($_elementName); $$_variableName = - isset($time[$prefix . $_elementName]) ? $time[$prefix . $_elementName] : + isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] : date($_elementKey); } - } elseif (isset($time[$field_array][$prefix . 'Year'])) { + } elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) { // $_REQUEST given - foreach ([ - 'Y' => 'Year', - 'm' => 'Month', - 'd' => 'Day' - ] as $_elementKey => $_elementName) { + foreach (array( + 'Y' => 'Year', + 'm' => 'Month', + 'd' => 'Day' + ) as $_elementKey => $_elementName) { $_variableName = '_' . strtolower($_elementName); - $$_variableName = isset($time[$field_array][$prefix . $_elementName]) ? - $time[$field_array][$prefix . $_elementName] : date($_elementKey); + $$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ? + $params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey); } } else { // no date found, use NOW - [$_year, $_month, $_day] = explode('-', date('Y-m-d')); + list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); } - } elseif (isset($time) && preg_match("/(\d*)-(\d*)-(\d*)/", $time, $matches)) { - $_year = $_month = $_day = null; - if ($matches[1] > '') $_year = (int) $matches[1]; - if ($matches[2] > '') $_month = (int) $matches[2]; - if ($matches[3] > '') $_day = (int) $matches[3]; } elseif ($time === null) { if (array_key_exists('time', $params)) { - $_year = $_month = $_day = null; + $_year = $_month = $_day = $time = null; } else { - [$_year, $_month, $_day] = explode('-', date('Y-m-d')); + list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); } } else { - $template->_checkPlugins( - array( - array( - 'function' => 'smarty_make_timestamp', - 'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php' - ) - ) - ); - $time = smarty_make_timestamp($time); - [$_year, $_month, $_day] = explode('-', date('Y-m-d', $time)); + list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d', $time)); } - // make syntax "+N" or "-N" work with $start_year and $end_year // Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr foreach (array( |