Upgraded to latest version of Smarty 2.6.9

This commit is contained in:
thepurpleblob
2005-04-19 09:52:16 +00:00
parent f55a672eea
commit c38950b11b
49 changed files with 678 additions and 510 deletions
@@ -8,11 +8,11 @@
/**
* Smarty {html_select_date} plugin
*
* Type: function<br />
* Name: html_select_date<br />
* Type: function<br>
* Name: html_select_date<br>
* Purpose: Prints the dropdowns for date selection.
*
* ChangeLog:<br />
* ChangeLog:<br>
* - 1.0 initial release
* - 1.1 added support for +/- N syntax for begin
* and end year values. (Monte)
@@ -22,9 +22,11 @@
* month values (Gary Loescher)
* - 1.3.1 added support for choosing format for
* day values (Marcus Bointon)
* - 1.3.2 suppport negative timestamps, force year
* dropdown to include given date unless explicitly set (Monte)
* @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date}
* (Smarty online manual)
* @version 1.3.1
* @version 1.3.2
* @author Andrei Zmievski
* @param array
* @param Smarty
@@ -122,16 +124,19 @@ function smarty_function_html_select_date($params, &$smarty)
}
}
if(preg_match('!^-\d+$!',$time)) {
// negative timestamp, use date()
$time = date('Y-m-d',$time);
}
// If $time is not in format yyyy-mm-dd
if (!preg_match('/^\d{0,4}-\d{0,2}-\d{0,2}$/', $time)) {
// then $time is empty or unix timestamp or mysql timestamp
// using smarty_make_timestamp to get an unix timestamp and
// use smarty_make_timestamp to get an unix timestamp and
// strftime to make yyyy-mm-dd
$time = strftime('%Y-%m-%d', smarty_make_timestamp($time));
}
// Now split this in pieces, which later can be used to set the select
$time = explode("-", $time);
// make syntax "+N" or "-N" work with start_year and end_year
if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
if ($match[1] == '+') {
@@ -147,6 +152,16 @@ function smarty_function_html_select_date($params, &$smarty)
$start_year = strftime('%Y') - $match[2];
}
}
if (strlen($time[0]) > 0) {
if ($start_year > $time[0] && !isset($params['start_year'])) {
// force start year to include given date if not explicitly set
$start_year = $time[0];
}
if($end_year < $time[0] && !isset($params['end_year'])) {
// force end year to include given date if not explicitly set
$end_year = $time[0];
}
}
$field_order = strtoupper($field_order);
@@ -183,10 +198,9 @@ function smarty_function_html_select_date($params, &$smarty)
$month_result .= smarty_function_html_options(array('output' => $month_names,
'values' => $month_values,
'selected' => $month_values[(int)$time[1]],
'selected' => $a=$time[1] ? strftime($month_value_format, mktime(0, 0, 0, (int)$time[1], 1, 2000)) : '',
'print_result' => false),
$smarty);
$month_result .= '</select>';
}
@@ -244,6 +258,8 @@ function smarty_function_html_select_date($params, &$smarty)
$years = range((int)$start_year, (int)$end_year);
if ($reverse_years) {
rsort($years, SORT_NUMERIC);
} else {
sort($years, SORT_NUMERIC);
}
$yearvals = $years;
if(isset($year_empty)) {