diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 05b8b541..7b4f91e5 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -24,6 +24,7 @@ SVN changes since 3.0 beta1 (2.91) - $CONF[default_aliases] can now use the new domain as alias target (patch#124) - check that vacation start/end date are not in the past (patch#122) - update vacation INSTALL.TXT with more secure locations +- update Smarty to 3.1.21 Version 3.0 beta1 (2.91) - 2014/05/06 - SVN r1670 ------------------------------------------------- diff --git a/smarty/libs/Smarty.class.php b/smarty/libs/Smarty.class.php index 4411c72d..832b0d30 100644 --- a/smarty/libs/Smarty.class.php +++ b/smarty/libs/Smarty.class.php @@ -2,33 +2,29 @@ /** * Project: Smarty: the PHP compiling template engine * File: Smarty.class.php - * SVN: $Id: Smarty.class.php 4800 2013-12-15 15:19:01Z Uwe.Tews@googlemail.com $ - * + * SVN: $Id: Smarty.class.php 4897 2014-10-14 22:29:58Z 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/ + * @link http://www.smarty.net/ * @copyright 2008 New Digital Group, Inc. - * @author Monte Ohrt - * @author Uwe Tews - * @author Rodney Rehm - * @package Smarty - * @version 3.1-DEV + * @author Monte Ohrt + * @author Uwe Tews + * @author Rodney Rehm + * @package Smarty + * @version 3.1.21 */ /** @@ -92,16 +88,17 @@ if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR /** * Load always needed external class files */ -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_data.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_templatebase.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_template.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_resource.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_resource_file.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_cacheresource.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_cacheresource_file.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_templatebase.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_template.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_resource.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_resource_file.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_cacheresource_file.php'; /** * This is the main Smarty class + * * @package Smarty */ class Smarty extends Smarty_Internal_TemplateBase @@ -113,7 +110,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = 'Smarty-3.1.16'; + const SMARTY_VERSION = 'Smarty-3.1.21-dev'; /** * define variable scopes @@ -131,7 +128,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * define constant for clearing cache files be saved expiration datees */ - const CLEAR_EXPIRED = -1; + const CLEAR_EXPIRED = - 1; /** * define compile check modes @@ -206,111 +203,133 @@ class Smarty extends Smarty_Internal_TemplateBase /** * auto literal on delimiters with whitspace + * * @var boolean */ public $auto_literal = true; /** * display error on not assigned variables + * * @var boolean */ public $error_unassigned = false; /** * look up relative filepaths in include_path + * * @var boolean */ public $use_include_path = false; /** * template directory + * * @var array */ private $template_dir = array(); /** * joined template directory string used in cache keys + * * @var string */ public $joined_template_dir = null; /** * joined config directory string used in cache keys + * * @var string */ public $joined_config_dir = null; /** * default template handler + * * @var callable */ public $default_template_handler_func = null; /** * default config handler + * * @var callable */ public $default_config_handler_func = null; /** * default plugin handler + * * @var callable */ public $default_plugin_handler_func = null; /** * compile directory + * * @var string */ private $compile_dir = null; /** * plugins directory + * * @var array */ private $plugins_dir = array(); /** * cache directory + * * @var string */ private $cache_dir = null; /** * config directory + * * @var array */ private $config_dir = array(); /** * force template compiling? + * * @var boolean */ public $force_compile = false; /** * check template for modifications? + * * @var boolean */ public $compile_check = true; /** * use sub dirs for compiled/cached files? + * * @var boolean */ public $use_sub_dirs = false; /** * allow ambiguous resources (that are made unique by the resource handler) + * * @var boolean */ public $allow_ambiguous_resources = false; /** * caching enabled + * * @var boolean */ public $caching = false; /** * merge compiled includes + * * @var boolean */ public $merge_compiled_includes = false; /** * template inheritance merge compiled includes + * * @var boolean - */ + */ public $inheritance_merge_compiled_includes = true; /** * cache lifetime in seconds + * * @var integer */ public $cache_lifetime = 3600; /** * force cache file creation + * * @var boolean */ public $force_cache = false; @@ -330,11 +349,13 @@ class Smarty extends Smarty_Internal_TemplateBase public $compile_id = null; /** * template left-delimiter + * * @var string */ public $left_delimiter = "{"; /** * template right-delimiter + * * @var string */ public $right_delimiter = "}"; @@ -343,7 +364,6 @@ class Smarty extends Smarty_Internal_TemplateBase */ /** * class name - * * This should be instance of Smarty_Security. * * @var string @@ -370,7 +390,6 @@ class Smarty extends Smarty_Internal_TemplateBase public $allow_php_templates = false; /** * Should compiled-templates be prevented from being called directly? - * * {@internal * Currently used by Smarty_Internal_Template only. * }} @@ -381,7 +400,6 @@ class Smarty extends Smarty_Internal_TemplateBase /**#@-*/ /** * debug mode - * * Setting this to true enables the debug-console. * * @var boolean @@ -393,12 +411,12 @@ class Smarty extends Smarty_Internal_TemplateBase *
  • NONE => no debugging control allowed
  • *
  • URL => enable debugging when SMARTY_DEBUG is found in the URL.
  • * + * * @var string */ public $debugging_ctrl = 'NONE'; /** * Name of debugging URL-param. - * * Only used when $debugging_ctrl is set to 'URL'. * The name of the URL-parameter that activates debugging. * @@ -407,16 +425,19 @@ class Smarty extends Smarty_Internal_TemplateBase public $smarty_debug_id = 'SMARTY_DEBUG'; /** * Path of debug template. + * * @var string */ public $debug_tpl = null; /** * When set, smarty uses this value as error_reporting-level. + * * @var int */ public $error_reporting = null; /** * Internal flag for getTags() + * * @var boolean */ public $get_used_tags = false; @@ -427,16 +448,19 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Controls whether variables with the same name overwrite each other. + * * @var boolean */ public $config_overwrite = true; /** * Controls whether config values of on/true/yes and off/false/no get converted to boolean. + * * @var boolean */ public $config_booleanize = true; /** * Controls whether hidden config sections/vars are read from the file. + * * @var boolean */ public $config_read_hidden = false; @@ -449,16 +473,19 @@ class Smarty extends Smarty_Internal_TemplateBase /** * locking concurrent compiles + * * @var boolean */ public $compile_locking = true; /** * Controls whether cache resources should emply locking mechanism + * * @var boolean */ public $cache_locking = false; /** * seconds to wait for acquiring a lock before ignoring the write lock + * * @var float */ public $locking_timeout = 10; @@ -467,19 +494,19 @@ class Smarty extends Smarty_Internal_TemplateBase /** * global template functions + * * @var array */ public $template_functions = array(); /** * resource type used if none given - * * Must be an valid key of $registered_resources. + * * @var string */ public $default_resource_type = 'file'; /** * caching type - * * Must be an element of $cache_resource_types. * * @var string @@ -487,121 +514,145 @@ class Smarty extends Smarty_Internal_TemplateBase public $caching_type = 'file'; /** * internal config properties + * * @var array */ public $properties = array(); /** * config type + * * @var string */ public $default_config_type = 'file'; /** * cached template objects + * * @var array */ public $template_objects = array(); /** * check If-Modified-Since headers + * * @var boolean */ public $cache_modified_check = false; /** * registered plugins + * * @var array */ public $registered_plugins = array(); /** * plugin search order + * * @var array */ public $plugin_search_order = array('function', 'block', 'compiler', 'class'); /** * registered objects + * * @var array */ public $registered_objects = array(); /** * registered classes + * * @var array */ public $registered_classes = array(); /** * registered filters + * * @var array */ public $registered_filters = array(); /** * registered resources + * * @var array */ public $registered_resources = array(); /** * resource handler cache + * * @var array */ public $_resource_handlers = array(); /** * registered cache resources + * * @var array */ public $registered_cache_resources = array(); /** * cache resource handler cache + * * @var array */ public $_cacheresource_handlers = array(); /** * autoload filter + * * @var array */ public $autoload_filters = array(); /** * default modifier + * * @var array */ public $default_modifiers = array(); /** * autoescape variable output + * * @var boolean */ public $escape_html = false; /** * global internal smarty vars + * * @var array */ public static $_smarty_vars = array(); /** * start time for execution time calculation + * * @var int */ public $start_time = 0; /** * default file permissions + * * @var int */ public $_file_perms = 0644; /** * default dir permissions + * * @var int */ public $_dir_perms = 0771; /** * block tag hierarchy + * * @var array */ public $_tag_stack = array(); /** * self pointer to Smarty object + * * @var Smarty */ public $smarty; /** * required by the compiler for BC + * * @var string */ public $_current_file = null; /** * internal flag to enable parser debugging + * * @var bool */ public $_parserdebug = false; @@ -611,11 +662,19 @@ class Smarty extends Smarty_Internal_TemplateBase * @var array */ public $merged_templates_func = array(); + + /** + * Cache of is_file results of loadPlugin() + * + * @var array + */ + public static $_is_file_cache= array(); + /**#@-*/ /** * Initialize new Smarty object - * + */ public function __construct() { @@ -656,33 +715,32 @@ class Smarty extends Smarty_Internal_TemplateBase /** * <> Generic getter. - * * Calls the appropriate getter function. * Issues an E_USER_NOTICE if no valid getter is found. * * @param string $name property name + * * @return mixed */ public function __get($name) { $allowed = array( - 'template_dir' => 'getTemplateDir', - 'config_dir' => 'getConfigDir', - 'plugins_dir' => 'getPluginsDir', - 'compile_dir' => 'getCompileDir', - 'cache_dir' => 'getCacheDir', + 'template_dir' => 'getTemplateDir', + 'config_dir' => 'getConfigDir', + 'plugins_dir' => 'getPluginsDir', + 'compile_dir' => 'getCompileDir', + 'cache_dir' => 'getCacheDir', ); if (isset($allowed[$name])) { return $this->{$allowed[$name]}(); } else { - trigger_error('Undefined property: '. get_class($this) .'::$'. $name, E_USER_NOTICE); + trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); } } /** * <> Generic setter. - * * Calls the appropriate setter function. * Issues an E_USER_NOTICE if no valid setter is found. * @@ -692,11 +750,11 @@ class Smarty extends Smarty_Internal_TemplateBase public function __set($name, $value) { $allowed = array( - 'template_dir' => 'setTemplateDir', - 'config_dir' => 'setConfigDir', - 'plugins_dir' => 'setPluginsDir', - 'compile_dir' => 'setCompileDir', - 'cache_dir' => 'setCacheDir', + 'template_dir' => 'setTemplateDir', + 'config_dir' => 'setConfigDir', + 'plugins_dir' => 'setPluginsDir', + 'compile_dir' => 'setCompileDir', + 'cache_dir' => 'setCacheDir', ); if (isset($allowed[$name])) { @@ -709,7 +767,8 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Check if a template resource exists * - * @param string $resource_name template name + * @param string $resource_name template name + * * @return boolean status */ public function templateExists($resource_name) @@ -727,8 +786,8 @@ class Smarty extends Smarty_Internal_TemplateBase /** * 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 */ public function getGlobal($varname = null) @@ -754,6 +813,7 @@ class Smarty extends Smarty_Internal_TemplateBase * * @param integer $exp_time expiration time * @param string $type resource type + * * @return integer number of cache files deleted */ public function clearAllCache($exp_time = null, $type = null) @@ -773,6 +833,7 @@ class Smarty extends Smarty_Internal_TemplateBase * @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 clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null) @@ -788,6 +849,7 @@ class Smarty extends Smarty_Internal_TemplateBase * Loads security class and enables security * * @param string|Smarty_Security $security_class if a string is used, it must be class-name + * * @return Smarty current Smarty instance for chaining * @throws SmartyException when an invalid class name is provided */ @@ -816,6 +878,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Disable security + * * @return Smarty current Smarty instance for chaining */ public function disableSecurity() @@ -829,13 +892,14 @@ class Smarty extends Smarty_Internal_TemplateBase * Set template directory * * @param string|array $template_dir directory(s) of template sources + * * @return Smarty current Smarty instance for chaining */ public function setTemplateDir($template_dir) { $this->template_dir = array(); foreach ((array) $template_dir as $k => $v) { - $this->template_dir[$k] = rtrim($v, '/\\') . DS; + $this->template_dir[$k] = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($v, '/\\')) . DS; } $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); @@ -846,32 +910,37 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Add template directory(s) * - * @param string|array $template_dir directory(s) of template sources - * @param string $key of the array element to assign the template dir to + * @param string|array $template_dir directory(s) of template sources + * @param string $key of the array element to assign the template dir to + * * @return Smarty current Smarty instance for chaining * @throws SmartyException when the given template directory is not valid */ - public function addTemplateDir($template_dir, $key=null) + public function addTemplateDir($template_dir, $key = null) { // make sure we're dealing with an array $this->template_dir = (array) $this->template_dir; if (is_array($template_dir)) { foreach ($template_dir as $k => $v) { + $v = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($v, '/\\')) . DS; if (is_int($k)) { // indexes are not merged but appended - $this->template_dir[] = rtrim($v, '/\\') . DS; + $this->template_dir[] = $v; } else { // string indexes are overridden - $this->template_dir[$k] = rtrim($v, '/\\') . DS; + $this->template_dir[$k] = $v; } } - } elseif ($key !== null) { - // override directory at specified index - $this->template_dir[$key] = rtrim($template_dir, '/\\') . DS; } else { - // append new directory - $this->template_dir[] = rtrim($template_dir, '/\\') . DS; + $v = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($template_dir, '/\\')) . DS; + if ($key !== null) { + // override directory at specified index + $this->template_dir[$key] = $v; + } else { + // append new directory + $this->template_dir[] = $v; + } } $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); @@ -881,10 +950,11 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Get template directories * - * @param mixed index of directory to get, null to get all + * @param mixed $index index of directory to get, null to get all + * * @return array|string list of template directories, or directory of $index */ - public function getTemplateDir($index=null) + public function getTemplateDir($index = null) { if ($index !== null) { return isset($this->template_dir[$index]) ? $this->template_dir[$index] : null; @@ -896,14 +966,15 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Set config directory * - * @param string|array $template_dir directory(s) of configuration sources + * @param $config_dir + * * @return Smarty current Smarty instance for chaining */ public function setConfigDir($config_dir) { $this->config_dir = array(); foreach ((array) $config_dir as $k => $v) { - $this->config_dir[$k] = rtrim($v, '/\\') . DS; + $this->config_dir[$k] = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($v, '/\\')) . DS; } $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); @@ -914,31 +985,36 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Add config directory(s) * - * @param string|array $config_dir directory(s) of config sources - * @param string key of the array element to assign the config dir to + * @param string|array $config_dir directory(s) of config sources + * @param mixed $key key of the array element to assign the config dir to + * * @return Smarty current Smarty instance for chaining */ - public function addConfigDir($config_dir, $key=null) + public function addConfigDir($config_dir, $key = null) { // make sure we're dealing with an array $this->config_dir = (array) $this->config_dir; if (is_array($config_dir)) { foreach ($config_dir as $k => $v) { + $v = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($v, '/\\')) . DS; if (is_int($k)) { // indexes are not merged but appended - $this->config_dir[] = rtrim($v, '/\\') . DS; + $this->config_dir[] = $v; } else { // string indexes are overridden - $this->config_dir[$k] = rtrim($v, '/\\') . DS; + $this->config_dir[$k] = $v; } } - } elseif ($key !== null) { - // override directory at specified index - $this->config_dir[$key] = rtrim($config_dir, '/\\') . DS; } else { - // append new directory - $this->config_dir[] = rtrim($config_dir, '/\\') . DS; + $v = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($config_dir, '/\\')) . DS; + if ($key !== null) { + // override directory at specified index + $this->config_dir[$key] = rtrim($v, '/\\') . DS; + } else { + // append new directory + $this->config_dir[] = rtrim($v, '/\\') . DS; + } } $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); @@ -949,10 +1025,11 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Get config directory * - * @param mixed index of directory to get, null to get all + * @param mixed $index index of directory to get, null to get all + * * @return array|string configuration directory */ - public function getConfigDir($index=null) + public function getConfigDir($index = null) { if ($index !== null) { return isset($this->config_dir[$index]) ? $this->config_dir[$index] : null; @@ -965,6 +1042,7 @@ class Smarty extends Smarty_Internal_TemplateBase * Set plugins directory * * @param string|array $plugins_dir directory(s) of plugins + * * @return Smarty current Smarty instance for chaining */ public function setPluginsDir($plugins_dir) @@ -980,8 +1058,8 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Adds directory of plugin files * - * @param object $smarty - * @param string $ |array $ plugins folder + * @param $plugins_dir + * * @return Smarty current Smarty instance for chaining */ public function addPluginsDir($plugins_dir) @@ -1023,6 +1101,7 @@ class Smarty extends Smarty_Internal_TemplateBase * Set compile directory * * @param string $compile_dir directory to store compiled templates in + * * @return Smarty current Smarty instance for chaining */ public function setCompileDir($compile_dir) @@ -1049,6 +1128,7 @@ class Smarty extends Smarty_Internal_TemplateBase * Set cache directory * * @param string $cache_dir directory to store cached templates in + * * @return Smarty current Smarty instance for chaining */ public function setCacheDir($cache_dir) @@ -1075,6 +1155,7 @@ class Smarty extends Smarty_Internal_TemplateBase * Set default modifiers * * @param array|string $modifiers modifier or list of modifiers to set + * * @return Smarty current Smarty instance for chaining */ public function setDefaultModifiers($modifiers) @@ -1088,6 +1169,7 @@ class Smarty extends Smarty_Internal_TemplateBase * Add default modifiers * * @param array|string $modifiers modifier or list of modifiers to add + * * @return Smarty current Smarty instance for chaining */ public function addDefaultModifiers($modifiers) @@ -1111,15 +1193,15 @@ class Smarty extends Smarty_Internal_TemplateBase return $this->default_modifiers; } - /** * Set autoload filters * * @param array $filters filters to load automatically * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types + * * @return Smarty current Smarty instance for chaining */ - public function setAutoloadFilters($filters, $type=null) + public function setAutoloadFilters($filters, $type = null) { if ($type !== null) { $this->autoload_filters[$type] = (array) $filters; @@ -1135,9 +1217,10 @@ class Smarty extends Smarty_Internal_TemplateBase * * @param array $filters filters to load automatically * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types + * * @return Smarty current Smarty instance for chaining */ - public function addAutoloadFilters($filters, $type=null) + public function addAutoloadFilters($filters, $type = null) { if ($type !== null) { if (!empty($this->autoload_filters[$type])) { @@ -1162,9 +1245,10 @@ class Smarty extends Smarty_Internal_TemplateBase * Get autoload filters * * @param string $type type of filter to get autoloads for. Defaults to all autoload filters + * * @return array array( 'type1' => array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type was specified */ - public function getAutoloadFilters($type=null) + public function getAutoloadFilters($type = null) { if ($type !== null) { return isset($this->autoload_filters[$type]) ? $this->autoload_filters[$type] : array(); @@ -1186,7 +1270,8 @@ class Smarty extends Smarty_Internal_TemplateBase /** * set the debug template * - * @param string $tpl_name + * @param string $tpl_name + * * @return Smarty current Smarty instance for chaining * @throws SmartyException if file is not readable */ @@ -1208,15 +1293,16 @@ class Smarty extends Smarty_Internal_TemplateBase * @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 + * * @return 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))) { + if ($cache_id !== null && (is_object($cache_id) || is_array($cache_id))) { $parent = $cache_id; $cache_id = null; } - if (!empty($parent) && is_array($parent)) { + if ($parent !== null && is_array($parent)) { $data = $parent; $parent = null; } else { @@ -1267,7 +1353,6 @@ class Smarty extends Smarty_Internal_TemplateBase return $tpl; } - /** * Takes unknown classes and loads plugin files for them * class name format: Smarty_PluginType_PluginName @@ -1275,6 +1360,8 @@ class Smarty extends Smarty_Internal_TemplateBase * * @param string $plugin_name class plugin name to load * @param bool $check check if already loaded + * + * @throws SmartyException * @return string |boolean filepath of loaded file or false */ public function loadPlugin($plugin_name, $check = true) @@ -1289,15 +1376,12 @@ class Smarty extends Smarty_Internal_TemplateBase // count($_name_parts) < 3 === !isset($_name_parts[2]) if (!isset($_name_parts[2]) || strtolower($_name_parts[0]) !== 'smarty') { throw new SmartyException("plugin {$plugin_name} is not a valid name format"); - - return false; } // if type is "internal", get plugin from sysplugins if (strtolower($_name_parts[1]) == 'internal') { $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php'; - if (file_exists($file)) { + if (isset(self::$_is_file_cache[$file]) ? self::$_is_file_cache[$file] : self::$_is_file_cache[$file] = is_file($file)) { require_once($file); - return $file; } else { return false; @@ -1315,9 +1399,8 @@ class Smarty extends Smarty_Internal_TemplateBase $_plugin_dir . strtolower($_plugin_filename), ); foreach ($names as $file) { - if (file_exists($file)) { + if (isset(self::$_is_file_cache[$file]) ? self::$_is_file_cache[$file] : self::$_is_file_cache[$file] = is_file($file)) { require_once($file); - return $file; } if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) { @@ -1343,10 +1426,11 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Compile all template files * - * @param string $extension file extension - * @param bool $force_compile force all to recompile - * @param int $time_limit - * @param int $max_errors + * @param string $extension file extension + * @param bool $force_compile force all to recompile + * @param int $time_limit + * @param int $max_errors + * * @return integer number of template files recompiled */ public function compileAllTemplates($extension = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null) @@ -1357,10 +1441,11 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Compile all config files * - * @param string $extension file extension - * @param bool $force_compile force all to recompile - * @param int $time_limit - * @param int $max_errors + * @param string $extension file extension + * @param bool $force_compile force all to recompile + * @param int $time_limit + * @param int $max_errors + * * @return integer number of template files recompiled */ public function compileAllConfig($extension = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null) @@ -1374,6 +1459,7 @@ class Smarty extends Smarty_Internal_TemplateBase * @param string $resource_name template name * @param string $compile_id compile id * @param integer $exp_time expiration time + * * @return integer number of template files deleted */ public function clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null) @@ -1381,11 +1467,11 @@ class Smarty extends Smarty_Internal_TemplateBase return Smarty_Internal_Utility::clearCompiledTemplate($resource_name, $compile_id, $exp_time, $this); } - /** * Return array of tag/attributes of all tags used by an template * - * @param object $templae template object + * @param Smarty_Internal_Template $template + * * @return array of tag/attributes */ public function getTags(Smarty_Internal_Template $template) @@ -1396,10 +1482,11 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Run installation test * - * @param array $errors Array to write errors into, rather than outputting them + * @param array $errors Array to write errors into, rather than outputting them + * * @return boolean true if setup is fine, false if something is wrong */ - public function testInstall(&$errors=null) + public function testInstall(&$errors = null) { return Smarty_Internal_Utility::testInstall($this, $errors); } @@ -1408,7 +1495,13 @@ class Smarty extends Smarty_Internal_TemplateBase * Error Handler to mute expected messages * * @link http://php.net/set_error_handler + * * @param integer $errno Error level + * @param $errstr + * @param $errfile + * @param $errline + * @param $errcontext + * * @return boolean */ public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext) @@ -1420,7 +1513,7 @@ class Smarty extends Smarty_Internal_TemplateBase $smarty_dir = realpath(SMARTY_DIR); if ($smarty_dir !== false) { Smarty::$_muted_directories[SMARTY_DIR] = array( - 'file' => $smarty_dir, + 'file' => $smarty_dir, 'length' => strlen($smarty_dir), ); } @@ -1437,7 +1530,7 @@ class Smarty extends Smarty_Internal_TemplateBase continue; } $dir = array( - 'file' => $file, + 'file' => $file, 'length' => strlen($file), ); } @@ -1511,6 +1604,7 @@ if (Smarty::$_CHARSET !== 'UTF-8') { /** * Smarty exception class + * * @package Smarty */ class SmartyException extends Exception @@ -1519,12 +1613,13 @@ class SmartyException extends Exception public function __toString() { - return ' --> Smarty: ' . (self::$escape ? htmlentities($this->message) : $this->message) . ' <-- '; + return ' --> Smarty: ' . (self::$escape ? htmlentities($this->message) : $this->message) . ' <-- '; } } /** * Smarty compiler exception class + * * @package Smarty */ class SmartyCompilerException extends SmartyException @@ -1533,23 +1628,28 @@ class SmartyCompilerException extends SmartyException { return ' --> Smarty Compiler: ' . $this->message . ' <-- '; } + /** * The line number of the template error + * * @type int|null */ public $line = null; /** * The template source snippet relating to the error + * * @type string|null */ public $source = null; /** * The raw text of the error message + * * @type string|null */ public $desc = null; /** * The resource identifier or template name + * * @type string|null */ public $template = null; @@ -1562,16 +1662,16 @@ function smartyAutoload($class) { $_class = strtolower($class); static $_classes = array( - 'smarty_config_source' => true, - 'smarty_config_compiled' => true, - 'smarty_security' => true, - 'smarty_cacheresource' => true, - 'smarty_cacheresource_custom' => true, + 'smarty_config_source' => true, + 'smarty_config_compiled' => true, + 'smarty_security' => true, + 'smarty_cacheresource' => true, + 'smarty_cacheresource_custom' => true, 'smarty_cacheresource_keyvaluestore' => true, - 'smarty_resource' => true, - 'smarty_resource_custom' => true, - 'smarty_resource_uncompiled' => true, - 'smarty_resource_recompiled' => true, + 'smarty_resource' => true, + 'smarty_resource_custom' => true, + 'smarty_resource_uncompiled' => true, + 'smarty_resource_recompiled' => true, ); if (!strncmp($_class, 'smarty_internal_', 16) || isset($_classes[$_class])) { diff --git a/smarty/libs/SmartyBC.class.php b/smarty/libs/SmartyBC.class.php index b1cd8d01..d572d185 100644 --- a/smarty/libs/SmartyBC.class.php +++ b/smarty/libs/SmartyBC.class.php @@ -3,36 +3,32 @@ * Project: Smarty: the PHP compiling template engine * File: SmartyBC.class.php * SVN: $Id$ - * * 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/ + * @link http://www.smarty.net/ * @copyright 2008 New Digital Group, Inc. - * @author Monte Ohrt - * @author Uwe Tews - * @author Rodney Rehm - * @package Smarty + * @author Monte Ohrt + * @author Uwe Tews + * @author Rodney Rehm + * @package Smarty */ /** * @ignore */ -require(dirname(__FILE__) . '/Smarty.class.php'); +require_once(dirname(__FILE__) . '/Smarty.class.php'); /** * Smarty Backward Compatability Wrapper Class @@ -43,6 +39,7 @@ class SmartyBC extends Smarty { /** * Smarty 2 BC + * * @var string */ public $_version = self::SMARTY_VERSION; @@ -52,7 +49,7 @@ class SmartyBC extends Smarty * * @param array $options options to set during initialization, e.g. array( 'forceCompile' => false ) */ - public function __construct(array $options=array()) + public function __construct(array $options = array()) { parent::__construct($options); // register {php} tag @@ -100,7 +97,7 @@ class SmartyBC extends Smarty * @param bool $cacheable * @param mixed $cache_attrs */ - public function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null) + public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null) { $this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs); } @@ -118,11 +115,14 @@ class SmartyBC extends Smarty /** * Registers object to be used in templates * - * @param string $object name of template object - * @param object $object_impl the referenced PHP object to register - * @param array $allowed list of allowed methods (empty = all) - * @param boolean $smarty_args smarty argument format, else traditional - * @param array $block_functs list of methods that are block format + * @param string $object name of template object + * @param object $object_impl the referenced PHP object to register + * @param array $allowed list of allowed methods (empty = all) + * @param boolean $smarty_args smarty argument format, else traditional + * @param array $block_methods list of methods that are block format + * + * @throws SmartyException + * @internal param array $block_functs list of methods that are block format */ public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) { @@ -144,12 +144,12 @@ class SmartyBC extends Smarty /** * Registers block function to be used in templates * - * @param string $block name of template block - * @param string $block_impl PHP function to register + * @param string $block name of template block + * @param string $block_impl PHP function to register * @param bool $cacheable * @param mixed $cache_attrs */ - public function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null) + public function register_block($block, $block_impl, $cacheable = true, $cache_attrs = null) { $this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs); } @@ -171,7 +171,7 @@ class SmartyBC extends Smarty * @param string $function_impl name of PHP function to register * @param bool $cacheable */ - public function register_compiler_function($function, $function_impl, $cacheable=true) + public function register_compiler_function($function, $function_impl, $cacheable = true) { $this->registerPlugin('compiler', $function, $function_impl, $cacheable); } @@ -305,10 +305,11 @@ class SmartyBC extends Smarty /** * clear cached content for the given template and cache id * - * @param string $tpl_file name of template file - * @param string $cache_id name of cache_id - * @param string $compile_id name of compile_id - * @param string $exp_time expiration time + * @param string $tpl_file name of template file + * @param string $cache_id name of cache_id + * @param string $compile_id name of compile_id + * @param string $exp_time expiration time + * * @return boolean */ public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) @@ -319,7 +320,8 @@ class SmartyBC extends Smarty /** * clear the entire contents of cache (all templates) * - * @param string $exp_time expire time + * @param string $exp_time expire time + * * @return boolean */ public function clear_all_cache($exp_time = null) @@ -330,9 +332,10 @@ class SmartyBC extends Smarty /** * test to see if valid cache exists for this template * - * @param string $tpl_file name of template file - * @param string $cache_id - * @param string $compile_id + * @param string $tpl_file name of template file + * @param string $cache_id + * @param string $compile_id + * * @return boolean */ public function is_cached($tpl_file, $cache_id = null, $compile_id = null) @@ -353,9 +356,10 @@ class SmartyBC extends Smarty * or all compiled template files if one is not specified. * This function is for advanced use only, not normally needed. * - * @param string $tpl_file - * @param string $compile_id - * @param string $exp_time + * @param string $tpl_file + * @param string $compile_id + * @param string $exp_time + * * @return boolean results of {@link smarty_core_rm_auto()} */ public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null) @@ -366,7 +370,8 @@ class SmartyBC extends Smarty /** * Checks whether requested template exists. * - * @param string $tpl_file + * @param string $tpl_file + * * @return boolean */ public function template_exists($tpl_file) @@ -378,9 +383,10 @@ class SmartyBC extends Smarty * Returns an array containing template variables * * @param string $name + * * @return array */ - public function get_template_vars($name=null) + public function get_template_vars($name = null) { return $this->getTemplateVars($name); } @@ -389,9 +395,10 @@ class SmartyBC extends Smarty * Returns an array containing config variables * * @param string $name + * * @return array */ - public function get_config_vars($name=null) + public function get_config_vars($name = null) { return $this->getConfigVars($name); } @@ -412,6 +419,7 @@ class SmartyBC extends Smarty * return a reference to a registered object * * @param string $name + * * @return object */ public function get_registered_object($name) @@ -439,7 +447,6 @@ class SmartyBC extends Smarty { trigger_error("Smarty error: $error_msg", $error_type); } - } /** @@ -449,6 +456,7 @@ class SmartyBC extends Smarty * @param string $content contents of the block * @param object $template template object * @param boolean &$repeat repeat flag + * * @return string content re-formatted */ function smarty_php_tag($params, $content, $template, &$repeat) diff --git a/smarty/libs/debug.tpl b/smarty/libs/debug.tpl index 12eef0ff..61b8876a 100644 --- a/smarty/libs/debug.tpl +++ b/smarty/libs/debug.tpl @@ -1,133 +1,137 @@ {capture name='_smarty_debug' assign=debug_output} - - - - Smarty Debug Console - - - - -

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

    - -{if !empty($template_data)} -

    included templates & config files (load time in seconds)

    - -
    -{foreach $template_data as $template} - {$template.name} - - (compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"}) + + + + Smarty Debug Console + + + + +

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

    + + {if !empty($template_data)} +

    included templates & config files (load time in seconds)

    +
    + {foreach $template_data as $template} + {$template.name} + + (compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"} + ) -
    -{/foreach} -
    -{/if} - -

    assigned template variables

    - - - {foreach $assigned_vars as $vars} - - - - {/foreach} -
    ${$vars@key|escape:'html'}{$vars|debug_print_var nofilter}
    - -

    assigned config file variables (outer template scope)

    - - - {foreach $config_vars as $vars} - - - - {/foreach} - -
    {$vars@key|escape:'html'}{$vars|debug_print_var nofilter}
    - - +
    + {/foreach} +
    + {/if} + +

    assigned template variables

    + + + {foreach $assigned_vars as $vars} + + + + + {/foreach} +
    ${$vars@key|escape:'html'}{$vars|debug_print_var nofilter}
    + +

    assigned config file variables (outer template scope)

    + + + {foreach $config_vars as $vars} + + + + + {/foreach} + +
    {$vars@key|escape:'html'}{$vars|debug_print_var nofilter}
    + + {/capture} diff --git a/smarty/libs/plugins/block.textformat.php b/smarty/libs/plugins/block.textformat.php index b62a4f8e..abf54493 100644 --- a/smarty/libs/plugins/block.textformat.php +++ b/smarty/libs/plugins/block.textformat.php @@ -2,13 +2,12 @@ /** * Smarty plugin to format text blocks * - * @package Smarty + * @package Smarty * @subpackage PluginsBlock */ /** * Smarty {textformat}{/textformat} block plugin - * * Type: block function
    * Name: textformat
    * Purpose: format text a certain way with preset styles @@ -23,12 +22,14 @@ * - wrap_boundary - boolean (true) * * - * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat} - * (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat} + * (Smarty online manual) + * * @param array $params parameters * @param string $content contents of the block * @param Smarty_Internal_Template $template template object * @param boolean &$repeat repeat flag + * * @return string content re-formatted * @author Monte Ohrt */ @@ -76,7 +77,6 @@ function smarty_block_textformat($params, $content, $template, &$repeat) } // split into paragraphs $_paragraphs = preg_split('![\r\n]{2}!', $content); - $_output = ''; foreach ($_paragraphs as &$_paragraph) { if (!$_paragraph) { diff --git a/smarty/libs/plugins/function.counter.php b/smarty/libs/plugins/function.counter.php index cd147634..4da85a14 100644 --- a/smarty/libs/plugins/function.counter.php +++ b/smarty/libs/plugins/function.counter.php @@ -1,22 +1,24 @@ * Name: counter
    * Purpose: print out a counter value * * @author Monte Ohrt - * @link http://www.smarty.net/manual/en/language.function.counter.php {counter} - * (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.function.counter.php {counter} + * (Smarty online manual) + * * @param array $params parameters * @param Smarty_Internal_Template $template template object + * * @return string|null */ function smarty_function_counter($params, $template) @@ -26,11 +28,11 @@ function smarty_function_counter($params, $template) $name = (isset($params['name'])) ? $params['name'] : 'default'; if (!isset($counters[$name])) { $counters[$name] = array( - 'start'=>1, - 'skip'=>1, - 'direction'=>'up', - 'count'=>1 - ); + 'start' => 1, + 'skip' => 1, + 'direction' => 'up', + 'count' => 1 + ); } $counter =& $counters[$name]; @@ -66,11 +68,11 @@ function smarty_function_counter($params, $template) $counter['direction'] = $params['direction']; } - if ($counter['direction'] == "down") + if ($counter['direction'] == "down") { $counter['count'] -= $counter['skip']; - else + } else { $counter['count'] += $counter['skip']; + } return $retval; - } diff --git a/smarty/libs/plugins/function.cycle.php b/smarty/libs/plugins/function.cycle.php index 9bf26f8c..8dc5cd9d 100644 --- a/smarty/libs/plugins/function.cycle.php +++ b/smarty/libs/plugins/function.cycle.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ /** * Smarty {cycle} function plugin - * * Type: function
    * Name: cycle
    * Date: May 3, 2002
    @@ -31,15 +30,17 @@ * {cycle name=row} * * - * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle} - * (Smarty online manual) - * @author Monte Ohrt - * @author credit to Mark Priatel - * @author credit to Gerard - * @author credit to Jason Sweat + * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle} + * (Smarty online manual) + * @author Monte Ohrt + * @author credit to Mark Priatel + * @author credit to Gerard + * @author credit to Jason Sweat * @version 1.3 + * * @param array $params parameters * @param Smarty_Internal_Template $template template object + * * @return string|null */ @@ -59,8 +60,9 @@ function smarty_function_cycle($params, $template) return; } } else { - if(isset($cycle_vars[$name]['values']) - && $cycle_vars[$name]['values'] != $params['values'] ) { + if (isset($cycle_vars[$name]['values']) + && $cycle_vars[$name]['values'] != $params['values'] + ) { $cycle_vars[$name]['index'] = 0; } $cycle_vars[$name]['values'] = $params['values']; @@ -75,10 +77,10 @@ function smarty_function_cycle($params, $template) if (is_array($cycle_vars[$name]['values'])) { $cycle_array = $cycle_vars[$name]['values']; } else { - $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']); + $cycle_array = explode($cycle_vars[$name]['delimiter'], $cycle_vars[$name]['values']); } - if (!isset($cycle_vars[$name]['index']) || $reset ) { + if (!isset($cycle_vars[$name]['index']) || $reset) { $cycle_vars[$name]['index'] = 0; } @@ -94,10 +96,10 @@ function smarty_function_cycle($params, $template) } if ($advance) { - if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) { + if ($cycle_vars[$name]['index'] >= count($cycle_array) - 1) { $cycle_vars[$name]['index'] = 0; } else { - $cycle_vars[$name]['index']++; + $cycle_vars[$name]['index'] ++; } } diff --git a/smarty/libs/plugins/function.fetch.php b/smarty/libs/plugins/function.fetch.php index a4eaef37..3506d4a8 100644 --- a/smarty/libs/plugins/function.fetch.php +++ b/smarty/libs/plugins/function.fetch.php @@ -2,28 +2,30 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ /** * Smarty {fetch} plugin - * * Type: function
    * Name: fetch
    * Purpose: fetch file, web or ftp data and display results * - * @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch} - * (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch} + * (Smarty online manual) * @author Monte Ohrt + * * @param array $params parameters * @param Smarty_Internal_Template $template template object + * + * @throws SmartyException * @return string|null if the assign parameter is passed, Smarty assigns the result to a template variable */ function smarty_function_fetch($params, $template) { if (empty($params['file'])) { - trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE); + trigger_error("[plugin] fetch parameter 'file' cannot be empty", E_USER_NOTICE); return; } @@ -60,7 +62,7 @@ function smarty_function_fetch($params, $template) $host = $server_name = $uri_parts['host']; $timeout = 30; $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; - $agent = "Smarty Template Engine ". Smarty::SMARTY_VERSION; + $agent = "Smarty Template Engine " . Smarty::SMARTY_VERSION; $referer = ""; $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; @@ -100,8 +102,8 @@ function smarty_function_fetch($params, $template) break; case "header": if (!empty($param_value)) { - if (!preg_match('![\w\d-]+: .+!',$param_value)) { - trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE); + if (!preg_match('![\w\d-]+: .+!', $param_value)) { + trigger_error("[plugin] invalid header format '" . $param_value . "'", E_USER_NOTICE); return; } else { @@ -118,7 +120,7 @@ function smarty_function_fetch($params, $template) if (!preg_match('!\D!', $param_value)) { $proxy_port = (int) $param_value; } else { - trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); + trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE); return; } @@ -137,26 +139,26 @@ function smarty_function_fetch($params, $template) if (!preg_match('!\D!', $param_value)) { $timeout = (int) $param_value; } else { - trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); + trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE); return; } break; default: - trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE); + trigger_error("[plugin] unrecognized attribute '" . $param_key . "'", E_USER_NOTICE); return; } } if (!empty($proxy_host) && !empty($proxy_port)) { $_is_proxy = true; - $fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout); + $fp = fsockopen($proxy_host, $proxy_port, $errno, $errstr, $timeout); } else { - $fp = fsockopen($server_name,$port,$errno,$errstr,$timeout); + $fp = fsockopen($server_name, $port, $errno, $errstr, $timeout); } if (!$fp) { - trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE); + trigger_error("[plugin] unable to fetch: $errstr ($errno)", E_USER_NOTICE); return; } else { @@ -179,35 +181,35 @@ function smarty_function_fetch($params, $template) } if (isset($extra_headers) && is_array($extra_headers)) { foreach ($extra_headers as $curr_header) { - fputs($fp, $curr_header."\r\n"); + fputs($fp, $curr_header . "\r\n"); } } if (!empty($user) && !empty($pass)) { - fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n"); + fputs($fp, "Authorization: BASIC " . base64_encode("$user:$pass") . "\r\n"); } fputs($fp, "\r\n"); while (!feof($fp)) { - $content .= fgets($fp,4096); + $content .= fgets($fp, 4096); } fclose($fp); - $csplit = preg_split("!\r\n\r\n!",$content,2); + $csplit = preg_split("!\r\n\r\n!", $content, 2); $content = $csplit[1]; if (!empty($params['assign_headers'])) { - $template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0])); + $template->assign($params['assign_headers'], preg_split("!\r\n!", $csplit[0])); } } } else { - trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE); + trigger_error("[plugin fetch] unable to parse URL, check syntax", E_USER_NOTICE); return; } } else { $content = @file_get_contents($params['file']); if ($content === false) { - throw new SmartyException("{fetch} cannot read resource '" . $params['file'] ."'"); + throw new SmartyException("{fetch} cannot read resource '" . $params['file'] . "'"); } } diff --git a/smarty/libs/plugins/function.html_checkboxes.php b/smarty/libs/plugins/function.html_checkboxes.php index ad0e9cd4..d7868036 100644 --- a/smarty/libs/plugins/function.html_checkboxes.php +++ b/smarty/libs/plugins/function.html_checkboxes.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ /** * Smarty {html_checkboxes} function plugin - * * File: function.html_checkboxes.php
    * Type: function
    * Name: html_checkboxes
    @@ -32,15 +31,17 @@ * - escape (optional) - escape the content (not value), defaults to true * * - * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} - * (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} + * (Smarty online manual) * @author Christopher Kvarme - * @author credits to Monte Ohrt + * @author credits to Monte Ohrt * @version 1.0 - * @param array $params parameters + * + * @param array $params parameters * @param object $template template object + * * @return string - * @uses smarty_function_escape_special_chars() + * @uses smarty_function_escape_special_chars() */ function smarty_function_html_checkboxes($params, $template) { @@ -89,7 +90,7 @@ function smarty_function_html_checkboxes($params, $template) if (method_exists($_sel, "__toString")) { $_sel = smarty_function_escape_special_chars((string) $_sel->__toString()); } else { - trigger_error("html_checkboxes: selected attribute contains an object of class '". get_class($_sel) ."' without __toString() method", E_USER_NOTICE); + trigger_error("html_checkboxes: selected attribute contains an object of class '" . get_class($_sel) . "' without __toString() method", E_USER_NOTICE); continue; } } else { @@ -101,7 +102,7 @@ function smarty_function_html_checkboxes($params, $template) if (method_exists($_val, "__toString")) { $selected = smarty_function_escape_special_chars((string) $_val->__toString()); } else { - trigger_error("html_checkboxes: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE); + trigger_error("html_checkboxes: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE); } } else { $selected = smarty_function_escape_special_chars((string) $_val); @@ -116,7 +117,8 @@ function smarty_function_html_checkboxes($params, $template) case 'assign': break; - case 'strict': break; + case 'strict': + break; case 'disabled': case 'readonly': @@ -131,11 +133,11 @@ function smarty_function_html_checkboxes($params, $template) break; } - // omit break; to fall through! + // omit break; to fall through! default: if (!is_array($_val)) { - $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; } else { trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE); } @@ -143,17 +145,18 @@ function smarty_function_html_checkboxes($params, $template) } } - if (!isset($options) && !isset($values)) - return ''; /* raise error here? */ + if (!isset($options) && !isset($values)) { + return ''; + } /* raise error here? */ $_html_result = array(); if (isset($options)) { - foreach ($options as $_key=>$_val) { + foreach ($options as $_key => $_val) { $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); } } else { - foreach ($values as $_i=>$_key) { + foreach ($values as $_i => $_key) { $_val = isset($output[$_i]) ? $output[$_i] : ''; $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); } @@ -164,10 +167,9 @@ function smarty_function_html_checkboxes($params, $template) } else { return implode("\n", $_html_result); } - } -function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape=true) +function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape = true) { $_output = ''; @@ -175,7 +177,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte if (method_exists($value, "__toString")) { $value = (string) $value->__toString(); } else { - trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE); + trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE); return ''; } @@ -187,7 +189,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte if (method_exists($output, "__toString")) { $output = (string) $output->__toString(); } else { - trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE); + trigger_error("html_options: output is an object of class '" . get_class($output) . "' without __toString() method", E_USER_NOTICE); return ''; } @@ -229,7 +231,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte $_output .= ''; } - $_output .= $separator; + $_output .= $separator; return $_output; } diff --git a/smarty/libs/plugins/function.html_image.php b/smarty/libs/plugins/function.html_image.php index 1674a262..5037e8bd 100644 --- a/smarty/libs/plugins/function.html_image.php +++ b/smarty/libs/plugins/function.html_image.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ /** * Smarty {html_image} function plugin - * * Type: function
    * Name: html_image
    * Date: Feb 24, 2003
    @@ -24,15 +23,18 @@ * - path_prefix - prefix for path output (optional, default empty) * * - * @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image} - * (Smarty online manual) - * @author Monte Ohrt - * @author credits to Duda + * @link http://www.smarty.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 * @param Smarty_Internal_Template $template template object + * + * @throws SmartyException * @return string - * @uses smarty_function_escape_special_chars() + * @uses smarty_function_escape_special_chars() */ function smarty_function_html_image($params, $template) { @@ -112,7 +114,7 @@ function smarty_function_html_image($params, $template) } } else { // local file - if (!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) { + if (!$template->smarty->security_policy->isTrustedResourceDir($_image_path)) { return; } } diff --git a/smarty/libs/plugins/function.html_options.php b/smarty/libs/plugins/function.html_options.php index 5ff98750..7ec3e065 100644 --- a/smarty/libs/plugins/function.html_options.php +++ b/smarty/libs/plugins/function.html_options.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ /** * Smarty {html_options} function plugin - * * Type: function
    * Name: html_options
    * Purpose: Prints the list of ' . "\n"; - $idx++; + $idx ++; } else { $_idx = 0; - $_html_result = smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id.'-'.$idx) : null, $class, $_idx); - $idx++; + $_html_result = smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null, $class, $_idx); + $idx ++; } return $_html_result; diff --git a/smarty/libs/plugins/function.html_radios.php b/smarty/libs/plugins/function.html_radios.php index 16606ebf..f121d5ea 100644 --- a/smarty/libs/plugins/function.html_radios.php +++ b/smarty/libs/plugins/function.html_radios.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ /** * Smarty {html_radios} function plugin - * * File: function.html_radios.php
    * Type: function
    * Name: html_radios
    @@ -32,15 +31,17 @@ * {html_radios values=$ids checked=$checked separator='
    ' output=$names} * * - * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios} - * (Smarty online manual) - * @author Christopher Kvarme - * @author credits to Monte Ohrt + * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios} + * (Smarty online manual) + * @author Christopher Kvarme + * @author credits to Monte Ohrt * @version 1.0 + * * @param array $params parameters * @param Smarty_Internal_Template $template template object + * * @return string - * @uses smarty_function_escape_special_chars() + * @uses smarty_function_escape_special_chars() */ function smarty_function_html_radios($params, $template) { @@ -72,7 +73,7 @@ function smarty_function_html_radios($params, $template) if (method_exists($_val, "__toString")) { $selected = smarty_function_escape_special_chars((string) $_val->__toString()); } else { - trigger_error("html_radios: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE); + trigger_error("html_radios: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE); } } else { $selected = (string) $_val; @@ -102,7 +103,8 @@ function smarty_function_html_radios($params, $template) case 'assign': break; - case 'strict': break; + case 'strict': + break; case 'disabled': case 'readonly': @@ -117,7 +119,7 @@ function smarty_function_html_radios($params, $template) break; } - // omit break; to fall through! + // omit break; to fall through! default: if (!is_array($_val)) { @@ -163,7 +165,7 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $ if (method_exists($value, "__toString")) { $value = (string) $value->__toString(); } else { - trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE); + trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE); return ''; } @@ -175,7 +177,7 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $ if (method_exists($output, "__toString")) { $output = (string) $output->__toString(); } else { - trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE); + trigger_error("html_options: output is an object of class '" . get_class($output) . "' without __toString() method", E_USER_NOTICE); return ''; } diff --git a/smarty/libs/plugins/function.html_select_date.php b/smarty/libs/plugins/function.html_select_date.php index b1bfee2b..d6625665 100644 --- a/smarty/libs/plugins/function.html_select_date.php +++ b/smarty/libs/plugins/function.html_select_date.php @@ -2,7 +2,7 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ @@ -17,11 +17,9 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); /** * Smarty {html_select_date} plugin - * * Type: function
    * Name: html_select_date
    * Purpose: Prints the dropdowns for date selection. - * * ChangeLog: *
      *            - 1.0 initial release
    @@ -41,17 +39,18 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
      *              added attributes month_names, *_id
      * 
    * - * @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date} - * (Smarty online manual) - * @version 2.0 - * @author Andrei Zmievski - * @author Monte Ohrt - * @author Rodney Rehm - * @param array $params parameters - * @param Smarty_Internal_Template $template template object + * @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date} + * (Smarty online manual) + * @version 2.0 + * @author Andrei Zmievski + * @author Monte Ohrt + * @author Rodney Rehm + * + * @param array $params parameters + * * @return string */ -function smarty_function_html_select_date($params, $template) +function smarty_function_html_select_date($params) { // generate timestamps used for month names only static $_month_timestamps = null; @@ -59,7 +58,7 @@ function smarty_function_html_select_date($params, $template) if ($_month_timestamps === null) { $_current_year = date('Y'); $_month_timestamps = array(); - for ($i = 1; $i <= 12; $i++) { + for ($i = 1; $i <= 12; $i ++) { $_month_timestamps[$i] = mktime(0, 0, 0, $i, 1, 2000); } } @@ -181,22 +180,20 @@ function smarty_function_html_select_date($params, $template) if (isset($params['time']) && is_array($params['time'])) { if (isset($params['time'][$prefix . 'Year'])) { // $_REQUEST[$field_array] given - foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { + foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { $_variableName = '_' . strtolower($_elementName); $$_variableName = isset($params['time'][$prefix . $_elementName]) ? $params['time'][$prefix . $_elementName] : date($_elementKey); } - $time = mktime(0, 0, 0, $_month, $_day, $_year); } elseif (isset($params['time'][$field_array][$prefix . 'Year'])) { // $_REQUEST given - foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { + foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { $_variableName = '_' . strtolower($_elementName); $$_variableName = isset($params['time'][$field_array][$prefix . $_elementName]) ? $params['time'][$field_array][$prefix . $_elementName] : date($_elementKey); } - $time = mktime(0, 0, 0, $_month, $_day, $_year); } else { // no date found, use NOW list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); @@ -219,9 +216,9 @@ function smarty_function_html_select_date($params, $template) if ($t === null) { $$key = (int) $_current_year; } elseif ($t[0] == '+') { - $$key = (int) ($_current_year + trim(substr($t, 1))); + $$key = (int) ($_current_year + (int)trim(substr($t, 1))); } elseif ($t[0] == '-') { - $$key = (int) ($_current_year - trim(substr($t, 1))); + $$key = (int) ($_current_year - (int)trim(substr($t, 1))); } else { $$key = (int) $$key; } @@ -236,7 +233,6 @@ function smarty_function_html_select_date($params, $template) // generate year if ($display_years) { - $_html_years = ''; $_extra = ''; $_name = $field_array ? ($field_array . '[' . $prefix . 'Year]') : ($prefix . 'Year'); if ($all_extra) { @@ -252,8 +248,8 @@ function smarty_function_html_select_date($params, $template) $_html_years = ' or if ($display_months) { - $_html_month = ''; $_extra = ''; $_name = $field_array ? ($field_array . '[' . $prefix . 'Month]') : ($prefix . 'Month'); if ($all_extra) { @@ -290,8 +285,8 @@ function smarty_function_html_select_date($params, $template) $_html_months = ' or if ($display_days) { - $_html_day = ''; $_extra = ''; $_name = $field_array ? ($field_array . '[' . $prefix . 'Day]') : ($prefix . 'Day'); if ($all_extra) { @@ -329,8 +323,8 @@ function smarty_function_html_select_date($params, $template) $_html_days = '' . $option_separator; if (isset($hour_empty) || isset($all_empty)) { - $_html_hours .= '' . $option_separator; + $_html_hours .= '' . $option_separator; } $start = $use_24_hours ? 0 : 1; $end = $use_24_hours ? 23 : 12; - for ($i=$start; $i <= $end; $i++) { + for ($i = $start; $i <= $end; $i ++) { $_val = sprintf('%02d', $i); $_text = $hour_format == '%02d' ? $_val : sprintf($hour_format, $i); $_value = $hour_value_format == '%02d' ? $_val : sprintf($hour_value_format, $i); @@ -226,7 +226,7 @@ function smarty_function_html_select_time($params, $template) if (!$use_24_hours) { $_hour12 = $_hour == 0 ? 12 - : ($_hour <= 12 ? $_hour : $_hour -12); + : ($_hour <= 12 ? $_hour : $_hour - 12); } $selected = $_hour !== null ? ($use_24_hours ? $_hour == $_val : $_hour12 == $_val) : null; @@ -253,8 +253,8 @@ function smarty_function_html_select_time($params, $template) $_html_minutes = '' . $option_separator; if (isset($second_empty) || isset($all_empty)) { - $_html_seconds .= '' . $option_separator; + $_html_seconds .= '' . $option_separator; } $selected = $_second !== null ? ($_second - $_second % $second_interval) : null; - for ($i=0; $i <= 59; $i += $second_interval) { + for ($i = 0; $i <= 59; $i += $second_interval) { $_val = sprintf('%02d', $i); $_text = $second_format == '%02d' ? $_val : sprintf($second_format, $i); $_value = $second_value_format == '%02d' ? $_val : sprintf($second_value_format, $i); @@ -333,8 +333,8 @@ function smarty_function_html_select_time($params, $template) $_html_meridian = ''; } diff --git a/smarty/libs/plugins/function.html_table.php b/smarty/libs/plugins/function.html_table.php index 275f6c24..ec7ba48a 100644 --- a/smarty/libs/plugins/function.html_table.php +++ b/smarty/libs/plugins/function.html_table.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ /** * Smarty {html_table} function plugin - * * Type: function
    * Name: html_table
    * Date: Feb 17, 2003
    @@ -37,17 +36,18 @@ * {table loop=$data cols="first,second,third" tr_attr=$colors} * * - * @author Monte Ohrt - * @author credit to Messju Mohr - * @author credit to boots - * @version 1.1 - * @link http://www.smarty.net/manual/en/language.function.html.table.php {html_table} - * (Smarty online manual) - * @param array $params parameters - * @param Smarty_Internal_Template $template template object + * @author Monte Ohrt + * @author credit to Messju Mohr + * @author credit to boots + * @version 1.1 + * @link http://www.smarty.net/manual/en/language.function.html.table.php {html_table} + * (Smarty online manual) + * + * @param array $params parameters + * * @return string */ -function smarty_function_html_table($params, $template) +function smarty_function_html_table($params) { $table_attr = 'border="1"'; $tr_attr = ''; @@ -63,7 +63,7 @@ function smarty_function_html_table($params, $template) $loop = null; if (!isset($params['loop'])) { - trigger_error("html_table: missing 'loop' parameter",E_USER_WARNING); + trigger_error("html_table: missing 'loop' parameter", E_USER_WARNING); return; } @@ -130,7 +130,7 @@ function smarty_function_html_table($params, $template) $cols = ($hdir == 'right') ? $cols : array_reverse($cols); $output .= "\n"; - for ($r = 0; $r < $cols_count; $r++) { + for ($r = 0; $r < $cols_count; $r ++) { $output .= ''; $output .= $cols[$r]; $output .= "\n"; @@ -139,12 +139,12 @@ function smarty_function_html_table($params, $template) } $output .= "\n"; - for ($r = 0; $r < $rows; $r++) { + for ($r = 0; $r < $rows; $r ++) { $output .= "\n"; - $rx = ($vdir == 'down') ? $r * $cols_count : ($rows-1 - $r) * $cols_count; + $rx = ($vdir == 'down') ? $r * $cols_count : ($rows - 1 - $r) * $cols_count; - for ($c = 0; $c < $cols_count; $c++) { - $x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count-1 - $c; + for ($c = 0; $c < $cols_count; $c ++) { + $x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count - 1 - $c; if ($inner != 'cols') { /* shuffle x to loop over rows*/ $x = floor($x / $cols_count) + ($x % $cols_count) * $rows; diff --git a/smarty/libs/plugins/function.mailto.php b/smarty/libs/plugins/function.mailto.php index ac94ae04..520fb7aa 100644 --- a/smarty/libs/plugins/function.mailto.php +++ b/smarty/libs/plugins/function.mailto.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ /** * Smarty {mailto} function plugin - * * Type: function
    * Name: mailto
    * Date: May 21, 2002 @@ -39,22 +38,23 @@ * {mailto address="me@domain.com" extra='class="mailto"'} * * - * @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto} - * (Smarty online manual) - * @version 1.2 - * @author Monte Ohrt - * @author credits to Jason Sweat (added cc, bcc and subject functionality) - * @param array $params parameters - * @param Smarty_Internal_Template $template template object + * @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto} + * (Smarty online manual) + * @version 1.2 + * @author Monte Ohrt + * @author credits to Jason Sweat (added cc, bcc and subject functionality) + * + * @param array $params parameters + * * @return string */ -function smarty_function_mailto($params, $template) +function smarty_function_mailto($params) { static $_allowed_encoding = array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true); $extra = ''; if (empty($params['address'])) { - trigger_error("mailto: missing 'address' parameter",E_USER_WARNING); + trigger_error("mailto: missing 'address' parameter", E_USER_WARNING); return; } else { @@ -72,8 +72,9 @@ function smarty_function_mailto($params, $template) case 'cc': case 'bcc': case 'followupto': - if (!empty($value)) - $mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value)); + if (!empty($value)) { + $mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value)); + } break; case 'subject': @@ -104,7 +105,7 @@ function smarty_function_mailto($params, $template) $string = 'document.write(\'' . $text . '\');'; $js_encode = ''; - for ($x = 0, $_length = strlen($string); $x < $_length; $x++) { + for ($x = 0, $_length = strlen($string); $x < $_length; $x ++) { $js_encode .= '%' . bin2hex($string[$x]); } @@ -112,7 +113,7 @@ function smarty_function_mailto($params, $template) } elseif ($encode == 'javascript_charcode') { $string = '' . $text . ''; - for ($x = 0, $y = strlen($string); $x < $y; $x++) { + for ($x = 0, $y = strlen($string); $x < $y; $x ++) { $ord[] = ord($string[$x]); } @@ -127,12 +128,12 @@ function smarty_function_mailto($params, $template) } elseif ($encode == 'hex') { preg_match('!^(.*)(\?.*)$!', $address, $match); if (!empty($match[2])) { - trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.",E_USER_WARNING); + trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING); return; } $address_encode = ''; - for ($x = 0, $_length = strlen($address); $x < $_length; $x++) { + for ($x = 0, $_length = strlen($address); $x < $_length; $x ++) { if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[$x])) { $address_encode .= '%' . bin2hex($address[$x]); } else { @@ -140,7 +141,7 @@ function smarty_function_mailto($params, $template) } } $text_encode = ''; - for ($x = 0, $_length = strlen($text); $x < $_length; $x++) { + for ($x = 0, $_length = strlen($text); $x < $_length; $x ++) { $text_encode .= '&#x' . bin2hex($text[$x]) . ';'; } diff --git a/smarty/libs/plugins/function.math.php b/smarty/libs/plugins/function.math.php index 7bcc8acf..aba76e82 100644 --- a/smarty/libs/plugins/function.math.php +++ b/smarty/libs/plugins/function.math.php @@ -1,36 +1,37 @@ * Name: math
    * Purpose: handle math computations in template * - * @link http://www.smarty.net/manual/en/language.function.math.php {math} - * (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.function.math.php {math} + * (Smarty online manual) * @author Monte Ohrt + * * @param array $params parameters * @param Smarty_Internal_Template $template template object + * * @return string|null */ function smarty_function_math($params, $template) { static $_allowed_funcs = array( - 'int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true, - 'log' => true, 'log10' => true, 'max' => true, 'min' => true, 'pi' => true, 'pow' => true, - 'rand' => true, 'round' => true, 'sin' => true, 'sqrt' => true, 'srand' => true ,'tan' => true + 'int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true, + 'log' => true, 'log10' => true, 'max' => true, 'min' => true, 'pi' => true, 'pow' => true, + 'rand' => true, 'round' => true, 'sin' => true, 'sqrt' => true, 'srand' => true, 'tan' => true ); // be sure equation parameter is present if (empty($params['equation'])) { - trigger_error("math: missing equation parameter",E_USER_WARNING); + trigger_error("math: missing equation parameter", E_USER_WARNING); return; } @@ -38,18 +39,18 @@ function smarty_function_math($params, $template) $equation = $params['equation']; // make sure parenthesis are balanced - if (substr_count($equation,"(") != substr_count($equation,")")) { - trigger_error("math: unbalanced parenthesis",E_USER_WARNING); + if (substr_count($equation, "(") != substr_count($equation, ")")) { + trigger_error("math: unbalanced parenthesis", E_USER_WARNING); return; } // match all vars in equation, make sure all are passed - preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match); + preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!", $equation, $match); foreach ($match[1] as $curr_var) { if ($curr_var && !isset($params[$curr_var]) && !isset($_allowed_funcs[$curr_var])) { - trigger_error("math: function call $curr_var not allowed",E_USER_WARNING); + trigger_error("math: function call $curr_var not allowed", E_USER_WARNING); return; } @@ -58,13 +59,13 @@ function smarty_function_math($params, $template) foreach ($params as $key => $val) { if ($key != "equation" && $key != "format" && $key != "assign") { // make sure value is not empty - if (strlen($val)==0) { - trigger_error("math: parameter $key is empty",E_USER_WARNING); + if (strlen($val) == 0) { + trigger_error("math: parameter $key is empty", E_USER_WARNING); return; } if (!is_numeric($val)) { - trigger_error("math: parameter $key: is not numeric",E_USER_WARNING); + trigger_error("math: parameter $key: is not numeric", E_USER_WARNING); return; } @@ -72,19 +73,19 @@ function smarty_function_math($params, $template) } } $smarty_math_result = null; - eval("\$smarty_math_result = ".$equation.";"); + eval("\$smarty_math_result = " . $equation . ";"); if (empty($params['format'])) { if (empty($params['assign'])) { return $smarty_math_result; } else { - $template->assign($params['assign'],$smarty_math_result); + $template->assign($params['assign'], $smarty_math_result); } } else { if (empty($params['assign'])) { - printf($params['format'],$smarty_math_result); + printf($params['format'], $smarty_math_result); } else { - $template->assign($params['assign'],sprintf($params['format'],$smarty_math_result)); + $template->assign($params['assign'], sprintf($params['format'], $smarty_math_result)); } } } diff --git a/smarty/libs/plugins/modifier.capitalize.php b/smarty/libs/plugins/modifier.capitalize.php index c019df5f..a8ad7637 100644 --- a/smarty/libs/plugins/modifier.capitalize.php +++ b/smarty/libs/plugins/modifier.capitalize.php @@ -2,22 +2,21 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifier */ /** * Smarty capitalize modifier plugin - * * Type: modifier
    * Name: capitalize
    * Purpose: capitalize words in the string - * * {@internal {$string|capitalize:true:true} is the fastest option for MBString enabled systems }} * * @param string $string string to capitalize * @param boolean $uc_digits also capitalize "x123" to "X123" * @param boolean $lc_rest capitalize first letters, lowercase all following letters "aAa" to "Aaa" + * * @return string capitalized string * @author Monte Ohrt * @author Rodney Rehm @@ -27,40 +26,40 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals if (Smarty::$_MBSTRING) { if ($lc_rest) { // uppercase (including hyphenated words) - $upper_string = mb_convert_case( $string, MB_CASE_TITLE, Smarty::$_CHARSET ); + $upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET); } else { // uppercase word breaks - $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert_cb', $string); + $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert_cb', $string); } // check uc_digits case if (!$uc_digits) { if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) { - foreach($matches[1] as $match) { + foreach ($matches[1] as $match) { $upper_string = substr_replace($upper_string, mb_strtolower($match[0], Smarty::$_CHARSET), $match[1], strlen($match[0])); } - } + } } $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb', $upper_string); return $upper_string; } - + // lowercase first if ($lc_rest) { $string = strtolower($string); } // uppercase (including hyphenated words) - $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb', $string); + $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb', $string); // check uc_digits case if (!$uc_digits) { if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) { - foreach($matches[1] as $match) { + foreach ($matches[1] as $match) { $upper_string = substr_replace($upper_string, strtolower($match[0]), $match[1], strlen($match[0])); } - } + } } $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb', $upper_string); return $upper_string; -} +} /* * @@ -70,18 +69,22 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals * * @author Kyle Renfrow */ -function smarty_mod_cap_mbconvert_cb($matches){ - return stripslashes($matches[1]).mb_convert_case(stripslashes($matches[2]),MB_CASE_UPPER, Smarty::$_CHARSET); +function smarty_mod_cap_mbconvert_cb($matches) +{ + return stripslashes($matches[1]) . mb_convert_case(stripslashes($matches[2]), MB_CASE_UPPER, Smarty::$_CHARSET); } -function smarty_mod_cap_mbconvert2_cb($matches){ - return stripslashes($matches[1]).mb_convert_case(stripslashes($matches[3]),MB_CASE_UPPER, Smarty::$_CHARSET); +function smarty_mod_cap_mbconvert2_cb($matches) +{ + return stripslashes($matches[1]) . mb_convert_case(stripslashes($matches[3]), MB_CASE_UPPER, Smarty::$_CHARSET); } -function smarty_mod_cap_ucfirst_cb($matches){ - return stripslashes($matches[1]).ucfirst(stripslashes($matches[2])); +function smarty_mod_cap_ucfirst_cb($matches) +{ + return stripslashes($matches[1]) . ucfirst(stripslashes($matches[2])); } -function smarty_mod_cap_ucfirst2_cb($matches){ - return stripslashes($matches[1]).ucfirst(stripslashes($matches[3])); +function smarty_mod_cap_ucfirst2_cb($matches) +{ + return stripslashes($matches[1]) . ucfirst(stripslashes($matches[3])); } diff --git a/smarty/libs/plugins/modifier.date_format.php b/smarty/libs/plugins/modifier.date_format.php index e1a9d33e..5ad7540b 100644 --- a/smarty/libs/plugins/modifier.date_format.php +++ b/smarty/libs/plugins/modifier.date_format.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifier */ /** * Smarty date_format modifier plugin - * * Type: modifier
    * Name: date_format
    * Purpose: format datestamps via strftime
    @@ -17,23 +16,25 @@ * - format: strftime format for output * - default_date: default date if $string is empty * - * @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual) * @author Monte Ohrt + * * @param string $string input date string * @param string $format strftime format for output * @param string $default_date default date if $string is empty * @param string $formatter either 'strftime' or 'auto' + * * @return string |void - * @uses smarty_make_timestamp() + * @uses smarty_make_timestamp() */ -function smarty_modifier_date_format($string, $format=null, $default_date='', $formatter='auto') +function smarty_modifier_date_format($string, $format = null, $default_date = '', $formatter = 'auto') { if ($format === null) { $format = Smarty::$_DATE_FORMAT; } /** - * Include the {@link shared.make_timestamp.php} plugin - */ + * Include the {@link shared.make_timestamp.php} plugin + */ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') { $timestamp = smarty_make_timestamp($string); @@ -42,7 +43,7 @@ function smarty_modifier_date_format($string, $format=null, $default_date='', $f } else { return; } - if ($formatter=='strftime'||($formatter=='auto'&&strpos($format,'%')!==false)) { + if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) { if (DS == '\\') { $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); diff --git a/smarty/libs/plugins/modifier.debug_print_var.php b/smarty/libs/plugins/modifier.debug_print_var.php index ea63c8a7..66363d25 100644 --- a/smarty/libs/plugins/modifier.debug_print_var.php +++ b/smarty/libs/plugins/modifier.debug_print_var.php @@ -2,38 +2,39 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage Debug */ /** * Smarty debug_print_var modifier plugin - * * Type: modifier
    * Name: debug_print_var
    * Purpose: formats variable contents for display in the console * * @author Monte Ohrt - * @param array|object $var variable to be formatted - * @param integer $depth maximum recursion depth if $var is an array - * @param integer $length maximum string length if $var is a string + * + * @param array|object $var variable to be formatted + * @param integer $depth maximum recursion depth if $var is an array + * @param integer $length maximum string length if $var is a string + * * @return string */ -function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40) +function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) { $_replace = array("\n" => '\n', - "\r" => '\r', - "\t" => '\t' - ); + "\r" => '\r', + "\t" => '\t' + ); switch (gettype($var)) { case 'array' : $results = 'Array (' . count($var) . ')'; foreach ($var as $curr_key => $curr_val) { $results .= '
    ' . str_repeat(' ', $depth * 2) - . '' . strtr($curr_key, $_replace) . ' => ' - . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); - $depth--; + . '' . strtr($curr_key, $_replace) . ' => ' + . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); + $depth --; } break; @@ -42,9 +43,9 @@ function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40) $results = '' . get_class($var) . ' Object (' . count($object_vars) . ')'; foreach ($object_vars as $curr_key => $curr_val) { $results .= '
    ' . str_repeat(' ', $depth * 2) - . ' ->' . strtr($curr_key, $_replace) . ' = ' - . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); - $depth--; + . ' ->' . strtr($curr_key, $_replace) . ' = ' + . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); + $depth --; } break; diff --git a/smarty/libs/plugins/modifier.escape.php b/smarty/libs/plugins/modifier.escape.php index bc8ad42a..9fdb0702 100644 --- a/smarty/libs/plugins/modifier.escape.php +++ b/smarty/libs/plugins/modifier.escape.php @@ -2,23 +2,24 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifier */ /** * Smarty escape modifier plugin - * * Type: modifier
    * Name: escape
    * Purpose: escape string for output * - * @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) + * @link http://www.smarty.net/docs/en/language.modifier.escape * @author Monte Ohrt + * * @param string $string input string * @param string $esc_type escape type * @param string $char_set character set, used for htmlspecialchars() or htmlentities() * @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities() + * * @return string escaped input string */ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true) @@ -105,7 +106,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ // Note that the UTF-8 encoded character ä will be represented as %c3%a4 $return = ''; $_length = strlen($string); - for ($x = 0; $x < $_length; $x++) { + for ($x = 0; $x < $_length; $x ++) { $return .= '%' . bin2hex($string[$x]); } @@ -124,7 +125,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ } // no MBString fallback $_length = strlen($string); - for ($x = 0; $x < $_length; $x++) { + for ($x = 0; $x < $_length; $x ++) { $return .= '&#x' . bin2hex($string[$x]) . ';'; } @@ -143,7 +144,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ } // no MBString fallback $_length = strlen($string); - for ($x = 0; $x < $_length; $x++) { + for ($x = 0; $x < $_length; $x ++) { $return .= '&#' . ord($string[$x]) . ';'; } @@ -179,7 +180,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ } $_length = strlen($string); - for ($_i = 0; $_i < $_length; $_i++) { + for ($_i = 0; $_i < $_length; $_i ++) { $_ord = ord(substr($string, $_i, 1)); // non-standard char, escape it if ($_ord >= 126) { diff --git a/smarty/libs/plugins/modifier.regex_replace.php b/smarty/libs/plugins/modifier.regex_replace.php index a44afb5f..abb1ff54 100644 --- a/smarty/libs/plugins/modifier.regex_replace.php +++ b/smarty/libs/plugins/modifier.regex_replace.php @@ -2,23 +2,24 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifier */ /** * Smarty regex_replace modifier plugin - * * Type: modifier
    * Name: regex_replace
    * Purpose: regular expression search/replace * - * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php + * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php * regex_replace (Smarty online manual) - * @author Monte Ohrt - * @param string $string input string - * @param string|array $search regular expression(s) to search for - * @param string|array $replace string(s) that should be replaced + * @author Monte Ohrt + * + * @param string $string input string + * @param string|array $search regular expression(s) to search for + * @param string|array $replace string(s) that should be replaced + * * @return string */ function smarty_modifier_regex_replace($string, $search, $replace) @@ -36,6 +37,7 @@ function smarty_modifier_regex_replace($string, $search, $replace) /** * @param string $search string(s) that should be replaced + * * @return string * @ignore */ @@ -43,12 +45,12 @@ function _smarty_regex_replace_check($search) { // null-byte injection detection // anything behind the first null-byte is ignored - if (($pos = strpos($search,"\0")) !== false) { - $search = substr($search,0,$pos); + if (($pos = strpos($search, "\0")) !== false) { + $search = substr($search, 0, $pos); } // remove eval-modifier from $search if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { - $search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); + $search = substr($search, 0, - strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); } return $search; diff --git a/smarty/libs/plugins/modifier.replace.php b/smarty/libs/plugins/modifier.replace.php index cf4f6459..aa5e8570 100644 --- a/smarty/libs/plugins/modifier.replace.php +++ b/smarty/libs/plugins/modifier.replace.php @@ -1,23 +1,25 @@ * Name: replace
    * Purpose: simple search/replace * - * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual) + * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual) * @author Monte Ohrt * @author Uwe Tews + * * @param string $string input string * @param string $search text to search for * @param string $replace replacement text + * * @return string */ function smarty_modifier_replace($string, $search, $replace) diff --git a/smarty/libs/plugins/modifier.spacify.php b/smarty/libs/plugins/modifier.spacify.php index 1a5f425a..e5c41ad8 100644 --- a/smarty/libs/plugins/modifier.spacify.php +++ b/smarty/libs/plugins/modifier.spacify.php @@ -1,25 +1,27 @@ * Name: spacify
    * Purpose: add spaces between characters in a string * - * @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual) + * @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual) * @author Monte Ohrt + * * @param string $string input string * @param string $spacify_char string to insert between characters. + * * @return string */ function smarty_modifier_spacify($string, $spacify_char = ' ') { // well… what about charsets besides latin and UTF-8? - return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY)); + return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, - 1, PREG_SPLIT_NO_EMPTY)); } diff --git a/smarty/libs/plugins/modifier.truncate.php b/smarty/libs/plugins/modifier.truncate.php index e2810ed7..fbe62e82 100644 --- a/smarty/libs/plugins/modifier.truncate.php +++ b/smarty/libs/plugins/modifier.truncate.php @@ -2,32 +2,34 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifier */ /** * Smarty truncate modifier plugin - * * Type: modifier
    * Name: truncate
    * Purpose: Truncate a string to a certain length if necessary, * optionally splitting in the middle of a word, and * appending the $etc string or inserting $etc into the middle. * - * @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual) + * @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual) * @author Monte Ohrt + * * @param string $string input string * @param integer $length length of truncated text * @param string $etc end string * @param boolean $break_words truncate at word boundary * @param boolean $middle truncate in the middle of text + * * @return string truncated string */ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) { - if ($length == 0) + if ($length == 0) { return ''; + } if (Smarty::$_MBSTRING) { if (mb_strlen($string, Smarty::$_CHARSET) > $length) { diff --git a/smarty/libs/plugins/modifiercompiler.cat.php b/smarty/libs/plugins/modifiercompiler.cat.php index 5dff7474..db9d81fb 100644 --- a/smarty/libs/plugins/modifiercompiler.cat.php +++ b/smarty/libs/plugins/modifiercompiler.cat.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty cat modifier plugin - * * Type: modifier
    * Name: cat
    * Date: Feb 24, 2003
    @@ -16,13 +15,15 @@ * Input: string to catenate
    * Example: {$var|cat:"foo"} * - * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat - * (Smarty online manual) + * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat + * (Smarty online manual) * @author Uwe Tews + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_cat($params, $compiler) +function smarty_modifiercompiler_cat($params) { - return '('.implode(').(', $params).')'; + return '(' . implode(').(', $params) . ')'; } diff --git a/smarty/libs/plugins/modifiercompiler.count_characters.php b/smarty/libs/plugins/modifiercompiler.count_characters.php index 778d0385..f8463d80 100644 --- a/smarty/libs/plugins/modifiercompiler.count_characters.php +++ b/smarty/libs/plugins/modifiercompiler.count_characters.php @@ -2,23 +2,24 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty count_characters modifier plugin - * * Type: modifier
    * Name: count_characteres
    * Purpose: count the number of characters in a text * - * @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) * @author Uwe Tews + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_count_characters($params, $compiler) +function smarty_modifiercompiler_count_characters($params) { if (!isset($params[1]) || $params[1] != 'true') { return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)'; diff --git a/smarty/libs/plugins/modifiercompiler.count_paragraphs.php b/smarty/libs/plugins/modifiercompiler.count_paragraphs.php index 581d291c..34f0bbb8 100644 --- a/smarty/libs/plugins/modifiercompiler.count_paragraphs.php +++ b/smarty/libs/plugins/modifiercompiler.count_paragraphs.php @@ -2,24 +2,25 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty count_paragraphs modifier plugin - * * Type: modifier
    * Name: count_paragraphs
    * Purpose: count the number of paragraphs in a text * - * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php + * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php * count_paragraphs (Smarty online manual) - * @author Uwe Tews + * @author Uwe Tews + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_count_paragraphs($params, $compiler) +function smarty_modifiercompiler_count_paragraphs($params) { // count \r or \n characters return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)'; diff --git a/smarty/libs/plugins/modifiercompiler.count_sentences.php b/smarty/libs/plugins/modifiercompiler.count_sentences.php index 5cb0f2ae..f1ec5600 100644 --- a/smarty/libs/plugins/modifiercompiler.count_sentences.php +++ b/smarty/libs/plugins/modifiercompiler.count_sentences.php @@ -2,24 +2,25 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty count_sentences modifier plugin - * * Type: modifier
    * Name: count_sentences * Purpose: count the number of sentences in a text * - * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php + * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php * count_sentences (Smarty online manual) - * @author Uwe Tews + * @author Uwe Tews + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_count_sentences($params, $compiler) +function smarty_modifiercompiler_count_sentences($params) { // find periods, question marks, exclamation marks with a word before but not after. return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)'; diff --git a/smarty/libs/plugins/modifiercompiler.count_words.php b/smarty/libs/plugins/modifiercompiler.count_words.php index 9146900d..8b4330f1 100644 --- a/smarty/libs/plugins/modifiercompiler.count_words.php +++ b/smarty/libs/plugins/modifiercompiler.count_words.php @@ -2,23 +2,24 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty count_words modifier plugin - * * Type: modifier
    * Name: count_words
    * Purpose: count the number of words in a text * - * @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual) * @author Uwe Tews + * * @param array $params parameters + * * @return string with compiled code -*/ -function smarty_modifiercompiler_count_words($params, $compiler) + */ +function smarty_modifiercompiler_count_words($params) { if (Smarty::$_MBSTRING) { // return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)'; diff --git a/smarty/libs/plugins/modifiercompiler.default.php b/smarty/libs/plugins/modifiercompiler.default.php index 83b3f365..fe777623 100644 --- a/smarty/libs/plugins/modifiercompiler.default.php +++ b/smarty/libs/plugins/modifiercompiler.default.php @@ -2,23 +2,24 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty default modifier plugin - * * Type: modifier
    * Name: default
    * Purpose: designate default value for empty variables * - * @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual) * @author Uwe Tews + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_default ($params, $compiler) +function smarty_modifiercompiler_default($params) { $output = $params[0]; if (!isset($params[1])) { diff --git a/smarty/libs/plugins/modifiercompiler.escape.php b/smarty/libs/plugins/modifiercompiler.escape.php index 6c6a356a..7e848aae 100644 --- a/smarty/libs/plugins/modifiercompiler.escape.php +++ b/smarty/libs/plugins/modifiercompiler.escape.php @@ -2,25 +2,27 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * @ignore */ -require_once( SMARTY_PLUGINS_DIR .'shared.literal_compiler_param.php' ); +require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'); /** * Smarty escape modifier plugin - * * Type: modifier
    * Name: escape
    * Purpose: escape string for output * - * @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual) + * @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual) * @author Rodney Rehm + * * @param array $params parameters + * @param $compiler + * * @return string with compiled code */ function smarty_modifiercompiler_escape($params, $compiler) @@ -43,13 +45,13 @@ function smarty_modifiercompiler_escape($params, $compiler) case 'html': if ($_double_encode) { return 'htmlspecialchars(' - . $params[0] .', ENT_QUOTES, ' - . var_export($char_set, true) . ', ' - . var_export($double_encode, true) . ')'; + . $params[0] . ', ENT_QUOTES, ' + . var_export($char_set, true) . ', ' + . var_export($double_encode, true) . ')'; } elseif ($double_encode) { return 'htmlspecialchars(' - . $params[0] .', ENT_QUOTES, ' - . var_export($char_set, true) . ')'; + . $params[0] . ', ENT_QUOTES, ' + . var_export($char_set, true) . ')'; } else { // fall back to modifier.escape.php } @@ -59,18 +61,18 @@ function smarty_modifiercompiler_escape($params, $compiler) if ($_double_encode) { // php >=5.2.3 - go native return 'mb_convert_encoding(htmlspecialchars(' - . $params[0] .', ENT_QUOTES, ' - . var_export($char_set, true) . ', ' - . var_export($double_encode, true) - . '), "HTML-ENTITIES", ' - . var_export($char_set, true) . ')'; + . $params[0] . ', ENT_QUOTES, ' + . var_export($char_set, true) . ', ' + . var_export($double_encode, true) + . '), "HTML-ENTITIES", ' + . var_export($char_set, true) . ')'; } elseif ($double_encode) { // php <5.2.3 - only handle double encoding return 'mb_convert_encoding(htmlspecialchars(' - . $params[0] .', ENT_QUOTES, ' - . var_export($char_set, true) - . '), "HTML-ENTITIES", ' - . var_export($char_set, true) . ')'; + . $params[0] . ', ENT_QUOTES, ' + . var_export($char_set, true) + . '), "HTML-ENTITIES", ' + . var_export($char_set, true) . ')'; } else { // fall back to modifier.escape.php } @@ -80,14 +82,14 @@ function smarty_modifiercompiler_escape($params, $compiler) if ($_double_encode) { // php >=5.2.3 - go native return 'htmlentities(' - . $params[0] .', ENT_QUOTES, ' - . var_export($char_set, true) . ', ' - . var_export($double_encode, true) . ')'; + . $params[0] . ', ENT_QUOTES, ' + . var_export($char_set, true) . ', ' + . var_export($double_encode, true) . ')'; } elseif ($double_encode) { // php <5.2.3 - only handle double encoding return 'htmlentities(' - . $params[0] .', ENT_QUOTES, ' - . var_export($char_set, true) . ')'; + . $params[0] . ', ENT_QUOTES, ' + . var_export($char_set, true) . ')'; } else { // fall back to modifier.escape.php } @@ -105,20 +107,20 @@ function smarty_modifiercompiler_escape($params, $compiler) case 'javascript': // escape quotes and backslashes, newlines, etc. return 'strtr(' . $params[0] . ', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", " "<\/" ))'; - } - } catch (SmartyException $e) { + } + catch (SmartyException $e) { // pass through to regular plugin fallback } // could not optimize |escape call, so fallback to regular plugin if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) { - $compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php'; + $compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php'; $compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape'; } else { - $compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php'; + $compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php'; $compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape'; } - return 'smarty_modifier_escape(' . join( ', ', $params ) . ')'; + return 'smarty_modifier_escape(' . join(', ', $params) . ')'; } diff --git a/smarty/libs/plugins/modifiercompiler.from_charset.php b/smarty/libs/plugins/modifiercompiler.from_charset.php index 1dfee367..dab43e9c 100644 --- a/smarty/libs/plugins/modifiercompiler.from_charset.php +++ b/smarty/libs/plugins/modifiercompiler.from_charset.php @@ -2,22 +2,23 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty from_charset modifier plugin - * * Type: modifier
    * Name: from_charset
    * Purpose: convert character encoding from $charset to internal encoding * * @author Rodney Rehm + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_from_charset($params, $compiler) +function smarty_modifiercompiler_from_charset($params) { if (!Smarty::$_MBSTRING) { // FIXME: (rodneyrehm) shouldn't this throw an error? diff --git a/smarty/libs/plugins/modifiercompiler.indent.php b/smarty/libs/plugins/modifiercompiler.indent.php index 85bc6105..e3ca2082 100644 --- a/smarty/libs/plugins/modifiercompiler.indent.php +++ b/smarty/libs/plugins/modifiercompiler.indent.php @@ -1,24 +1,26 @@ * Name: indent
    * Purpose: indent lines of text * - * @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual) * @author Uwe Tews + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_indent($params, $compiler) +function smarty_modifiercompiler_indent($params) { if (!isset($params[1])) { $params[1] = 4; diff --git a/smarty/libs/plugins/modifiercompiler.lower.php b/smarty/libs/plugins/modifiercompiler.lower.php index b1a23186..1d255f37 100644 --- a/smarty/libs/plugins/modifiercompiler.lower.php +++ b/smarty/libs/plugins/modifiercompiler.lower.php @@ -1,28 +1,30 @@ * Name: lower
    * Purpose: convert string to lowercase * - * @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual) * @author Monte Ohrt * @author Uwe Tews + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_lower($params, $compiler) +function smarty_modifiercompiler_lower($params) { if (Smarty::$_MBSTRING) { - return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')' ; + return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; } // no MBString fallback return 'strtolower(' . $params[0] . ')'; diff --git a/smarty/libs/plugins/modifiercompiler.noprint.php b/smarty/libs/plugins/modifiercompiler.noprint.php index 71f6bfae..4906908b 100644 --- a/smarty/libs/plugins/modifiercompiler.noprint.php +++ b/smarty/libs/plugins/modifiercompiler.noprint.php @@ -2,22 +2,20 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty noprint modifier plugin - * * Type: modifier
    * Name: noprint
    * Purpose: return an empty string * * @author Uwe Tews - * @param array $params parameters * @return string with compiled code */ -function smarty_modifiercompiler_noprint($params, $compiler) +function smarty_modifiercompiler_noprint() { return "''"; } diff --git a/smarty/libs/plugins/modifiercompiler.string_format.php b/smarty/libs/plugins/modifiercompiler.string_format.php index defbf6e2..71cdf281 100644 --- a/smarty/libs/plugins/modifiercompiler.string_format.php +++ b/smarty/libs/plugins/modifiercompiler.string_format.php @@ -2,23 +2,24 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty string_format modifier plugin - * * Type: modifier
    * Name: string_format
    * Purpose: format strings via sprintf * - * @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual) * @author Uwe Tews + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_string_format($params, $compiler) +function smarty_modifiercompiler_string_format($params) { return 'sprintf(' . $params[1] . ',' . $params[0] . ')'; } diff --git a/smarty/libs/plugins/modifiercompiler.strip.php b/smarty/libs/plugins/modifiercompiler.strip.php index 6c732e81..fcd6cbae 100644 --- a/smarty/libs/plugins/modifiercompiler.strip.php +++ b/smarty/libs/plugins/modifiercompiler.strip.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty strip modifier plugin - * * Type: modifier
    * Name: strip
    * Purpose: Replace all repeated spaces, newlines, tabs @@ -16,13 +15,15 @@ * Example: {$var|strip} {$var|strip:" "}
    * Date: September 25th, 2002 * - * @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual) * @author Uwe Tews + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_strip($params, $compiler) +function smarty_modifiercompiler_strip($params) { if (!isset($params[1])) { $params[1] = "' '"; diff --git a/smarty/libs/plugins/modifiercompiler.strip_tags.php b/smarty/libs/plugins/modifiercompiler.strip_tags.php index bc5eab26..3e6e1304 100644 --- a/smarty/libs/plugins/modifiercompiler.strip_tags.php +++ b/smarty/libs/plugins/modifiercompiler.strip_tags.php @@ -2,26 +2,27 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty strip_tags modifier plugin - * * Type: modifier
    * Name: strip_tags
    * Purpose: strip html tags from text * - * @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual) * @author Uwe Tews + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_strip_tags($params, $compiler) +function smarty_modifiercompiler_strip_tags($params) { - if (!isset($params[1]) || $params[1] === true || trim($params[1],'"') == 'true') { - return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})"; + if (!isset($params[1]) || $params[1] === true || trim($params[1], '"') == 'true') { + return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})"; } else { return 'strip_tags(' . $params[0] . ')'; } diff --git a/smarty/libs/plugins/modifiercompiler.to_charset.php b/smarty/libs/plugins/modifiercompiler.to_charset.php index af75779a..9122d8bb 100644 --- a/smarty/libs/plugins/modifiercompiler.to_charset.php +++ b/smarty/libs/plugins/modifiercompiler.to_charset.php @@ -2,22 +2,23 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty to_charset modifier plugin - * * Type: modifier
    * Name: to_charset
    * Purpose: convert character encoding from internal encoding to $charset * * @author Rodney Rehm + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_to_charset($params, $compiler) +function smarty_modifiercompiler_to_charset($params) { if (!Smarty::$_MBSTRING) { // FIXME: (rodneyrehm) shouldn't this throw an error? diff --git a/smarty/libs/plugins/modifiercompiler.unescape.php b/smarty/libs/plugins/modifiercompiler.unescape.php index 19474fcb..3b17ea2e 100644 --- a/smarty/libs/plugins/modifiercompiler.unescape.php +++ b/smarty/libs/plugins/modifiercompiler.unescape.php @@ -2,22 +2,23 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty unescape modifier plugin - * * Type: modifier
    * Name: unescape
    * Purpose: unescape html entities * * @author Rodney Rehm + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_unescape($params, $compiler) +function smarty_modifiercompiler_unescape($params) { if (!isset($params[1])) { $params[1] = 'html'; diff --git a/smarty/libs/plugins/modifiercompiler.upper.php b/smarty/libs/plugins/modifiercompiler.upper.php index f10ed187..52ca4e8f 100644 --- a/smarty/libs/plugins/modifiercompiler.upper.php +++ b/smarty/libs/plugins/modifiercompiler.upper.php @@ -2,26 +2,27 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty upper modifier plugin - * * Type: modifier
    * Name: lower
    * Purpose: convert string to uppercase * - * @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual) + * @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual) * @author Uwe Tews + * * @param array $params parameters + * * @return string with compiled code */ -function smarty_modifiercompiler_upper($params, $compiler) +function smarty_modifiercompiler_upper($params) { if (Smarty::$_MBSTRING) { - return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')' ; + return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; } // no MBString fallback return 'strtoupper(' . $params[0] . ')'; diff --git a/smarty/libs/plugins/modifiercompiler.wordwrap.php b/smarty/libs/plugins/modifiercompiler.wordwrap.php index 39312b41..2ad928ea 100644 --- a/smarty/libs/plugins/modifiercompiler.wordwrap.php +++ b/smarty/libs/plugins/modifiercompiler.wordwrap.php @@ -2,20 +2,22 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsModifierCompiler */ /** * Smarty wordwrap modifier plugin - * * Type: modifier
    * Name: wordwrap
    * Purpose: wrap a string of text at a given length * - * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual) + * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual) * @author Uwe Tews + * * @param array $params parameters + * @param $compiler + * * @return string with compiled code */ function smarty_modifiercompiler_wordwrap($params, $compiler) @@ -31,11 +33,11 @@ function smarty_modifiercompiler_wordwrap($params, $compiler) } $function = 'wordwrap'; if (Smarty::$_MBSTRING) { - if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) { - $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR .'shared.mb_wordwrap.php'; + if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) { + $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap'; } else { - $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR .'shared.mb_wordwrap.php'; + $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap'; } $function = 'smarty_mb_wordwrap'; diff --git a/smarty/libs/plugins/outputfilter.trimwhitespace.php b/smarty/libs/plugins/outputfilter.trimwhitespace.php index 9da7f3db..62ab4e77 100644 --- a/smarty/libs/plugins/outputfilter.trimwhitespace.php +++ b/smarty/libs/plugins/outputfilter.trimwhitespace.php @@ -2,22 +2,22 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFilter */ /** * Smarty trimwhitespace outputfilter plugin - * * Trim unnecessary whitespace from HTML markup. * * @author Rodney Rehm - * @param string $source input string - * @param Smarty_Internal_Template $smarty Smarty object + * + * @param string $source input string + * * @return string filtered output - * @todo substr_replace() is not overloaded by mbstring.func_overload - so this function might fail! + * @todo substr_replace() is not overloaded by mbstring.func_overload - so this function might fail! */ -function smarty_outputfilter_trimwhitespace($source, Smarty_Internal_Template $smarty) +function smarty_outputfilter_trimwhitespace($source) { $store = array(); $_store = 0; @@ -35,13 +35,13 @@ function smarty_outputfilter_trimwhitespace($source, Smarty_Internal_Template $s $source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length); $_offset += $_length - strlen($replace); - $_store++; + $_store ++; } } // Strip all HTML-Comments // yes, even the ones in