From 3f53c39913b2ecde038b43e860f67af1ca12d974 Mon Sep 17 00:00:00 2001 From: cajus Date: Wed, 6 Oct 2010 10:22:10 +0000 Subject: [PATCH] Updated smarty to 3.0 rc4 git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19920 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/smarty/Smarty.class.php | 63 +- .../include/smarty/plugins/block.php.php | 33 +- .../smarty/plugins/block.textformat.php | 62 +- .../smarty/plugins/function.counter.php | 9 +- .../include/smarty/plugins/function.cycle.php | 12 +- .../include/smarty/plugins/function.fetch.php | 4 +- .../plugins/function.html_checkboxes.php | 4 +- .../smarty/plugins/function.html_image.php | 70 +- .../smarty/plugins/function.html_options.php | 57 +- .../smarty/plugins/function.html_radios.php | 78 +- .../plugins/function.html_select_date.php | 77 +- .../plugins/function.html_select_time.php | 44 +- .../smarty/plugins/function.html_table.php | 98 +- .../smarty/plugins/function.mailto.php | 96 +- .../include/smarty/plugins/function.math.php | 4 +- .../include/smarty/plugins/function.popup.php | 5 +- .../smarty/plugins/function.popup_init.php | 38 +- .../smarty/plugins/modifier.capitalize.php | 48 +- .../smarty/plugins/modifier.date_format.php | 48 +- .../plugins/modifier.debug_print_var.php | 38 +- .../smarty/plugins/modifier.escape.php | 65 +- .../smarty/plugins/modifier.regex_replace.php | 5 +- .../smarty/plugins/modifier.replace.php | 61 +- .../smarty/plugins/modifier.spacify.php | 50 +- .../smarty/plugins/modifier.truncate.php | 95 +- .../smarty/plugins/modifiercompiler.cat.php | 29 + .../modifiercompiler.count_characters.php | 39 + .../modifiercompiler.count_paragraphs.php | 27 + .../modifiercompiler.count_sentences.php | 27 + .../plugins/modifiercompiler.count_words.php | 31 + .../plugins/modifiercompiler.default.php | 33 + .../plugins/modifiercompiler.indent.php | 32 + .../smarty/plugins/modifiercompiler.lower.php | 31 + .../plugins/modifiercompiler.noprint.php | 24 + .../modifiercompiler.string_format.php | 26 + .../smarty/plugins/modifiercompiler.strip.php | 33 + .../plugins/modifiercompiler.strip_tags.php | 34 + .../smarty/plugins/modifiercompiler.upper.php | 30 + .../plugins/modifiercompiler.wordwrap.php | 35 + .../plugins/outputfilter.trimwhitespace.php | 3 +- .../plugins/shared.escape_special_chars.php | 3 +- .../smarty/plugins/shared.make_timestamp.php | 22 +- .../variablefilter.htmlspecialchars.php | 23 +- .../sysplugins/smarty_internal_cache.php | 2 +- .../smarty_internal_cacheresource_file.php | 84 +- .../smarty_internal_compile_append.php | 40 +- .../smarty_internal_compile_assign.php | 62 +- .../smarty_internal_compile_block.php | 44 +- .../smarty_internal_compile_break.php | 56 + .../smarty_internal_compile_call.php | 3 +- .../smarty_internal_compile_capture.php | 51 +- .../smarty_internal_compile_config_load.php | 41 +- .../smarty_internal_compile_continue.php | 56 + .../smarty_internal_compile_debug.php | 35 +- .../smarty_internal_compile_eval.php | 35 +- .../smarty_internal_compile_extends.php | 47 +- .../smarty_internal_compile_for.php | 1 + .../smarty_internal_compile_foreach.php | 7 +- .../smarty_internal_compile_function.php | 24 +- .../sysplugins/smarty_internal_compile_if.php | 67 +- .../smarty_internal_compile_include.php | 43 +- .../smarty_internal_compile_include_php.php | 35 +- .../smarty_internal_compile_insert.php | 47 +- .../smarty_internal_compile_ldelim.php | 36 +- .../smarty_internal_compile_nocache.php | 53 +- ..._internal_compile_private_block_plugin.php | 49 +- ...ternal_compile_private_function_plugin.php | 41 +- ...arty_internal_compile_private_modifier.php | 109 +- ..._compile_private_object_block_function.php | 37 +- ...ternal_compile_private_object_function.php | 6 +- ...ernal_compile_private_print_expression.php | 17 +- ...ernal_compile_private_registered_block.php | 43 +- ...al_compile_private_registered_function.php | 6 +- ...ernal_compile_private_special_variable.php | 49 +- .../smarty_internal_compile_rdelim.php | 38 +- .../smarty_internal_compile_section.php | 72 +- .../smarty_internal_compile_while.php | 12 +- .../smarty_internal_compilebase.php | 4 +- .../sysplugins/smarty_internal_config.php | 7 +- .../smarty_internal_config_file_compiler.php | 3 +- .../smarty_internal_configfilelexer.php | 13 +- .../smarty_internal_configfileparser.php | 9 +- .../sysplugins/smarty_internal_data.php | 284 +- .../sysplugins/smarty_internal_debug.php | 89 +- .../smarty_internal_filter_handler.php | 2 +- .../smarty_internal_function_call_handler.php | 5 +- .../smarty_internal_nocache_insert.php | 49 + .../sysplugins/smarty_internal_parsetree.php | 133 +- .../sysplugins/smarty_internal_register.php | 291 +- .../smarty_internal_resource_eval.php | 90 + .../smarty_internal_resource_extends.php | 72 +- .../smarty_internal_resource_file.php | 73 +- .../smarty_internal_resource_php.php | 84 +- .../smarty_internal_resource_registered.php | 91 +- .../smarty_internal_resource_stream.php | 72 +- .../smarty_internal_resource_string.php | 129 +- .../smarty_internal_security_handler.php | 96 +- ...smarty_internal_smartytemplatecompiler.php | 2 + .../sysplugins/smarty_internal_template.php | 87 +- .../smarty_internal_templatecompilerbase.php | 47 +- .../smarty_internal_templatelexer.php | 95 +- .../smarty_internal_templateparser.php | 5437 +++++++++-------- .../sysplugins/smarty_internal_unregister.php | 151 +- .../sysplugins/smarty_internal_utility.php | 28 +- .../sysplugins/smarty_internal_wrapper.php | 76 +- .../sysplugins/smarty_internal_write_file.php | 33 +- .../smarty/sysplugins/smarty_security.php | 120 +- 107 files changed, 5939 insertions(+), 4727 deletions(-) create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.cat.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.count_characters.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.count_paragraphs.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.count_sentences.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.count_words.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.default.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.indent.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.lower.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.noprint.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.string_format.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.strip.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.strip_tags.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.upper.php create mode 100644 gosa-core/include/smarty/plugins/modifiercompiler.wordwrap.php create mode 100644 gosa-core/include/smarty/sysplugins/smarty_internal_compile_break.php create mode 100644 gosa-core/include/smarty/sysplugins/smarty_internal_compile_continue.php create mode 100644 gosa-core/include/smarty/sysplugins/smarty_internal_nocache_insert.php create mode 100644 gosa-core/include/smarty/sysplugins/smarty_internal_resource_eval.php 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