diff --git a/NEWS b/NEWS
index e6e1627a..8a727b8d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+ - changed crc32() generated values, replace '-' with 'N' (Monte)
+ - added support for +/- N syntax in html_select_date year values (Monte)
- fixed behavior of inserts with script attribute. (Andrei)
- fixed bug with $smarty.cookies and $smarty.server. (Andrei)
- wordwrap and indent are missing from 2.0 release, now fixed. (Monte)
diff --git a/Smarty.class.php b/Smarty.class.php
index f11b924f..3b576363 100644
--- a/Smarty.class.php
+++ b/Smarty.class.php
@@ -1252,9 +1252,9 @@ function _run_insert_handler($args)
\*======================================================================*/
function _get_auto_filename($auto_base, $auto_source, $auto_id = null)
{
- $source_hash = crc32($auto_source);
+ $source_hash = str_replace('-','N',crc32($auto_source));
$res = $auto_base . '/' . substr($source_hash, 0, 3) . '/' .
- $source_hash . '/' . crc32($auto_id) . '.php';
+ $source_hash . '/' . str_replace('-','N',crc32($auto_id)) . '.php';
return $res;
}
@@ -1275,7 +1275,7 @@ function _run_insert_handler($args)
$tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id);
$res = is_file($tname) && unlink( $tname);
} else {
- $source_hash = crc32($auto_source);
+ $source_hash = str_replace('-','N',crc32($auto_source));
$tname = $auto_base . '/' . substr($source_hash, 0, 3) . '/' . $source_hash;
$res = $this->_rmdir($tname);
}
diff --git a/docs/designers.sgml b/docs/designers.sgml
index a0d02961..944515e8 100644
--- a/docs/designers.sgml
+++ b/docs/designers.sgml
@@ -3036,14 +3036,16 @@ OUTPUT:
string
No
current year
- the first year in the dropdown
+ the first year in the dropdown, either
+ year number, or relative to current year (+/- N)
end_year
string
No
same as start_year
- the last year in the dropdown
+ the last year in the dropdown, either
+ year number, or relative to current year (+/- N)
display_days
@@ -3249,9 +3251,10 @@ OUTPUT:
html_select_date
-{html_select_date prefix="StartDate" time=$time start_year=1995 end_year=2001 display_days=false}
+{* start and end year can be relative to current year *}
+{html_select_date prefix="StartDate" time=$time start_year="-5" end_year="+1" display_days=false}
-OUTPUT:
+OUTPUT: (current year is 2000)
<select name="StartDateMonth">
<option value="1">January</option>
diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php
index f11b924f..3b576363 100644
--- a/libs/Smarty.class.php
+++ b/libs/Smarty.class.php
@@ -1252,9 +1252,9 @@ function _run_insert_handler($args)
\*======================================================================*/
function _get_auto_filename($auto_base, $auto_source, $auto_id = null)
{
- $source_hash = crc32($auto_source);
+ $source_hash = str_replace('-','N',crc32($auto_source));
$res = $auto_base . '/' . substr($source_hash, 0, 3) . '/' .
- $source_hash . '/' . crc32($auto_id) . '.php';
+ $source_hash . '/' . str_replace('-','N',crc32($auto_id)) . '.php';
return $res;
}
@@ -1275,7 +1275,7 @@ function _run_insert_handler($args)
$tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id);
$res = is_file($tname) && unlink( $tname);
} else {
- $source_hash = crc32($auto_source);
+ $source_hash = str_replace('-','N',crc32($auto_source));
$tname = $auto_base . '/' . substr($source_hash, 0, 3) . '/' . $source_hash;
$res = $this->_rmdir($tname);
}
diff --git a/libs/plugins/function.fetch.php b/libs/plugins/function.fetch.php
index 17c0a58d..4b34f65e 100644
--- a/libs/plugins/function.fetch.php
+++ b/libs/plugins/function.fetch.php
@@ -13,7 +13,7 @@ function smarty_function_fetch($params, &$smarty)
$file = $params['file'];
if (empty($file)) {
- $smarty->trigger_error("parameter 'file' cannot be empty");
+ $smarty->_trigger_plugin_error("parameter 'file' cannot be empty");
return;
}
@@ -26,11 +26,11 @@ function smarty_function_fetch($params, &$smarty)
}
}
if (!$resource_is_secure) {
- $smarty->trigger_error("(secure mode) fetch '$file' is not allowed");
+ $smarty->_trigger_plugin_error("(secure mode) fetch '$file' is not allowed");
return;
}
if (!@is_readable($file)) {
- $smarty->trigger_error("fetch cannot read file '$file'");
+ $smarty->_trigger_plugin_error("fetch cannot read file '$file'");
return;
}
// fetch the file
@@ -89,7 +89,7 @@ function smarty_function_fetch($params, &$smarty)
case "header":
if(!empty($param_value)) {
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
- $smarty->trigger_error("invalid header format '".$param_value."'");
+ $smarty->_trigger_plugin_error("invalid header format '".$param_value."'");
return;
} else {
$extra_headers[] = $param_value;
@@ -105,7 +105,7 @@ function smarty_function_fetch($params, &$smarty)
if(!preg_match('!\D!', $param_value)) {
$proxy_port = (int) $param_value;
} else {
- $smarty->trigger_error("invalid value for attribute '".$param_key."'");
+ $smarty->_trigger_plugin_error("invalid value for attribute '".$param_key."'");
return;
}
break;
@@ -123,7 +123,7 @@ function smarty_function_fetch($params, &$smarty)
if(!preg_match('!\D!', $param_value)) {
$timeout = (int) $param_value;
} else {
- $smarty->trigger_error("invalid value for attribute '".$param_key."'");
+ $smarty->_trigger_plugin_error("invalid value for attribute '".$param_key."'");
return;
}
break;
@@ -134,7 +134,7 @@ function smarty_function_fetch($params, &$smarty)
}
break;
default:
- $smarty->trigger_error("unrecognized attribute '".$param_key."'");
+ $smarty->_trigger_plugin_error("unrecognized attribute '".$param_key."'");
return;
}
}
@@ -146,7 +146,7 @@ function smarty_function_fetch($params, &$smarty)
}
if(!$fp) {
- $smarty->trigger_error("unable to fetch: $errstr ($errno)");
+ $smarty->_trigger_plugin_error("unable to fetch: $errstr ($errno)");
return;
} else {
if($_is_proxy) {
@@ -189,7 +189,7 @@ function smarty_function_fetch($params, &$smarty)
}
}
} else {
- $smarty->trigger_error("unable to parse URL, check syntax");
+ $smarty->_trigger_plugin_error("unable to parse URL, check syntax");
return;
}
} else {
diff --git a/libs/plugins/function.html_select_date.php b/libs/plugins/function.html_select_date.php
index 46113a2c..e4bfbb04 100644
--- a/libs/plugins/function.html_select_date.php
+++ b/libs/plugins/function.html_select_date.php
@@ -5,7 +5,13 @@
* -------------------------------------------------------------
* Type: function
* Name: html_select_date
+ * Version: 1.1
* Purpose: Prints the dropdowns for date selection.
+ * Author: Andrei Zmievski
+ *
+ * ChangeLog: 1.0 initial release
+ * 1.1 added support for +/- N syntax for begin
+ * and end year values. (Monte)
* -------------------------------------------------------------
*/
require_once SMARTY_DIR . 'plugins/.make_timestamp.php';
@@ -49,6 +55,22 @@ function smarty_function_html_select_date($params, &$smarty)
extract($params);
+ // make syntax "+N" or "-N" work with start_year and end_year
+ if(preg_match('!(\+|\-)\s*(\d+)!',$end_year,$match)) {
+ if($match[1] == '+') {
+ $end_year = $match[2] + strftime("%Y");
+ } else {
+ $end_year = $match[2] - strftime("%Y");
+ }
+ }
+ if(preg_match('!(\+|\-)\s*(\d+)!',$start_year,$match)) {
+ if($match[1] == '+') {
+ $start_year = $match[2] + strftime("%Y");
+ } else {
+ $start_year = $match[2] - strftime("%Y");
+ }
+ }
+
$time = smarty_make_timestamp($time);
$field_order = strtoupper($field_order);
diff --git a/plugins/function.fetch.php b/plugins/function.fetch.php
index 17c0a58d..4b34f65e 100644
--- a/plugins/function.fetch.php
+++ b/plugins/function.fetch.php
@@ -13,7 +13,7 @@ function smarty_function_fetch($params, &$smarty)
$file = $params['file'];
if (empty($file)) {
- $smarty->trigger_error("parameter 'file' cannot be empty");
+ $smarty->_trigger_plugin_error("parameter 'file' cannot be empty");
return;
}
@@ -26,11 +26,11 @@ function smarty_function_fetch($params, &$smarty)
}
}
if (!$resource_is_secure) {
- $smarty->trigger_error("(secure mode) fetch '$file' is not allowed");
+ $smarty->_trigger_plugin_error("(secure mode) fetch '$file' is not allowed");
return;
}
if (!@is_readable($file)) {
- $smarty->trigger_error("fetch cannot read file '$file'");
+ $smarty->_trigger_plugin_error("fetch cannot read file '$file'");
return;
}
// fetch the file
@@ -89,7 +89,7 @@ function smarty_function_fetch($params, &$smarty)
case "header":
if(!empty($param_value)) {
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
- $smarty->trigger_error("invalid header format '".$param_value."'");
+ $smarty->_trigger_plugin_error("invalid header format '".$param_value."'");
return;
} else {
$extra_headers[] = $param_value;
@@ -105,7 +105,7 @@ function smarty_function_fetch($params, &$smarty)
if(!preg_match('!\D!', $param_value)) {
$proxy_port = (int) $param_value;
} else {
- $smarty->trigger_error("invalid value for attribute '".$param_key."'");
+ $smarty->_trigger_plugin_error("invalid value for attribute '".$param_key."'");
return;
}
break;
@@ -123,7 +123,7 @@ function smarty_function_fetch($params, &$smarty)
if(!preg_match('!\D!', $param_value)) {
$timeout = (int) $param_value;
} else {
- $smarty->trigger_error("invalid value for attribute '".$param_key."'");
+ $smarty->_trigger_plugin_error("invalid value for attribute '".$param_key."'");
return;
}
break;
@@ -134,7 +134,7 @@ function smarty_function_fetch($params, &$smarty)
}
break;
default:
- $smarty->trigger_error("unrecognized attribute '".$param_key."'");
+ $smarty->_trigger_plugin_error("unrecognized attribute '".$param_key."'");
return;
}
}
@@ -146,7 +146,7 @@ function smarty_function_fetch($params, &$smarty)
}
if(!$fp) {
- $smarty->trigger_error("unable to fetch: $errstr ($errno)");
+ $smarty->_trigger_plugin_error("unable to fetch: $errstr ($errno)");
return;
} else {
if($_is_proxy) {
@@ -189,7 +189,7 @@ function smarty_function_fetch($params, &$smarty)
}
}
} else {
- $smarty->trigger_error("unable to parse URL, check syntax");
+ $smarty->_trigger_plugin_error("unable to parse URL, check syntax");
return;
}
} else {
diff --git a/plugins/function.html_select_date.php b/plugins/function.html_select_date.php
index 46113a2c..e4bfbb04 100644
--- a/plugins/function.html_select_date.php
+++ b/plugins/function.html_select_date.php
@@ -5,7 +5,13 @@
* -------------------------------------------------------------
* Type: function
* Name: html_select_date
+ * Version: 1.1
* Purpose: Prints the dropdowns for date selection.
+ * Author: Andrei Zmievski
+ *
+ * ChangeLog: 1.0 initial release
+ * 1.1 added support for +/- N syntax for begin
+ * and end year values. (Monte)
* -------------------------------------------------------------
*/
require_once SMARTY_DIR . 'plugins/.make_timestamp.php';
@@ -49,6 +55,22 @@ function smarty_function_html_select_date($params, &$smarty)
extract($params);
+ // make syntax "+N" or "-N" work with start_year and end_year
+ if(preg_match('!(\+|\-)\s*(\d+)!',$end_year,$match)) {
+ if($match[1] == '+') {
+ $end_year = $match[2] + strftime("%Y");
+ } else {
+ $end_year = $match[2] - strftime("%Y");
+ }
+ }
+ if(preg_match('!(\+|\-)\s*(\d+)!',$start_year,$match)) {
+ if($match[1] == '+') {
+ $start_year = $match[2] + strftime("%Y");
+ } else {
+ $start_year = $match[2] - strftime("%Y");
+ }
+ }
+
$time = smarty_make_timestamp($time);
$field_order = strtoupper($field_order);