Redbean + Smarty update

This commit is contained in:
Robin Kloppe 2014-10-13 11:24:53 +02:00
parent c1b8226466
commit eb0835ff74
122 changed files with 12653 additions and 11637 deletions

View file

@ -2,7 +2,7 @@
/**
* Smarty plugin
*
* @package Smarty
* @package Smarty
* @subpackage PluginsFunction
*/
@ -17,11 +17,9 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
/**
* Smarty {html_select_date} plugin
*
* Type: function<br>
* Name: html_select_date<br>
* Purpose: Prints the dropdowns for date selection.
*
* ChangeLog:
* <pre>
* - 1.0 initial release
@ -41,17 +39,18 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
* added attributes month_names, *_id
* </pre>
*
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
* (Smarty online manual)
* @version 2.0
* @author Andrei Zmievski
* @author Monte Ohrt <monte at ohrt dot com>
* @author Rodney Rehm
* @param array $params parameters
* @param Smarty_Internal_Template $template template object
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
* (Smarty online manual)
* @version 2.0
* @author Andrei Zmievski
* @author Monte Ohrt <monte at ohrt dot com>
* @author Rodney Rehm
*
* @param array $params parameters
*
* @return string
*/
function smarty_function_html_select_date($params, $template)
function smarty_function_html_select_date($params)
{
// generate timestamps used for month names only
static $_month_timestamps = null;
@ -59,7 +58,7 @@ function smarty_function_html_select_date($params, $template)
if ($_month_timestamps === null) {
$_current_year = date('Y');
$_month_timestamps = array();
for ($i = 1; $i <= 12; $i++) {
for ($i = 1; $i <= 12; $i ++) {
$_month_timestamps[$i] = mktime(0, 0, 0, $i, 1, 2000);
}
}
@ -181,22 +180,20 @@ function smarty_function_html_select_date($params, $template)
if (isset($params['time']) && is_array($params['time'])) {
if (isset($params['time'][$prefix . 'Year'])) {
// $_REQUEST[$field_array] given
foreach (array('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($params['time'][$prefix . $_elementName])
? $params['time'][$prefix . $_elementName]
: date($_elementKey);
}
$time = mktime(0, 0, 0, $_month, $_day, $_year);
} elseif (isset($params['time'][$field_array][$prefix . 'Year'])) {
// $_REQUEST given
foreach (array('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($params['time'][$field_array][$prefix . $_elementName])
? $params['time'][$field_array][$prefix . $_elementName]
: date($_elementKey);
}
$time = mktime(0, 0, 0, $_month, $_day, $_year);
} else {
// no date found, use NOW
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
@ -219,9 +216,9 @@ function smarty_function_html_select_date($params, $template)
if ($t === null) {
$$key = (int) $_current_year;
} elseif ($t[0] == '+') {
$$key = (int) ($_current_year + trim(substr($t, 1)));
$$key = (int) ($_current_year + (int)trim(substr($t, 1)));
} elseif ($t[0] == '-') {
$$key = (int) ($_current_year - trim(substr($t, 1)));
$$key = (int) ($_current_year - (int)trim(substr($t, 1)));
} else {
$$key = (int) $$key;
}
@ -236,7 +233,6 @@ function smarty_function_html_select_date($params, $template)
// generate year <select> or <input>
if ($display_years) {
$_html_years = '';
$_extra = '';
$_name = $field_array ? ($field_array . '[' . $prefix . 'Year]') : ($prefix . 'Year');
if ($all_extra) {
@ -252,8 +248,8 @@ function smarty_function_html_select_date($params, $template)
$_html_years = '<select name="' . $_name . '"';
if ($year_id !== null || $all_id !== null) {
$_html_years .= ' id="' . smarty_function_escape_special_chars(
$year_id !== null ? ( $year_id ? $year_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
) . '"';
$year_id !== null ? ($year_id ? $year_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
) . '"';
}
if ($year_size) {
$_html_years .= ' size="' . $year_size . '"';
@ -261,11 +257,11 @@ function smarty_function_html_select_date($params, $template)
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($year_empty) || isset($all_empty)) {
$_html_years .= '<option value="">' . ( isset($year_empty) ? $year_empty : $all_empty ) . '</option>' . $option_separator;
$_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' . $option_separator;
}
$op = $start_year > $end_year ? -1 : 1;
for ($i=$start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) {
$op = $start_year > $end_year ? - 1 : 1;
for ($i = $start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) {
$_html_years .= '<option value="' . $i . '"'
. ($_year == $i ? ' selected="selected"' : '')
. '>' . $i . '</option>' . $option_separator;
@ -277,7 +273,6 @@ function smarty_function_html_select_date($params, $template)
// generate month <select> or <input>
if ($display_months) {
$_html_month = '';
$_extra = '';
$_name = $field_array ? ($field_array . '[' . $prefix . 'Month]') : ($prefix . 'Month');
if ($all_extra) {
@ -290,8 +285,8 @@ function smarty_function_html_select_date($params, $template)
$_html_months = '<select name="' . $_name . '"';
if ($month_id !== null || $all_id !== null) {
$_html_months .= ' id="' . smarty_function_escape_special_chars(
$month_id !== null ? ( $month_id ? $month_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
) . '"';
$month_id !== null ? ($month_id ? $month_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
) . '"';
}
if ($month_size) {
$_html_months .= ' size="' . $month_size . '"';
@ -299,10 +294,10 @@ function smarty_function_html_select_date($params, $template)
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($month_empty) || isset($all_empty)) {
$_html_months .= '<option value="">' . ( isset($month_empty) ? $month_empty : $all_empty ) . '</option>' . $option_separator;
$_html_months .= '<option value="">' . (isset($month_empty) ? $month_empty : $all_empty) . '</option>' . $option_separator;
}
for ($i = 1; $i <= 12; $i++) {
for ($i = 1; $i <= 12; $i ++) {
$_val = sprintf('%02d', $i);
$_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[$i]) : ($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[$i]));
$_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[$i]);
@ -316,7 +311,6 @@ function smarty_function_html_select_date($params, $template)
// generate day <select> or <input>
if ($display_days) {
$_html_day = '';
$_extra = '';
$_name = $field_array ? ($field_array . '[' . $prefix . 'Day]') : ($prefix . 'Day');
if ($all_extra) {
@ -329,8 +323,8 @@ function smarty_function_html_select_date($params, $template)
$_html_days = '<select name="' . $_name . '"';
if ($day_id !== null || $all_id !== null) {
$_html_days .= ' id="' . smarty_function_escape_special_chars(
$day_id !== null ? ( $day_id ? $day_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
) . '"';
$day_id !== null ? ($day_id ? $day_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
) . '"';
}
if ($day_size) {
$_html_days .= ' size="' . $day_size . '"';
@ -338,13 +332,13 @@ function smarty_function_html_select_date($params, $template)
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($day_empty) || isset($all_empty)) {
$_html_days .= '<option value="">' . ( isset($day_empty) ? $day_empty : $all_empty ) . '</option>' . $option_separator;
$_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' . $option_separator;
}
for ($i = 1; $i <= 31; $i++) {
for ($i = 1; $i <= 31; $i ++) {
$_val = sprintf('%02d', $i);
$_text = $day_format == '%02d' ? $_val : sprintf($day_format, $i);
$_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i);
$_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i);
$_html_days .= '<option value="' . $_value . '"'
. ($_val == $_day ? ' selected="selected"' : '')
. '>' . $_text . '</option>' . $option_separator;
@ -355,7 +349,7 @@ function smarty_function_html_select_date($params, $template)
// order the fields for output
$_html = '';
for ($i=0; $i <= 2; $i++) {
for ($i = 0; $i <= 2; $i ++) {
switch ($field_order[$i]) {
case 'Y':
case 'y':
@ -365,7 +359,7 @@ function smarty_function_html_select_date($params, $template)
}
$_html .= $_html_years;
}
break;
break;
case 'm':
case 'M':
@ -375,7 +369,7 @@ function smarty_function_html_select_date($params, $template)
}
$_html .= $_html_months;
}
break;
break;
case 'd':
case 'D':
@ -385,7 +379,7 @@ function smarty_function_html_select_date($params, $template)
}
$_html .= $_html_days;
}
break;
break;
}
}