From 6cf1d45205641e6641780b1488d2f20c0ac00ebe Mon Sep 17 00:00:00 2001 From: cajus Date: Tue, 26 Jul 2011 13:01:27 +0000 Subject: [PATCH] Updated smarty to recent 3.0.8 git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6@20950 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/smarty/Smarty.class.php | 1008 +-- gosa-core/include/smarty/debug.tpl | 15 +- .../include/smarty/plugins/block.php.php | 36 +- .../smarty/plugins/block.textformat.php | 65 +- .../smarty/plugins/function.counter.php | 16 +- .../include/smarty/plugins/function.cycle.php | 73 +- .../include/smarty/plugins/function.fetch.php | 13 +- .../plugins/function.html_checkboxes.php | 8 +- .../smarty/plugins/function.html_image.php | 80 +- .../smarty/plugins/function.html_options.php | 95 +- .../smarty/plugins/function.html_radios.php | 80 +- .../plugins/function.html_select_date.php | 87 +- .../plugins/function.html_select_time.php | 55 +- .../smarty/plugins/function.html_table.php | 99 +- .../smarty/plugins/function.mailto.php | 97 +- .../include/smarty/plugins/function.math.php | 11 +- .../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 | 64 +- .../smarty/plugins/modifier.regex_replace.php | 8 +- .../smarty/plugins/modifier.replace.php | 65 +- .../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 | 6 +- .../smarty/plugins/shared.make_timestamp.php | 22 +- .../smarty/plugins/shared.mb_str_replace.php | 38 + .../variablefilter.htmlspecialchars.php | 27 +- .../smarty_internal_cacheresource_file.php | 197 +- .../smarty_internal_compile_append.php | 81 +- .../smarty_internal_compile_assign.php | 87 +- .../smarty_internal_compile_block.php | 237 +- .../smarty_internal_compile_break.php | 65 + .../smarty_internal_compile_call.php | 117 +- .../smarty_internal_compile_capture.php | 69 +- .../smarty_internal_compile_config_load.php | 67 +- .../smarty_internal_compile_continue.php | 64 + .../smarty_internal_compile_debug.php | 40 +- .../smarty_internal_compile_eval.php | 39 +- .../smarty_internal_compile_extends.php | 134 +- .../smarty_internal_compile_for.php | 148 +- .../smarty_internal_compile_foreach.php | 147 +- .../smarty_internal_compile_function.php | 143 +- .../sysplugins/smarty_internal_compile_if.php | 161 +- .../smarty_internal_compile_include.php | 155 +- .../smarty_internal_compile_include_php.php | 84 +- .../smarty_internal_compile_insert.php | 102 +- .../smarty_internal_compile_ldelim.php | 39 +- .../smarty_internal_compile_nocache.php | 56 +- ..._internal_compile_private_block_plugin.php | 75 +- ...ternal_compile_private_function_plugin.php | 57 +- ...arty_internal_compile_private_modifier.php | 128 +- ..._compile_private_object_block_function.php | 83 +- ...ternal_compile_private_object_function.php | 75 +- ...ernal_compile_private_print_expression.php | 96 +- ...ernal_compile_private_registered_block.php | 174 +- ...al_compile_private_registered_function.php | 118 +- ...ernal_compile_private_special_variable.php | 57 +- .../smarty_internal_compile_rdelim.php | 41 +- .../smarty_internal_compile_section.php | 79 +- .../smarty_internal_compile_while.php | 40 +- .../smarty_internal_compilebase.php | 153 +- .../sysplugins/smarty_internal_config.php | 194 +- .../smarty_internal_config_file_compiler.php | 94 +- .../smarty_internal_configfilelexer.php | 36 +- .../smarty_internal_configfileparser.php | 84 +- .../sysplugins/smarty_internal_data.php | 564 +- .../sysplugins/smarty_internal_debug.php | 256 +- .../sysplugins/smarty_internal_filter.php | 89 + .../smarty_internal_filter_handler.php | 77 +- .../smarty_internal_function_call_handler.php | 87 +- .../smarty_internal_get_include_path.php | 44 + .../smarty_internal_nocache_insert.php | 49 + .../sysplugins/smarty_internal_parsetree.php | 236 + .../sysplugins/smarty_internal_register.php | 156 + .../smarty_internal_resource_eval.php | 89 + .../smarty_internal_resource_extends.php | 168 +- .../smarty_internal_resource_file.php | 81 +- .../smarty_internal_resource_php.php | 92 +- .../smarty_internal_resource_registered.php | 110 +- .../smarty_internal_resource_stream.php | 60 +- .../smarty_internal_resource_string.php | 129 +- ...smarty_internal_smartytemplatecompiler.php | 59 +- .../sysplugins/smarty_internal_template.php | 988 +-- .../smarty_internal_templatecompilerbase.php | 531 +- .../smarty_internal_templatelexer.php | 1335 +--- .../smarty_internal_templateparser.php | 5684 +++++++++-------- .../sysplugins/smarty_internal_utility.php | 300 + .../sysplugins/smarty_internal_wrapper.php | 131 + .../sysplugins/smarty_internal_write_file.php | 45 +- .../smarty/sysplugins/smarty_security.php | 255 +- 106 files changed, 10475 insertions(+), 7737 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/plugins/shared.mb_str_replace.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_filter.php create mode 100644 gosa-core/include/smarty/sysplugins/smarty_internal_get_include_path.php create mode 100644 gosa-core/include/smarty/sysplugins/smarty_internal_nocache_insert.php create mode 100644 gosa-core/include/smarty/sysplugins/smarty_internal_parsetree.php create mode 100644 gosa-core/include/smarty/sysplugins/smarty_internal_register.php create mode 100644 gosa-core/include/smarty/sysplugins/smarty_internal_resource_eval.php create mode 100644 gosa-core/include/smarty/sysplugins/smarty_internal_utility.php create mode 100644 gosa-core/include/smarty/sysplugins/smarty_internal_wrapper.php diff --git a/gosa-core/include/smarty/Smarty.class.php b/gosa-core/include/smarty/Smarty.class.php index 6f2885731..c0bc78bb5 100644 --- a/gosa-core/include/smarty/Smarty.class.php +++ b/gosa-core/include/smarty/Smarty.class.php @@ -1,545 +1,815 @@ -* @author Uwe Tews -* @package Smarty -* @version 3-SVN$Rev: 3286 $ -*/ + * Project: Smarty: the PHP compiling template engine + * File: Smarty.class.php + * SVN: $Id: Smarty.class.php 4074 2011-04-22 02:19:14Z 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 + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For questions, help, comments, discussion, etc., please join the + * Smarty mailing list. Send a blank e-mail to + * smarty-discussion-subscribe@googlegroups.com + * + * @link http://www.smarty.net/ + * @copyright 2008 New Digital Group, Inc. + * @author Monte Ohrt + * @author Uwe Tews + * @package Smarty + * @version 3.0.8 + */ /** -* define shorthand directory separator constant -*/ + * define shorthand directory separator constant + */ if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); -} +} /** -* set SMARTY_DIR to absolute path to Smarty library files. -* Sets SMARTY_DIR only if user application has not already defined it. -*/ + * set SMARTY_DIR to absolute path to Smarty library files. + * Sets SMARTY_DIR only if user application has not already defined it. + */ if (!defined('SMARTY_DIR')) { define('SMARTY_DIR', dirname(__FILE__) . DS); -} +} /** -* set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins. -* Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it. -*/ + * set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins. + * Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it. + */ if (!defined('SMARTY_SYSPLUGINS_DIR')) { define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS); -} +} if (!defined('SMARTY_PLUGINS_DIR')) { define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS); -} +} if (!defined('SMARTY_RESOURCE_CHAR_SET')) { define('SMARTY_RESOURCE_CHAR_SET', 'UTF-8'); -} +} if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) { define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y'); -} +} /** -* define variable scopes -*/ -define('SMARTY_LOCAL_SCOPE', 0); -define('SMARTY_PARENT_SCOPE', 1); -define('SMARTY_ROOT_SCOPE', 2); -define('SMARTY_GLOBAL_SCOPE', 3); - -/** -* define caching modes -*/ -define('SMARTY_CACHING_OFF', 0); -define('SMARTY_CACHING_LIFETIME_CURRENT', 1); -define('SMARTY_CACHING_LIFETIME_SAVED', 2); - -/** -* This determines how Smarty handles "" tags in templates. -* possible values: -*/ -define('SMARTY_PHP_PASSTHRU', 0); //-> print tags as plain text -define('SMARTY_PHP_QUOTE', 1); //-> escape tags as entities -define('SMARTY_PHP_REMOVE', 2); //-> escape tags as entities -define('SMARTY_PHP_ALLOW', 3); //-> escape tags as entities - -/** -* register the class autoloader -*/ + * register the class autoloader + */ if (!defined('SMARTY_SPL_AUTOLOAD')) { define('SMARTY_SPL_AUTOLOAD', 0); -} +} if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) { $registeredAutoLoadFunctions = spl_autoload_functions(); if (!isset($registeredAutoLoadFunctions['spl_autoload'])) { spl_autoload_register(); - } + } } else { spl_autoload_register('smartyAutoload'); -} +} /** -* This is the main Smarty class -*/ + * This is the main Smarty class + */ class Smarty extends Smarty_Internal_Data { + /** + * constant definitions + */ // smarty version - const SMARTY_VERSION = 'Smarty3-b7'; + const SMARTY_VERSION = 'Smarty-3.0.8'; + //define variable scopes + const SCOPE_LOCAL = 0; + const SCOPE_PARENT = 1; + const SCOPE_ROOT = 2; + const SCOPE_GLOBAL = 3; + // define caching modes + const CACHING_OFF = 0; + const CACHING_LIFETIME_CURRENT = 1; + const CACHING_LIFETIME_SAVED = 2; + /** modes for handling of "" tags in templates. **/ + const PHP_PASSTHRU = 0; //-> print tags as plain text + const PHP_QUOTE = 1; //-> escape tags as entities + const PHP_REMOVE = 2; //-> escape tags as entities + const PHP_ALLOW = 3; //-> escape tags as entities + // filter types + const FILTER_POST = 'post'; + const FILTER_PRE = 'pre'; + const FILTER_OUTPUT = 'output'; + const FILTER_VARIABLE = 'variable'; + // plugin types + const PLUGIN_FUNCTION = 'function'; + const PLUGIN_BLOCK = 'block'; + const PLUGIN_COMPILER = 'compiler'; + const PLUGIN_MODIFIER = 'modifier'; + + /** + * static variables + */ + // assigned global tpl vars + static $global_tpl_vars = array(); + + /** + * variables + */ // auto literal on delimiters with whitspace - public $auto_literal = true; + public $auto_literal = true; // display error on not assigned variables - public $error_unassigned = false; + public $error_unassigned = false; // template directory - public $template_dir = null; + public $template_dir = null; // default template handler - public $default_template_handler_func = null; + public $default_template_handler_func = null; // compile directory - public $compile_dir = null; + public $compile_dir = null; // plugins directory - public $plugins_dir = null; + public $plugins_dir = null; // cache directory - public $cache_dir = null; + public $cache_dir = null; // config directory - public $config_dir = null; + public $config_dir = null; // force template compiling? - public $force_compile = false; + public $force_compile = false; // check template for modifications? - public $compile_check = true; + public $compile_check = true; + // locking concurrent compiles + public $compile_locking = true; // use sub dirs for compiled/cached files? - public $use_sub_dirs = false; + public $use_sub_dirs = false; // compile_error? - public $compile_error = false; + public $compile_error = false; // caching enabled - public $caching = false; - // merge compiled includea - public $merge_compiled_includes = false; + public $caching = false; + // merge compiled includes + public $merge_compiled_includes = false; // cache lifetime - public $cache_lifetime = 3600; + public $cache_lifetime = 3600; // force cache file creation - public $force_cache = false; + public $force_cache = false; // cache_id - public $cache_id = null; + public $cache_id = null; // compile_id - public $compile_id = null; + public $compile_id = null; // template delimiters public $left_delimiter = "{"; - public $right_delimiter = "}"; + public $right_delimiter = "}"; // security public $security_class = 'Smarty_Security'; - public $php_handling = SMARTY_PHP_PASSTHRU; + public $security_policy = null; + public $php_handling = self::PHP_PASSTHRU; public $allow_php_tag = false; public $allow_php_templates = false; - public $security = false; - public $security_policy = null; - public $security_handler = null; - public $direct_access_security = true; + public $direct_access_security = true; + public $trusted_dir = array(); // debug mode public $debugging = false; - public $debugging_ctrl = 'URL'; + public $debugging_ctrl = 'NONE'; public $smarty_debug_id = 'SMARTY_DEBUG'; - public $debug_tpl = null; + public $debug_tpl = null; // When set, smarty does uses this value as error_reporting-level. - public $error_reporting = null; + public $error_reporting = null; // config var settings public $config_overwrite = true; //Controls whether variables with the same name overwrite each other. public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean - public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file. + public $config_read_hidden = false; //Controls whether hidden config sections/vars are read from the file. // config vars - public $config_vars = array(); + public $config_vars = array(); // assigned tpl vars - public $tpl_vars = array(); - // assigned global tpl vars - public $global_tpl_vars = array(); + public $tpl_vars = array(); // dummy parent object - public $parent = null; + public $parent = null; // global template functions - public $template_functions = array(); + public $template_functions = array(); // resource type used if none given - public $default_resource_type = 'file'; + public $default_resource_type = 'file'; // caching type - public $caching_type = 'file'; + public $caching_type = 'file'; // internal cache resource types - public $cache_resource_types = array('file'); + public $cache_resource_types = array('file'); + // internal config properties + public $properties = array(); // config type - public $default_config_type = 'file'; - // exception handler: array('ExceptionClass','ExceptionMethod'); - public $exception_handler = null; + public $default_config_type = 'file'; // cached template objects - public $template_objects = null; + public $template_objects = null; // check If-Modified-Since headers - public $cache_modified_check = false; + public $cache_modified_check = false; // registered plugins - public $registered_plugins = array(); + public $registered_plugins = array(); // plugin search order - public $plugin_search_order = array('function', 'block', 'compiler', 'class'); + public $plugin_search_order = array('function', 'block', 'compiler', 'class'); // registered objects - public $registered_objects = array(); + public $registered_objects = array(); + // registered classes + public $registered_classes = array(); // registered filters - public $registered_filters = array(); + public $registered_filters = array(); + // registered resources + public $registered_resources = array(); // autoload filter - public $autoload_filters = array(); + public $autoload_filters = array(); // status of filter on variable output - public $variable_filter = true; + public $variable_filter = true; + // default modifier + public $default_modifiers = array(); // global internal smarty vars - public $_smarty_vars = array(); + static $_smarty_vars = array(); // start time for execution time calculation - public $start_time = 0; + public $start_time = 0; // default file permissions - public $_file_perms = 0644; + public $_file_perms = 0644; // default dir permissions - public $_dir_perms = 0771; - // smarty object reference - public $smarty = null; + public $_dir_perms = 0771; + // block tag hierarchy + public $_tag_stack = array(); + // flag if {block} tag is compiled for template inheritance + public $inheritance = false; + // generate deprecated function call notices? + public $deprecation_notices = true; + // Smarty 2 BC + public $_version = self::SMARTY_VERSION; + // self pointer to Smarty object + public $smarty; /** - * Class constructor, initializes basic smarty properties - */ - public function __construct() { - // self reference needed by other classes methods - $this->smarty = $this; - + * Class constructor, initializes basic smarty properties + */ + public function __construct() + { + // selfpointer need by some other class methods + $this->smarty = $this; 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; $this->plugins_dir = array(SMARTY_PLUGINS_DIR); $this->cache_dir = '.' . DS . 'cache' . DS; $this->config_dir = '.' . DS . 'configs' . DS; - $this->debug_tpl = SMARTY_DIR . 'debug.tpl'; + $this->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl'; + if (isset($_SERVER['SCRIPT_NAME'])) { + $this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']); + } + } + + /** + * Class destructor + */ + public function __destruct() + { + } + + /** + * fetches a rendered Smarty template + * + * @param string $template the resource handle of the template file or template object + * @param mixed $cache_id cache id to be used with this template + * @param mixed $compile_id compile id to be used with this template + * @param object $ |null $parent next higher level of Smarty variables + * @return string rendered template output + */ + public function fetch($template, $cache_id = null, $compile_id = null, $parent = null, $display = false) + { + if (!empty($cache_id) && is_object($cache_id)) { + $parent = $cache_id; + $cache_id = null; + } + if ($parent === null) { + // get default Smarty data object + $parent = $this; + } + // create template object if necessary + ($template instanceof $this->template_class)? $_template = $template : + $_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent, false); + if (isset($this->error_reporting)) { + $_smarty_old_error_level = error_reporting($this->error_reporting); + } + // check URL debugging control if (!$this->debugging && $this->debugging_ctrl == 'URL') { if (isset($_SERVER['QUERY_STRING'])) { $_query_string = $_SERVER['QUERY_STRING']; - } - else { + } else { $_query_string = ''; - } + } if (false !== strpos($_query_string, $this->smarty_debug_id)) { if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) { // enable debugging for this browser session setcookie('SMARTY_DEBUG', true); $this->debugging = true; - } - elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) { + } elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) { // disable debugging for this browser session setcookie('SMARTY_DEBUG', false); $this->debugging = false; - } - else { + } else { // enable debugging for this page $this->debugging = true; - } - } - else { + } + } else { if (isset($_COOKIE['SMARTY_DEBUG'])) { $this->debugging = true; - } - } - } - $this->assign_global('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']); - } + } + } + } + // obtain data for cache modified check + if ($this->cache_modified_check && $this->caching && $display) { + $_isCached = $_template->isCached() && !$_template->has_nocache_code; + if ($_isCached) { + $_gmt_mtime = gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT'; + } else { + $_gmt_mtime = ''; + } + } + // return rendered template + if ((!$this->caching || $_template->resource_object->isEvaluated) && (isset($this->autoload_filters['output']) || isset($this->registered_filters['output']))) { + $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $_template); + } else { + $_output = $_template->getRenderedTemplate(); + } + $_template->rendered_content = null; + if (isset($this->error_reporting)) { + error_reporting($_smarty_old_error_level); + } + // display or fetch + if ($display) { + if ($this->caching && $this->cache_modified_check) { + $_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); + if ($_isCached && $_gmt_mtime == $_last_modified_date) { + if (php_sapi_name() == 'cgi') + header('Status: 304 Not Modified'); + else + header('HTTP/1.1 304 Not Modified'); + } else { + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT'); + echo $_output; + } + } else { + echo $_output; + } + // debug output + if ($this->debugging) { + Smarty_Internal_Debug::display_debug($this); + } + return; + } else { + // return fetched content + return $_output; + } + } /** - * Class destructor - */ - public function __destruct() { - // restore to previous exception handler, if any - if (!empty($this->exception_handler)) - restore_exception_handler(); - } + * displays a Smarty template + * + * @param string $ |object $template the resource handle of the template file or template object + * @param mixed $cache_id cache id to be used with this template + * @param mixed $compile_id compile id to be used with this template + * @param object $parent next higher level of Smarty variables + */ + public function display($template, $cache_id = null, $compile_id = null, $parent = null) + { + // display template + $this->fetch ($template, $cache_id, $compile_id, $parent, true); + } /** - * fetches a rendered Smarty template - * - * @param string $template the resource handle of the template file or template object - * @param mixed $cache_id cache id to be used with this template - * @param mixed $compile_id compile id to be used with this template - * @param object $ |null $parent next higher level of Smarty variables - * @return string rendered template output - */ - public function fetch($template, $cache_id = null, $compile_id = null, $parent = null) { - if (is_object($cache_id)) { + * test if cache i valid + * + * @param string $ |object $template the resource handle of the template file or template object + * @param mixed $cache_id cache id to be used with this template + * @param mixed $compile_id compile id to be used with this template + * @param object $parent next higher level of Smarty variables + * @return boolean cache status + */ + public function isCached($template, $cache_id = null, $compile_id = null, $parent = null) + { + if ($parent === null) { + $parent = $this; + } + if (!($template instanceof $this->template_class)) { + $template = $this->createTemplate ($template, $cache_id, $compile_id, $parent, false); + } + // return cache status of template + return $template->isCached(); + } + + /** + * creates a data object + * + * @param object $parent next higher level of Smarty variables + * @returns object data object + */ + public function createData($parent = null) + { + return new Smarty_Data($parent, $this); + } + + /** + * creates a template object + * + * @param string $template the resource handle of the template file + * @param mixed $cache_id cache id to be used with this template + * @param mixed $compile_id compile id to be used with this template + * @param object $parent next higher level of Smarty variables + * @param boolean $do_clone flag is Smarty object shall be cloned + * @returns object template object + */ + public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true) + { + if (!empty($cache_id) && (is_object($cache_id) || is_array($cache_id))) { $parent = $cache_id; $cache_id = null; - } - if ($parent === null) { - // get default Smarty data object - $parent = $this; - } - // create template object if necessary - ($template instanceof $this->template_class)? $_template = $template : - $_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent); - $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting) - ? $this->error_reporting : error_reporting() &~E_NOTICE); - // return redered template - if (isset($this->autoload_filters['output']) || isset($this->registered_filters['output'])) { - $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $this); - } - else { - $_output = $_template->getRenderedTemplate(); - } - $_template->rendered_content = null; - error_reporting($_smarty_old_error_level); - return $_output; - } + } + if (!empty($parent) && is_array($parent)) { + $data = $parent; + $parent = null; + } else { + $data = null; + } + if (!is_object($template)) { + // we got a template resource + // already in template cache? + $_templateId = sha1($template . $cache_id . $compile_id); + if (isset($this->template_objects[$_templateId]) && $this->caching) { + // return cached template object + $tpl = $this->template_objects[$_templateId]; + } else { + // create new template object + if ($do_clone) { + $tpl = new $this->template_class($template, clone $this, $parent, $cache_id, $compile_id); + } else { + $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id); + } + } + } else { + // just return a copy of template class + $tpl = $template; + } + // fill data if present + if (!empty($data) && is_array($data)) { + // set up variable values + foreach ($data as $_key => $_val) { + $tpl->tpl_vars[$_key] = new Smarty_variable($_val); + } + } + return $tpl; + } + + + + /** + * Check if a template resource exists + * + * @param string $resource_name template name + * @return boolean status + */ + function templateExists($resource_name) + { + // create template object + $save = $this->template_objects; + $tpl = new $this->template_class($resource_name, $this); + // check if it does exists + $result = $tpl->isExisting(); + $this->template_objects = $save; + return $result; + } + + /** + * Returns a single or all global variables + * + * @param object $smarty + * @param string $varname variable name or null + * @return string variable value or or array of variables + */ + function getGlobal($varname = null) + { + if (isset($varname)) { + if (isset(self::$global_tpl_vars[$varname])) { + return self::$global_tpl_vars[$varname]->value; + } else { + return ''; + } + } else { + $_result = array(); + foreach (self::$global_tpl_vars AS $key => $var) { + $_result[$key] = $var->value; + } + return $_result; + } + } /** - * displays a Smarty template - * - * @param string $ |object $template the resource handle of the template file or template object - * @param mixed $cache_id cache id to be used with this template - * @param mixed $compile_id compile id to be used with this template - * @param object $parent next higher level of Smarty variables + * Empty cache folder + * + * @param integer $exp_time expiration time + * @param string $type resource type + * @return integer number of cache files deleted */ - public function display($template, $cache_id = null, $compile_id = null, $parent = null) { - // display template - echo $this->fetch ($template, $cache_id, $compile_id, $parent); - // debug output - if ($this->debugging) { - Smarty_Internal_Debug::display_debug($this); - } - return true; - } + function clearAllCache($exp_time = null, $type = null) + { + // load cache resource and call clearAll + return $this->loadCacheResource($type)->clearAll($exp_time); + } /** - * test if cache i valid - * - * @param string $ |object $template the resource handle of the template file or template object - * @param mixed $cache_id cache id to be used with this template - * @param mixed $compile_id compile id to be used with this template - * @return boolean cache status + * Empty cache for a specific template + * + * @param string $template_name template name + * @param string $cache_id cache id + * @param string $compile_id compile id + * @param integer $exp_time expiration time + * @param string $type resource type + * @return integer number of cache files deleted */ - public function is_cached($template, $cache_id = null, $compile_id = null) { - if (!($template instanceof $this->template_class)) { - $template = $this->createTemplate ($template, $cache_id, $compile_id, $this); - } - // return cache status of template - return $template->isCached(); - } + function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null) + { + // load cache resource and call clear + return $this->loadCacheResource($type)->clear($template_name, $cache_id, $compile_id, $exp_time); + } /** - * Loads security class and enables security + * Loads security class and enables security + */ + public function enableSecurity($security_class = null) + { + if ($security_class instanceof Smarty_Security) { + $this->security_policy = $security_class; + return; + } + if ($security_class == null) { + $security_class = $this->security_class; + } + if (class_exists($security_class)) { + $this->security_policy = new $security_class($this); + } else { + throw new SmartyException("Security class '$security_class' is not defined"); + } + } + + /** + * Disable security + */ + public function disableSecurity() + { + $this->security_policy = null; + } + + /** + * Loads cache resource. + * + * @param string $type cache resource type + * @return object of cache resource */ - public function enableSecurity() { - if (isset($this->security_class)) { - $this->security_policy = new $this->security_class; - $this->security_handler = new Smarty_Internal_Security_Handler($this); - $this->security = true; - } + public function loadCacheResource($type = null) { + if (!isset($type)) { + $type = $this->caching_type; + } + if (in_array($type, $this->cache_resource_types)) { + $cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type); + return new $cache_resource_class($this); + } else { - throw new Exception('Property security_class is not defined'); - } - } + // try plugins dir + $cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type); + if ($this->loadPlugin($cache_resource_class)) { + return new $cache_resource_class($this); + } + else { + throw new SmartyException("Unable to load cache resource '{$type}'"); + } + } + } + /** - * Set template directory - * - * @param string $ |array $template_dir folder(s) of template sorces - */ - public function setTemplateDir($template_dir) { + * Set template directory + * + * @param string $ |array $template_dir folder(s) of template sorces + */ + public function setTemplateDir($template_dir) + { $this->template_dir = (array)$template_dir; return; - } + } + /** - * Adds template directory(s) to existing ones - * - * @param string $ |array $template_dir folder(s) of template sources - */ - public function addTemplateDir($template_dir) { - $this->template_dir = array_merge((array)$this->template_dir, (array)$template_dir); - $this->template_dir = array_unique($this->template_dir); + * Adds template directory(s) to existing ones + * + * @param string $ |array $template_dir folder(s) of template sources + */ + public function addTemplateDir($template_dir) + { + $this->template_dir = array_unique(array_merge((array)$this->template_dir, (array)$template_dir)); return; - } + } + /** - * Set compile directory - * - * @param string $compile_dir folder of compiled template sources - */ - public function setCompileDir($compile_dir) { - $this->compile_dir = $compile_dir; + * Adds directory of plugin files + * + * @param object $smarty + * @param string $ |array $ plugins folder + * @return + */ + function addPluginsDir($plugins_dir) + { + $this->plugins_dir = array_unique(array_merge((array)$this->plugins_dir, (array)$plugins_dir)); return; - } + } + + /** - * Set cache directory - * - * @param string $cache_dir folder of cache files - */ - public function setCacheDir($cache_dir) { - $this->cache_dir = $cache_dir; - return; - } + * return a reference to a registered object + * + * @param string $name object name + * @return object + */ + function getRegisteredObject($name) + { + if (!isset($this->registered_objects[$name])) + throw new SmartyException("'$name' is not a registered object"); + + if (!is_object($this->registered_objects[$name][0])) + throw new SmartyException("registered '$name' is not an object"); + + return $this->registered_objects[$name][0]; + } + + /** - * Enable Caching - */ - public function enableCaching() { - $this->caching = SMARTY_CACHING_LIFETIME_CURRENT; - return; - } + * return name of debugging template + * + * @return string + */ + function getDebugTemplate() + { + return $this->debug_tpl; + } + /** - * Set caching life time - * - * @param integer $lifetime lifetime of cached file in seconds - */ - public function setCacheLifetime($lifetime) { - $this->cache_lifetime = $lifetime; - return; - } + * set the debug template + * + * @param string $tpl_name + * @return bool + */ + function setDebugTemplate($tpl_name) + { + return $this->debug_tpl = $tpl_name; + } + /** - * Takes unknown classes and loads plugin files for them - * class name format: Smarty_PluginType_PluginName - * plugin filename format: plugintype.pluginname.php - * - * @param string $plugin_name class plugin name to load - * @return string|boolean filepath of loaded file or false - */ - public function loadPlugin($plugin_name, $check = true) { + * Takes unknown classes and loads plugin files for them + * class name format: Smarty_PluginType_PluginName + * plugin filename format: plugintype.pluginname.php + * + * @param string $plugin_name class plugin name to load + * @return string |boolean filepath of loaded file or false + */ + public function loadPlugin($plugin_name, $check = true) + { // if function or class exists, exit silently (already loaded) if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) - return true; + return true; // Plugin name is expected to be: Smarty_[Type]_[Name] $_plugin_name = strtolower($plugin_name); - $_name_parts = explode('_', $_plugin_name, 3); + $_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 if ($_name_parts[1] == 'internal') { $file = SMARTY_SYSPLUGINS_DIR . $_plugin_name . '.php'; if (file_exists($file)) { require_once($file); return $file; - } - else { + } else { return false; - } - } + } + } // plugin filename is expected to be: [type].[name].php - $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php"; + $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php"; // loop through plugin dirs and find the plugin foreach((array)$this->plugins_dir as $_plugin_dir) { if (strpos('/\\', substr($_plugin_dir, -1)) === false) { $_plugin_dir .= DS; - } + } $file = $_plugin_dir . $_plugin_filename; if (file_exists($file)) { require_once($file); return $file; - } - } + } + } // no plugin loaded return false; - } + } /** - * Sets the exception handler for Smarty. - * - * @param mixed $handler function name or array with object/method names - * @return string previous exception handler - */ - public function setExceptionHandler($handler) { - $this->exception_handler = $handler; - return set_exception_handler($handler); - } + * clean up properties on cloned object + */ + public function __clone() + { + // clear config vars + $this->config_vars = array(); + // clear assigned tpl vars + $this->tpl_vars = array(); + // clear objects for external methods + unset($this->register); + unset($this->filter); + } - /** - * Loads cache resource. - * - * @return object of cache resource - */ - public function loadCacheResource($type = null) { - if (!isset($type)) { - $type = $this->caching_type; - } - // already loaded? - if (isset($this->cache_resource_objects[$type])) { - return $this->cache_resource_objects[$type]; - } - if (in_array($type, $this->cache_resource_types)) { - $cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type); - return $this->cache_resource_objects[$type] = new $cache_resource_class($this); - } - else { - // try plugins dir - $cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type); - if ($this->loadPlugin($cache_resource_class)) { - return $this->cache_resource_objects[$type] = new $cache_resource_class($this); - } - else { - throw new Exception("Unable to load cache resource '{$type}'"); - } - } - } /** - * trigger Smarty error - * - * @param string $error_msg - * @param integer $error_type - */ - public function trigger_error($error_msg, $error_type = E_USER_WARNING) { - throw new Exception("Smarty error: $error_msg"); - } + * Handle unknown class methods + * + * @param string $name unknown methode name + * @param array $args aurgument array + */ + public function __call($name, $args) + { + static $camel_func; + if (!isset($camel_func)) + $camel_func = create_function('$c', 'return "_" . strtolower($c[1]);'); + // see if this is a set/get for a property + $first3 = strtolower(substr($name, 0, 3)); + if (in_array($first3, array('set', 'get')) && substr($name, 3, 1) !== '_') { + // try to keep case correct for future PHP 6.0 case-sensitive class methods + // lcfirst() not available < PHP 5.3.0, so improvise + $property_name = strtolower(substr($name, 3, 1)) . substr($name, 4); + // 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 SmartyException("property '$property_name' does not exist."); + return false; + } + if ($first3 == 'get') + return $this->$property_name; + else + return $this->$property_name = $args[0]; + } + // Smarty Backward Compatible wrapper + if (strpos($name,'_') !== false) { + if (!isset($this->wrapper)) { + $this->wrapper = new Smarty_Internal_Wrapper($this); + } + return $this->wrapper->convert($name, $args); + } + // external Smarty methods ? + foreach(array('Filter','Register') as $external) { + if (class_exists("Smarty_Internal_{$external}") && method_exists("Smarty_Internal_{$external}",$name)) { + if (!isset($this->$external)) { + $class = "Smarty_Internal_{$external}"; + $this->$external = new $class($this); + } + return call_user_func_array(array($this->$external,$name), $args); + } + } + if (in_array($name,array('clearCompiledTemplate','compileAllTemplates','compileAllConfig','testInstall','getTags'))) { + if (!isset($this->utility)) { + $this->utility = new Smarty_Internal_Utility($this); + } + return call_user_func_array(array($this->utility,$name), $args); + } + // PHP4 call to constructor? + if (strtolower($name) == 'smarty') { + throw new SmartyException('Please use parent::__construct() to call parent constuctor'); + return false; + } + throw new SmartyException("Call of unknown function '$name'."); + } +} - /** - * Takes unknown class methods and lazy loads sysplugin files for them - * class name format: Smarty_Method_MethodName - * plugin filename format: method.methodname.php - * - * @param string $name unknown methode name - * @param array $args aurgument array - */ - public function __call($name, $args) { - $name = strtolower($name); - if ($name == 'smarty') { - throw new Exception('Please use parent::__construct() to call parent constuctor'); - } - $function_name = 'smarty_method_' . $name; - if (!is_callable($function_name)) { - if (!file_exists(SMARTY_SYSPLUGINS_DIR . $function_name . '.php')) { - throw new Exception('Undefined Smarty method "' . $name . '"'); - } - require_once(SMARTY_SYSPLUGINS_DIR . $function_name . '.php'); - } - return call_user_func_array($function_name, array_merge(array($this), $args)); - } -} - -function smartyAutoload($class) { +/** + * Autoloader + */ +function smartyAutoload($class) +{ $_class = strtolower($class); if (substr($_class, 0, 16) === 'smarty_internal_' || $_class == 'smarty_security') { include SMARTY_SYSPLUGINS_DIR . $_class . '.php'; - } -} + } +} + +/** + * Smarty exception class + */ +Class SmartyException extends Exception { +} + +/** + * Smarty compiler exception class + */ +Class SmartyCompilerException extends SmartyException { +} ?> diff --git a/gosa-core/include/smarty/debug.tpl b/gosa-core/include/smarty/debug.tpl index 9fd46b153..058c5b204 100644 --- a/gosa-core/include/smarty/debug.tpl +++ b/gosa-core/include/smarty/debug.tpl @@ -1,4 +1,4 @@ -{capture assign=debug_output} +{capture name='_smarty_debug' assign=debug_output} @@ -86,8 +86,9 @@ td { -

