Browse files

updating smarty to version 3.0.8

  • Loading branch information...
1 parent 6c63b21 commit 9cae7f880ce29aa0eab751221be571380f8e398b @akuzemchak committed Jun 24, 2011
View
368 vendor/Smarty.class.php
@@ -3,81 +3,81 @@
/**
* Project: Smarty: the PHP compiling template engine
* File: Smarty.class.php
- * SVN: $Id: Smarty.class.php 3895 2010-12-31 13:47:12Z uwe.tews@googlemail.com $
- *
+ * SVN: $Id: Smarty.class.php 4074 2011-04-22 02:19:14Z uwe.tews@googlemail.com $
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ *
* For questions, help, comments, discussion, etc., please join the
* Smarty mailing list. Send a blank e-mail to
* smarty-discussion-subscribe@googlegroups.com
- *
+ *
* @link http://www.smarty.net/
* @copyright 2008 New Digital Group, Inc.
- * @author Monte Ohrt <monte at ohrt dot com>
- * @author Uwe Tews
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author Uwe Tews
* @package Smarty
- * @version 3.0.7
+ * @version 3.0.8
*/
/**
* define shorthand directory separator constant
*/
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
-}
+}
/**
* set SMARTY_DIR to absolute path to Smarty library files.
* Sets SMARTY_DIR only if user application has not already defined it.
*/
if (!defined('SMARTY_DIR')) {
define('SMARTY_DIR', dirname(__FILE__) . DS);
-}
+}
/**
* set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins.
* Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it.
*/
if (!defined('SMARTY_SYSPLUGINS_DIR')) {
define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS);
-}
+}
if (!defined('SMARTY_PLUGINS_DIR')) {
define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS);
-}
+}
if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
define('SMARTY_RESOURCE_CHAR_SET', 'UTF-8');
-}
+}
if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y');
-}
+}
/**
* register the class autoloader
*/
if (!defined('SMARTY_SPL_AUTOLOAD')) {
define('SMARTY_SPL_AUTOLOAD', 0);
-}
+}
if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) {
$registeredAutoLoadFunctions = spl_autoload_functions();
if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
spl_autoload_register();
- }
+ }
} else {
spl_autoload_register('smartyAutoload');
-}
+}
/**
* This is the main Smarty class
@@ -87,7 +87,7 @@ class Smarty extends Smarty_Internal_Data {
* constant definitions
*/
// smarty version
- const SMARTY_VERSION = 'Smarty-3.0.7';
+ const SMARTY_VERSION = 'Smarty-3.0.8';
//define variable scopes
const SCOPE_LOCAL = 0;
const SCOPE_PARENT = 1;
@@ -117,121 +117,121 @@ class Smarty extends Smarty_Internal_Data {
* static variables
*/
// assigned global tpl vars
- static $global_tpl_vars = array();
+ static $global_tpl_vars = array();
/**
* variables
*/
// auto literal on delimiters with whitspace
- public $auto_literal = true;
+ public $auto_literal = true;
// display error on not assigned variables
- public $error_unassigned = false;
+ public $error_unassigned = false;
// template directory
- public $template_dir = null;
+ public $template_dir = null;
// default template handler
- public $default_template_handler_func = null;
+ public $default_template_handler_func = null;
// compile directory
- public $compile_dir = null;
+ public $compile_dir = null;
// plugins directory
- public $plugins_dir = null;
+ public $plugins_dir = null;
// cache directory
- public $cache_dir = null;
+ public $cache_dir = null;
// config directory
- public $config_dir = null;
+ public $config_dir = null;
// force template compiling?
- public $force_compile = false;
+ public $force_compile = false;
// check template for modifications?
- public $compile_check = true;
+ public $compile_check = true;
// locking concurrent compiles
- public $compile_locking = true;
+ public $compile_locking = true;
// use sub dirs for compiled/cached files?
- public $use_sub_dirs = false;
+ public $use_sub_dirs = false;
// compile_error?
- public $compile_error = false;
+ public $compile_error = false;
// caching enabled
- public $caching = false;
+ public $caching = false;
// merge compiled includes
- public $merge_compiled_includes = false;
+ public $merge_compiled_includes = false;
// cache lifetime
- public $cache_lifetime = 3600;
+ public $cache_lifetime = 3600;
// force cache file creation
- public $force_cache = false;
+ public $force_cache = false;
// cache_id
- public $cache_id = null;
+ public $cache_id = null;
// compile_id
- public $compile_id = null;
+ public $compile_id = null;
// template delimiters
public $left_delimiter = "{";
- public $right_delimiter = "}";
+ public $right_delimiter = "}";
// security
public $security_class = 'Smarty_Security';
public $security_policy = null;
public $php_handling = self::PHP_PASSTHRU;
public $allow_php_tag = false;
public $allow_php_templates = false;
- public $direct_access_security = true;
+ public $direct_access_security = true;
public $trusted_dir = array();
// debug mode
public $debugging = false;
public $debugging_ctrl = 'NONE';
public $smarty_debug_id = 'SMARTY_DEBUG';
- public $debug_tpl = null;
+ public $debug_tpl = null;
// When set, smarty does uses this value as error_reporting-level.
- public $error_reporting = null;
+ public $error_reporting = null;
// config var settings
public $config_overwrite = true; //Controls whether variables with the same name overwrite each other.
public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean
- public $config_read_hidden = false; //Controls whether hidden config sections/vars are read from the file.
+ public $config_read_hidden = false; //Controls whether hidden config sections/vars are read from the file.
// config vars
- public $config_vars = array();
+ public $config_vars = array();
// assigned tpl vars
- public $tpl_vars = array();
+ public $tpl_vars = array();
// dummy parent object
- public $parent = null;
+ public $parent = null;
// global template functions
- public $template_functions = array();
+ public $template_functions = array();
// resource type used if none given
- public $default_resource_type = 'file';
+ public $default_resource_type = 'file';
// caching type
- public $caching_type = 'file';
+ public $caching_type = 'file';
// internal cache resource types
- public $cache_resource_types = array('file');
+ public $cache_resource_types = array('file');
// internal config properties
- public $properties = array();
+ public $properties = array();
// config type
- public $default_config_type = 'file';
+ public $default_config_type = 'file';
// cached template objects
- public $template_objects = null;
+ public $template_objects = null;
// check If-Modified-Since headers
- public $cache_modified_check = false;
+ public $cache_modified_check = false;
// registered plugins
- public $registered_plugins = array();
+ public $registered_plugins = array();
// plugin search order
- public $plugin_search_order = array('function', 'block', 'compiler', 'class');
+ public $plugin_search_order = array('function', 'block', 'compiler', 'class');
// registered objects
- public $registered_objects = array();
+ public $registered_objects = array();
// registered classes
- public $registered_classes = array();
+ public $registered_classes = array();
// registered filters
- public $registered_filters = array();
+ public $registered_filters = array();
// registered resources
- public $registered_resources = array();
+ public $registered_resources = array();
// autoload filter
- public $autoload_filters = array();
+ public $autoload_filters = array();
// status of filter on variable output
- public $variable_filter = true;
+ public $variable_filter = true;
// default modifier
- public $default_modifiers = array();
+ public $default_modifiers = array();
// global internal smarty vars
- static $_smarty_vars = array();
+ static $_smarty_vars = array();
// start time for execution time calculation
- public $start_time = 0;
+ public $start_time = 0;
// default file permissions
- public $_file_perms = 0644;
+ public $_file_perms = 0644;
// default dir permissions
- public $_dir_perms = 0771;
+ public $_dir_perms = 0771;
// block tag hierarchy
- public $_tag_stack = array();
+ public $_tag_stack = array();
// flag if {block} tag is compiled for template inheritance
public $inheritance = false;
// generate deprecated function call notices?
@@ -245,35 +245,35 @@ class Smarty extends Smarty_Internal_Data {
* Class constructor, initializes basic smarty properties
*/
public function __construct()
- {
+ {
// selfpointer need by some other class methods
$this->smarty = $this;
if (is_callable('mb_internal_encoding')) {
mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET);
- }
- $this->start_time = microtime(true);
+ }
+ $this->start_time = microtime(true);
// set default dirs
$this->template_dir = array('.' . DS . 'templates' . DS);
$this->compile_dir = '.' . DS . 'templates_c' . DS;
$this->plugins_dir = array(SMARTY_PLUGINS_DIR);
$this->cache_dir = '.' . DS . 'cache' . DS;
$this->config_dir = '.' . DS . 'configs' . DS;
- $this->debug_tpl = SMARTY_DIR . 'debug.tpl';
+ $this->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl';
if (isset($_SERVER['SCRIPT_NAME'])) {
$this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
- }
- }
+ }
+ }
/**
* Class destructor
*/
public function __destruct()
- {
- }
+ {
+ }
/**
* fetches a rendered Smarty template
- *
+ *
* @param string $template the resource handle of the template file or template object
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
@@ -285,11 +285,11 @@ public function fetch($template, $cache_id = null, $compile_id = null, $parent =
if (!empty($cache_id) && is_object($cache_id)) {
$parent = $cache_id;
$cache_id = null;
- }
+ }
if ($parent === null) {
// get default Smarty data object
$parent = $this;
- }
+ }
// create template object if necessary
($template instanceof $this->template_class)? $_template = $template :
$_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent, false);
@@ -302,7 +302,7 @@ public function fetch($template, $cache_id = null, $compile_id = null, $parent =
$_query_string = $_SERVER['QUERY_STRING'];
} else {
$_query_string = '';
- }
+ }
if (false !== strpos($_query_string, $this->smarty_debug_id)) {
if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) {
// enable debugging for this browser session
@@ -315,32 +315,32 @@ public function fetch($template, $cache_id = null, $compile_id = null, $parent =
} else {
// enable debugging for this page
$this->debugging = true;
- }
+ }
} else {
if (isset($_COOKIE['SMARTY_DEBUG'])) {
$this->debugging = true;
- }
- }
- }
+ }
+ }
+ }
// obtain data for cache modified check
if ($this->cache_modified_check && $this->caching && $display) {
$_isCached = $_template->isCached() && !$_template->has_nocache_code;
if ($_isCached) {
$_gmt_mtime = gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT';
} else {
$_gmt_mtime = '';
- }
- }
+ }
+ }
// return rendered template
if ((!$this->caching || $_template->resource_object->isEvaluated) && (isset($this->autoload_filters['output']) || isset($this->registered_filters['output']))) {
$_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $_template);
} else {
$_output = $_template->getRenderedTemplate();
- }
+ }
$_template->rendered_content = null;
if (isset($this->error_reporting)) {
error_reporting($_smarty_old_error_level);
- }
+ }
// display or fetch
if ($display) {
if ($this->caching && $this->cache_modified_check) {
@@ -353,38 +353,38 @@ public function fetch($template, $cache_id = null, $compile_id = null, $parent =
} else {
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT');
echo $_output;
- }
+ }
} else {
echo $_output;
- }
+ }
// debug output
if ($this->debugging) {
Smarty_Internal_Debug::display_debug($this);
- }
+ }
return;
} else {
// return fetched content
return $_output;
- }
- }
+ }
+ }
/**
* displays a Smarty template
- *
+ *
* @param string $ |object $template the resource handle of the template file or template object
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
*/
public function display($template, $cache_id = null, $compile_id = null, $parent = null)
- {
+ {
// display template
$this->fetch ($template, $cache_id, $compile_id, $parent, true);
- }
+ }
/**
* test if cache i valid
- *
+ *
* @param string $ |object $template the resource handle of the template file or template object
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
@@ -398,25 +398,25 @@ public function isCached($template, $cache_id = null, $compile_id = null, $paren
}
if (!($template instanceof $this->template_class)) {
$template = $this->createTemplate ($template, $cache_id, $compile_id, $parent, false);
- }
+ }
// return cache status of template
return $template->isCached();
- }
+ }
/**
* creates a data object
- *
+ *
* @param object $parent next higher level of Smarty variables
* @returns object data object
*/
public function createData($parent = null)
{
return new Smarty_Data($parent, $this);
- }
+ }
/**
* creates a template object
- *
+ *
* @param string $template the resource handle of the template file
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
@@ -429,13 +429,13 @@ public function createTemplate($template, $cache_id = null, $compile_id = null,
if (!empty($cache_id) && (is_object($cache_id) || is_array($cache_id))) {
$parent = $cache_id;
$cache_id = null;
- }
+ }
if (!empty($parent) && is_array($parent)) {
$data = $parent;
$parent = null;
} else {
$data = null;
- }
+ }
if (!is_object($template)) {
// we got a template resource
// already in template cache?
@@ -450,44 +450,44 @@ public function createTemplate($template, $cache_id = null, $compile_id = null,
} else {
$tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id);
}
- }
+ }
} else {
// just return a copy of template class
$tpl = $template;
- }
+ }
// fill data if present
if (!empty($data) && is_array($data)) {
// set up variable values
foreach ($data as $_key => $_val) {
$tpl->tpl_vars[$_key] = new Smarty_variable($_val);
- }
- }
+ }
+ }
return $tpl;
- }
-
-
+ }
+
+
/**
* Check if a template resource exists
- *
+ *
* @param string $resource_name template name
* @return boolean status
*/
function templateExists($resource_name)
- {
+ {
// create template object
$save = $this->template_objects;
- $tpl = new $this->template_class($resource_name, $this);
+ $tpl = new $this->template_class($resource_name, $this);
// check if it does exists
$result = $tpl->isExisting();
$this->template_objects = $save;
return $result;
- }
+ }
/**
* Returns a single or all global variables
- *
- * @param object $smarty
+ *
+ * @param object $smarty
* @param string $varname variable name or null
* @return string variable value or or array of variables
*/
@@ -498,32 +498,32 @@ function getGlobal($varname = null)
return self::$global_tpl_vars[$varname]->value;
} else {
return '';
- }
+ }
} else {
$_result = array();
foreach (self::$global_tpl_vars AS $key => $var) {
$_result[$key] = $var->value;
- }
+ }
return $_result;
- }
- }
+ }
+ }
/**
* Empty cache folder
- *
+ *
* @param integer $exp_time expiration time
* @param string $type resource type
* @return integer number of cache files deleted
*/
function clearAllCache($exp_time = null, $type = null)
- {
+ {
// load cache resource and call clearAll
return $this->loadCacheResource($type)->clearAll($exp_time);
- }
+ }
/**
* Empty cache for a specific template
- *
+ *
* @param string $template_name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
@@ -532,7 +532,7 @@ function clearAllCache($exp_time = null, $type = null)
* @return integer number of cache files deleted
*/
function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
- {
+ {
// load cache resource and call clear
return $this->loadCacheResource($type)->clear($template_name, $cache_id, $compile_id, $exp_time);
}
@@ -553,85 +553,85 @@ public function enableSecurity($security_class = null)
$this->security_policy = new $security_class($this);
} else {
throw new SmartyException("Security class '$security_class' is not defined");
- }
- }
+ }
+ }
/**
* Disable security
*/
public function disableSecurity()
{
$this->security_policy = null;
- }
+ }
/**
* Loads cache resource.
- *
+ *
* @param string $type cache resource type
* @return object of cache resource
*/
public function loadCacheResource($type = null) {
if (!isset($type)) {
$type = $this->caching_type;
- }
+ }
if (in_array($type, $this->cache_resource_types)) {
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
return new $cache_resource_class($this);
- }
+ }
else {
// try plugins dir
$cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
if ($this->loadPlugin($cache_resource_class)) {
return new $cache_resource_class($this);
- }
+ }
else {
throw new SmartyException("Unable to load cache resource '{$type}'");
- }
- }
- }
+ }
+ }
+ }
/**
* Set template directory
- *
+ *
* @param string $ |array $template_dir folder(s) of template sorces
*/
public function setTemplateDir($template_dir)
{
$this->template_dir = (array)$template_dir;
return;
- }
+ }
/**
* Adds template directory(s) to existing ones
- *
+ *
* @param string $ |array $template_dir folder(s) of template sources
*/
public function addTemplateDir($template_dir)
{
$this->template_dir = array_unique(array_merge((array)$this->template_dir, (array)$template_dir));
return;
- }
-
+ }
+
/**
* Adds directory of plugin files
- *
- * @param object $smarty
+ *
+ * @param object $smarty
* @param string $ |array $ plugins folder
- * @return
+ * @return
*/
function addPluginsDir($plugins_dir)
{
$this->plugins_dir = array_unique(array_merge((array)$this->plugins_dir, (array)$plugins_dir));
return;
- }
+ }
/**
* return a reference to a registered object
- *
+ *
* @param string $name object name
- * @return object
+ * @return object
*/
function getRegisteredObject($name)
{
@@ -642,51 +642,51 @@ function getRegisteredObject($name)
throw new SmartyException("registered '$name' is not an object");
return $this->registered_objects[$name][0];
- }
+ }
/**
* return name of debugging template
- *
- * @return string
+ *
+ * @return string
*/
function getDebugTemplate()
{
return $this->debug_tpl;
- }
+ }
/**
* set the debug template
- *
- * @param string $tpl_name
- * @return bool
+ *
+ * @param string $tpl_name
+ * @return bool
*/
function setDebugTemplate($tpl_name)
{
return $this->debug_tpl = $tpl_name;
- }
+ }
/**
* Takes unknown classes and loads plugin files for them
* class name format: Smarty_PluginType_PluginName
* plugin filename format: plugintype.pluginname.php
- *
+ *
* @param string $plugin_name class plugin name to load
* @return string |boolean filepath of loaded file or false
*/
public function loadPlugin($plugin_name, $check = true)
- {
+ {
// if function or class exists, exit silently (already loaded)
if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false)))
- return true;
+ return true;
// Plugin name is expected to be: Smarty_[Type]_[Name]
$_plugin_name = strtolower($plugin_name);
- $_name_parts = explode('_', $_plugin_name, 3);
+ $_name_parts = explode('_', $_plugin_name, 3);
// class name must have three parts to be valid plugin
if (count($_name_parts) < 3 || $_name_parts[0] !== 'smarty') {
throw new SmartyException("plugin {$plugin_name} is not a valid name format");
return false;
- }
+ }
// if type is "internal", get plugin from sysplugins
if ($_name_parts[1] == 'internal') {
$file = SMARTY_SYSPLUGINS_DIR . $_plugin_name . '.php';
@@ -695,37 +695,37 @@ public function loadPlugin($plugin_name, $check = true)
return $file;
} else {
return false;
- }
- }
+ }
+ }
// plugin filename is expected to be: [type].[name].php
- $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
+ $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
// loop through plugin dirs and find the plugin
foreach((array)$this->plugins_dir as $_plugin_dir) {
if (strpos('/\\', substr($_plugin_dir, -1)) === false) {
$_plugin_dir .= DS;
- }
+ }
$file = $_plugin_dir . $_plugin_filename;
if (file_exists($file)) {
require_once($file);
return $file;
- }
- }
+ }
+ }
// no plugin loaded
return false;
- }
+ }
/**
* clean up properties on cloned object
*/
public function __clone()
{
// clear config vars
- $this->config_vars = array();
+ $this->config_vars = array();
// clear assigned tpl vars
$this->tpl_vars = array();
// clear objects for external methods
- unset($this->register);
- unset($this->filter);
+ unset($this->register);
+ unset($this->filter);
}
@@ -739,19 +739,19 @@ public function __call($name, $args)
{
static $camel_func;
if (!isset($camel_func))
- $camel_func = create_function('$c', 'return "_" . strtolower($c[1]);');
+ $camel_func = create_function('$c', 'return "_" . strtolower($c[1]);');
// see if this is a set/get for a property
$first3 = strtolower(substr($name, 0, 3));
if (in_array($first3, array('set', 'get')) && substr($name, 3, 1) !== '_') {
// try to keep case correct for future PHP 6.0 case-sensitive class methods
// lcfirst() not available < PHP 5.3.0, so improvise
- $property_name = strtolower(substr($name, 3, 1)) . substr($name, 4);
+ $property_name = strtolower(substr($name, 3, 1)) . substr($name, 4);
// convert camel case to underscored name
$property_name = preg_replace_callback('/([A-Z])/', $camel_func, $property_name);
if (!property_exists($this, $property_name)) {
throw new SmartyException("property '$property_name' does not exist.");
return false;
- }
+ }
if ($first3 == 'get')
return $this->$property_name;
else
@@ -761,33 +761,33 @@ public function __call($name, $args)
if (strpos($name,'_') !== false) {
if (!isset($this->wrapper)) {
$this->wrapper = new Smarty_Internal_Wrapper($this);
- }
+ }
return $this->wrapper->convert($name, $args);
}
// external Smarty methods ?
- foreach(array('filter','register') as $external) {
- if (method_exists("Smarty_Internal_{$external}",$name)) {
+ foreach(array('Filter','Register') as $external) {
+ if (class_exists("Smarty_Internal_{$external}") && method_exists("Smarty_Internal_{$external}",$name)) {
if (!isset($this->$external)) {
$class = "Smarty_Internal_{$external}";
$this->$external = new $class($this);
- }
+ }
return call_user_func_array(array($this->$external,$name), $args);
}
}
if (in_array($name,array('clearCompiledTemplate','compileAllTemplates','compileAllConfig','testInstall','getTags'))) {
if (!isset($this->utility)) {
$this->utility = new Smarty_Internal_Utility($this);
- }
+ }
return call_user_func_array(array($this->utility,$name), $args);
}
// PHP4 call to constructor?
if (strtolower($name) == 'smarty') {
throw new SmartyException('Please use parent::__construct() to call parent constuctor');
return false;
- }
+ }
throw new SmartyException("Call of unknown function '$name'.");
- }
-}
+ }
+}
/**
* Autoloader
@@ -797,8 +797,8 @@ function smartyAutoload($class)
$_class = strtolower($class);
if (substr($_class, 0, 16) === 'smarty_internal_' || $_class == 'smarty_security') {
include SMARTY_SYSPLUGINS_DIR . $_class . '.php';
- }
-}
+ }
+}
/**
* Smarty exception class
View
8 vendor/plugins/modifier.replace.php
@@ -22,8 +22,10 @@
*/
function smarty_modifier_replace($string, $search, $replace)
{
- require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
- return smarty_mb_str_replace($search, $replace, $string);
+ if (function_exists('mb_split')) {
+ require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
+ return smarty_mb_str_replace($search, $replace, $string);
+ }
+ return str_replace($search, $replace, $string);
}
-
?>
View
4 vendor/plugins/modifiercompiler.strip.php
@@ -26,8 +26,8 @@ function smarty_modifiercompiler_strip($params, $compiler)
{
if (!isset($params[1])) {
$params[1] = "' '";
- }
- return "preg_replace('!\s+!', {$params[1]},{$params[0]})";
+ }
+ return "preg_replace('!\s+!u', {$params[1]},{$params[0]})";
}
?>
View
8 vendor/sysplugins/smarty_internal_cacheresource_file.php
@@ -145,12 +145,14 @@ public function clear($resource_name, $cache_id, $compile_id, $exp_time)
$_save_stat = $this->smarty->caching;
$this->smarty->caching = true;
$tpl = new $this->smarty->template_class($resource_name, $this->smarty);
- // remove from template cache
- unset($this->smarty->template_objects[crc32($tpl->template_resource . $tpl->cache_id . $tpl->compile_id)]);
$this->smarty->caching = $_save_stat;
if ($tpl->isExisting()) {
$_resourcename_parts = basename(str_replace('^', '/', $tpl->getCachedFilepath()));
+ // remove from template cache
+ unset($this->smarty->template_objects[sha1($tpl->template_resource . $tpl->cache_id . $tpl->compile_id)]);
} else {
+ // remove from template cache
+ unset($this->smarty->template_objects[sha1($tpl->template_resource . $tpl->cache_id . $tpl->compile_id)]);
return 0;
}
}
@@ -159,7 +161,7 @@ public function clear($resource_name, $cache_id, $compile_id, $exp_time)
$_cacheDirs = new RecursiveDirectoryIterator($_dir);
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($_cache as $_file) {
- if (strpos($_file, '.svn') !== false) continue;
+ if (substr($_file->getBasename(),0,1) == '.') continue;
// directory ?
if ($_file->isDir()) {
if (!$_cache->isDot()) {
View
36 vendor/sysplugins/smarty_internal_compile_block.php
@@ -1,12 +1,12 @@
<?php
/**
* Smarty Internal Plugin Compile Block
- *
+ *
* Compiles the {block}{/block} tags
- *
+ *
* @package Smarty
* @subpackage Compiler
- * @author Uwe Tews
+ * @author Uwe Tews
*/
/**
@@ -18,7 +18,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
public $shorttag_order = array('name');
/**
* Compiles code for the {block} tag
- *
+ *
* @param array $args array with attributes from parser
* @param object $compiler compiler object
* @return boolean true
@@ -36,12 +36,12 @@ public function compile($args, $compiler)
// set flag for {block} tag
$compiler->smarty->inheritance = true;
// must merge includes
- $this->compiler->smarty->merge_compiled_includes = true;
+ $this->compiler->smarty->merge_compiled_includes = true;
$compiler->parser->current_buffer = new _smarty_template_buffer($compiler->parser);
$compiler->has_code = false;
return true;
- }
+ }
static function saveBlockData($block_content, $block_tag, $template, $filepath)
@@ -53,7 +53,7 @@ static function saveBlockData($block_content, $block_tag, $template, $filepath)
$error_text = 'Syntax Error in template "' . $template->getTemplateFilepath() . '" "' . htmlspecialchars($block_tag) . '" illegal options';
throw new SmartyCompilerException($error_text);
} else {
- $_name = trim($_match[3], '\'"');
+ $_name = trim($_match[3], '\'"');
// replace {$smarty.block.child}
if (strpos($block_content, $template->smarty->left_delimiter . '$smarty.block.child' . $template->smarty->right_delimiter) !== false) {
if (isset($template->block_data[$_name])) {
@@ -63,8 +63,8 @@ static function saveBlockData($block_content, $block_tag, $template, $filepath)
} else {
$block_content = str_replace($template->smarty->left_delimiter . '$smarty.block.child' . $template->smarty->right_delimiter,
'', $block_content);
- }
- }
+ }
+ }
if (isset($template->block_data[$_name])) {
if (strpos($template->block_data[$_name]['source'], '%%%%SMARTY_PARENT%%%%') !== false) {
$template->block_data[$_name]['source'] =
@@ -73,17 +73,17 @@ static function saveBlockData($block_content, $block_tag, $template, $filepath)
$template->block_data[$_name]['source'] .= $block_content;
} elseif ($template->block_data[$_name]['mode'] == 'append') {
$template->block_data[$_name]['source'] = $block_content . $template->block_data[$_name]['source'];
- }
+ }
} else {
$template->block_data[$_name]['source'] = $block_content;
- }
+ }
if ($_match[6] == 'append') {
$template->block_data[$_name]['mode'] = 'append';
} elseif ($_match[6] == 'prepend') {
$template->block_data[$_name]['mode'] = 'prepend';
} else {
$template->block_data[$_name]['mode'] = 'replace';
- }
+ }
$template->block_data[$_name]['file'] = $filepath;
}
}
@@ -104,13 +104,13 @@ static function compileChildBlock ($compiler, $_name = null)
$compiler->template->block_data[$_name]['compiled'] = true;
}
if ($_name == null) {
- $compiler->trigger_template_error('{$smarty.block.child} used out of context', $this->compiler->lex->taglineno);
+ $compiler->trigger_template_error('{$smarty.block.child} used out of context', $compiler->lex->taglineno);
}
// undefined child?
if (!isset($compiler->template->block_data[$_name])) {
return '';
}
- $_tpl = new Smarty_Internal_template ('eval:' . $compiler->template->block_data[$_name]['source'], $compiler->smarty, $compiler->template, $compiler->template->cache_id,
+ $_tpl = new Smarty_Internal_template ('eval:' . $compiler->template->block_data[$_name]['source'], $compiler->smarty, $compiler->template, $compiler->template->cache_id,
$compiler->template->compile_id = null, $compiler->template->caching, $compiler->template->cache_lifetime);
$_tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash'];
$_tpl->template_filepath = $compiler->template->block_data[$_name]['file'];
@@ -154,7 +154,7 @@ static function compileChildBlock ($compiler, $_name = null)
class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase {
/**
* Compiles code for the {/block} tag
- *
+ *
* @param array $args array with attributes from parser
* @param object $compiler compiler object
* @return string compiled code
@@ -163,7 +163,7 @@ public function compile($args, $compiler)
{
$this->compiler = $compiler;
$this->smarty = $compiler->smarty;
- $this->compiler->has_code = true;
+ $this->compiler->has_code = true;
// check and get attributes
$_attr = $this->_get_attributes($args);
$saved_data = $this->_close_tag(array('block'));
@@ -182,6 +182,6 @@ public function compile($args, $compiler)
// $_output content has already nocache code processed
$compiler->suppressNocacheProcessing = true;
return $_output;
- }
-}
+ }
+}
?>
View
32 vendor/sysplugins/smarty_internal_compile_extends.php
@@ -2,12 +2,12 @@
/**
* Smarty Internal Plugin Compile extend
- *
+ *
* Compiles the {extends} tag
- *
+ *
* @package Smarty
* @subpackage Compiler
- * @author Uwe Tews
+ * @author Uwe Tews
*/
/**
@@ -20,7 +20,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
/**
* Compiles code for the {extends} tag
- *
+ *
* @param array $args array with attributes from parser
* @param object $compiler compiler object
* @return string compiled code
@@ -38,14 +38,14 @@ public function compile($args, $compiler)
$this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno);
}
- $_smarty_tpl = $compiler->template;
+ $_smarty_tpl = $compiler->template;
$include_file = null;
- if (strpos($_attr['file'],'$_tmp') !== false) {
- $this->compiler->trigger_template_error('illegal value for file attribute', $this->compiler->lex->taglineno);
+ if (strpos($_attr['file'],'$_tmp') !== false || strpos($_attr['file'],'$_smarty_tpl') !== false || strpos($_attr['file'],'::') !== false) {
+ $this->compiler->trigger_template_error('a variable file attribute is illegal', $this->compiler->lex->taglineno);
}
- eval('$include_file = ' . $_attr['file'] . ';');
+ eval('$include_file = ' . $_attr['file'] . ';');
// create template object
- $_template = new $compiler->smarty->template_class($include_file, $this->smarty, $compiler->template);
+ $_template = new $compiler->smarty->template_class($include_file, $this->smarty, $compiler->template);
// save file dependency
if (in_array($_template->resource_type,array('eval','string'))) {
$template_sha1 = sha1($include_file);
@@ -54,13 +54,13 @@ public function compile($args, $compiler)
}
if (isset($compiler->template->properties['file_dependency'][$template_sha1])) {
$this->compiler->trigger_template_error("illegal recursive call of \"{$include_file}\"",$compiler->lex->line-1);
- }
+ }
$compiler->template->properties['file_dependency'][$template_sha1] = array($_template->getTemplateFilepath(), $_template->getTemplateTimestamp(),$_template->resource_type);
$_content = substr($compiler->template->template_source,$compiler->lex->counter-1);
if (preg_match_all("!({$this->_ldl}block\s(.+?){$this->_rdl})!", $_content, $s) !=
preg_match_all("!({$this->_ldl}/block{$this->_rdl})!", $_content, $c)) {
$this->compiler->trigger_template_error('unmatched {block} {/block} pairs');
- }
+ }
preg_match_all("!{$this->_ldl}block\s(.+?){$this->_rdl}|{$this->_ldl}/block{$this->_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
$_result_count = count($_result[0]);
$_start = 0;
@@ -73,18 +73,18 @@ public function compile($args, $compiler)
$_level++;
} else {
$_level--;
- }
- }
+ }
+ }
$_block_content = str_replace($this->smarty->left_delimiter . '$smarty.block.parent' . $this->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%',
substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + strlen($_result[0][$_start][0])));
Smarty_Internal_Compile_Block::saveBlockData($_block_content, $_result[0][$_start][0], $compiler->template, $filepath);
$_start = $_start + $_end + 1;
- }
+ }
$compiler->template->template_source = $_template->getTemplateSource();
$compiler->template->template_filepath = $_template->getTemplateFilepath();
$compiler->abort_and_recompile = true;
return '';
- }
+ }
-}
+}
?>
View
16 vendor/sysplugins/smarty_internal_compile_include.php
@@ -101,7 +101,7 @@ public function compile($args, $compiler)
$_caching = Smarty::CACHING_OFF;
}
// default for included templates
- if ($this->compiler->template->caching && !$this->compiler->nocache && !$this->compiler->tag_nocache) {
+ if ($compiler->template->caching && !$this->compiler->nocache && !$this->compiler->tag_nocache) {
$_caching = self::CACHING_NOCACHE_CODE;
}
/*
@@ -136,7 +136,17 @@ public function compile($args, $compiler)
$_caching = Smarty::CACHING_OFF;
}
// create template object
- $_output = "<?php \$_template = new {$compiler->smarty->template_class}($include_file, \$_smarty_tpl->smarty, \$_smarty_tpl, $_cache_id, $_compile_id, $_caching, $_cache_lifetime);\n";
+ $_output = "<?php ";
+ if ($_caching != 'null' && $_caching != Smarty::CACHING_OFF) {
+ $_output .= "\$sha = sha1($include_file . $_cache_id . $_compile_id);\n";
+ $_output .= "if (isset(\$_smarty_tpl->smarty->template_objects[\$sha])) {\n";
+ $_output .= "\$_template = \$_smarty_tpl->smarty->template_objects[\$sha]; \$_template->caching = $_caching; \$_template->cache_lifetime = $_cache_lifetime;\n";
+ $_output .= "} else {\n";
+ }
+ $_output .= "\$_template = new {$compiler->smarty->template_class}($include_file, \$_smarty_tpl->smarty, \$_smarty_tpl, $_cache_id, $_compile_id, $_caching, $_cache_lifetime);\n";
+ if ($_caching != 'null' && $_caching != Smarty::CACHING_OFF) {
+ $_output .= "}\n";
+ }
// delete {include} standard attributes
unset($_attr['file'], $_attr['assign'], $_attr['cache_id'], $_attr['compile_id'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope'], $_attr['inline']);
// remaining attributes must be assigned as smarty variable
@@ -162,7 +172,7 @@ public function compile($args, $compiler)
$_output .= "<?php /* End of included template \"" . $tpl->getTemplateFilepath() . "\" */ ?>\n";
$_output .= "<?php \$_smarty_tpl = array_pop(\$_tpl_stack);?>";
} else {
- $_output .= " echo \$_template->getRenderedTemplate();?>";
+ $_output .= " echo \$_template->getRenderedTemplate(); \$_template->rendered_content = null;?>";
if ($_parent_scope != Smarty::SCOPE_LOCAL) {
$_output .= "<?php \$_template->updateParentVariables($_parent_scope);?>";
}
View
22 vendor/sysplugins/smarty_internal_config.php
@@ -272,16 +272,18 @@ public function loadConfigVars ($sections = null, $scope = 'local')
}
}
// scan sections
- foreach ($_config_vars['sections'] as $this_section => $dummy) {
- if ($sections == null || in_array($this_section, (array)$sections)) {
- foreach ($_config_vars['sections'][$this_section]['vars'] as $variable => $value) {
- if ($this->smarty->config_overwrite || !isset($scope_ptr->config_vars[$variable])) {
- $scope_ptr->config_vars[$variable] = $value;
- } else {
- $scope_ptr->config_vars[$variable] = array_merge((array)$scope_ptr->config_vars[$variable], (array)$value);
- }
- }
- }
+ if(!empty($sections)) {
+ foreach ($_config_vars['sections'] as $this_section => $dummy) {
+ if (in_array($this_section, (array)$sections)) {
+ foreach ($_config_vars['sections'][$this_section]['vars'] as $variable => $value) {
+ if ($this->smarty->config_overwrite || !isset($scope_ptr->config_vars[$variable])) {
+ $scope_ptr->config_vars[$variable] = $value;
+ } else {
+ $scope_ptr->config_vars[$variable] = array_merge((array)$scope_ptr->config_vars[$variable], (array)$value);
+ }
+ }
+ }
+ }
}
}
}
View
26 vendor/sysplugins/smarty_internal_configfilelexer.php
@@ -2,10 +2,10 @@
/**
* Smarty Internal Plugin Configfilelexer
*
-* This is the lexer to break the config file source into tokens
+* This is the lexer to break the config file source into tokens
* @package Smarty
* @subpackage Config
-* @author Uwe Tews
+* @author Uwe Tews
*/
/**
* Smarty Internal Plugin Configfilelexer
@@ -22,24 +22,24 @@ class Smarty_Internal_Configfilelexer
private $state = 1;
public $smarty_token_names = array ( // Text for parser error messages
);
-
-
+
+
function __construct($data, $smarty)
{
// set instance object
- self::instance($this);
+ self::instance($this);
$this->data = $data . "\n"; //now all lines are \n-terminated
$this->counter = 0;
$this->line = 1;
- $this->smarty = $smarty;
+ $this->smarty = $smarty;
}
public static function &instance($new_instance = null)
{
static $instance = null;
if (isset($new_instance) && is_object($new_instance))
$instance = $new_instance;
return $instance;
- }
+ }
@@ -183,15 +183,15 @@ function yylex2()
3 => 0,
4 => 0,
5 => 0,
- 6 => 0,
- 7 => 0,
+ 6 => 1,
8 => 0,
9 => 0,
+ 10 => 0,
);
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
- $yy_global_pattern = "/^([ \t\r]+)|^(\\d+\\.\\d+(?=[ \t\r]*[\n#]))|^(\\d+(?=[ \t\r]*[\n#]))|^('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#]))|^(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#]))|^(\"\"\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"\"\"(?=[ \t\r]*[\n#]))|^([a-zA-Z]+(?=[ \t\r]*[\n#]))|^([^\n]+?(?=[ \t\r]*\n))|^(\n)/iS";
+ $yy_global_pattern = "/^([ \t\r]+)|^(\\d+\\.\\d+(?=[ \t\r]*[\n#]))|^(\\d+(?=[ \t\r]*[\n#]))|^('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#]))|^(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#]))|^(\"\"\"([^\"]|\\\\\"|\"{1,2}[^\"])*\"\"\"(?=[ \t\r]*[\n#]))|^([a-zA-Z]+(?=[ \t\r]*[\n#]))|^([^\n]+?(?=[ \t\r]*\n))|^(\n)/iS";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@@ -276,7 +276,7 @@ function yy_r2_6($yy_subpatterns)
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_DOUBLE_QUOTED_STRING;
$this->yypopstate();
}
- function yy_r2_7($yy_subpatterns)
+ function yy_r2_8($yy_subpatterns)
{
if (!$this->smarty->config_booleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no")) ) {
@@ -288,13 +288,13 @@ function yy_r2_7($yy_subpatterns)
$this->yypopstate();
}
}
- function yy_r2_8($yy_subpatterns)
+ function yy_r2_9($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
$this->yypopstate();
}
- function yy_r2_9($yy_subpatterns)
+ function yy_r2_10($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
View
214 vendor/sysplugins/smarty_internal_data.php
@@ -2,12 +2,12 @@
/**
* Smarty Internal Plugin Data
- *
+ *
* This file contains the basic classes and methodes for template and variable creation
- *
+ *
* @package Smarty
* @subpackage Templates
- * @author Uwe Tews
+ * @author Uwe Tews
*/
/**
@@ -19,7 +19,7 @@ class Smarty_Internal_Data {
/**
* assigns a Smarty variable
- *
+ *
* @param array $ |string $tpl_var the template variable name(s)
* @param mixed $value the value to assign
* @param boolean $nocache if true any output of this variable will be not cached
@@ -31,17 +31,17 @@ public function assign($tpl_var, $value = null, $nocache = false)
foreach ($tpl_var as $_key => $_val) {
if ($_key != '') {
$this->tpl_vars[$_key] = new Smarty_variable($_val, $nocache);
- }
- }
+ }
+ }
} else {
if ($tpl_var != '') {
$this->tpl_vars[$tpl_var] = new Smarty_variable($value, $nocache);
- }
- }
- }
+ }
+ }
+ }
/**
* assigns a global Smarty variable
- *
+ *
* @param string $varname the global variable name
* @param mixed $value the value to assign
* @param boolean $nocache if true any output of this variable will be not cached
@@ -50,11 +50,11 @@ public function assignGlobal($varname, $value = null, $nocache = false)
{
if ($varname != '') {
Smarty::$global_tpl_vars[$varname] = new Smarty_variable($value, $nocache);
- }
- }
+ }
+ }
/**
* assigns values to template variables by reference
- *
+ *
* @param string $tpl_var the template variable name
* @param mixed $ &$value the referenced value to assign
* @param boolean $nocache if true any output of this variable will be not cached
@@ -64,12 +64,12 @@ public function assignByRef($tpl_var, &$value, $nocache = false)
if ($tpl_var != '') {
$this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache);
$this->tpl_vars[$tpl_var]->value = &$value;
- }
- }
+ }
+ }
/**
* wrapper function for Smarty 2 BC
- *
+ *
* @param string $tpl_var the template variable name
* @param mixed $ &$value the referenced value to assign
*/
@@ -78,10 +78,10 @@ public function assign_by_ref($tpl_var, &$value)
if($this->smarty->deprecation_notices)
trigger_error("function call 'assign_by_ref' is unknown or deprecated, use 'assignByRef'", E_USER_NOTICE);
$this->assignByRef($tpl_var, $value);
- }
+ }
/**
* appends values to template variables
- *
+ *
* @param array $ |string $tpl_var the template variable name(s)
* @param mixed $value the value to append
* @param boolean $merge flag if array elements shall be merged
@@ -99,20 +99,20 @@ public function append($tpl_var, $value = null, $merge = false, $nocache = false
$this->tpl_vars[$_key] = new Smarty_variable(null, $nocache);
} else {
$this->tpl_vars[$_key] = clone $tpl_var_inst;
- }
- }
+ }
+ }
if (!(is_array($this->tpl_vars[$_key]->value) || $this->tpl_vars[$_key]->value instanceof ArrayAccess)) {
settype($this->tpl_vars[$_key]->value, 'array');
- }
+ }
if ($merge && is_array($_val)) {
foreach($_val as $_mkey => $_mval) {
$this->tpl_vars[$_key]->value[$_mkey] = $_mval;
- }
+ }
} else {
$this->tpl_vars[$_key]->value[] = $_val;
- }
- }
- }
+ }
+ }
+ }
} else {
if ($tpl_var != '' && isset($value)) {
if (!isset($this->tpl_vars[$tpl_var])) {
@@ -121,25 +121,25 @@ public function append($tpl_var, $value = null, $merge = false, $nocache = false
$this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache);
} else {
$this->tpl_vars[$tpl_var] = clone $tpl_var_inst;
- }
- }
+ }
+ }
if (!(is_array($this->tpl_vars[$tpl_var]->value) || $this->tpl_vars[$tpl_var]->value instanceof ArrayAccess)) {
settype($this->tpl_vars[$tpl_var]->value, 'array');
- }
+ }
if ($merge && is_array($value)) {
foreach($value as $_mkey => $_mval) {
$this->tpl_vars[$tpl_var]->value[$_mkey] = $_mval;
- }
+ }
} else {
$this->tpl_vars[$tpl_var]->value[] = $value;
- }
- }
- }
- }
+ }
+ }
+ }
+ }
/**
* appends values to template variables by reference
- *
+ *
* @param string $tpl_var the template variable name
* @param mixed $ &$value the referenced value to append
* @param boolean $merge flag if array elements shall be merged
@@ -149,22 +149,22 @@ public function appendByRef($tpl_var, &$value, $merge = false)
if ($tpl_var != '' && isset($value)) {
if (!isset($this->tpl_vars[$tpl_var])) {
$this->tpl_vars[$tpl_var] = new Smarty_variable();
- }
+ }
if (!@is_array($this->tpl_vars[$tpl_var]->value)) {
settype($this->tpl_vars[$tpl_var]->value, 'array');
- }
+ }
if ($merge && is_array($value)) {
foreach($value as $_key => $_val) {
$this->tpl_vars[$tpl_var]->value[$_key] = &$value[$_key];
- }
+ }
} else {
$this->tpl_vars[$tpl_var]->value[] = &$value;
- }
- }
- }
-
+ }
+ }
+ }
+
/**
- *
+ *
* @param string $tpl_var the template variable name
* @param mixed $ &$value the referenced value to append
* @param boolean $merge flag if array elements shall be merged
@@ -174,10 +174,10 @@ public function append_by_ref($tpl_var, &$value, $merge = false)
if($this->smarty->deprecation_notices)
trigger_error("function call 'append_by_ref' is unknown or deprecated, use 'appendByRef'", E_USER_NOTICE);
$this->appendByRef($tpl_var, $value, $merge);
- }
+ }
/**
* Returns a single or all template variables
- *
+ *
* @param string $varname variable name or null
* @return string variable value or or array of variables
*/
@@ -189,7 +189,7 @@ function getTemplateVars($varname = null, $_ptr = null, $search_parents = true)
return $_var->value;
} else {
return null;
- }
+ }
} else {
$_result = array();
if ($_ptr === null) {
@@ -199,65 +199,65 @@ function getTemplateVars($varname = null, $_ptr = null, $search_parents = true)
if (!array_key_exists($key, $_result)) {
$_result[$key] = $var->value;
}
- }
+ }
// not found, try at parent
if ($search_parents) {
$_ptr = $_ptr->parent;
} else {
$_ptr = null;
- }
- }
+ }
+ }
if ($search_parents && isset(Smarty::$global_tpl_vars)) {
foreach (Smarty::$global_tpl_vars AS $key => $var) {
if (!array_key_exists($key, $_result)) {
$_result[$key] = $var->value;
}
- }
- }
+ }
+ }
return $_result;
- }
- }
+ }
+ }
/**
* clear the given assigned template variable.
- *
+ *
* @param string $ |array $tpl_var the template variable(s) to clear
*/
public function clearAssign($tpl_var)
{
if (is_array($tpl_var)) {
foreach ($tpl_var as $curr_var) {
unset($this->tpl_vars[$curr_var]);
- }
+ }
} else {
unset($this->tpl_vars[$tpl_var]);
- }
- }
+ }
+ }
/**
* clear all the assigned template variables.
*/
public function clearAllAssign()
{
$this->tpl_vars = array();
- }
+ }
/**
* load a config file, optionally load just selected sections
- *
+ *
* @param string $config_file filename
* @param mixed $sections array of section names, single section or null
*/
public function configLoad($config_file, $sections = null)
- {
+ {
// load Config class
$config = new Smarty_Internal_Config($config_file, $this->smarty, $this);
$config->loadConfigVars($sections);
- }
+ }
/**
* gets the object of a Smarty variable
- *
+ *
* @param string $variable the name of the Smarty variable
* @param object $_ptr optional pointer to data object
* @param boolean $search_parents search also in parent data
@@ -271,18 +271,18 @@ public function getVariable($_variable, $_ptr = null, $search_parents = true, $e
if (isset($_ptr->tpl_vars[$_variable])) {
// found it, return it
return $_ptr->tpl_vars[$_variable];
- }
+ }
// not found, try at parent
if ($search_parents) {
$_ptr = $_ptr->parent;
} else {
$_ptr = null;
- }
- }
+ }
+ }
if (isset(Smarty::$global_tpl_vars[$_variable])) {
// found it, return it
return Smarty::$global_tpl_vars[$_variable];
- }
+ }
if ($this->smarty->error_unassigned && $error_enable) {
throw new SmartyException('Undefined Smarty variable "' . $_variable . '"');
} else {
@@ -291,11 +291,11 @@ public function getVariable($_variable, $_ptr = null, $search_parents = true, $e
$x = $$_variable;
}
return new Undefined_Smarty_Variable;
- }
- }
+ }
+ }
/**
* gets a config variable
- *
+ *
* @param string $variable the name of the config variable
* @return mixed the value of the config variable
*/
@@ -306,46 +306,46 @@ public function getConfigVariable($_variable)
if (isset($_ptr->config_vars[$_variable])) {
// found it, return it
return $_ptr->config_vars[$_variable];
- }
+ }
// not found, try at parent
$_ptr = $_ptr->parent;
- }
+ }
if ($this->smarty->error_unassigned) {
throw new SmartyException('Undefined config variable "' . $_variable . '"');
} else {
// force a notice
$x = $$_variable;
return null;
- }
- }
+ }
+ }
/**
* gets a stream variable
- *
+ *
* @param string $variable the stream of the variable
* @return mixed the value of the stream variable
*/
public function getStreamVariable($variable)
{
$_result = '';
if ($fp = fopen($variable, 'r+')) {
- while (!feof($fp)) {
- $_result .= fgets($fp);
- }
+ while (!feof($fp) && ($current_line = fgets($fp)) !== false ) {
+ $_result .= $current_line;
+ }
fclose($fp);
return $_result;
- }
+ }
if ($this->smarty->error_unassigned) {
throw new SmartyException('Undefined stream variable "' . $variable . '"');
} else {
return null;
- }
- }
+ }
+ }
/**
* Returns a single or all config variables
- *
+ *
* @param string $varname variable name or null
* @return string variable value or or array of variables
*/
@@ -361,24 +361,24 @@ function getConfigVars($varname = null, $search_parents = true)
}
} else {
$var_array = array_merge($_ptr->config_vars, $var_array);
- }
+ }
// not found, try at parent
if ($search_parents) {
$_ptr = $_ptr->parent;
} else {
$_ptr = null;
- }
- }
+ }
+ }
if (isset($varname)) {
return '';
} else {
return $var_array;
- }
- }
+ }
+ }
/**
* Deassigns a single or all config variables
- *
+ *
* @param string $varname variable name or null
*/
function clearConfig($varname = null)
@@ -389,25 +389,25 @@ function clearConfig($varname = null)
} else {
$this->config_vars = array();
return;
- }
- }
+ }
+ }
-}
+}
/**
* class for the Smarty data object
- *
+ *
* The Smarty data object will hold Smarty variables in the current scope
- *
+ *
* @param object $parent tpl_vars next higher level of Smarty variables
*/
class Smarty_Data extends Smarty_Internal_Data {
// array of variable objects
- public $tpl_vars = array();
+ public $tpl_vars = array();
// back pointer to parent object
- public $parent = null;
+ public $parent = null;
// config vars
- public $config_vars = array();
+ public $config_vars = array();
// Smarty object
public $smarty = null;
/**
@@ -423,15 +423,15 @@ public function __construct ($_parent = null, $smarty = null)
// set up variable values
foreach ($_parent as $_key => $_val) {
$this->tpl_vars[$_key] = new Smarty_variable($_val);
- }
+ }
} elseif ($_parent != null) {
throw new SmartyException("Wrong type for template variables");
- }
- }
-}
+ }
+ }
+}
/**
* class for the Smarty variable object
- *
+ *
* This class defines the Smarty variable object
*/
class Smarty_Variable {
@@ -441,7 +441,7 @@ class Smarty_Variable {
public $scope;
/**
* create Smarty variable object
- *
+ *
* @param mixed $value the value to assign
* @param boolean $nocache if true any output of this variable will be not cached
* @param boolean $scope the scope the variable will have (local,parent or root)