- replaced most hard errors (exceptions) by softerrors(trigger_error) in plugins

This commit is contained in:
Uwe.Tews
2009-12-01 20:34:32 +00:00
parent e5cd6c8a17
commit 7e45bcf527
14 changed files with 35 additions and 34 deletions

View File

@@ -2,6 +2,7 @@
- fixed parsing of names of special formated tags like if,elseif,while,for,foreach
- removed direct access to constants in templates because of some syntax problems
- removed cache resource plugin for mysql from the distribution
- replaced most hard errors (exceptions) by softerrors(trigger_error) in plugins
11/30/2009
- map 'true' to SMARTY_CACHING_LIFETIME_CURRENT for the $smarty->caching parameter

View File

@@ -50,7 +50,7 @@ function smarty_function_cycle($params, $smarty, $template)
if (!in_array('values', array_keys($params))) {
if(!isset($template->plugin_data['cycle'][$name]['values'])) {
throw new Exception ("cycle: missing 'values' parameter");
trigger_error("cycle: missing 'values' parameter",E_USER_WARNING);
return;
}
} else {

View File

@@ -24,7 +24,7 @@
function smarty_function_fetch($params, $smarty, $template)
{
if (empty($params['file'])) {
throw new Exception ("[plugin] fetch parameter 'file' cannot be empty");
trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE);
return;
}
@@ -41,7 +41,7 @@ function smarty_function_fetch($params, $smarty, $template)
}
fclose($fp);
} else {
throw new Exception ('[plugin] fetch cannot read file \'' . $params['file'] . '\'');
trigger_error('[plugin] fetch cannot read file \'' . $params['file'] . '\'',E_USER_NOTICE);
return;
}
} else {
@@ -94,7 +94,7 @@ function smarty_function_fetch($params, $smarty, $template)
case "header":
if(!empty($param_value)) {
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
throw new Exception ("[plugin] invalid header format '".$param_value."'");
trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE);
return;
} else {
$extra_headers[] = $param_value;
@@ -110,7 +110,7 @@ function smarty_function_fetch($params, $smarty, $template)
if(!preg_match('!\D!', $param_value)) {
$proxy_port = (int) $param_value;
} else {
throw new Exception ("[plugin] invalid value for attribute '".$param_key."'");
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
return;
}
break;
@@ -128,12 +128,12 @@ function smarty_function_fetch($params, $smarty, $template)
if(!preg_match('!\D!', $param_value)) {
$timeout = (int) $param_value;
} else {
throw new Exception ("[plugin] invalid value for attribute '".$param_key."'");
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
return;
}
break;
default:
throw new Exception ("[plugin] unrecognized attribute '".$param_key."'");
trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE);
return;
}
}
@@ -145,7 +145,7 @@ function smarty_function_fetch($params, $smarty, $template)
}
if(!$fp) {
throw new Exception ("[plugin] unable to fetch: $errstr ($errno)");
trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE);
return;
} else {
if($_is_proxy) {
@@ -188,7 +188,7 @@ function smarty_function_fetch($params, $smarty, $template)
}
}
} else {
throw new Exception ("[plugin] unable to parse URL, check syntax");
trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE);
return;
}
} else {
@@ -199,7 +199,7 @@ function smarty_function_fetch($params, $smarty, $template)
}
fclose($fp);
} else {
throw new Exception ('[plugin] fetch cannot read file \'' . $params['file'] .'\'');
trigger_error('[plugin] fetch cannot read file \'' . $params['file'] .'\'',E_USER_NOTICE);
return;
}
}

View File