Smarty Debug Console - Total Time {$execution_time|string_format:"%.5f"}

+

Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}

+{if !empty($template_data)}

included templates & config files (load time in seconds)

@@ -99,6 +100,7 @@ td {
{/foreach}
+{/if}

assigned template variables

@@ -124,13 +126,8 @@ td { {/capture} diff --git a/gosa-core/include/smarty/plugins/block.php.php b/gosa-core/include/smarty/plugins/block.php.php index d1de74002..8fedd8b43 100644 --- a/gosa-core/include/smarty/plugins/block.php.php +++ b/gosa-core/include/smarty/plugins/block.php.php @@ -1,27 +1,27 @@ allow_php_tag) { - throw new Exception("{php} is deprecated, set allow_php_tag = true to enable"); + if (!$template->allow_php_tag) { + 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..517fd62dd 100644 --- a/gosa-core/include/smarty/plugins/block.textformat.php +++ b/gosa-core/include/smarty/plugins/block.textformat.php @@ -1,38 +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 -*/ -function smarty_block_textformat($params, $content, $smarty, &$repeat, $template) + * 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 $template template object + * @param boolean &$repeat repeat flag + * @return string content re-formatted + */ +function smarty_block_textformat($params, $content, $template, &$repeat) { if (is_null($content)) { return; @@ -67,7 +66,7 @@ function smarty_block_textformat($params, $content, $smarty, &$repeat, $template break; default: - $smarty->trigger_error("textformat: unknown attribute '$_key'"); + trigger_error("textformat: unknown attribute '$_key'"); } } @@ -100,4 +99,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 88e49d801..7c50bd44b 100644 --- a/gosa-core/include/smarty/plugins/function.counter.php +++ b/gosa-core/include/smarty/plugins/function.counter.php @@ -5,7 +5,6 @@ * @subpackage PluginsFunction */ - /** * Smarty {counter} function plugin * @@ -15,24 +14,25 @@ * @author Monte Ohrt * @link http://smarty.php.net/manual/en/language.function.counter.php {counter} * (Smarty online manual) - * @param array $params parameters - * @param object $smarty Smarty object + * @param array parameters + * @param Smarty * @param object $template template object * @return string|null */ -function smarty_function_counter($params, $smarty, $template) +function smarty_function_counter($params, $template) { + static $counters = array(); $name = (isset($params['name'])) ? $params['name'] : 'default'; - if (!isset($template->plugin_data['counter'][$name])) { - $template->plugin_data['counter'][$name] = array( + if (!isset($counters[$name])) { + $counters[$name] = array( 'start'=>1, 'skip'=>1, 'direction'=>'up', 'count'=>1 ); } - $counter = &$template->plugin_data['counter'][$name]; + $counter =& $counters[$name]; if (isset($params['start'])) { $counter['start'] = $counter['count'] = (int)$params['start']; @@ -75,4 +75,4 @@ function smarty_function_counter($params, $smarty, $template) } -?> +?> \ 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 f1cb46ba6..98e3e2878 100644 --- a/gosa-core/include/smarty/plugins/function.cycle.php +++ b/gosa-core/include/smarty/plugins/function.cycle.php @@ -1,6 +1,7 @@ * Date: May 3, 2002
* Purpose: cycle through given values
+ * Input: + * - name = name of cycle (optional) + * - values = comma separated list of values to cycle, + * or an array of values to cycle + * (this can be left out for subsequent calls) + * - reset = boolean - resets given var to true + * - print = boolean - print var or not. default is true + * - advance = boolean - whether or not to advance the cycle + * - delimiter = the value delimiter, default is "," + * - assign = boolean, assigns to template var instead of + * printed. * * Examples:
*
@@ -25,77 +37,70 @@
  * @author credit to Mark Priatel 
  * @author credit to Gerard 
  * @author credit to Jason Sweat 
- * @param array $params parameters
- * Input:
- *         - name = name of cycle (optional)
- *         - values = comma separated list of values to cycle,
- *                    or an array of values to cycle
- *                    (this can be left out for subsequent calls)
- *         - reset = boolean - resets given var to true
- *         - print = boolean - print var or not. default is true
- *         - advance = boolean - whether or not to advance the cycle
- *         - delimiter = the value delimiter, default is ","
- *         - assign = boolean, assigns to template var instead of
- *                    printed.
- * @param object $smarty Smarty object
+ * @version  1.3
+ * @param array
  * @param object $template template object
  * @return string|null
  */
-function smarty_function_cycle($params, $smarty, $template)
+
+function smarty_function_cycle($params, $template)
 {
+    static $cycle_vars;
+    
     $name = (empty($params['name'])) ? 'default' : $params['name'];
     $print = (isset($params['print'])) ? (bool)$params['print'] : true;
     $advance = (isset($params['advance'])) ? (bool)$params['advance'] : true;
     $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false;
             
     if (!in_array('values', array_keys($params))) {
-        if(!isset($template->plugin_data['cycle'][$name]['values'])) {
-            trigger_error("cycle: missing 'values' parameter",E_USER_WARNING);
+        if(!isset($cycle_vars[$name]['values'])) {
+            trigger_error("cycle: missing 'values' parameter");
             return;
         }
     } else {
-        if(isset($template->plugin_data['cycle'][$name]['values'])
-            && $template->plugin_data['cycle'][$name]['values'] != $params['values'] ) {
-            $template->plugin_data['cycle'][$name]['index'] = 0;
+        if(isset($cycle_vars[$name]['values'])
+            && $cycle_vars[$name]['values'] != $params['values'] ) {
+            $cycle_vars[$name]['index'] = 0;
         }
-        $template->plugin_data['cycle'][$name]['values'] = $params['values'];
+        $cycle_vars[$name]['values'] = $params['values'];
     }
 
     if (isset($params['delimiter'])) {
-      $template->plugin_data['cycle'][$name]['delimiter'] = $params['delimiter'];
-    } elseif (!isset($template->plugin_data['cycle'][$name]['delimiter'])) {
-      $template->plugin_data['cycle'][$name]['delimiter'] = ',';
+        $cycle_vars[$name]['delimiter'] = $params['delimiter'];
+    } elseif (!isset($cycle_vars[$name]['delimiter'])) {
+        $cycle_vars[$name]['delimiter'] = ',';       
     }
     
-    if(is_array($template->plugin_data['cycle'][$name]['values'])) {
-        $cycle_array = $template->plugin_data['cycle'][$name]['values'];
+    if(is_array($cycle_vars[$name]['values'])) {
+        $cycle_array = $cycle_vars[$name]['values'];
     } else {
-        $cycle_array = explode($template->plugin_data['cycle'][$name]['delimiter'],$template->plugin_data['cycle'][$name]['values']);
+        $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
     }
     
-    if(!isset($template->plugin_data['cycle'][$name]['index']) || $reset ) {
-        $template->plugin_data['cycle'][$name]['index'] = 0;
+    if(!isset($cycle_vars[$name]['index']) || $reset ) {
+        $cycle_vars[$name]['index'] = 0;
     }
     
     if (isset($params['assign'])) {
         $print = false;
-        $template->assign($params['assign'], $cycle_array[$template->plugin_data['cycle'][$name]['index']]);
+        $template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
     }
         
     if($print) {
-        $retval = $cycle_array[$template->plugin_data['cycle'][$name]['index']];
+        $retval = $cycle_array[$cycle_vars[$name]['index']];
     } else {
         $retval = null;
     }
 
     if($advance) {
-        if ( $template->plugin_data['cycle'][$name]['index'] >= count($cycle_array) -1 ) {
-            $template->plugin_data['cycle'][$name]['index'] = 0;
+        if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
+            $cycle_vars[$name]['index'] = 0;
         } else {
-            $template->plugin_data['cycle'][$name]['index']++;
+            $cycle_vars[$name]['index']++;
         }
     }
     
     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..2b09fb947 100644
--- a/gosa-core/include/smarty/plugins/function.fetch.php
+++ b/gosa-core/include/smarty/plugins/function.fetch.php
@@ -1,11 +1,11 @@
 
  * @param array $params parameters
- * @param object $smarty Smarty object
  * @param object $template template object
  * @return string|null if the assign parameter is passed, Smarty assigns the
  *                     result to a template variable
  */
-function smarty_function_fetch($params, $smarty, $template)
+function smarty_function_fetch($params, $template)
 {
     if (empty($params['file'])) {
         trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE);
@@ -29,8 +28,8 @@ function smarty_function_fetch($params, $smarty, $template)
     }
 
     $content = '';
-    if ($template->security && !preg_match('!^(http|ftp)://!i', $params['file'])) {
-        if(!$smarty->security_handler->isTrustedResourceDir($params['file'])) {
+    if (isset($template->security_policy) && !preg_match('!^(http|ftp)://!i', $params['file'])) {
+        if(!$template->security_policy->isTrustedResourceDir($params['file'])) {
             return;
         }
         
@@ -53,7 +52,7 @@ function smarty_function_fetch($params, $smarty, $template)
                 $host = $server_name = $uri_parts['host'];
                 $timeout = 30;
                 $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
-                $agent = "Smarty Template Engine ".$smarty->_version;
+                $agent = "Smarty Template Engine ".$template->_version;
                 $referer = "";
                 $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
                 $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
@@ -214,4 +213,4 @@ function smarty_function_fetch($params, $smarty, $template)
     }
 }
 
-?>
+?>
\ 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..6a1a3ffdc 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 @@
  or  
  *           - output     (optional) - the output next to each checkbox
  *           - assign     (optional) - assign the output as an array to this variable
- * @param object $smarty Smarty object
  * @param object $template template object
  * @return string
  * @uses smarty_function_escape_special_chars()
  */
-function smarty_function_html_checkboxes($params, $smarty, $template)
+function smarty_function_html_checkboxes($params, $template)
 {
     require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
-    //$smarty->loadPlugin('Smarty_shared_escape_special_chars');
 
     $name = 'checkbox';
     $values = null;
@@ -142,4 +140,4 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
     return $_output;
 }
 
-?>
+?>
\ 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..abb7b5789 100644
--- a/gosa-core/include/smarty/plugins/function.html_image.php
+++ b/gosa-core/include/smarty/plugins/function.html_image.php
@@ -1,44 +1,42 @@
 
-* 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) + * 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 $template template object + * @return string + * @uses smarty_function_escape_special_chars() + */ +function smarty_function_html_image($params, $template) { require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); - //$smarty->loadPlugin('Smarty_shared_escape_special_chars'); - + $alt = ''; $file = ''; $height = ''; @@ -47,7 +45,7 @@ function smarty_function_html_image($params, $smarty, $template) $prefix = ''; $suffix = ''; $path_prefix = ''; - $server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; + $server_vars = $_SERVER; $basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : ''; foreach($params as $_key => $_val) { switch ($_key) { @@ -64,7 +62,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 +76,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; } @@ -108,8 +106,8 @@ function smarty_function_html_image($params, $smarty, $template) return; } } - if ($template->security) { - if (!$smarty->security_handler->isTrustedResourceDir($_image_path)) { + if (isset($template->security_policy)) { + if (!$template->security_policy->isTrustedResourceDir($_image_path)) { return; } } @@ -136,4 +134,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 69f56e801..7ac039028 100644 --- a/gosa-core/include/smarty/plugins/function.html_options.php +++ b/gosa-core/include/smarty/plugins/function.html_options.php @@ -1,51 +1,53 @@ -* Name: html_options
-* Purpose: Prints the list of