From: cajus Date: Wed, 6 Oct 2010 10:22:10 +0000 (+0000) Subject: Updated smarty to 3.0 rc4 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3f53c39913b2ecde038b43e860f67af1ca12d974;p=gosa.git Updated smarty to 3.0 rc4 git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19920 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/smarty/Smarty.class.php b/gosa-core/include/smarty/Smarty.class.php index 319debf11..1e3ffbd55 100644 --- a/gosa-core/include/smarty/Smarty.class.php +++ b/gosa-core/include/smarty/Smarty.class.php @@ -3,7 +3,7 @@ /** * Project: Smarty: the PHP compiling template engine * File: Smarty.class.php - * SVN: $Id: Smarty.class.php 3557 2010-04-28 20:30:27Z Uwe.Tews $ + * SVN: $Id: Smarty.class.php 3669 2010-09-17 18:10:10Z uwe.tews@googlemail.com $ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -108,7 +108,7 @@ if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR */ class Smarty extends Smarty_Internal_Data { // smarty version - const SMARTY_VERSION = 'Smarty-3.0-RC2'; + const SMARTY_VERSION = 'Smarty3rc4'; // auto literal on delimiters with whitspace public $auto_literal = true; // display error on not assigned variables @@ -159,6 +159,7 @@ class Smarty extends Smarty_Internal_Data { public $security_policy = null; public $security_handler = null; public $direct_access_security = true; + public $trusted_dir = array(); // debug mode public $debugging = false; public $debugging_ctrl = 'NONE'; @@ -192,8 +193,6 @@ class Smarty extends Smarty_Internal_Data { public $properties = array(); // config type public $default_config_type = 'file'; - // exception handler: array('ExceptionClass','ExceptionMethod'); - public $exception_handler = null; // cached template objects public $template_objects = null; // check If-Modified-Since headers @@ -204,6 +203,8 @@ class Smarty extends Smarty_Internal_Data { public $plugin_search_order = array('function', 'block', 'compiler', 'class'); // registered objects public $registered_objects = array(); + // registered classes + public $registered_classes = array(); // registered filters public $registered_filters = array(); // autoload filter @@ -222,11 +223,10 @@ class Smarty extends Smarty_Internal_Data { public $_dir_perms = 0771; // smarty object reference public $smarty = null; - // block data at template inheritance - public $block_data = array(); - public $block_data_stack = array(); // block tag hierarchy public $_tag_stack = array(); + // flag if {block} tag is compiled for template inheritance + public $inheritance = false; // plugins public $_plugins = array(); // generate deprecated function call notices? @@ -243,10 +243,7 @@ class Smarty extends Smarty_Internal_Data { if (is_callable('mb_internal_encoding')) { mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET); } - $this->start_time = $this->_get_time(); - // set exception handler - if (!empty($this->exception_handler)) - set_exception_handler($this->exception_handler); + $this->start_time = microtime(true); // set default dirs $this->template_dir = array('.' . DS . 'templates' . DS); $this->compile_dir = '.' . DS . 'templates_c' . DS; @@ -289,9 +286,6 @@ class Smarty extends Smarty_Internal_Data { */ public function __destruct() { - // restore to previous exception handler, if any - if (!empty($this->exception_handler)) - restore_exception_handler(); } /** @@ -313,8 +307,6 @@ class Smarty extends Smarty_Internal_Data { // get default Smarty data object $parent = $this; } - array_push($this->block_data_stack, $this->block_data); - $this->block_data = array(); // create template object if necessary ($template instanceof $this->template_class)? $_template = $template : $_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent); @@ -357,11 +349,9 @@ class Smarty extends Smarty_Internal_Data { if ($this->debugging) { Smarty_Internal_Debug::display_debug($this); } - $this->block_data = array_pop($this->block_data_stack); return; } else { // return fetched content - $this->block_data = array_pop($this->block_data_stack); return $_output; } } @@ -464,7 +454,7 @@ class Smarty extends Smarty_Internal_Data { $this->security_handler = new Smarty_Internal_Security_Handler($this); $this->security = true; } else { - throw new Exception('Property security_class is not defined'); + throw new SmartyException('Property security_class is not defined'); } } @@ -508,9 +498,13 @@ class Smarty extends Smarty_Internal_Data { function templateExists($resource_name) { // create template object + $save = $this->template_objects; $tpl = new $this->template_class($resource_name, $this); // check if it does exists - return $tpl->isExisting(); + $result = $tpl->isExisting(); + $this->template_objects = $save; + unset ($tpl); + return $result; } /** @@ -531,7 +525,7 @@ class Smarty extends Smarty_Internal_Data { $_name_parts = explode('_', $_plugin_name, 3); // class name must have three parts to be valid plugin 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; } // if type is "internal", get plugin from sysplugins @@ -580,7 +574,7 @@ class Smarty extends Smarty_Internal_Data { 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; } @@ -604,7 +598,7 @@ class Smarty extends Smarty_Internal_Data { */ 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"); } /** @@ -670,10 +664,10 @@ class Smarty extends Smarty_Internal_Data { function getRegisteredObject($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])) - throw new Exception("registered '$name' is not an object"); + throw new SmartyException("registered '$name' is not an object"); return $this->registered_objects[$name][0]; } @@ -733,7 +727,7 @@ class Smarty extends Smarty_Internal_Data { $camel_func = create_function('$c', 'return "_" . strtolower($c[1]);'); // PHP4 call to constructor? 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; } // see if this is a set/get for a property @@ -745,7 +739,7 @@ class Smarty extends Smarty_Internal_Data { // convert camel case to underscored name $property_name = preg_replace_callback('/([A-Z])/', $camel_func, $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; } if ($first3 == 'get') @@ -761,6 +755,9 @@ class Smarty extends Smarty_Internal_Data { } } +/** + * Autoloader + */ function smartyAutoload($class) { $_class = strtolower($class); @@ -769,4 +766,16 @@ function smartyAutoload($class) } } +/** + * Smarty exception class + */ +Class SmartyException extends Exception { +} + +/** + * Smarty compiler exception class + */ +Class SmartyCompilerException extends SmartyException { +} + ?> diff --git a/gosa-core/include/smarty/plugins/block.php.php b/gosa-core/include/smarty/plugins/block.php.php index d1de74002..84a0275e0 100644 --- a/gosa-core/include/smarty/plugins/block.php.php +++ b/gosa-core/include/smarty/plugins/block.php.php @@ -1,27 +1,28 @@ 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); return ''; } -?> + +?> \ No newline at end of file diff --git a/gosa-core/include/smarty/plugins/block.textformat.php b/gosa-core/include/smarty/plugins/block.textformat.php index f578bfb9b..733f6e234 100644 --- a/gosa-core/include/smarty/plugins/block.textformat.php +++ b/gosa-core/include/smarty/plugins/block.textformat.php @@ -1,37 +1,37 @@ -* Name: textformat
-* Purpose: format text a certain way with preset styles -* or custom wrap/indent settings
-* -* @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat} - (Smarty online manual) -* @param array $params parameters -*
-* Params:   style: string (email)
-*            indent: integer (0)
-*            wrap: integer (80)
-*            wrap_char string ("\n")
-*            indent_char: string (" ")
-*            wrap_boundary: boolean (true)
-* 
-* @author Monte Ohrt -* @param string $content contents of the block -* @param object $smarty Smarty object -* @param boolean &$repeat repeat flag -* @param object $template template object -* @return string content re-formatted -*/ + * Smarty {textformat}{/textformat} block plugin + * + * Type: block function
+ * Name: textformat
+ * Purpose: format text a certain way with preset styles + * or custom wrap/indent settings
+ * + * @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat} + * (Smarty online manual) + * @param array $params parameters + *
+ * Params:   style: string (email)
+ *            indent: integer (0)
+ *            wrap: integer (80)
+ *            wrap_char string ("\n")
+ *            indent_char: string (" ")
+ *            wrap_boundary: boolean (true)
+ * 
+ * @author Monte Ohrt + * @param string $content contents of the block + * @param object $smarty Smarty object + * @param boolean &$repeat repeat flag + * @param object $template template object + * @return string content re-formatted + */ function smarty_block_textformat($params, $content, $smarty, &$repeat, $template) { if (is_null($content)) { @@ -100,4 +100,4 @@ function smarty_block_textformat($params, $content, $smarty, &$repeat, $template return $assign ? $template->assign($assign, $_output) : $_output; } -?> +?> \ No newline at end of file diff --git a/gosa-core/include/smarty/plugins/function.counter.php b/gosa-core/include/smarty/plugins/function.counter.php index 1f6e1cf7c..534e9981b 100644 --- a/gosa-core/include/smarty/plugins/function.counter.php +++ b/gosa-core/include/smarty/plugins/function.counter.php @@ -2,10 +2,9 @@ /** * Smarty plugin * @package Smarty - * @subpackage plugins + * @subpackage PluginsFunction */ - /** * Smarty {counter} function plugin * @@ -17,9 +16,10 @@ * (Smarty online manual) * @param array parameters * @param Smarty + * @param object $template template object * @return string|null */ -function smarty_function_counter($params, $smarty) +function smarty_function_counter($params, $smarty, $template) { static $counters = array(); @@ -43,7 +43,7 @@ function smarty_function_counter($params, $smarty) } if (isset($counter['assign'])) { - $smarty->assign($counter['assign'], $counter['count']); + $template->assign($counter['assign'], $counter['count']); } if (isset($params['print'])) { @@ -74,4 +74,5 @@ function smarty_function_counter($params, $smarty) return $retval; } + ?> \ No newline at end of file diff --git a/gosa-core/include/smarty/plugins/function.cycle.php b/gosa-core/include/smarty/plugins/function.cycle.php index 509584c97..76ff0c6b0 100644 --- a/gosa-core/include/smarty/plugins/function.cycle.php +++ b/gosa-core/include/smarty/plugins/function.cycle.php @@ -1,8 +1,9 @@ * @version 1.3 * @param array - * @param Smarty + * @param object $smarty Smarty object + * @param object $template template object * @return string|null */ -function smarty_function_cycle($params, $smarty) + +function smarty_function_cycle($params, $smarty, $template) { static $cycle_vars; @@ -81,7 +84,7 @@ function smarty_function_cycle($params, $smarty) if (isset($params['assign'])) { $print = false; - $smarty->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); + $template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); } if($print) { @@ -100,4 +103,5 @@ function smarty_function_cycle($params, $smarty) return $retval; } + ?> \ No newline at end of file diff --git a/gosa-core/include/smarty/plugins/function.fetch.php b/gosa-core/include/smarty/plugins/function.fetch.php index 391ff1bb9..0a511830b 100644 --- a/gosa-core/include/smarty/plugins/function.fetch.php +++ b/gosa-core/include/smarty/plugins/function.fetch.php @@ -1,11 +1,11 @@ +?> \ No newline at end of file diff --git a/gosa-core/include/smarty/plugins/function.html_checkboxes.php b/gosa-core/include/smarty/plugins/function.html_checkboxes.php index ac72f3fdf..328faf448 100644 --- a/gosa-core/include/smarty/plugins/function.html_checkboxes.php +++ b/gosa-core/include/smarty/plugins/function.html_checkboxes.php @@ -1,11 +1,11 @@ +?> \ No newline at end of file diff --git a/gosa-core/include/smarty/plugins/function.html_image.php b/gosa-core/include/smarty/plugins/function.html_image.php index 3f031dc00..e2714a67e 100644 --- a/gosa-core/include/smarty/plugins/function.html_image.php +++ b/gosa-core/include/smarty/plugins/function.html_image.php @@ -1,39 +1,39 @@ -* Name: html_image
-* Date: Feb 24, 2003
-* Purpose: format HTML tags for the image
-* Examples: {html_image file="/images/masthead.gif"} -* Output: -* -* @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image} - (Smarty online manual) -* @author Monte Ohrt -* @author credits to Duda -* @version 1.0 -* @param array $params parameters -* Input:
-* - file = file (and path) of image (required) -* - height = image height (optional, default actual height) -* - width = image width (optional, default actual width) -* - basedir = base directory for absolute paths, default -* is environment variable DOCUMENT_ROOT -* - path_prefix = prefix for path output (optional, default empty) -* @param object $smarty Smarty object -* @param object $template template object -* @return string -* @uses smarty_function_escape_special_chars() -*/ + * Smarty {html_image} function plugin + * + * Type: function
+ * Name: html_image
+ * Date: Feb 24, 2003
+ * Purpose: format HTML tags for the image
+ * Examples: {html_image file="/images/masthead.gif"} + * Output: + * + * @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image} + * (Smarty online manual) + * @author Monte Ohrt + * @author credits to Duda + * @version 1.0 + * @param array $params parameters + * Input:
+ * - file = file (and path) of image (required) + * - height = image height (optional, default actual height) + * - width = image width (optional, default actual width) + * - basedir = base directory for absolute paths, default + * is environment variable DOCUMENT_ROOT + * - path_prefix = prefix for path output (optional, default empty) + * @param object $smarty Smarty object + * @param object $template template object + * @return string + * @uses smarty_function_escape_special_chars() + */ function smarty_function_html_image($params, $smarty, $template) { require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); @@ -64,7 +64,7 @@ function smarty_function_html_image($params, $smarty, $template) if (!is_array($_val)) { $$_key = smarty_function_escape_special_chars($_val); } 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; @@ -78,7 +78,7 @@ function smarty_function_html_image($params, $smarty, $template) if (!is_array($_val)) { $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; } 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; } @@ -136,4 +136,4 @@ function smarty_function_html_image($params, $smarty, $template) return $prefix . '' . $alt . '' . $suffix; } -?> +?> \ No newline at end of file diff --git a/gosa-core/include/smarty/plugins/function.html_options.php b/gosa-core/include/smarty/plugins/function.html_options.php index 85b05f7dc..a4725809a 100644 --- a/gosa-core/include/smarty/plugins/function.html_options.php +++ b/gosa-core/include/smarty/plugins/function.html_options.php @@ -1,35 +1,34 @@ -* Name: html_options
-* Purpose: Prints the list of