@@ -80,7 +80,7 @@ function smarty_function_html_checkboxes($params, $smarty, $template)
break;
case 'checkboxes':
throw new Exception ('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING);
trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING);
$options = (array)$_val;
break;
@@ -91,7 +91,7 @@ function smarty_function_html_checkboxes($params, $smarty, $template)
if(!is_array($_val)) {
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
} else {
throw new Exception ("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}

View File

@@ -85,7 +85,7 @@ function smarty_function_html_image($params, $smarty, $template)
}
if (empty($file)) {
throw new Exception ("html_image: missing 'file' parameter", E_USER_NOTICE);
trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
return;
}
@@ -98,13 +98,13 @@ function smarty_function_html_image($params, $smarty, $template)
if (!isset($params['width']) || !isset($params['height'])) {
if (!$_image_data = @getimagesize($_image_path)) {
if (!file_exists($_image_path)) {
throw new Exception ("html_image: unable to find '$_image_path'", E_USER_NOTICE);
trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
return;
} else if (!is_readable($_image_path)) {
throw new Exception ("html_image: unable to read '$_image_path'", E_USER_NOTICE);
trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
return;
} else {
throw new Exception ("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
return;
}
}

View File

@@ -66,7 +66,7 @@ function smarty_function_html_options($params, $smarty, $template)
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
} else {
throw new Exception ("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}

View File

@@ -65,7 +65,7 @@ function smarty_function_html_radios($params, $smarty, $template)
case 'checked':
case 'selected':
if (is_array($_val)) {
throw new Exception ('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
} else {
$selected = (string)$_val;
}
@@ -86,7 +86,7 @@ function smarty_function_html_radios($params, $smarty, $template)
break;
case 'radios':
throw new Exception ('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING);
trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING);
$options = (array)$_val;
break;
@@ -97,7 +97,7 @@ function smarty_function_html_radios($params, $smarty, $template)
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
} else {
throw new Exception ("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}

View File

@@ -134,7 +134,7 @@ function smarty_function_html_select_date($params, $smarty, $template)
if (!is_array($_value)) {
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
} else {
throw new Exception ("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}

View File

@@ -78,7 +78,7 @@ function smarty_function_html_select_time($params, $smarty, $template)
break;
default:
throw new Exception ("[html_select_time] unknown parameter $_key", E_USER_WARNING);
trigger_error("[html_select_time] unknown parameter $_key", E_USER_WARNING);
}
}

View File

@@ -63,7 +63,7 @@ function smarty_function_html_table($params, $smarty, $template)
$caption = '';
if (!isset($params['loop'])) {
throw new Exception ("html_table: missing 'loop' parameter");
trigger_error("html_table: missing 'loop' parameter",E_USER_WARNING);
return;
}

View File

@@ -54,7 +54,7 @@ function smarty_function_mailto($params, $smarty, $template)
$extra = '';
if (empty($params['address'])) {
throw new Exception ("mailto: missing 'address' parameter");
trigger_error("mailto: missing 'address' parameter",E_USER_WARNING);
return;
} else {
$address = $params['address'];
@@ -97,7 +97,7 @@ function smarty_function_mailto($params, $smarty, $template)
$encode = (empty($params['encode'])) ? 'none' : $params['encode'];
if (!in_array($encode, array('javascript', 'javascript_charcode', 'hex', 'none'))) {
throw new Exception ("mailto: 'encode' parameter must be none, javascript or hex");
trigger_error("mailto: 'encode' parameter must be none, javascript or hex",E_USER_WARNING);
return;
}
@@ -130,7 +130,7 @@ function smarty_function_mailto($params, $smarty, $template)
} elseif ($encode == 'hex') {
preg_match('!^(.*)(\?.*)$!', $address, $match);
if (!empty($match[2])) {
throw new Exception ("mailto: hex encoding does not work with extra attributes. Try javascript.");
trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.",E_USER_WARNING);
return;
}
$address_encode = '';

View File

@@ -26,7 +26,7 @@ function smarty_function_math($params, $smarty, $template)
{
// be sure equation parameter is present
if (empty($params['equation'])) {
throw new Exception ("math: missing equation parameter");
trigger_error("math: missing equation parameter",E_USER_WARNING);
return;
}
@@ -34,7 +34,7 @@ function smarty_function_math($params, $smarty, $template)
// make sure parenthesis are balanced
if (substr_count($equation,"(") != substr_count($equation,")")) {
throw new Exception ("math: unbalanced parenthesis");
trigger_error("math: unbalanced parenthesis",E_USER_WARNING);
return;
}
@@ -45,7 +45,7 @@ function smarty_function_math($params, $smarty, $template)
foreach($match[1] as $curr_var) {
if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
throw new Exception ("math: function call $curr_var not allowed");
trigger_error("math: function call $curr_var not allowed",E_USER_WARNING);
return;
}
}
@@ -54,11 +54,11 @@ function smarty_function_math($params, $smarty, $template)
if ($key != "equation" && $key != "format" && $key != "assign") {
// make sure value is not empty
if (strlen($val)==0) {
throw new Exception ("math: parameter $key is empty");
trigger_error("math: parameter $key is empty",E_USER_WARNING);
return;
}
if (!is_numeric($val)) {
throw new Exception ("math: parameter $key: is not numeric");
trigger_error("math: parameter $key: is not numeric",E_USER_WARNING);
return;
}
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);

View File

@@ -96,12 +96,12 @@ function smarty_function_popup($params, $smarty, $template)
break;
default:
throw new Exception ("[popup] unknown parameter $_key", E_USER_WARNING);
trigger_error("[popup] unknown parameter $_key", E_USER_WARNING);
}
}
if (empty($text) && !isset($inarray) && empty($function)) {
throw new Exception ("overlib: attribute 'text' or 'inarray' or 'function' required");
trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required",E_USER_WARNING);
return false;
}

View File

@@ -32,7 +32,7 @@ function smarty_function_popup_init($params, $smarty, $template)
return '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:'.$zindex.';"></div>' . "\n"
. '<script type="text/javascript" language="JavaScript" src="'.$params['src'].'"></script>' . "\n";
} else {
throw new Exception ("popup_init: missing src parameter");
trigger_error("popup_init: missing src parameter",E_USER_WARNING);
}
}