mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 03:14:27 +02:00
- remove exception_handler property from Smarty class
- added Smarty's own exceptions SmartyException and SmartyCompilerException
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
13/08/2010
|
||||||
|
- remove exception_handler property from Smarty class
|
||||||
|
- added Smarty's own exceptions SmartyException and SmartyCompilerException
|
||||||
|
|
||||||
09/08/2010
|
09/08/2010
|
||||||
- bugfix on modifier with doublequoted strings as parameter containing embedded tags
|
- bugfix on modifier with doublequoted strings as parameter containing embedded tags
|
||||||
|
|
||||||
|
@@ -193,8 +193,6 @@ class Smarty extends Smarty_Internal_Data {
|
|||||||
public $properties = array();
|
public $properties = array();
|
||||||
// config type
|
// config type
|
||||||
public $default_config_type = 'file';
|
public $default_config_type = 'file';
|
||||||
// exception handler: array('ExceptionClass','ExceptionMethod');
|
|
||||||
public $exception_handler = null;
|
|
||||||
// cached template objects
|
// cached template objects
|
||||||
public $template_objects = null;
|
public $template_objects = null;
|
||||||
// check If-Modified-Since headers
|
// check If-Modified-Since headers
|
||||||
@@ -247,9 +245,6 @@ class Smarty extends Smarty_Internal_Data {
|
|||||||
mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET);
|
mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET);
|
||||||
}
|
}
|
||||||
$this->start_time = microtime(true);
|
$this->start_time = microtime(true);
|
||||||
// set exception handler
|
|
||||||
if (!empty($this->exception_handler))
|
|
||||||
set_exception_handler($this->exception_handler);
|
|
||||||
// set default dirs
|
// set default dirs
|
||||||
$this->template_dir = array('.' . DS . 'templates' . DS);
|
$this->template_dir = array('.' . DS . 'templates' . DS);
|
||||||
$this->compile_dir = '.' . DS . 'templates_c' . DS;
|
$this->compile_dir = '.' . DS . 'templates_c' . DS;
|
||||||
@@ -292,9 +287,6 @@ class Smarty extends Smarty_Internal_Data {
|
|||||||
*/
|
*/
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
// restore to previous exception handler, if any
|
|
||||||
if (!empty($this->exception_handler))
|
|
||||||
restore_exception_handler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -467,7 +459,7 @@ class Smarty extends Smarty_Internal_Data {
|
|||||||
$this->security_handler = new Smarty_Internal_Security_Handler($this);
|
$this->security_handler = new Smarty_Internal_Security_Handler($this);
|
||||||
$this->security = true;
|
$this->security = true;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Property security_class is not defined');
|
throw new SmartyException('Property security_class is not defined');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,7 +530,7 @@ class Smarty extends Smarty_Internal_Data {
|
|||||||
$_name_parts = explode('_', $_plugin_name, 3);
|
$_name_parts = explode('_', $_plugin_name, 3);
|
||||||
// class name must have three parts to be valid plugin
|
// class name must have three parts to be valid plugin
|
||||||
if (count($_name_parts) < 3 || $_name_parts[0] !== 'smarty') {
|
if (count($_name_parts) < 3 || $_name_parts[0] !== 'smarty') {
|
||||||
throw new Exception("plugin {$plugin_name} is not a valid name format");
|
throw new SmartyException("plugin {$plugin_name} is not a valid name format");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if type is "internal", get plugin from sysplugins
|
// if type is "internal", get plugin from sysplugins
|
||||||
@@ -587,7 +579,7 @@ class Smarty extends Smarty_Internal_Data {
|
|||||||
return $this->registered_filters[$type][$_filter_name] = $_plugin;
|
return $this->registered_filters[$type][$_filter_name] = $_plugin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception("{$type}filter \"{$name}\" not callable");
|
throw new SmartyException("{$type}filter \"{$name}\" not callable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,7 +603,7 @@ class Smarty extends Smarty_Internal_Data {
|
|||||||
*/
|
*/
|
||||||
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
||||||
{
|
{
|
||||||
throw new Exception("Smarty error: $error_msg");
|
throw new SmartyException("Smarty error: $error_msg");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -677,10 +669,10 @@ class Smarty extends Smarty_Internal_Data {
|
|||||||
function getRegisteredObject($name)
|
function getRegisteredObject($name)
|
||||||
{
|
{
|
||||||
if (!isset($this->registered_objects[$name]))
|
if (!isset($this->registered_objects[$name]))
|
||||||
throw new Exception("'$name' is not a registered object");
|
throw new SmartyException("'$name' is not a registered object");
|
||||||
|
|
||||||
if (!is_object($this->registered_objects[$name][0]))
|
if (!is_object($this->registered_objects[$name][0]))
|
||||||
throw new Exception("registered '$name' is not an object");
|
throw new SmartyException("registered '$name' is not an object");
|
||||||
|
|
||||||
return $this->registered_objects[$name][0];
|
return $this->registered_objects[$name][0];
|
||||||
}
|
}
|
||||||
@@ -740,7 +732,7 @@ class Smarty extends Smarty_Internal_Data {
|
|||||||
$camel_func = create_function('$c', 'return "_" . strtolower($c[1]);');
|
$camel_func = create_function('$c', 'return "_" . strtolower($c[1]);');
|
||||||
// PHP4 call to constructor?
|
// PHP4 call to constructor?
|
||||||
if (strtolower($name) == 'smarty') {
|
if (strtolower($name) == 'smarty') {
|
||||||
throw new Exception('Please use parent::__construct() to call parent constuctor');
|
throw new SmartyException('Please use parent::__construct() to call parent constuctor');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// see if this is a set/get for a property
|
// see if this is a set/get for a property
|
||||||
@@ -752,7 +744,7 @@ class Smarty extends Smarty_Internal_Data {
|
|||||||
// convert camel case to underscored name
|
// convert camel case to underscored name
|
||||||
$property_name = preg_replace_callback('/([A-Z])/', $camel_func, $property_name);
|
$property_name = preg_replace_callback('/([A-Z])/', $camel_func, $property_name);
|
||||||
if (!property_exists($this, $property_name)) {
|
if (!property_exists($this, $property_name)) {
|
||||||
throw new Exception("property '$property_name' does not exist.");
|
throw new SmartyException("property '$property_name' does not exist.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($first3 == 'get')
|
if ($first3 == 'get')
|
||||||
@@ -776,4 +768,11 @@ function smartyAutoload($class)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Class SmartyException extends Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
Class SmartyCompilerException extends SmartyException {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
@@ -19,9 +19,9 @@
|
|||||||
function smarty_block_php($params, $content, $smarty, &$repeat, $template)
|
function smarty_block_php($params, $content, $smarty, &$repeat, $template)
|
||||||
{
|
{
|
||||||
if (!$smarty->allow_php_tag) {
|
if (!$smarty->allow_php_tag) {
|
||||||
throw new Exception("{php} is deprecated, set allow_php_tag = true to enable");
|
throw new SmartyException("{php} is deprecated, set allow_php_tag = true to enable");
|
||||||
}
|
}
|
||||||
eval($content);
|
eval($content);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@@ -64,7 +64,7 @@ function smarty_function_html_image($params, $smarty, $template)
|
|||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$$_key = smarty_function_escape_special_chars($_val);
|
$$_key = smarty_function_escape_special_chars($_val);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ function smarty_function_html_image($params, $smarty, $template)
|
|||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||||
} else {
|
} else {
|
||||||
throw new Exception ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -136,4 +136,4 @@ function smarty_function_html_image($params, $smarty, $template)
|
|||||||
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '"' . $extra . ' />' . $suffix;
|
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '"' . $extra . ' />' . $suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@@ -64,7 +64,7 @@ class Smarty_Internal_Cache {
|
|||||||
return $this->smarty->cache_resource_objects[$type] = new $cache_resource_class($this->smarty);
|
return $this->smarty->cache_resource_objects[$type] = new $cache_resource_class($this->smarty);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Exception("Unable to load cache resource '{$type}'");
|
throw new SmartyException("Unable to load cache resource '{$type}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,7 @@ class Smarty_Internal_Config {
|
|||||||
$this->compiler_object = null;
|
$this->compiler_object = null;
|
||||||
// parse config resource name
|
// parse config resource name
|
||||||
if (!$this->parseConfigResourceName ($config_resource)) {
|
if (!$this->parseConfigResourceName ($config_resource)) {
|
||||||
throw new Exception ("Unable to parse config resource '{$config_resource}'");
|
throw new SmartyException ("Unable to parse config resource '{$config_resource}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ class Smarty_Internal_Config {
|
|||||||
if (file_exists($this->config_resource_name))
|
if (file_exists($this->config_resource_name))
|
||||||
return $this->config_resource_name;
|
return $this->config_resource_name;
|
||||||
// no tpl file found
|
// no tpl file found
|
||||||
throw new Exception("Unable to load config file \"{$this->config_resource_name}\"");
|
throw new SmartyException("Unable to load config file \"{$this->config_resource_name}\"");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -106,7 +106,7 @@ class Smarty_Internal_Config {
|
|||||||
{
|
{
|
||||||
if ($this->config_source === null) {
|
if ($this->config_source === null) {
|
||||||
if ($this->readConfigSource($this) === false) {
|
if ($this->readConfigSource($this) === false) {
|
||||||
throw new Exception("Unable to load config file \"{$this->config_resource_name}\"");
|
throw new SmartyException("Unable to load config file \"{$this->config_resource_name}\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->config_source;
|
return $this->config_source;
|
||||||
|
@@ -98,7 +98,7 @@ class Smarty_Internal_Config_File_Compiler {
|
|||||||
// output parser error message
|
// output parser error message
|
||||||
$error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect);
|
$error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect);
|
||||||
}
|
}
|
||||||
throw new Exception($error_text);
|
throw new SmartyCompilerException($error_text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -287,7 +287,7 @@ class Smarty_Internal_Data {
|
|||||||
return $this->smarty->global_tpl_vars[$variable];
|
return $this->smarty->global_tpl_vars[$variable];
|
||||||
}
|
}
|
||||||
if ($this->smarty->error_unassigned && $error_enable) {
|
if ($this->smarty->error_unassigned && $error_enable) {
|
||||||
throw new Exception('Undefined Smarty variable "' . $variable . '"');
|
throw new SmartyException('Undefined Smarty variable "' . $variable . '"');
|
||||||
} else {
|
} else {
|
||||||
return new Undefined_Smarty_Variable;
|
return new Undefined_Smarty_Variable;
|
||||||
}
|
}
|
||||||
@@ -310,7 +310,7 @@ class Smarty_Internal_Data {
|
|||||||
$_ptr = $_ptr->parent;
|
$_ptr = $_ptr->parent;
|
||||||
}
|
}
|
||||||
if ($this->smarty->error_unassigned) {
|
if ($this->smarty->error_unassigned) {
|
||||||
throw new Exception('Undefined config variable "' . $variable . '"');
|
throw new SmartyException('Undefined config variable "' . $variable . '"');
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -333,7 +333,7 @@ class Smarty_Internal_Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->smarty->$error_unassigned) {
|
if ($this->smarty->$error_unassigned) {
|
||||||
throw new Exception('Undefined stream variable "' . $variable . '"');
|
throw new SmartyException('Undefined stream variable "' . $variable . '"');
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -407,7 +407,7 @@ class Smarty_Data extends Smarty_Internal_Data {
|
|||||||
$this->tpl_vars[$_key] = new Smarty_variable($_val);
|
$this->tpl_vars[$_key] = new Smarty_variable($_val);
|
||||||
}
|
}
|
||||||
} elseif ($_parent != null) {
|
} elseif ($_parent != null) {
|
||||||
throw new Exception("Wrong type for template variables");
|
throw new SmartyException("Wrong type for template variables");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,7 @@ class Smarty_Internal_Filter_Handler {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// nothing found, throw exception
|
// nothing found, throw exception
|
||||||
throw new Exception("Unable to load filter {$plugin_name}");
|
throw new SmartyException("Unable to load filter {$plugin_name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,9 +51,9 @@ class Smarty_Internal_Register {
|
|||||||
function block($block_tag, $block_impl, $cacheable = true, $cache_attr = array())
|
function block($block_tag, $block_impl, $cacheable = true, $cache_attr = array())
|
||||||
{
|
{
|
||||||
if (isset($this->smarty->registered_plugins['block'][$block_tag])) {
|
if (isset($this->smarty->registered_plugins['block'][$block_tag])) {
|
||||||
throw new Exception("Plugin tag \"{$block_tag}\" already registered");
|
throw new SmartyException("Plugin tag \"{$block_tag}\" already registered");
|
||||||
} elseif (!is_callable($block_impl)) {
|
} elseif (!is_callable($block_impl)) {
|
||||||
throw new Exception("Plugin \"{$block_tag}\" not callable");
|
throw new SmartyException("Plugin \"{$block_tag}\" not callable");
|
||||||
} else {
|
} else {
|
||||||
$this->smarty->registered_plugins['block'][$block_tag] =
|
$this->smarty->registered_plugins['block'][$block_tag] =
|
||||||
array($block_impl, $cacheable, $cache_attr);
|
array($block_impl, $cacheable, $cache_attr);
|
||||||
@@ -70,9 +70,9 @@ class Smarty_Internal_Register {
|
|||||||
function compilerFunction($compiler_tag, $compiler_impl, $cacheable = true)
|
function compilerFunction($compiler_tag, $compiler_impl, $cacheable = true)
|
||||||
{
|
{
|
||||||
if (isset($this->smarty->registered_plugins['compiler'][$compiler_tag])) {
|
if (isset($this->smarty->registered_plugins['compiler'][$compiler_tag])) {
|
||||||
throw new Exception("Plugin tag \"{$compiler_tag}\" already registered");
|
throw new SmartyException("Plugin tag \"{$compiler_tag}\" already registered");
|
||||||
} elseif (!is_callable($compiler_impl)) {
|
} elseif (!is_callable($compiler_impl)) {
|
||||||
throw new Exception("Plugin \"{$compiler_tag}\" not callable");
|
throw new SmartyException("Plugin \"{$compiler_tag}\" not callable");
|
||||||
} else {
|
} else {
|
||||||
$this->smarty->registered_plugins['compiler'][$compiler_tag] =
|
$this->smarty->registered_plugins['compiler'][$compiler_tag] =
|
||||||
array($compiler_impl, $cacheable);
|
array($compiler_impl, $cacheable);
|
||||||
@@ -90,9 +90,9 @@ class Smarty_Internal_Register {
|
|||||||
function templateFunction($function_tag, $function_impl, $cacheable = true, $cache_attr = array())
|
function templateFunction($function_tag, $function_impl, $cacheable = true, $cache_attr = array())
|
||||||
{
|
{
|
||||||
if (isset($this->smarty->registered_plugins['function'][$function_tag])) {
|
if (isset($this->smarty->registered_plugins['function'][$function_tag])) {
|
||||||
throw new Exception("Plugin tag \"{$function_tag}\" already registered");
|
throw new SmartyException("Plugin tag \"{$function_tag}\" already registered");
|
||||||
} elseif (!is_callable($function_impl)) {
|
} elseif (!is_callable($function_impl)) {
|
||||||
throw new Exception("Plugin \"{$function_tag}\" not callable");
|
throw new SmartyException("Plugin \"{$function_tag}\" not callable");
|
||||||
} else {
|
} else {
|
||||||
$this->smarty->registered_plugins['function'][$function_tag] =
|
$this->smarty->registered_plugins['function'][$function_tag] =
|
||||||
array($function_impl, $cacheable, $cache_attr);
|
array($function_impl, $cacheable, $cache_attr);
|
||||||
@@ -108,9 +108,9 @@ class Smarty_Internal_Register {
|
|||||||
function modifier($modifier_name, $modifier_impl)
|
function modifier($modifier_name, $modifier_impl)
|
||||||
{
|
{
|
||||||
if (isset($this->smarty->registered_plugins['modifier'][$modifier_name])) {
|
if (isset($this->smarty->registered_plugins['modifier'][$modifier_name])) {
|
||||||
throw new Exception("Plugin \"{$modifier_name}\" already registered");
|
throw new SmartyException("Plugin \"{$modifier_name}\" already registered");
|
||||||
} elseif (!is_callable($modifier_impl)) {
|
} elseif (!is_callable($modifier_impl)) {
|
||||||
throw new Exception("Plugin \"{$modifier_name}\" not callable");
|
throw new SmartyException("Plugin \"{$modifier_name}\" not callable");
|
||||||
} else {
|
} else {
|
||||||
$this->smarty->registered_plugins['modifier'][$modifier_name] =
|
$this->smarty->registered_plugins['modifier'][$modifier_name] =
|
||||||
array($modifier_impl);
|
array($modifier_impl);
|
||||||
@@ -132,7 +132,7 @@ class Smarty_Internal_Register {
|
|||||||
if (!empty($allowed)) {
|
if (!empty($allowed)) {
|
||||||
foreach ((array)$allowed as $method) {
|
foreach ((array)$allowed as $method) {
|
||||||
if (!is_callable(array($object_impl, $method))) {
|
if (!is_callable(array($object_impl, $method))) {
|
||||||
throw new Exception("Undefined method '$method' in registered object");
|
throw new SmartyException("Undefined method '$method' in registered object");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ class Smarty_Internal_Register {
|
|||||||
if (!empty($block_methods)) {
|
if (!empty($block_methods)) {
|
||||||
foreach ((array)$block_methods as $method) {
|
foreach ((array)$block_methods as $method) {
|
||||||
if (!is_callable(array($object_impl, $method))) {
|
if (!is_callable(array($object_impl, $method))) {
|
||||||
throw new Exception("Undefined method '$method' in registered object");
|
throw new SmartyException("Undefined method '$method' in registered object");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ class Smarty_Internal_Register {
|
|||||||
{
|
{
|
||||||
// test if exists
|
// test if exists
|
||||||
if (!class_exists($class_impl)) {
|
if (!class_exists($class_impl)) {
|
||||||
throw new Exception("Undefined class '$class_impl' in register template class");
|
throw new SmartyException("Undefined class '$class_impl' in register template class");
|
||||||
}
|
}
|
||||||
// register the class
|
// register the class
|
||||||
$this->smarty->registered_classes[$class_name] = $class_impl;
|
$this->smarty->registered_classes[$class_name] = $class_impl;
|
||||||
@@ -217,7 +217,7 @@ class Smarty_Internal_Register {
|
|||||||
array(&$function_names[0], $function_names[4])),
|
array(&$function_names[0], $function_names[4])),
|
||||||
false);
|
false);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("malformed function-list for '$resource_type' in register_resource");
|
throw new SmartyException("malformed function-list for '$resource_type' in register_resource");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ class Smarty_Internal_Register {
|
|||||||
if (is_callable($function_name)) {
|
if (is_callable($function_name)) {
|
||||||
$this->smarty->default_plugin_handler_func = $function_name;
|
$this->smarty->default_plugin_handler_func = $function_name;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Default plugin handler '$function_name' not callable");
|
throw new SmartyException("Default plugin handler '$function_name' not callable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ class Smarty_Internal_Register {
|
|||||||
if (is_callable($function_name)) {
|
if (is_callable($function_name)) {
|
||||||
$this->smarty->default_template_handler_func = $function_name;
|
$this->smarty->default_template_handler_func = $function_name;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Default template handler '$function_name' not callable");
|
throw new SmartyException("Default template handler '$function_name' not callable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -90,7 +90,7 @@ class Smarty_Internal_Resource_Extends {
|
|||||||
foreach ($_files as $_filepath) {
|
foreach ($_files as $_filepath) {
|
||||||
// read template file
|
// read template file
|
||||||
if ($_filepath === false) {
|
if ($_filepath === false) {
|
||||||
throw new Exception("Unable to load template 'file : {$_file}'");
|
throw new SmartyException("Unable to load template 'file : {$_file}'");
|
||||||
}
|
}
|
||||||
if ($_filepath != $_files[0]) {
|
if ($_filepath != $_files[0]) {
|
||||||
$_template->properties['file_dependency'][sha1($_filepath)] = array($_filepath, filemtime($_filepath));
|
$_template->properties['file_dependency'][sha1($_filepath)] = array($_filepath, filemtime($_filepath));
|
||||||
|
@@ -102,10 +102,10 @@ class Smarty_Internal_Resource_PHP {
|
|||||||
public function renderUncompiled($_smarty_template)
|
public function renderUncompiled($_smarty_template)
|
||||||
{
|
{
|
||||||
if (!$this->smarty->allow_php_templates) {
|
if (!$this->smarty->allow_php_templates) {
|
||||||
throw new Exception("PHP templates are disabled");
|
throw new SmartyException("PHP templates are disabled");
|
||||||
}
|
}
|
||||||
if ($this->getTemplateFilepath($_smarty_template) === false) {
|
if ($this->getTemplateFilepath($_smarty_template) === false) {
|
||||||
throw new Exception("Unable to load template \"{$_smarty_template->resource_type} : {$_smarty_template->resource_name}\"");
|
throw new SmartyException("Unable to load template \"{$_smarty_template->resource_type} : {$_smarty_template->resource_name}\"");
|
||||||
}
|
}
|
||||||
// prepare variables
|
// prepare variables
|
||||||
$_smarty_ptr = $_smarty_template;
|
$_smarty_ptr = $_smarty_template;
|
||||||
@@ -124,4 +124,4 @@ class Smarty_Internal_Resource_PHP {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@@ -75,7 +75,7 @@ class Smarty_Internal_Security_Handler {
|
|||||||
if (empty($this->smarty->security_policy->streams) || in_array($stream_name, $this->smarty->security_policy->streams)) {
|
if (empty($this->smarty->security_policy->streams) || in_array($stream_name, $this->smarty->security_policy->streams)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception ("stream '{$stream_name}' not allowed by security setting");
|
throw new SmartyException ("stream '{$stream_name}' not allowed by security setting");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ class Smarty_Internal_Security_Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception ("directory '{$_rp}' not allowed by security setting");
|
throw new SmartyException ("directory '{$_rp}' not allowed by security setting");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -138,7 +138,7 @@ class Smarty_Internal_Security_Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception ("directory '{$_rp}' not allowed by security setting");
|
throw new SmartyException ("directory '{$_rp}' not allowed by security setting");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -98,7 +98,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
$this->template_resource = $template_resource;
|
$this->template_resource = $template_resource;
|
||||||
// parse resource name
|
// parse resource name
|
||||||
if (!$this->parseResourceName ($template_resource, $this->resource_type, $this->resource_name, $this->resource_object)) {
|
if (!$this->parseResourceName ($template_resource, $this->resource_type, $this->resource_name, $this->resource_object)) {
|
||||||
throw new Exception ("Unable to parse resource name \"{$template_resource}\"");
|
throw new SmartyException ("Unable to parse resource name \"{$template_resource}\"");
|
||||||
}
|
}
|
||||||
// load cache resource
|
// load cache resource
|
||||||
if (!$this->resource_object->isEvaluated && ($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) {
|
if (!$this->resource_object->isEvaluated && ($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) {
|
||||||
@@ -145,7 +145,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
{
|
{
|
||||||
if ($this->template_source === null) {
|
if ($this->template_source === null) {
|
||||||
if (!$this->resource_object->getTemplateSource($this)) {
|
if (!$this->resource_object->getTemplateSource($this)) {
|
||||||
throw new Exception("Unable to read template {$this->resource_type} '{$this->resource_name}'");
|
throw new SmartyException("Unable to read template {$this->resource_type} '{$this->resource_name}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->template_source;
|
return $this->template_source;
|
||||||
@@ -164,7 +164,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
$this->isExisting = $this->resource_object->isExisting($this);
|
$this->isExisting = $this->resource_object->isExisting($this);
|
||||||
}
|
}
|
||||||
if (!$this->isExisting && $error) {
|
if (!$this->isExisting && $error) {
|
||||||
throw new Exception("Unable to load template {$this->resource_type} '{$this->resource_name}'");
|
throw new SmartyException("Unable to load template {$this->resource_type} '{$this->resource_name}'");
|
||||||
}
|
}
|
||||||
return $this->isExisting;
|
return $this->isExisting;
|
||||||
}
|
}
|
||||||
@@ -461,7 +461,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
ob_start();
|
ob_start();
|
||||||
$this->resource_object->renderUncompiled($this);
|
$this->resource_object->renderUncompiled($this);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Resource '$this->resource_type' must have 'renderUncompiled' methode");
|
throw new SmartyException("Resource '$this->resource_type' must have 'renderUncompiled' methode");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->rendered_content = ob_get_clean();
|
$this->rendered_content = ob_get_clean();
|
||||||
@@ -593,7 +593,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
// no tpl file found
|
// no tpl file found
|
||||||
if (!empty($this->smarty->default_template_handler_func)) {
|
if (!empty($this->smarty->default_template_handler_func)) {
|
||||||
if (!is_callable($this->smarty->default_template_handler_func)) {
|
if (!is_callable($this->smarty->default_template_handler_func)) {
|
||||||
throw new Exception("Default template handler not callable");
|
throw new SmartyException("Default template handler not callable");
|
||||||
} else {
|
} else {
|
||||||
$_return = call_user_func_array($this->smarty->default_template_handler_func,
|
$_return = call_user_func_array($this->smarty->default_template_handler_func,
|
||||||
array($this->resource_type, $this->resource_name, &$this->template_source, &$this->template_timestamp, $this));
|
array($this->resource_type, $this->resource_name, &$this->template_source, &$this->template_timestamp, $this));
|
||||||
@@ -604,7 +604,6 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// throw new Exception("Unable to load template \"{$file}\"");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -729,7 +728,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
}
|
}
|
||||||
return new Smarty_Internal_Resource_Stream($this->smarty);
|
return new Smarty_Internal_Resource_Stream($this->smarty);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Unkown resource type \'' . $resource_type . '\'');
|
throw new SmartyException('Unkown resource type \'' . $resource_type . '\'');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -883,7 +882,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
// convert camel case to underscored name
|
// convert camel case to underscored name
|
||||||
$property_name = preg_replace_callback('/([A-Z])/', $camel_func, $property_name);
|
$property_name = preg_replace_callback('/([A-Z])/', $camel_func, $property_name);
|
||||||
if (!property_exists($this, $property_name)) {
|
if (!property_exists($this, $property_name)) {
|
||||||
throw new Exception("property '$property_name' does not exist.");
|
throw new SmartyException("property '$property_name' does not exist.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($first3 == 'get')
|
if ($first3 == 'get')
|
||||||
|
@@ -183,7 +183,7 @@ class Smarty_Internal_TemplateCompilerBase {
|
|||||||
return $plugin_object->compile($args, $this);
|
return $plugin_object->compile($args, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception("Plugin \"{$tag}\" not callable");
|
throw new SmartyException("Plugin \"{$tag}\" not callable");
|
||||||
} else {
|
} else {
|
||||||
if ($function = $this->getPlugin($tag, $plugin_type)) {
|
if ($function = $this->getPlugin($tag, $plugin_type)) {
|
||||||
return $this->callTagCompiler('private_' . $plugin_type . '_plugin', $args, $tag, $function);
|
return $this->callTagCompiler('private_' . $plugin_type . '_plugin', $args, $tag, $function);
|
||||||
@@ -222,7 +222,7 @@ class Smarty_Internal_TemplateCompilerBase {
|
|||||||
return $plugin_object->compile($args, $this);
|
return $plugin_object->compile($args, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception("Plugin \"{$tag}\" not callable");
|
throw new SmartyException("Plugin \"{$tag}\" not callable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->trigger_template_error ("unknown tag \"" . $tag . "\"", $this->lex->taglineno);
|
$this->trigger_template_error ("unknown tag \"" . $tag . "\"", $this->lex->taglineno);
|
||||||
@@ -400,7 +400,7 @@ class Smarty_Internal_TemplateCompilerBase {
|
|||||||
// output parser error message
|
// output parser error message
|
||||||
$error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect);
|
$error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect);
|
||||||
}
|
}
|
||||||
throw new Exception($error_text);
|
throw new SmartyCompilerException($error_text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -114,7 +114,7 @@ class Smarty_Internal_Wrapper {
|
|||||||
}
|
}
|
||||||
$func_name = implode('',$name_parts);
|
$func_name = implode('',$name_parts);
|
||||||
if(!method_exists($this->smarty,$func_name)) {
|
if(!method_exists($this->smarty,$func_name)) {
|
||||||
throw new Exception("unknown method '$name'");
|
throw new SmartyException("unknown method '$name'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return call_user_func_array(array($this->smarty,$func_name),$args);
|
return call_user_func_array(array($this->smarty,$func_name),$args);
|
||||||
|
@@ -31,7 +31,7 @@ class Smarty_Internal_Write_File {
|
|||||||
|
|
||||||
if (!file_put_contents($_tmp_file, $_contents)) {
|
if (!file_put_contents($_tmp_file, $_contents)) {
|
||||||
umask($old_umask);
|
umask($old_umask);
|
||||||
throw new Exception("unable to write file {$_tmp_file}");
|
throw new SmartyException("unable to write file {$_tmp_file}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// remove original file
|
// remove original file
|
||||||
@@ -46,4 +46,4 @@ class Smarty_Internal_Write_File {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user