diff --git a/libs/Config_File.class.php b/libs/Config_File.class.php
index 5a7ca50a..62b1f68e 100644
--- a/libs/Config_File.class.php
+++ b/libs/Config_File.class.php
@@ -37,274 +37,274 @@
* @package Smarty
*/
class Config_File {
- /**#@+
+ /**#@+
* Options
* @var boolean
*/
- /**
- * Controls whether variables with the same name overwrite each other.
- */
- var $overwrite = true;
+ /**
+ * Controls whether variables with the same name overwrite each other.
+ */
+ var $overwrite = true;
- /**
- * Controls whether config values of on/true/yes and off/false/no get
- * converted to boolean values automatically.
- */
- var $booleanize = true;
+ /**
+ * Controls whether config values of on/true/yes and off/false/no get
+ * converted to boolean values automatically.
+ */
+ var $booleanize = true;
- /**
- * Controls whether hidden config sections/vars are read from the file.
- */
- var $read_hidden = true;
+ /**
+ * Controls whether hidden config sections/vars are read from the file.
+ */
+ var $read_hidden = true;
- /**
- * Controls whether or not to fix mac or dos formatted newlines.
- * If set to true, \r or \r\n will be changed to \n.
- */
- var $fix_newlines = true;
- /**#@-*/
-
- /** @access private */
- var $_config_path = "";
- var $_config_data = array();
+ /**
+ * Controls whether or not to fix mac or dos formatted newlines.
+ * If set to true, \r or \r\n will be changed to \n.
+ */
+ var $fix_newlines = true;
/**#@-*/
- /**
- * Constructs a new config file class.
- *
- * @param string $config_path (optional) path to the config files
- */
- function Config_File($config_path = NULL)
- {
- if (isset($config_path))
- $this->set_path($config_path);
- }
+ /** @access private */
+ var $_config_path = "";
+ var $_config_data = array();
+ /**#@-*/
+
+ /**
+ * Constructs a new config file class.
+ *
+ * @param string $config_path (optional) path to the config files
+ */
+ function Config_File($config_path = NULL)
+ {
+ if (isset($config_path))
+ $this->set_path($config_path);
+ }
- /**
- * Set the path where configuration files can be found.
- *
- * @param string $config_path path to the config files
- */
- function set_path($config_path)
- {
- if (!empty($config_path)) {
- if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) {
- $this->_trigger_error_msg("Bad config file path '$config_path'");
- return;
- }
- if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
- $config_path .= DIRECTORY_SEPARATOR;
- }
+ /**
+ * Set the path where configuration files can be found.
+ *
+ * @param string $config_path path to the config files
+ */
+ function set_path($config_path)
+ {
+ if (!empty($config_path)) {
+ if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) {
+ $this->_trigger_error_msg("Bad config file path '$config_path'");
+ return;
+ }
+ if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
+ $config_path .= DIRECTORY_SEPARATOR;
+ }
- $this->_config_path = $config_path;
- }
- }
+ $this->_config_path = $config_path;
+ }
+ }
-
- /**
- * Retrieves config info based on the file, section, and variable name.
- *
- * @param string $file_name config file to get info for
- * @param string $section_name (optional) section to get info for
- * @param string $var_name (optional) variable to get info for
- * @return string|array a value or array of values
- */
- function &get($file_name, $section_name = NULL, $var_name = NULL)
- {
- if (empty($file_name)) {
- $this->_trigger_error_msg('Empty config file name');
- return;
- } else {
- $file_name = $this->_config_path . $file_name;
- if (!isset($this->_config_data[$file_name]))
- $this->load_file($file_name, false);
- }
-
- if (!empty($var_name)) {
- if (empty($section_name)) {
- return $this->_config_data[$file_name]["vars"][$var_name];
- } else {
- if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]))
- return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name];
- else
- return array();
- }
- } else {
- if (empty($section_name)) {
- return (array)$this->_config_data[$file_name]["vars"];
- } else {
- if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"]))
- return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"];
- else
- return array();
- }
- }
- }
-
- /**
- * Retrieves config info based on the key.
- *
- * @param $file_name string config key (filename/section/var)
- * @return string|array same as get()
+ /**
+ * Retrieves config info based on the file, section, and variable name.
+ *
+ * @param string $file_name config file to get info for
+ * @param string $section_name (optional) section to get info for
+ * @param string $var_name (optional) variable to get info for
+ * @return string|array a value or array of values
+ */
+ function &get($file_name, $section_name = NULL, $var_name = NULL)
+ {
+ if (empty($file_name)) {
+ $this->_trigger_error_msg('Empty config file name');
+ return;
+ } else {
+ $file_name = $this->_config_path . $file_name;
+ if (!isset($this->_config_data[$file_name]))
+ $this->load_file($file_name, false);
+ }
+
+ if (!empty($var_name)) {
+ if (empty($section_name)) {
+ return $this->_config_data[$file_name]["vars"][$var_name];
+ } else {
+ if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]))
+ return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name];
+ else
+ return array();
+ }
+ } else {
+ if (empty($section_name)) {
+ return (array)$this->_config_data[$file_name]["vars"];
+ } else {
+ if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"]))
+ return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"];
+ else
+ return array();
+ }
+ }
+ }
+
+
+ /**
+ * Retrieves config info based on the key.
+ *
+ * @param $file_name string config key (filename/section/var)
+ * @return string|array same as get()
* @uses get() retrieves information from config file and returns it
- */
- function &get_key($config_key)
- {
- list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
- $result = &$this->get($file_name, $section_name, $var_name);
- return $result;
- }
+ */
+ function &get_key($config_key)
+ {
+ list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
+ $result = &$this->get($file_name, $section_name, $var_name);
+ return $result;
+ }
- /**
- * Get all loaded config file names.
- *
- * @return array an array of loaded config file names
- */
- function get_file_names()
- {
- return array_keys($this->_config_data);
- }
-
-
- /**
- * Get all section names from a loaded file.
- *
- * @param string $file_name config file to get section names from
- * @return array an array of section names from the specified file
- */
- function get_section_names($file_name)
- {
- $file_name = $this->_config_path . $file_name;
- if (!isset($this->_config_data[$file_name])) {
- $this->_trigger_error_msg("Unknown config file '$file_name'");
- return;
- }
-
- return array_keys($this->_config_data[$file_name]["sections"]);
- }
-
-
- /**
- * Get all global or section variable names.
- *
- * @param string $file_name config file to get info for
- * @param string $section_name (optional) section to get info for
- * @return array an array of variables names from the specified file/section
- */
- function get_var_names($file_name, $section = NULL)
- {
- if (empty($file_name)) {
- $this->_trigger_error_msg('Empty config file name');
- return;
- } else if (!isset($this->_config_data[$file_name])) {
- $this->_trigger_error_msg("Unknown config file '$file_name'");
- return;
- }
-
- if (empty($section))
- return array_keys($this->_config_data[$file_name]["vars"]);
- else
- return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]);
- }
-
-
- /**
- * Clear loaded config data for a certain file or all files.
- *
- * @param string $file_name file to clear config data for
- */
- function clear($file_name = NULL)
- {
- if ($file_name === NULL)
- $this->_config_data = array();
- else if (isset($this->_config_data[$file_name]))
- $this->_config_data[$file_name] = array();
- }
+ /**
+ * Get all loaded config file names.
+ *
+ * @return array an array of loaded config file names
+ */
+ function get_file_names()
+ {
+ return array_keys($this->_config_data);
+ }
- /**
- * Load a configuration file manually.
- *
- * @param string $file_name file name to load
- * @param boolean $prepend_path whether current config path should be
+ /**
+ * Get all section names from a loaded file.
+ *
+ * @param string $file_name config file to get section names from
+ * @return array an array of section names from the specified file
+ */
+ function get_section_names($file_name)
+ {
+ $file_name = $this->_config_path . $file_name;
+ if (!isset($this->_config_data[$file_name])) {
+ $this->_trigger_error_msg("Unknown config file '$file_name'");
+ return;
+ }
+
+ return array_keys($this->_config_data[$file_name]["sections"]);
+ }
+
+
+ /**
+ * Get all global or section variable names.
+ *
+ * @param string $file_name config file to get info for
+ * @param string $section_name (optional) section to get info for
+ * @return array an array of variables names from the specified file/section
+ */
+ function get_var_names($file_name, $section = NULL)
+ {
+ if (empty($file_name)) {
+ $this->_trigger_error_msg('Empty config file name');
+ return;
+ } else if (!isset($this->_config_data[$file_name])) {
+ $this->_trigger_error_msg("Unknown config file '$file_name'");
+ return;
+ }
+
+ if (empty($section))
+ return array_keys($this->_config_data[$file_name]["vars"]);
+ else
+ return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]);
+ }
+
+
+ /**
+ * Clear loaded config data for a certain file or all files.
+ *
+ * @param string $file_name file to clear config data for
+ */
+ function clear($file_name = NULL)
+ {
+ if ($file_name === NULL)
+ $this->_config_data = array();
+ else if (isset($this->_config_data[$file_name]))
+ $this->_config_data[$file_name] = array();
+ }
+
+
+ /**
+ * Load a configuration file manually.
+ *
+ * @param string $file_name file name to load
+ * @param boolean $prepend_path whether current config path should be
* prepended to the filename
- */
- function load_file($file_name, $prepend_path = true)
- {
- if ($prepend_path && $this->_config_path != "")
- $config_file = $this->_config_path . $file_name;
- else
- $config_file = $file_name;
+ */
+ function load_file($file_name, $prepend_path = true)
+ {
+ if ($prepend_path && $this->_config_path != "")
+ $config_file = $this->_config_path . $file_name;
+ else
+ $config_file = $file_name;
- ini_set('track_errors', true);
- $fp = @fopen($config_file, "r");
- if (!is_resource($fp)) {
- $this->_trigger_error_msg("Could not open config file '$config_file'");
- return false;
- }
+ ini_set('track_errors', true);
+ $fp = @fopen($config_file, "r");
+ if (!is_resource($fp)) {
+ $this->_trigger_error_msg("Could not open config file '$config_file'");
+ return false;
+ }
- $contents = fread($fp, filesize($config_file));
- fclose($fp);
-
- if($this->fix_newlines) {
- // fix mac/dos formatted newlines
- $contents = preg_replace('!\r\n?!',"\n",$contents);
- }
+ $contents = fread($fp, filesize($config_file));
+ fclose($fp);
- $config_data = array();
+ if($this->fix_newlines) {
+ // fix mac/dos formatted newlines
+ $contents = preg_replace('!\r\n?!',"\n",$contents);
+ }
- /* Get global variables first. */
- if ($contents{0} != '[' && preg_match("/^(.*?)(\n\[|\Z)/s", $contents, $match))
- $config_data["vars"] = $this->_parse_config_block($match[1]);
-
- /* Get section variables. */
- $config_data["sections"] = array();
- preg_match_all("/^\[(.*?)\]/m", $contents, $match);
- foreach ($match[1] as $section) {
- if ($section{0} == '.' && !$this->read_hidden)
- continue;
- if (preg_match("/\[".preg_quote($section, '/')."\](.*?)(\n\[|\Z)/s", $contents, $match))
- if ($section{0} == '.')
- $section = substr($section, 1);
- $config_data["sections"][$section]["vars"] = $this->_parse_config_block($match[1]);
- }
+ $config_data = array();
- $this->_config_data[$config_file] = $config_data;
-
- return true;
- }
+ /* Get global variables first. */
+ if ($contents{0} != '[' && preg_match("/^(.*?)(\n\[|\Z)/s", $contents, $match))
+ $config_data["vars"] = $this->_parse_config_block($match[1]);
- /**#@+ @access private */
+ /* Get section variables. */
+ $config_data["sections"] = array();
+ preg_match_all("/^\[(.*?)\]/m", $contents, $match);
+ foreach ($match[1] as $section) {
+ if ($section{0} == '.' && !$this->read_hidden)
+ continue;
+ if (preg_match("/\[".preg_quote($section, '/')."\](.*?)(\n\[|\Z)/s", $contents, $match))
+ if ($section{0} == '.')
+ $section = substr($section, 1);
+ $config_data["sections"][$section]["vars"] = $this->_parse_config_block($match[1]);
+ }
+
+ $this->_config_data[$config_file] = $config_data;
+
+ return true;
+ }
+
+ /**#@+ @access private */
/**
* @var string $config_block
*/
- function _parse_config_block($config_block)
- {
- $vars = array();
+ function _parse_config_block($config_block)
+ {
+ $vars = array();
- /* First we grab the multi-line values. */
- if (preg_match_all("/^([^=\n]+)=\s*\"{3}(.*?)\"{3}\s*$/ms", $config_block, $match, PREG_SET_ORDER)) {
- for ($i = 0; $i < count($match); $i++) {
- $this->_set_config_var($vars, trim($match[$i][1]), $match[$i][2], false);
- }
- $config_block = preg_replace("/^[^=\n]+=\s*\"{3}.*?\"{3}\s*$/ms", "", $config_block);
- }
-
-
- $config_lines = preg_split("/\n+/", $config_block);
+ /* First we grab the multi-line values. */
+ if (preg_match_all("/^([^=\n]+)=\s*\"{3}(.*?)\"{3}\s*$/ms", $config_block, $match, PREG_SET_ORDER)) {
+ for ($i = 0; $i < count($match); $i++) {
+ $this->_set_config_var($vars, trim($match[$i][1]), $match[$i][2], false);
+ }
+ $config_block = preg_replace("/^[^=\n]+=\s*\"{3}.*?\"{3}\s*$/ms", "", $config_block);
+ }
- foreach ($config_lines as $line) {
- if (preg_match("/^\s*(\.?\w+)\s*=(.*)/", $line, $match)) {
- $var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', trim($match[2]));
- $this->_set_config_var($vars, trim($match[1]), $var_value, $this->booleanize);
- }
- }
- return $vars;
- }
-
+ $config_lines = preg_split("/\n+/", $config_block);
+
+ foreach ($config_lines as $line) {
+ if (preg_match("/^\s*(\.?\w+)\s*=(.*)/", $line, $match)) {
+ $var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', trim($match[2]));
+ $this->_set_config_var($vars, trim($match[1]), $var_value, $this->booleanize);
+ }
+ }
+
+ return $vars;
+ }
+
/**
* @param array &$container
* @param string $var_name
@@ -312,44 +312,44 @@ class Config_File {
* @param boolean $booleanize determines whether $var_value is converted to
* to true/false
*/
- function _set_config_var(&$container, $var_name, $var_value, $booleanize)
- {
- if ($var_name{0} == '.') {
- if (!$this->read_hidden)
- return;
- else
- $var_name = substr($var_name, 1);
- }
+ function _set_config_var(&$container, $var_name, $var_value, $booleanize)
+ {
+ if ($var_name{0} == '.') {
+ if (!$this->read_hidden)
+ return;
+ else
+ $var_name = substr($var_name, 1);
+ }
- if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) {
- $this->_trigger_error_msg("Bad variable name '$var_name'");
- return;
- }
+ if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) {
+ $this->_trigger_error_msg("Bad variable name '$var_name'");
+ return;
+ }
- if ($booleanize) {
- if (preg_match("/^(on|true|yes)$/i", $var_value))
- $var_value = true;
- else if (preg_match("/^(off|false|no)$/i", $var_value))
- $var_value = false;
- }
-
- if (!isset($container[$var_name]) || $this->overwrite)
- $container[$var_name] = $var_value;
- else {
- settype($container[$var_name], 'array');
- $container[$var_name][] = $var_value;
- }
- }
+ if ($booleanize) {
+ if (preg_match("/^(on|true|yes)$/i", $var_value))
+ $var_value = true;
+ else if (preg_match("/^(off|false|no)$/i", $var_value))
+ $var_value = false;
+ }
+
+ if (!isset($container[$var_name]) || $this->overwrite)
+ $container[$var_name] = $var_value;
+ else {
+ settype($container[$var_name], 'array');
+ $container[$var_name][] = $var_value;
+ }
+ }
/**
* @uses trigger_error() creates a PHP warning/error
* @param string $error_msg
- * @param integer $error_type one of
+ * @param integer $error_type one of
*/
- function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
- {
- trigger_error("Config_File error: $error_msg", $error_type);
- }
+ function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
+ {
+ trigger_error("Config_File error: $error_msg", $error_type);
+ }
/**#@-*/
}
diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php
index 83a202f8..4aee6d1d 100644
--- a/libs/Smarty.class.php
+++ b/libs/Smarty.class.php
@@ -49,7 +49,7 @@
* DIR_SEP isn't used anymore, but third party apps might
*/
if(!defined('DIR_SEP')) {
- define('DIR_SEP', DIRECTORY_SEPARATOR);
+ define('DIR_SEP', DIRECTORY_SEPARATOR);
}
/**
@@ -78,28 +78,28 @@ class Smarty
/**
* The name of the directory where templates are located.
- *
+ *
* @var string
*/
var $template_dir = 'templates';
/**
* The directory where compiled templates are located.
- *
+ *
* @var string
*/
var $compile_dir = 'templates_c';
/**
* The directory where config files are located.
- *
+ *
* @var string
*/
var $config_dir = 'configs';
/**
* An array of directories searched for plugins.
- *
+ *
* @var array
*/
var $plugins_dir = array('plugins');
@@ -108,7 +108,7 @@ class Smarty
* If debugging is enabled, a debug console window will display
* when the page loads (make sure your browser allows unrequested
* popup windows)
- *
+ *
* @var boolean
*/
var $debugging = false;
@@ -116,7 +116,7 @@ class Smarty
/**
* This is the path to the debug console template. If not set,
* the default one will be used.
- *
+ *
* @var string
*/
var $debug_tpl = '';
@@ -134,10 +134,10 @@ class Smarty
/**
* This tells Smarty whether to check for recompiling or not. Recompiling
- * does not need to happen unless a template or config file is changed.
+ * does not need to happen unless a template or config file is changed.
* Typically you enable this during development, and disable for
* production.
- *
+ *
* @var boolean
*/
var $compile_check = true;
@@ -145,7 +145,7 @@ class Smarty
/**
* This forces templates to compile every time. Useful for development
* or debugging.
- *
+ *
* @var boolean
*/
var $force_compile = false;
@@ -163,7 +163,7 @@ class Smarty
/**
* The name of the directory for cache files.
- *
+ *
* @var string
*/
var $cache_dir = 'cache';
@@ -174,7 +174,7 @@ class Smarty
*
0 = always regenerate cache
* -1 = never expires
*
- *
+ *
* @var integer
*/
var $cache_lifetime = 3600;
@@ -184,7 +184,7 @@ class Smarty
* are respected with cached content, and appropriate HTTP headers are sent.
* This way repeated hits to a cached page do not send the entire page to the
* client every time.
- *
+ *
* @var boolean
*/
var $cache_modified_check = false;
@@ -208,7 +208,7 @@ class Smarty
* in the templates that normally would go unchecked. This is useful when
* untrusted parties are editing templates and you want a reasonable level
* of security. (no direct execution of PHP in templates for example)
- *
+ *
* @var boolean
*/
var $security = false;
@@ -217,7 +217,7 @@ class Smarty
* This is the list of template directories that are considered secure. This
* is used only if {@link $security} is enabled. One directory per array
* element. {@link $template_dir} is in this list implicitly.
- *
+ *
* @var array
*/
var $secure_dir = array();
@@ -225,7 +225,7 @@ class Smarty
/**
* These are the security settings for Smarty. They are used only when
* {@link $security} is enabled.
- *
+ *
* @var array
*/
var $security_settings = array(
@@ -234,7 +234,7 @@ class Smarty
'isset', 'empty',
'count', 'sizeof',
'in_array', 'is_array',
- 'true','false'),
+ 'true','false'),
'INCLUDE_ANY' => false,
'PHP_TAGS' => false,
'MODIFIER_FUNCS' => array('count'),
@@ -251,14 +251,14 @@ class Smarty
/**
* The left delimiter used for the template tags.
- *
+ *
* @var string
*/
var $left_delimiter = '{';
/**
* The right delimiter used for the template tags.
- *
+ *
* @var string
*/
var $right_delimiter = '}';
@@ -267,17 +267,17 @@ class Smarty
* The order in which request variables are registered, similar to
* variables_order in php.ini E = Environment, G = GET, P = POST,
* C = Cookies, S = Server
- *
+ *
* @var string
*/
- var $request_vars_order = "EGPCS";
+ var $request_vars_order = "EGPCS";
/**
* Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false)
* are uses as request-vars or $_*[]-vars. note: if
* request_use_auto_globals is true, then $request_vars_order has
* no effect, but the php-ini-value "gpc_order"
- *
+ *
* @var boolean
*/
var $request_use_auto_globals = false;
@@ -296,9 +296,9 @@ class Smarty
* This tells Smarty whether or not to use sub dirs in the cache/ and
* templates_c/ directories. sub directories better organized, but
* may not work well with PHP safe mode enabled.
- *
+ *
* @var boolean
- *
+ *
*/
var $use_sub_dirs = true;
@@ -313,52 +313,52 @@ class Smarty
/**
* This is the resource type to be used when not specified
- * at the beginning of the resource path. examples:
- * $smarty->display('file:index.tpl');
- * $smarty->display('db:index.tpl');
- * $smarty->display('index.tpl'); // will use default resource type
- * {include file="file:index.tpl"}
- * {include file="db:index.tpl"}
- * {include file="index.tpl"} {* will use default resource type *}
+ * at the beginning of the resource path. examples:
+ * $smarty->display('file:index.tpl');
+ * $smarty->display('db:index.tpl');
+ * $smarty->display('index.tpl'); // will use default resource type
+ * {include file="file:index.tpl"}
+ * {include file="db:index.tpl"}
+ * {include file="index.tpl"} {* will use default resource type *}
*
* @var array
*/
- var $default_resource_type = 'file';
-
+ var $default_resource_type = 'file';
+
/**
* The function used for cache file handling. If not set, built-in caching is used.
- *
+ *
* @var null|string function name
*/
var $cache_handler_func = null;
-
+
/**
* These are the variables from the globals array that are
* assigned to all templates automatically. This isn't really
* necessary any more, you can use the $smarty var to access them
* directly.
- *
+ *
* @var array
*/
var $global_assign = array('HTTP_SERVER_VARS' => array('SCRIPT_NAME'));
/**
* The value of "undefined". Leave it alone :-)
- *
+ *
* @var null
*/
var $undefined = null;
/**
* This indicates which filters are automatically loaded into Smarty.
- *
+ *
* @var array array of filter names
*/
var $autoload_filters = array();
/**#@+
* @var boolean
- */
+ */
/**
* This tells if config file vars of the same name overwrite each other or not.
* if disabled, same name variables are accumulated in an array.
@@ -386,11 +386,11 @@ class Smarty
*/
var $config_fix_newlines = true;
/**#@-*/
-
+
/**
* If a template cannot be found, this PHP function will be executed.
* Useful for creating templates on-the-fly or other special action.
- *
+ *
* @var string function name
*/
var $default_template_handler_func = '';
@@ -398,14 +398,14 @@ class Smarty
/**
* The file that contains the compiler class. This can a full
* pathname, or relative to the php_include path.
- *
+ *
* @var string
*/
var $compiler_file = 'Smarty_Compiler.class.php';
/**
* The class used for compiling templates.
- *
+ *
* @var string
*/
var $compiler_class = 'Smarty_Compiler';
@@ -641,49 +641,49 @@ class Smarty
*
* @param string $tpl_var the template variable name
* @param mixed $value the referenced value to assign
- */
+ */
function assign_by_ref($tpl_var, &$value)
{
if ($tpl_var != '')
$this->_tpl_vars[$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
- */
+ */
function append($tpl_var, $value=null, $merge=false)
{
if (is_array($tpl_var)) {
- // $tpl_var is an array, ignore $value
+ // $tpl_var is an array, ignore $value
foreach ($tpl_var as $_key => $_val) {
if ($_key != '') {
- if(!@is_array($this->_tpl_vars[$_key])) {
- settype($this->_tpl_vars[$_key],'array');
- }
- if($merge && is_array($_val)) {
- foreach($_val as $_mkey => $_mval) {
- $this->_tpl_vars[$_key][$_mkey] = $_mval;
- }
- } else {
- $this->_tpl_vars[$_key][] = $_val;
- }
+ if(!@is_array($this->_tpl_vars[$_key])) {
+ settype($this->_tpl_vars[$_key],'array');
+ }
+ if($merge && is_array($_val)) {
+ foreach($_val as $_mkey => $_mval) {
+ $this->_tpl_vars[$_key][$_mkey] = $_mval;
+ }
+ } else {
+ $this->_tpl_vars[$_key][] = $_val;
+ }
}
}
} else {
if ($tpl_var != '' && isset($value)) {
- if(!@is_array($this->_tpl_vars[$tpl_var])) {
- settype($this->_tpl_vars[$tpl_var],'array');
- }
- if($merge && is_array($value)) {
- foreach($value as $_mkey => $_mval) {
- $this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
- }
- } else {
- $this->_tpl_vars[$tpl_var][] = $value;
- }
+ if(!@is_array($this->_tpl_vars[$tpl_var])) {
+ settype($this->_tpl_vars[$tpl_var],'array');
+ }
+ if($merge && is_array($value)) {
+ foreach($value as $_mkey => $_mval) {
+ $this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
+ }
+ } else {
+ $this->_tpl_vars[$tpl_var][] = $value;
+ }
}
}
}
@@ -693,20 +693,20 @@ class Smarty
*
* @param string $tpl_var the template variable name
* @param mixed $value the referenced value to append
- */
+ */
function append_by_ref($tpl_var, &$value, $merge=false)
{
if ($tpl_var != '' && isset($value)) {
- if(!@is_array($this->_tpl_vars[$tpl_var])) {
- settype($this->_tpl_vars[$tpl_var],'array');
- }
- if ($merge && is_array($value)) {
- foreach($value as $_key => $_val) {
- $this->_tpl_vars[$tpl_var][$_key] = &$value[$_key];
- }
- } else {
- $this->_tpl_vars[$tpl_var][] = &$value;
- }
+ if(!@is_array($this->_tpl_vars[$tpl_var])) {
+ settype($this->_tpl_vars[$tpl_var],'array');
+ }
+ if ($merge && is_array($value)) {
+ foreach($value as $_key => $_val) {
+ $this->_tpl_vars[$tpl_var][$_key] = &$value[$_key];
+ }
+ } else {
+ $this->_tpl_vars[$tpl_var][] = &$value;
+ }
}
}
@@ -715,7 +715,7 @@ class Smarty
* clear the given assigned template variable.
*
* @param string $tpl_var the template variable to clear
- */
+ */
function clear_assign($tpl_var)
{
if (is_array($tpl_var))
@@ -731,19 +731,19 @@ class Smarty
*
* @param string $function the name of the template function
* @param string $function_impl the name of the PHP function to register
- */
+ */
function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)
{
$this->_plugins['function'][$function] =
array($function_impl, null, null, false, $cacheable, $cache_attrs);
-
+
}
/**
* Unregisters custom function
*
* @param string $function name of template function
- */
+ */
function unregister_function($function)
{
unset($this->_plugins['function'][$function]);
@@ -757,11 +757,11 @@ class Smarty
* @param null|array $allowed list of allowed methods (empty = all)
* @param boolean $smarty_args smarty argument format, else traditional
* @param null|array $block_functs list of methods that are block format
- */
+ */
function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
{
- settype($allowed, 'array');
- settype($smarty_args, 'boolean');
+ settype($allowed, 'array');
+ settype($smarty_args, 'boolean');
$this->_reg_objects[$object] =
array(&$object_impl, $allowed, $smarty_args, $block_methods);
}
@@ -770,19 +770,19 @@ class Smarty
* Unregisters object
*
* @param string $object name of template object
- */
+ */
function unregister_object($object)
{
unset($this->_reg_objects[$object]);
}
-
-
+
+
/**
* Registers block function to be used in templates
*
* @param string $block name of template block
* @param string $block_impl PHP function to register
- */
+ */
function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
{
$this->_plugins['block'][$block] =
@@ -793,7 +793,7 @@ class Smarty
* Unregisters block function
*
* @param string $block name of template function
- */
+ */
function unregister_block($block)
{
unset($this->_plugins['block'][$block]);
@@ -804,7 +804,7 @@ class Smarty
*
* @param string $function name of template function
* @param string $function_impl name of PHP function to register
- */
+ */
function register_compiler_function($function, $function_impl, $cacheable=true)
{
$this->_plugins['compiler'][$function] =
@@ -815,7 +815,7 @@ class Smarty
* Unregisters compiler function
*
* @param string $function name of template function
- */
+ */
function unregister_compiler_function($function)
{
unset($this->_plugins['compiler'][$function]);
@@ -826,7 +826,7 @@ class Smarty
*
* @param string $modifier name of template modifier
* @param string $modifier_impl name of PHP function to register
- */
+ */
function register_modifier($modifier, $modifier_impl)
{
$this->_plugins['modifier'][$modifier] =
@@ -837,7 +837,7 @@ class Smarty
* Unregisters modifier
*
* @param string $modifier name of template modifier
- */
+ */
function unregister_modifier($modifier)
{
unset($this->_plugins['modifier'][$modifier]);
@@ -848,7 +848,7 @@ class Smarty
*
* @param string $type name of resource
* @param array $functions array of functions to handle resource
- */
+ */
function register_resource($type, $functions)
{
if (count($functions)==4) {
@@ -873,7 +873,7 @@ class Smarty
* Unregisters a resource
*
* @param string $type name of resource
- */
+ */
function unregister_resource($type)
{
unset($this->_plugins['resource'][$type]);
@@ -884,10 +884,10 @@ class Smarty
* to a template before compiling
*
* @param string $function name of PHP function to register
- */
+ */
function register_prefilter($function)
{
- $_name = (is_array($function)) ? $function[1] : $function;
+ $_name = (is_array($function)) ? $function[1] : $function;
$this->_plugins['prefilter'][$_name]
= array($function, null, null, false);
}
@@ -896,7 +896,7 @@ class Smarty
* Unregisters a prefilter function
*
* @param string $function name of PHP function
- */
+ */
function unregister_prefilter($function)
{
unset($this->_plugins['prefilter'][$function]);
@@ -907,10 +907,10 @@ class Smarty
* to a compiled template after compilation
*
* @param string $function name of PHP function to register
- */
+ */
function register_postfilter($function)
{
- $_name = (is_array($function)) ? $function[1] : $function;
+ $_name = (is_array($function)) ? $function[1] : $function;
$this->_plugins['postfilter'][$_name]
= array($function, null, null, false);
}
@@ -919,7 +919,7 @@ class Smarty
* Unregisters a postfilter function
*
* @param string $function name of PHP function
- */
+ */
function unregister_postfilter($function)
{
unset($this->_plugins['postfilter'][$function]);
@@ -930,10 +930,10 @@ class Smarty
* to a template output
*
* @param string $function name of PHP function
- */
+ */
function register_outputfilter($function)
{
- $_name = (is_array($function)) ? $function[1] : $function;
+ $_name = (is_array($function)) ? $function[1] : $function;
$this->_plugins['outputfilter'][$_name]
= array($function, null, null, false);
}
@@ -942,24 +942,24 @@ class Smarty
* Unregisters an outputfilter function
*
* @param string $function name of PHP function
- */
+ */
function unregister_outputfilter($function)
{
unset($this->_plugins['outputfilter'][$function]);
- }
-
+ }
+
/**
* load a filter of specified type and name
*
* @param string $type filter type
* @param string $name filter name
- */
+ */
function load_filter($type, $name)
{
switch ($type) {
case 'output':
- $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false)));
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
+ $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false)));
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
smarty_core_load_plugins($_params, $this);
break;
@@ -979,30 +979,30 @@ class Smarty
* @param string $compile_id name of compile_id
* @param string $exp_time expiration time
* @return boolean
- */
+ */
function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
{
-
+
if (!isset($compile_id))
$compile_id = $this->compile_id;
- if (!isset($tpl_file))
- $compile_id = null;
+ if (!isset($tpl_file))
+ $compile_id = null;
- $_auto_id = $this->_get_auto_id($cache_id, $compile_id);
+ $_auto_id = $this->_get_auto_id($cache_id, $compile_id);
if (!empty($this->cache_handler_func)) {
return call_user_func_array($this->cache_handler_func,
array('clear', &$this, &$dummy, $tpl_file, $cache_id, $compile_id));
} else {
- $_params = array('auto_base' => $this->cache_dir,
- 'auto_source' => $tpl_file,
- 'auto_id' => $_auto_id,
- 'exp_time' => $exp_time);
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php');
- return smarty_core_rm_auto($_params, $this);
+ $_params = array('auto_base' => $this->cache_dir,
+ 'auto_source' => $tpl_file,
+ 'auto_id' => $_auto_id,
+ 'exp_time' => $exp_time);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php');
+ return smarty_core_rm_auto($_params, $this);
}
-
+
}
@@ -1011,19 +1011,19 @@ class Smarty
*
* @param string $exp_time expire time
* @return boolean results of {@link smarty_core_rm_auto()}
- */
+ */
function clear_all_cache($exp_time = null)
{
if (!empty($this->cache_handler_func)) {
call_user_func_array($this->cache_handler_func,
array('clear', &$this, &$dummy));
} else {
- $_params = array('auto_base' => $this->cache_dir,
- 'auto_source' => null,
- 'auto_id' => null,
- 'exp_time' => $exp_time);
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php');
- return smarty_core_rm_auto($_params, $this);
+ $_params = array('auto_base' => $this->cache_dir,
+ 'auto_source' => null,
+ 'auto_id' => null,
+ 'exp_time' => $exp_time);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php');
+ return smarty_core_rm_auto($_params, $this);
}
}
@@ -1035,7 +1035,7 @@ class Smarty
* @param string $cache_id
* @param string $compile_id
* @return string|false results of {@link _read_cache_file()}
- */
+ */
function is_cached($tpl_file, $cache_id = null, $compile_id = null)
{
if (!$this->caching)
@@ -1044,12 +1044,12 @@ class Smarty
if (!isset($compile_id))
$compile_id = $this->compile_id;
- $_params = array(
- 'tpl_file' => $tpl_file,
- 'cache_id' => $cache_id,
- 'compile_id' => $compile_id
- );
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php');
+ $_params = array(
+ 'tpl_file' => $tpl_file,
+ 'cache_id' => $cache_id,
+ 'compile_id' => $compile_id
+ );
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php');
return smarty_core_read_cache_file($_params, $this);
}
@@ -1057,7 +1057,7 @@ class Smarty
/**
* clear all the assigned template variables.
*
- */
+ */
function clear_all_assign()
{
$this->_tpl_vars = array();
@@ -1072,19 +1072,19 @@ class Smarty
* @param string $compile_id
* @param string $exp_time
* @return boolean results of {@link smarty_core_rm_auto()}
- */
+ */
function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
{
if (!isset($compile_id)) {
- $compile_id = $this->compile_id;
- }
- $_params = array('auto_base' => $this->compile_dir,
- 'auto_source' => $tpl_file,
- 'auto_id' => $compile_id,
+ $compile_id = $this->compile_id;
+ }
+ $_params = array('auto_base' => $this->compile_dir,
+ 'auto_source' => $tpl_file,
+ 'auto_id' => $compile_id,
'exp_time' => $exp_time,
'extensions' => array('.inc', '.php'));
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php');
- return smarty_core_rm_auto($_params, $this);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php');
+ return smarty_core_rm_auto($_params, $this);
}
/**
@@ -1092,10 +1092,10 @@ class Smarty
*
* @param string $tpl_file
* @return boolean
- */
+ */
function template_exists($tpl_file)
{
- $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false);
+ $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false);
return $this->_fetch_resource_info($_params);
}
@@ -1105,15 +1105,15 @@ class Smarty
* @param string $name
* @param string $type
* @return array
- */
+ */
function &get_template_vars($name=null)
{
- if(!isset($name)) {
- return $this->_tpl_vars;
- }
- if(isset($this->_tpl_vars[$name])) {
- return $this->_tpl_vars[$name];
- }
+ if(!isset($name)) {
+ return $this->_tpl_vars;
+ }
+ if(isset($this->_tpl_vars[$name])) {
+ return $this->_tpl_vars[$name];
+ }
}
/**
@@ -1122,14 +1122,14 @@ class Smarty
* @param string $name
* @param string $type
* @return array
- */
+ */
function &get_config_vars($name=null)
{
- if(!isset($name) && is_array($this->_config[0])) {
- return $this->_config[0]['vars'];
- } else if(isset($this->_config[0]['vars'][$name])) {
- return $this->_config[0]['vars'][$name];
- }
+ if(!isset($name) && is_array($this->_config[0])) {
+ return $this->_config[0]['vars'];
+ } else if(isset($this->_config[0]['vars'][$name])) {
+ return $this->_config[0]['vars'][$name];
+ }
}
/**
@@ -1137,7 +1137,7 @@ class Smarty
*
* @param string $error_msg
* @param integer $error_type
- */
+ */
function trigger_error($error_msg, $error_type = E_USER_WARNING)
{
trigger_error("Smarty error: $error_msg", $error_type);
@@ -1150,7 +1150,7 @@ class Smarty
* @param string $resource_name
* @param string $cache_id
* @param string $compile_id
- */
+ */
function display($resource_name, $cache_id = null, $compile_id = null)
{
$this->fetch($resource_name, $cache_id, $compile_id, true);
@@ -1180,11 +1180,11 @@ class Smarty
// enable debugging from URL
$this->debugging = true;
}
-
+
if ($this->debugging) {
// capture time for debugging info
- $_params = array();
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
+ $_params = array();
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$_debug_start_time = smarty_core_get_microtime($_params, $this);
$this->_smarty_debug_info[] = array('type' => 'template',
'filename' => $resource_name,
@@ -1203,21 +1203,21 @@ class Smarty
// save old cache_info, initialize cache_info
array_push($_cache_info, $this->_cache_info);
$this->_cache_info = array();
- $_params = array(
- 'tpl_file' => $resource_name,
- 'cache_id' => $cache_id,
- 'compile_id' => $compile_id,
- 'results' => null
- );
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php');
+ $_params = array(
+ 'tpl_file' => $resource_name,
+ 'cache_id' => $cache_id,
+ 'compile_id' => $compile_id,
+ 'results' => null
+ );
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php');
if (smarty_core_read_cache_file($_params, $this)) {
- $_smarty_results = $_params['results'];
+ $_smarty_results = $_params['results'];
if (@count($this->_cache_info['insert_tags'])) {
- $_params = array('plugins' => $this->_cache_info['insert_tags']);
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
- smarty_core_load_plugins($_params, $this);
- $_params = array('results' => $_smarty_results);
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php');
+ $_params = array('plugins' => $this->_cache_info['insert_tags']);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
+ smarty_core_load_plugins($_params, $this);
+ $_params = array('results' => $_smarty_results);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php');
$_smarty_results = smarty_core_process_cached_inserts($_params, $this);
}
if (@count($this->_cache_info['cache_serials'])) {
@@ -1231,10 +1231,10 @@ class Smarty
if ($this->debugging)
{
// capture time for debugging info
- $_params = array();
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
+ $_params = array();
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php');
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php');
$_smarty_results .= smarty_core_display_debug_console($_params, $this);
}
if ($this->cache_modified_check) {
@@ -1253,12 +1253,12 @@ class Smarty
echo $_smarty_results;
}
} else {
- echo $_smarty_results;
+ echo $_smarty_results;
}
error_reporting($_smarty_old_error_level);
// restore initial cache_info
$this->_cache_info = array_pop($_cache_info);
- return true;
+ return true;
} else {
error_reporting($_smarty_old_error_level);
// restore initial cache_info
@@ -1271,15 +1271,15 @@ class Smarty
header("Last-Modified: ".gmdate('D, d M Y H:i:s', time()).' GMT');
}
}
- }
-
- // load filters that are marked as autoload
+ }
+
+ // load filters that are marked as autoload
if (count($this->autoload_filters)) {
- foreach ($this->autoload_filters as $_filter_type => $_filters) {
- foreach ($_filters as $_filter) {
- $this->load_filter($_filter_type, $_filter);
- }
- }
+ foreach ($this->autoload_filters as $_filter_type => $_filters) {
+ foreach ($_filters as $_filter) {
+ $this->load_filter($_filter_type, $_filter);
+ }
+ }
}
$_smarty_compile_path = $this->_get_compile_path($resource_name);
@@ -1290,14 +1290,14 @@ class Smarty
$this->_cache_including = false;
if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) {
if ($this->_is_compiled($resource_name, $_smarty_compile_path)
- || $this->_compile_resource($resource_name, $_smarty_compile_path))
+ || $this->_compile_resource($resource_name, $_smarty_compile_path))
{
include($_smarty_compile_path);
}
} else {
ob_start();
if ($this->_is_compiled($resource_name, $_smarty_compile_path)
- || $this->_compile_resource($resource_name, $_smarty_compile_path))
+ || $this->_compile_resource($resource_name, $_smarty_compile_path))
{
include($_smarty_compile_path);
}
@@ -1310,14 +1310,14 @@ class Smarty
}
if ($this->caching) {
- $_params = array('tpl_file' => $resource_name,
- 'cache_id' => $cache_id,
- 'compile_id' => $compile_id,
- 'results' => $_smarty_results);
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_cache_file.php');
- smarty_core_write_cache_file($_params, $this);
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php');
- $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
+ $_params = array('tpl_file' => $resource_name,
+ 'cache_id' => $cache_id,
+ 'compile_id' => $compile_id,
+ 'results' => $_smarty_results);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_cache_file.php');
+ smarty_core_write_cache_file($_params, $this);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php');
+ $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
if ($this->_cache_serials) {
// strip nocache-tags from output
@@ -1334,10 +1334,10 @@ class Smarty
if (isset($_smarty_results)) { echo $_smarty_results; }
if ($this->debugging) {
// capture time for debugging info
- $_params = array();
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
+ $_params = array();
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time);
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php');
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php');
echo smarty_core_display_debug_console($_params, $this);
}
error_reporting($_smarty_old_error_level);
@@ -1354,11 +1354,11 @@ class Smarty
* @param string $file
* @param string $section
* @param string $scope
- */
+ */
function config_load($file, $section = null, $scope = 'global')
{
- require_once($this->_get_plugin_filepath('function', 'config_load'));
- smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this);
+ require_once($this->_get_plugin_filepath('function', 'config_load'));
+ smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this);
}
/**
@@ -1366,22 +1366,22 @@ class Smarty
*
* @param string $name
* @return object
- */
- function &get_registered_object($name) {
- if (!isset($this->_reg_objects[$name]))
- $this->_trigger_fatal_error("'$name' is not a registered object");
+ */
+ function &get_registered_object($name) {
+ if (!isset($this->_reg_objects[$name]))
+ $this->_trigger_fatal_error("'$name' is not a registered object");
- if (!is_object($this->_reg_objects[$name][0]))
- $this->_trigger_fatal_error("registered '$name' is not an object");
+ if (!is_object($this->_reg_objects[$name][0]))
+ $this->_trigger_fatal_error("registered '$name' is not an object");
- return $this->_reg_objects[$name][0];
- }
+ return $this->_reg_objects[$name][0];
+ }
/**
* clear configuration values
*
* @param string $var
- */
+ */
function clear_config($var = null)
{
if(!isset($var)) {
@@ -1389,9 +1389,9 @@ class Smarty
$this->_config = array(array('vars' => array(),
'files' => array()));
} else {
- unset($this->_config[0]['vars'][$var]);
+ unset($this->_config[0]['vars'][$var]);
}
- }
+ }
/**
* Quote subpattern references
@@ -1413,18 +1413,18 @@ class Smarty
*/
function _get_plugin_filepath($type, $name)
{
- $_params = array('type' => $type, 'name' => $name);
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assemble_plugin_filepath.php');
- return smarty_core_assemble_plugin_filepath($_params, $this);
- }
-
+ $_params = array('type' => $type, 'name' => $name);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assemble_plugin_filepath.php');
+ return smarty_core_assemble_plugin_filepath($_params, $this);
+ }
+
/**
* test if resource needs compiling
*
* @param string $resource_name
* @param string $compile_path
* @return boolean
- */
+ */
function _is_compiled($resource_name, $compile_path)
{
if (!$this->force_compile && file_exists($compile_path)) {
@@ -1433,7 +1433,7 @@ class Smarty
return true;
} else {
// get file source and timestamp
- $_params = array('resource_name' => $resource_name, 'get_source'=>false);
+ $_params = array('resource_name' => $resource_name, 'get_source'=>false);
if (!$this->_fetch_resource_info($_params, $this)) {
return false;
}
@@ -1441,7 +1441,7 @@ class Smarty
// template not expired, no recompile
return true;
} else {
- // compile template
+ // compile template
return false;
}
}
@@ -1457,37 +1457,37 @@ class Smarty
* @param string $resource_name
* @param string $compile_path
* @return boolean
- */
+ */
function _compile_resource($resource_name, $compile_path)
{
-
- $_params = array('resource_name' => $resource_name);
+
+ $_params = array('resource_name' => $resource_name);
if (!$this->_fetch_resource_info($_params)) {
return false;
}
- $_source_content = $_params['source_content'];
- $_resource_timestamp = $_params['resource_timestamp'];
- $_cache_include = substr($compile_path, 0, -4).'.inc';
+ $_source_content = $_params['source_content'];
+ $_resource_timestamp = $_params['resource_timestamp'];
+ $_cache_include = substr($compile_path, 0, -4).'.inc';
if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) {
// if a _cache_serial was set, we also have to write an include-file:
if ($this->_cache_include_info) {
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_include.php');
smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content)), $this);
- }
+ }
+
+ $_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content, 'resource_timestamp' => $_resource_timestamp);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php');
+ smarty_core_write_compiled_resource($_params, $this);
- $_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content, 'resource_timestamp' => $_resource_timestamp);
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php');
- smarty_core_write_compiled_resource($_params, $this);
-
return true;
} else {
$this->trigger_error($smarty_compiler->_error_msg);
return false;
- }
+ }
- }
+ }
/**
* compile the given source
@@ -1496,7 +1496,7 @@ class Smarty
* @param string $source_content
* @param string $compiled_content
* @return boolean
- */
+ */
function _compile_source($resource_name, &$source_content, &$compiled_content, $cache_include_path=null)
{
if (file_exists(SMARTY_DIR . $this->compiler_file)) {
@@ -1528,14 +1528,14 @@ class Smarty
$smarty_compiler->_tpl_vars = &$this->_tpl_vars;
$smarty_compiler->default_modifiers = $this->default_modifiers;
$smarty_compiler->compile_id = $this->_compile_id;
- $smarty_compiler->_config = $this->_config;
+ $smarty_compiler->_config = $this->_config;
$smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals;
$smarty_compiler->_cache_serial = null;
$smarty_compiler->_cache_include = $cache_include_path;
-
- $_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
+
+ $_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
if ($smarty_compiler->_cache_serial) {
$this->_cache_include_info = array(
@@ -1548,15 +1548,15 @@ class Smarty
}
- return $_results;
- }
-
+ return $_results;
+ }
+
/**
* Get the compile path for this resource
*
* @param string $resource_name
* @return string results of {@link _get_auto_filename()}
- */
+ */
function _get_compile_path($resource_name)
{
return $this->_get_auto_filename($this->compile_dir, $resource_name,
@@ -1599,7 +1599,7 @@ class Smarty
$_return = is_file($_resource_name);
break;
- default:
+ default:
// call resource functions to fetch the template source and timestamp
if ($params['get_source']) {
$_source_return = isset($this->_plugins['resource'][$_resource_type]) &&
@@ -1617,7 +1617,7 @@ class Smarty
break;
}
}
-
+
if (!$_return) {
// see if we can get a template with the default template handler
if (!empty($this->default_template_handler_func)) {
@@ -1658,13 +1658,13 @@ class Smarty
* @param string $resource_name
* @return boolean
*/
-
+
function _parse_resource_name(&$params)
{
-
+
// split tpl_path by the first colon
$_resource_name_parts = explode(':', $params['resource_name'], 2);
-
+
if (count($_resource_name_parts) == 1) {
// no resource type given
$params['resource_type'] = $this->default_resource_type;
@@ -1673,19 +1673,19 @@ class Smarty
if(strlen($_resource_name_parts[0]) == 1) {
// 1 char is not resource type, but part of filepath
$params['resource_type'] = $this->default_resource_type;
- $params['resource_name'] = $params['resource_name'];
+ $params['resource_name'] = $params['resource_name'];
} else {
$params['resource_type'] = $_resource_name_parts[0];
$params['resource_name'] = $_resource_name_parts[1];
}
- }
-
+ }
+
if ($params['resource_type'] == 'file') {
if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $params['resource_name'])) {
// relative pathname to $params['resource_base_path']
// use the first directory where the file is found
if (isset($params['resource_base_path'])) {
- $_resource_base_path = (array)$params['resource_base_path'];
+ $_resource_base_path = (array)$params['resource_base_path'];
} else {
$_resource_base_path = (array)$this->template_dir;
$_resource_base_path[] = '.';
@@ -1743,7 +1743,7 @@ class Smarty
*
* @param string $string
* @return string
- */
+ */
function _dequote($string)
{
if (($string{0} == "'" || $string{0} == '"') &&
@@ -1762,7 +1762,7 @@ class Smarty
* @param integer $start
* @param integer $lines
* @return string
- */
+ */
function _read_file($filename, $start=null, $lines=null)
{
if (!($fd = @fopen($filename, 'r'))) {
@@ -1847,14 +1847,14 @@ class Smarty
*
* @param string $resource
* @param integer $exp_time
- */
+ */
function _unlink($resource, $exp_time = null)
{
if(isset($exp_time)) {
if(time() - @filemtime($resource) >= $exp_time) {
return @unlink($resource);
}
- } else {
+ } else {
return @unlink($resource);
}
}
@@ -1867,12 +1867,12 @@ class Smarty
* @return string|null
*/
function _get_auto_id($cache_id=null, $compile_id=null) {
- if (isset($cache_id))
- return (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id;
- elseif(isset($compile_id))
- return $compile_id;
- else
- return null;
+ if (isset($cache_id))
+ return (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id;
+ elseif(isset($compile_id))
+ return $compile_id;
+ else
+ return null;
}
/**
@@ -1884,7 +1884,7 @@ class Smarty
* @param string $file
* @param integer $line
* @param integer $error_type
- */
+ */
function _trigger_fatal_error($error_msg, $tpl_file = null, $tpl_line = null,
$file = null, $line = null, $error_type = E_USER_ERROR)
{
@@ -1922,9 +1922,9 @@ class Smarty
* @param string $_smarty_include_tpl_file
* @param string $_smarty_include_vars
*/
-
+
// $_smarty_include_tpl_file, $_smarty_include_vars
-
+
function _smarty_include($params)
{
if ($this->debugging) {
diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php
index df583249..518f706d 100644
--- a/libs/Smarty_Compiler.class.php
+++ b/libs/Smarty_Compiler.class.php
@@ -60,26 +60,26 @@ class Smarty_Compiler extends Smarty {
var $_capture_stack = array(); // keeps track of nested capture buffers
var $_plugin_info = array(); // keeps track of plugins to load
var $_init_smarty_vars = false;
- var $_permitted_tokens = array('true','false','yes','no','on','off','null');
- var $_output_type = 'php';
- var $_db_qstr_regexp = null; // regexps are setup in the constructor
- var $_si_qstr_regexp = null;
- var $_qstr_regexp = null;
- var $_func_regexp = null;
- var $_var_bracket_regexp = null;
- var $_dvar_guts_regexp = null;
- var $_dvar_regexp = null;
- var $_cvar_regexp = null;
- var $_svar_regexp = null;
- var $_avar_regexp = null;
- var $_mod_regexp = null;
- var $_var_regexp = null;
- var $_parenth_param_regexp = null;
- var $_func_call_regexp = null;
- var $_obj_ext_regexp = null;
- var $_obj_start_regexp = null;
- var $_obj_params_regexp = null;
- var $_obj_call_regexp = null;
+ var $_permitted_tokens = array('true','false','yes','no','on','off','null');
+ var $_output_type = 'php';
+ var $_db_qstr_regexp = null; // regexps are setup in the constructor
+ var $_si_qstr_regexp = null;
+ var $_qstr_regexp = null;
+ var $_func_regexp = null;
+ var $_var_bracket_regexp = null;
+ var $_dvar_guts_regexp = null;
+ var $_dvar_regexp = null;
+ var $_cvar_regexp = null;
+ var $_svar_regexp = null;
+ var $_avar_regexp = null;
+ var $_mod_regexp = null;
+ var $_var_regexp = null;
+ var $_parenth_param_regexp = null;
+ var $_func_call_regexp = null;
+ var $_obj_ext_regexp = null;
+ var $_obj_start_regexp = null;
+ var $_obj_params_regexp = null;
+ var $_obj_call_regexp = null;
var $_cacheable_state = 0;
var $_cache_attrs_count = 0;
@@ -91,144 +91,144 @@ class Smarty_Compiler extends Smarty {
var $_additional_newline = "\n";
/**#@-*/
- /**
- * The class constructor.
- */
+ /**
+ * The class constructor.
+ */
function Smarty_Compiler()
{
- // matches double quoted strings:
- // "foobar"
- // "foo\"bar"
- $this->_db_qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"';
+ // matches double quoted strings:
+ // "foobar"
+ // "foo\"bar"
+ $this->_db_qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"';
- // matches single quoted strings:
- // 'foobar'
- // 'foo\'bar'
- $this->_si_qstr_regexp = '\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
+ // matches single quoted strings:
+ // 'foobar'
+ // 'foo\'bar'
+ $this->_si_qstr_regexp = '\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
- // matches single or double quoted strings
- $this->_qstr_regexp = '(?:' . $this->_db_qstr_regexp . '|' . $this->_si_qstr_regexp . ')';
+ // matches single or double quoted strings
+ $this->_qstr_regexp = '(?:' . $this->_db_qstr_regexp . '|' . $this->_si_qstr_regexp . ')';
- // matches bracket portion of vars
- // [0]
- // [foo]
- // [$bar]
- $this->_var_bracket_regexp = '\[\$?[\w\.]+\]';
-
- // matches $ vars (not objects):
- // $foo
- // $foo.bar
- // $foo.bar.foobar
- // $foo[0]
- // $foo[$bar]
- // $foo[5][blah]
- // $foo[5].bar[$foobar][4]
- $this->_dvar_math_regexp = '[\+\-\*\/\%]';
- $this->_dvar_math_var_regexp = '[\$\w\.\+\-\*\/\%\d\|\>\[\]]';
- $this->_dvar_num_var_regexp = '\-?\d+(?:\.\d+)?' . $this->_dvar_math_var_regexp;
- $this->_dvar_guts_regexp = '\w+(?:' . $this->_var_bracket_regexp
- . ')*(?:\.\$?\w+(?:' . $this->_var_bracket_regexp . ')*)*(?:' . $this->_dvar_math_regexp . '(?:\-?\d+(?:\.\d+)?|' . $this->_dvar_math_var_regexp . '*))?';
- $this->_dvar_regexp = '\$' . $this->_dvar_guts_regexp;
+ // matches bracket portion of vars
+ // [0]
+ // [foo]
+ // [$bar]
+ $this->_var_bracket_regexp = '\[\$?[\w\.]+\]';
- // matches config vars:
- // #foo#
- // #foobar123_foo#
- $this->_cvar_regexp = '\#\w+\#';
+ // matches $ vars (not objects):
+ // $foo
+ // $foo.bar
+ // $foo.bar.foobar
+ // $foo[0]
+ // $foo[$bar]
+ // $foo[5][blah]
+ // $foo[5].bar[$foobar][4]
+ $this->_dvar_math_regexp = '[\+\-\*\/\%]';
+ $this->_dvar_math_var_regexp = '[\$\w\.\+\-\*\/\%\d\|\>\[\]]';
+ $this->_dvar_num_var_regexp = '\-?\d+(?:\.\d+)?' . $this->_dvar_math_var_regexp;
+ $this->_dvar_guts_regexp = '\w+(?:' . $this->_var_bracket_regexp
+ . ')*(?:\.\$?\w+(?:' . $this->_var_bracket_regexp . ')*)*(?:' . $this->_dvar_math_regexp . '(?:\-?\d+(?:\.\d+)?|' . $this->_dvar_math_var_regexp . '*))?';
+ $this->_dvar_regexp = '\$' . $this->_dvar_guts_regexp;
- // matches section vars:
- // %foo.bar%
- $this->_svar_regexp = '\%\w+\.\w+\%';
+ // matches config vars:
+ // #foo#
+ // #foobar123_foo#
+ $this->_cvar_regexp = '\#\w+\#';
- // matches all valid variables (no quotes, no modifiers)
- $this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|'
- . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')';
+ // matches section vars:
+ // %foo.bar%
+ $this->_svar_regexp = '\%\w+\.\w+\%';
- // matches valid variable syntax:
- // $foo
- // $foo
- // #foo#
- // #foo#
- // "text"
- // "text"
- $this->_var_regexp = '(?:' . $this->_avar_regexp . '|' . $this->_qstr_regexp . ')';
-
- // matches valid object call (no objects allowed in parameters):
- // $foo->bar
- // $foo->bar()
- // $foo->bar("text")
- // $foo->bar($foo, $bar, "text")
- // $foo->bar($foo, "foo")
- // $foo->bar->foo()
- // $foo->bar->foo->bar()
- $this->_obj_ext_regexp = '\->(?:\$?' . $this->_dvar_guts_regexp . ')';
- $this->_obj_params_regexp = '\((?:\w+|'
- . $this->_var_regexp . '(?:\s*,\s*(?:(?:\w+|'
- . $this->_var_regexp . ')))*)?\)';
- $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)';
- $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?)';
+ // matches all valid variables (no quotes, no modifiers)
+ $this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|'
+ . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')';
- // matches valid modifier syntax:
- // |foo
- // |@foo
- // |foo:"bar"
- // |foo:$bar
- // |foo:"bar":$foobar
- // |foo|bar
- // |foo:$foo->bar
- $this->_mod_regexp = '(?:\|@?\w+(?::(?>-?\w+|'
- . $this->_obj_call_regexp . '|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)';
-
- // matches valid function name:
- // foo123
- // _foo_bar
- $this->_func_regexp = '[a-zA-Z_]\w*';
+ // matches valid variable syntax:
+ // $foo
+ // $foo
+ // #foo#
+ // #foo#
+ // "text"
+ // "text"
+ $this->_var_regexp = '(?:' . $this->_avar_regexp . '|' . $this->_qstr_regexp . ')';
- // matches valid registered object:
- // foo->bar
- $this->_reg_obj_regexp = '[a-zA-Z_]\w*->[a-zA-Z_]\w*';
-
- // matches valid parameter values:
- // true
- // $foo
- // $foo|bar
- // #foo#
- // #foo#|bar
- // "text"
- // "text"|bar
- // $foo->bar
- $this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|'
- . $this->_var_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)';
-
- // matches valid parenthesised function parameters:
- //
- // "text"
- // $foo, $bar, "text"
- // $foo|bar, "foo"|bar, $foo->bar($foo)|bar
- $this->_parenth_param_regexp = '(?:\((?:\w+|'
- . $this->_param_regexp . '(?:\s*,\s*(?:(?:\w+|'
- . $this->_param_regexp . ')))*)?\))';
-
- // matches valid function call:
- // foo()
- // foo_bar($foo)
- // _foo_bar($foo,"bar")
- // foo123($foo,$foo->bar(),"foo")
- $this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:'
- . $this->_parenth_param_regexp . '))';
- }
-
- /**
- * compile a resource
- *
+ // matches valid object call (no objects allowed in parameters):
+ // $foo->bar
+ // $foo->bar()
+ // $foo->bar("text")
+ // $foo->bar($foo, $bar, "text")
+ // $foo->bar($foo, "foo")
+ // $foo->bar->foo()
+ // $foo->bar->foo->bar()
+ $this->_obj_ext_regexp = '\->(?:\$?' . $this->_dvar_guts_regexp . ')';
+ $this->_obj_params_regexp = '\((?:\w+|'
+ . $this->_var_regexp . '(?:\s*,\s*(?:(?:\w+|'
+ . $this->_var_regexp . ')))*)?\)';
+ $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)';
+ $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?)';
+
+ // matches valid modifier syntax:
+ // |foo
+ // |@foo
+ // |foo:"bar"
+ // |foo:$bar
+ // |foo:"bar":$foobar
+ // |foo|bar
+ // |foo:$foo->bar
+ $this->_mod_regexp = '(?:\|@?\w+(?::(?>-?\w+|'
+ . $this->_obj_call_regexp . '|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)';
+
+ // matches valid function name:
+ // foo123
+ // _foo_bar
+ $this->_func_regexp = '[a-zA-Z_]\w*';
+
+ // matches valid registered object:
+ // foo->bar
+ $this->_reg_obj_regexp = '[a-zA-Z_]\w*->[a-zA-Z_]\w*';
+
+ // matches valid parameter values:
+ // true
+ // $foo
+ // $foo|bar
+ // #foo#
+ // #foo#|bar
+ // "text"
+ // "text"|bar
+ // $foo->bar
+ $this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|'
+ . $this->_var_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)';
+
+ // matches valid parenthesised function parameters:
+ //
+ // "text"
+ // $foo, $bar, "text"
+ // $foo|bar, "foo"|bar, $foo->bar($foo)|bar
+ $this->_parenth_param_regexp = '(?:\((?:\w+|'
+ . $this->_param_regexp . '(?:\s*,\s*(?:(?:\w+|'
+ . $this->_param_regexp . ')))*)?\))';
+
+ // matches valid function call:
+ // foo()
+ // foo_bar($foo)
+ // _foo_bar($foo,"bar")
+ // foo123($foo,$foo->bar(),"foo")
+ $this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:'
+ . $this->_parenth_param_regexp . '))';
+ }
+
+ /**
+ * compile a resource
+ *
* sets $compiled_content to the compiled source
- * @param string $resource_name
- * @param string $source_content
- * @param string $compiled_content
+ * @param string $resource_name
+ * @param string $source_content
+ * @param string $compiled_content
* @return true
- */
+ */
function _compile_file($resource_name, $source_content, &$compiled_content)
{
-
+
if ($this->security) {
// do not allow php syntax to be executed unless specified
if ($this->php_handling == SMARTY_PHP_ALLOW &&
@@ -257,7 +257,7 @@ class Smarty_Compiler extends Smarty {
}
}
}
-
+
/* Annihilate the comments. */
$source_content = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se",
"'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'",
@@ -274,23 +274,23 @@ class Smarty_Compiler extends Smarty {
$this->_php_blocks = $_match[1];
$source_content = preg_replace("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s",
$this->quote_replace($this->left_delimiter.'php'.$this->right_delimiter), $source_content);
-
+
/* Gather all template tags. */
preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $source_content, $_match);
$template_tags = $_match[1];
/* Split content by template tags to obtain non-template content. */
$text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $source_content);
-
+
/* loop through text blocks */
for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) {
/* match anything resembling php tags */
if (preg_match_all('!(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?php[\"\']?)!is', $text_blocks[$curr_tb], $sp_match)) {
- /* replace tags with placeholders to prevent recursive replacements */
- $sp_match[1] = array_unique($sp_match[1]);
- usort($sp_match[1], '_smarty_sort_length');
+ /* replace tags with placeholders to prevent recursive replacements */
+ $sp_match[1] = array_unique($sp_match[1]);
+ usort($sp_match[1], '_smarty_sort_length');
for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
- $text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],'%%%SMARTYSP'.$curr_sp.'%%%',$text_blocks[$curr_tb]);
- }
+ $text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],'%%%SMARTYSP'.$curr_sp.'%%%',$text_blocks[$curr_tb]);
+ }
/* process each one */
for ($curr_sp = 0, $for_max2 = count($sp_match[0]); $curr_sp < $for_max2; $curr_sp++) {
if ($this->php_handling == SMARTY_PHP_PASSTHRU) {
@@ -303,10 +303,10 @@ class Smarty_Compiler extends Smarty {
/* remove php tags */
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '', $text_blocks[$curr_tb]);
} else {
- /* SMARTY_PHP_ALLOW, but echo non php starting tags */
- $sp_match[1][$curr_sp] = preg_replace('%(<\?(?!php|=|$))%i', ''."\n", $sp_match[1][$curr_sp]);
- $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', $sp_match[1][$curr_sp], $text_blocks[$curr_tb]);
- }
+ /* SMARTY_PHP_ALLOW, but echo non php starting tags */
+ $sp_match[1][$curr_sp] = preg_replace('%(<\?(?!php|=|$))%i', ''."\n", $sp_match[1][$curr_sp]);
+ $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', $sp_match[1][$curr_sp], $text_blocks[$curr_tb]);
+ }
}
}
}
@@ -319,14 +319,14 @@ class Smarty_Compiler extends Smarty {
$this->_current_line_no += substr_count($template_tags[$i], "\n");
}
- $compiled_content = '';
-
+ $compiled_content = '';
+
/* Interleave the compiled contents and text blocks to get the final result. */
for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {
- if ($compiled_tags[$i] == '') {
- // tag result empty, remove first newline from following text block
- $text_blocks[$i+1] = preg_replace('!^(\r\n|\r|\n)!', '', $text_blocks[$i+1]);
- }
+ if ($compiled_tags[$i] == '') {
+ // tag result empty, remove first newline from following text block
+ $text_blocks[$i+1] = preg_replace('!^(\r\n|\r|\n)!', '', $text_blocks[$i+1]);
+ }
$compiled_content .= $text_blocks[$i].$compiled_tags[$i];
}
$compiled_content .= $text_blocks[$i];
@@ -383,7 +383,7 @@ class Smarty_Compiler extends Smarty {
}
}
$_plugins_params .= '))';
- $plugins_code = "\n";
+ $plugins_code = "\n";
$template_header .= $plugins_code;
$this->_plugin_info = array();
$this->_plugins_code = $plugins_code;
@@ -399,50 +399,50 @@ class Smarty_Compiler extends Smarty {
return true;
}
- /**
- * Compile a template tag
- *
- * @param string $template_tag
+ /**
+ * Compile a template tag
+ *
+ * @param string $template_tag
* @return string
- */
+ */
function _compile_tag($template_tag)
{
- // default to php output
- $this->_output_type = 'php';
-
+ // default to php output
+ $this->_output_type = 'php';
+
/* Matched comment. */
if ($template_tag{0} == '*' && $template_tag{strlen($template_tag) - 1} == '*')
return '';
-
+
/* Split tag into two three parts: command, command modifiers and the arguments. */
if(! preg_match('/^(?:(' . $this->_obj_call_regexp . '|' . $this->_var_regexp
- . '|\/?' . $this->_reg_obj_regexp . '|\/?' . $this->_func_regexp . ')(' . $this->_mod_regexp . '*))
+ . '|\/?' . $this->_reg_obj_regexp . '|\/?' . $this->_func_regexp . ')(' . $this->_mod_regexp . '*))
(?:\s+(.*))?$
/xs', $template_tag, $match)) {
- $this->_syntax_error("unrecognized tag: $template_tag", E_USER_ERROR, __FILE__, __LINE__);
- }
+ $this->_syntax_error("unrecognized tag: $template_tag", E_USER_ERROR, __FILE__, __LINE__);
+ }
$tag_command = $match[1];
$tag_modifier = isset($match[2]) ? $match[2] : null;
$tag_args = isset($match[3]) ? $match[3] : null;
if (preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '$!', $tag_command)) {
- /* tag name is a variable or object */
+ /* tag name is a variable or object */
$_return = $this->_parse_var_props($tag_command . $tag_modifier, $this->_parse_attrs($tag_args));
- if(isset($_tag_attrs['assign'])) {
- return "assign('" . $this->_dequote($_tag_attrs['assign']) . "', $_return ); ?>\n";
- } elseif ($this->_output_type == 'php') {
- return "" . $this->_additional_newline;
- } else {
- // static
- return $_return;
- }
- }
-
- /* If the tag name is a registered object, we process it. */
+ if(isset($_tag_attrs['assign'])) {
+ return "assign('" . $this->_dequote($_tag_attrs['assign']) . "', $_return ); ?>\n";
+ } elseif ($this->_output_type == 'php') {
+ return "" . $this->_additional_newline;
+ } else {
+ // static
+ return $_return;
+ }
+ }
+
+ /* If the tag name is a registered object, we process it. */
if (preg_match('!^\/?' . $this->_reg_obj_regexp . '$!', $tag_command)) {
- return $this->_compile_registered_object_tag($tag_command, $this->_parse_attrs($tag_args), $tag_modifier);
- }
+ return $this->_compile_registered_object_tag($tag_command, $this->_parse_attrs($tag_args), $tag_modifier);
+ }
switch ($tag_command) {
case 'include':
@@ -548,15 +548,15 @@ class Smarty_Compiler extends Smarty {
}
- /**
- * compile the custom compiler tag
- *
+ /**
+ * compile the custom compiler tag
+ *
* sets $output to the compiled custom compiler tag
- * @param string $tag_command
- * @param string $tag_args
- * @param string $output
+ * @param string $tag_command
+ * @param string $tag_args
+ * @param string $output
* @return boolean
- */
+ */
function _compile_compiler_tag($tag_command, $tag_args, &$output)
{
$found = false;
@@ -601,11 +601,11 @@ class Smarty_Compiler extends Smarty {
if ($found) {
if ($have_function) {
$output = call_user_func_array($plugin_func, array($tag_args, &$this));
- if($output != '') {
- $output = '_push_cacheable_state('compiler', $tag_command)
+ if($output != '') {
+ $output = '_push_cacheable_state('compiler', $tag_command)
. $output
. $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>';
- }
+ }
} else {
$this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
}
@@ -616,16 +616,16 @@ class Smarty_Compiler extends Smarty {
}
- /**
- * compile block function tag
- *
+ /**
+ * compile block function tag
+ *
* sets $output to compiled block function tag
- * @param string $tag_command
- * @param string $tag_args
- * @param string $tag_modifier
- * @param string $output
+ * @param string $tag_command
+ * @param string $tag_args
+ * @param string $tag_modifier
+ * @param string $output
* @return boolean
- */
+ */
function _compile_block_tag($tag_command, $tag_args, $tag_modifier, &$output)
{
if ($tag_command{0} == '/') {
@@ -696,50 +696,50 @@ class Smarty_Compiler extends Smarty {
$this->_parse_modifiers($_out_tag_text, $tag_modifier);
}
$output .= 'echo '.$_out_tag_text.'; } ';
- $output .= " array_pop(\$this->_tag_stack); " . $this->_pop_cacheable_state('block', $tag_command) . '?>';
+ $output .= " array_pop(\$this->_tag_stack); " . $this->_pop_cacheable_state('block', $tag_command) . '?>';
}
return true;
}
- /**
- * compile custom function tag
- *
- * @param string $tag_command
- * @param string $tag_args
- * @param string $tag_modifier
+ /**
+ * compile custom function tag
+ *
+ * @param string $tag_command
+ * @param string $tag_args
+ * @param string $tag_modifier
* @return string
- */
+ */
function _compile_custom_tag($tag_command, $tag_args, $tag_modifier)
- {
+ {
$this->_add_plugin('function', $tag_command);
$_cacheable_state = $this->_push_cacheable_state('function', $tag_command);
$attrs = $this->_parse_attrs($tag_args);
$arg_list = $this->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs='');
- $_return = $this->_compile_plugin_call('function', $tag_command).'(array('.implode(',', $arg_list)."), \$this)";
- if($tag_modifier != '') {
- $this->_parse_modifiers($_return, $tag_modifier);
- }
-
- if($_return != '') {
+ $_return = $this->_compile_plugin_call('function', $tag_command).'(array('.implode(',', $arg_list)."), \$this)";
+ if($tag_modifier != '') {
+ $this->_parse_modifiers($_return, $tag_modifier);
+ }
+
+ if($_return != '') {
$_return = '_pop_cacheable_state('function', $tag_command) . "?>" . $this->_additional_newline;
- }
-
- return $_return;
+ }
+
+ return $_return;
}
- /**
- * compile a registered object tag
- *
- * @param string $tag_command
- * @param array $attrs
- * @param string $tag_modifier
+ /**
+ * compile a registered object tag
+ *
+ * @param string $tag_command
+ * @param array $attrs
+ * @param string $tag_modifier
* @return string
- */
+ */
function _compile_registered_object_tag($tag_command, $attrs, $tag_modifier)
{
if ($tag_command{0} == '/') {
@@ -749,23 +749,23 @@ class Smarty_Compiler extends Smarty {
$start_tag = true;
}
- list($object, $obj_comp) = explode('->', $tag_command);
+ list($object, $obj_comp) = explode('->', $tag_command);
$arg_list = array();
- if(count($attrs)) {
- $_assign_var = false;
- foreach ($attrs as $arg_name => $arg_value) {
- if($arg_name == 'assign') {
- $_assign_var = $arg_value;
- unset($attrs['assign']);
- continue;
- }
- if (is_bool($arg_value))
- $arg_value = $arg_value ? 'true' : 'false';
- $arg_list[] = "'$arg_name' => $arg_value";
- }
- }
-
+ if(count($attrs)) {
+ $_assign_var = false;
+ foreach ($attrs as $arg_name => $arg_value) {
+ if($arg_name == 'assign') {
+ $_assign_var = $arg_value;
+ unset($attrs['assign']);
+ continue;
+ }
+ if (is_bool($arg_value))
+ $arg_value = $arg_value ? 'true' : 'false';
+ $arg_list[] = "'$arg_name' => $arg_value";
+ }
+ }
+
if($this->_reg_objects[$object][2]) {
// smarty object argument format
$args = "array(".implode(',', (array)$arg_list)."), \$this";
@@ -780,21 +780,21 @@ class Smarty_Compiler extends Smarty {
$prefix = '';
$postfix = '';
$newline = '';
- if(!is_object($this->_reg_objects[$object][0])) {
- $this->_trigger_fatal_error("registered '$object' is not an object");
- } elseif(!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) {
- $this->_trigger_fatal_error("'$obj_comp' is not a registered component of object '$object'");
- } elseif(method_exists($this->_reg_objects[$object][0], $obj_comp)) {
- // method
+ if(!is_object($this->_reg_objects[$object][0])) {
+ $this->_trigger_fatal_error("registered '$object' is not an object");
+ } elseif(!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) {
+ $this->_trigger_fatal_error("'$obj_comp' is not a registered component of object '$object'");
+ } elseif(method_exists($this->_reg_objects[$object][0], $obj_comp)) {
+ // method
if(in_array($obj_comp, $this->_reg_objects[$object][3])) {
- // block method
+ // block method
if ($start_tag) {
$prefix = "\$this->_tag_stack[] = array('$obj_comp', $args); ";
$prefix .= "\$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], null, \$this, \$_block_repeat=true); ";
$prefix .= "while (\$_block_repeat) { ob_start();";
$return = null;
$postfix = '';
- } else {
+ } else {
$prefix = "\$this->_obj_block_content = ob_get_contents(); ob_end_clean(); ";
$return = "\$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], \$this->_obj_block_content, \$this, \$_block_repeat=false)";
$postfix = "} array_pop(\$this->_tag_stack);";
@@ -802,11 +802,11 @@ class Smarty_Compiler extends Smarty {
} else {
// non-block method
$return = "\$this->_reg_objects['$object'][0]->$obj_comp($args)";
- }
- } else {
- // property
- $return = "\$this->_reg_objects['$object'][0]->$obj_comp";
- }
+ }
+ } else {
+ // property
+ $return = "\$this->_reg_objects['$object'][0]->$obj_comp";
+ }
if($return != null) {
if($tag_modifier != '') {
@@ -826,12 +826,12 @@ class Smarty_Compiler extends Smarty {
return '" . $newline;
}
- /**
- * Compile {insert ...} tag
- *
- * @param string $tag_args
+ /**
+ * Compile {insert ...} tag
+ *
+ * @param string $tag_args
* @return string
- */
+ */
function _compile_insert_tag($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -844,8 +844,8 @@ class Smarty_Compiler extends Smarty {
if (!empty($attrs['script'])) {
$delayed_loading = true;
} else {
- $delayed_loading = false;
- }
+ $delayed_loading = false;
+ }
foreach ($attrs as $arg_name => $arg_value) {
if (is_bool($arg_value))
@@ -855,17 +855,17 @@ class Smarty_Compiler extends Smarty {
$this->_add_plugin('insert', $name, $delayed_loading);
- $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))";
-
+ $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))";
+
return "" . $this->_additional_newline;
}
- /**
- * Compile {include ...} tag
- *
- * @param string $tag_args
+ /**
+ * Compile {include ...} tag
+ *
+ * @param string $tag_args
* @return string
- */
+ */
function _compile_include_tag($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -891,34 +891,34 @@ class Smarty_Compiler extends Smarty {
$output = '_tpl_vars;\n";
-
-
- $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))";
- $output .= "\$this->_smarty_include($_params);\n" .
+
+
+ $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))";
+ $output .= "\$this->_smarty_include($_params);\n" .
"\$this->_tpl_vars = \$_smarty_tpl_vars;\n" .
"unset(\$_smarty_tpl_vars);\n";
if (isset($assign_var)) {
- $output .= "\$this->assign(" . $assign_var . ", ob_get_contents()); ob_end_clean();\n";
+ $output .= "\$this->assign(" . $assign_var . ", ob_get_contents()); ob_end_clean();\n";
}
$output .= ' ?>';
- return $output;
+ return $output;
}
- /**
- * Compile {include ...} tag
- *
- * @param string $tag_args
+ /**
+ * Compile {include ...} tag
+ *
+ * @param string $tag_args
* @return string
- */
+ */
function _compile_include_php_tag($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -927,29 +927,29 @@ class Smarty_Compiler extends Smarty {
$this->_syntax_error("missing 'file' attribute in include_php tag", E_USER_ERROR, __FILE__, __LINE__);
}
- $assign_var = $this->_dequote($attrs['assign']);
- $once_var = ( $attrs['once'] == 'false' ) ? 'false' : 'true';
-
- foreach($attrs as $arg_name => $arg_value) {
- if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') {
- if(is_bool($arg_value))
- $arg_value = $arg_value ? 'true' : 'false';
- $arg_list[] = "'$arg_name' => $arg_value";
- }
- }
+ $assign_var = $this->_dequote($attrs['assign']);
+ $once_var = ( $attrs['once'] == 'false' ) ? 'false' : 'true';
- $_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))";
-
- return "" . $this->_additional_newline;
+ foreach($attrs as $arg_name => $arg_value) {
+ if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') {
+ if(is_bool($arg_value))
+ $arg_value = $arg_value ? 'true' : 'false';
+ $arg_list[] = "'$arg_name' => $arg_value";
+ }
+ }
+
+ $_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))";
+
+ return "" . $this->_additional_newline;
}
-
- /**
- * Compile {section ...} tag
- *
- * @param string $tag_args
+
+ /**
+ * Compile {section ...} tag
+ *
+ * @param string $tag_args
* @return string
- */
+ */
function _compile_section_start($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -1048,13 +1048,13 @@ class Smarty_Compiler extends Smarty {
return $output;
}
-
- /**
- * Compile {foreach ...} tag.
- *
- * @param string $tag_args
+
+ /**
+ * Compile {foreach ...} tag.
+ *
+ * @param string $tag_args
* @return string
- */
+ */
function _compile_foreach_start($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -1113,13 +1113,13 @@ class Smarty_Compiler extends Smarty {
}
- /**
- * Compile {capture} .. {/capture} tags
- *
- * @param boolean $start true if this is the {capture} tag
- * @param string $tag_args
+ /**
+ * Compile {capture} .. {/capture} tags
+ *
+ * @param boolean $start true if this is the {capture} tag
+ * @param string $tag_args
* @return string
- */
+ */
function _compile_capture_tag($start, $tag_args = '')
{
@@ -1149,39 +1149,39 @@ class Smarty_Compiler extends Smarty {
return $output;
}
- /**
- * Compile {if ...} tag
- *
- * @param string $tag_args
- * @param boolean $elseif if true, uses elseif instead of if
+ /**
+ * Compile {if ...} tag
+ *
+ * @param string $tag_args
+ * @param boolean $elseif if true, uses elseif instead of if
* @return string
- */
+ */
function _compile_if_tag($tag_args, $elseif = false)
{
/* Tokenize args for 'if' tag. */
preg_match_all('/(?>
- ' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*)? | # valid object call
- ' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)? | # var or quoted string
- \-?0[xX][0-9a-fA-F]+|\-?\d+(?:\.\d+)?|\.\d+|!==|===|==|!=|<>|<<|>>|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token
- \b\w+\b | # valid word token
- \S+ # anything else
- )/x', $tag_args, $match);
-
+ ' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*)? | # valid object call
+ ' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)? | # var or quoted string
+ \-?0[xX][0-9a-fA-F]+|\-?\d+(?:\.\d+)?|\.\d+|!==|===|==|!=|<>|<<|>>|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token
+ \b\w+\b | # valid word token
+ \S+ # anything else
+ )/x', $tag_args, $match);
+
$tokens = $match[0];
-
- // make sure we have balanced parenthesis
- $token_count = array_count_values($tokens);
- if(isset($token_count['(']) && $token_count['('] != $token_count[')']) {
- $this->_syntax_error("unbalanced parenthesis in if statement", E_USER_ERROR, __FILE__, __LINE__);
- }
-
+
+ // make sure we have balanced parenthesis
+ $token_count = array_count_values($tokens);
+ if(isset($token_count['(']) && $token_count['('] != $token_count[')']) {
+ $this->_syntax_error("unbalanced parenthesis in if statement", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
$is_arg_stack = array();
for ($i = 0; $i < count($tokens); $i++) {
$token = &$tokens[$i];
-
+
switch (strtolower($token)) {
case '!':
case '%':
@@ -1198,18 +1198,18 @@ class Smarty_Compiler extends Smarty {
case '>=':
case '&&':
case '||':
- case '|':
- case '^':
- case '&':
- case '~':
- case ')':
- case ',':
- case '+':
- case '-':
- case '*':
- case '/':
- case '@':
- break;
+ case '|':
+ case '^':
+ case '&':
+ case '~':
+ case ')':
+ case ',':
+ case '+':
+ case '-':
+ case '*':
+ case '/':
+ case '@':
+ break;
case 'eq':
$token = '==';
@@ -1257,7 +1257,7 @@ class Smarty_Compiler extends Smarty {
case '(':
array_push($is_arg_stack, $i);
break;
-
+
case 'is':
/* If last token was a ')', we operate on the parenthesized
expression. The start of the expression is on the stack.
@@ -1269,14 +1269,14 @@ class Smarty_Compiler extends Smarty {
/* Construct the argument for 'is' expression, so it knows
what to operate on. */
$is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
-
+
/* Pass all tokens from next one until the end to the
'is' expression parsing function. The function will
return modified tokens, where the first one is the result
of the 'is' expression and the rest are the tokens it
- didn't touch. */
+ didn't touch. */
$new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1));
-
+
/* Replace the old tokens with the new ones. */
array_splice($tokens, $is_arg_start, count($tokens), $new_tokens);
@@ -1284,26 +1284,26 @@ class Smarty_Compiler extends Smarty {
current position for the next iteration. */
$i = $is_arg_start;
break;
-
+
default:
- if(preg_match('!^' . $this->_func_regexp . '$!', $token) ) {
- // function call
- if($this->security &&
- !in_array($token, $this->security_settings['IF_FUNCS'])) {
- $this->_syntax_error("(secure mode) '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__);
- }
- } elseif(preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)$!', $token)) {
- // object or variable
- $token = $this->_parse_var_props($token);
- } elseif(is_numeric($token)) {
- // number, skip it
- } else {
- $this->_syntax_error("unidentified token '$token'", E_USER_ERROR, __FILE__, __LINE__);
- }
+ if(preg_match('!^' . $this->_func_regexp . '$!', $token) ) {
+ // function call
+ if($this->security &&
+ !in_array($token, $this->security_settings['IF_FUNCS'])) {
+ $this->_syntax_error("(secure mode) '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ } elseif(preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)$!', $token)) {
+ // object or variable
+ $token = $this->_parse_var_props($token);
+ } elseif(is_numeric($token)) {
+ // number, skip it
+ } else {
+ $this->_syntax_error("unidentified token '$token'", E_USER_ERROR, __FILE__, __LINE__);
+ }
break;
}
}
-
+
if ($elseif)
return '';
else
@@ -1313,7 +1313,7 @@ class Smarty_Compiler extends Smarty {
function _compile_arg_list($type, $name, $attrs, &$cache_code) {
$arg_list = array();
-
+
if (isset($type) && isset($name)
&& isset($this->_plugins[$type])
&& isset($this->_plugins[$type][$name])
@@ -1344,13 +1344,13 @@ class Smarty_Compiler extends Smarty {
return $arg_list;
}
- /**
- * Parse is expression
- *
- * @param string $is_arg
- * @param array $tokens
+ /**
+ * Parse is expression
+ *
+ * @param string $is_arg
+ * @param array $tokens
* @return array
- */
+ */
function _parse_is_expr($is_arg, $tokens)
{
$expr_end = 0;
@@ -1399,36 +1399,36 @@ class Smarty_Compiler extends Smarty {
if ($negate_expr) {
$expr = "!($expr)";
}
-
- array_splice($tokens, 0, $expr_end, $expr);
-
+
+ array_splice($tokens, 0, $expr_end, $expr);
+
return $tokens;
}
- /**
- * Parse attribute string
- *
- * @param string $tag_args
+ /**
+ * Parse attribute string
+ *
+ * @param string $tag_args
* @return array
- */
+ */
function _parse_attrs($tag_args)
{
-
+
/* Tokenize tag attributes. */
preg_match_all('/(?:' . $this->_obj_call_regexp . '|' . $this->_qstr_regexp . ' | (?>[^"\'=\s]+)
)+ |
[=]
/x', $tag_args, $match);
- $tokens = $match[0];
-
+ $tokens = $match[0];
+
$attrs = array();
/* Parse state:
0 - expecting attribute name
1 - expecting '='
2 - expecting attribute value (not '=') */
$state = 0;
-
+
foreach ($tokens as $token) {
switch ($state) {
case 0:
@@ -1457,16 +1457,16 @@ class Smarty_Compiler extends Smarty {
boolean value. */
if (preg_match('!^(on|yes|true)$!', $token)) {
$token = 'true';
- } else if (preg_match('!^(off|no|false)$!', $token)) {
+ } else if (preg_match('!^(off|no|false)$!', $token)) {
$token = 'false';
- } else if ($token == 'null') {
+ } else if ($token == 'null') {
$token = 'null';
- } else if (preg_match('!^-?([0-9]+|0[xX][0-9a-fA-F]+)$!', $token)) {
+ } else if (preg_match('!^-?([0-9]+|0[xX][0-9a-fA-F]+)$!', $token)) {
/* treat integer literally */
- } else if (!preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')*$!', $token)) {
- /* treat as a string, double-quote it escaping quotes */
+ } else if (!preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')*$!', $token)) {
+ /* treat as a string, double-quote it escaping quotes */
$token = '"'.addslashes($token).'"';
- }
+ }
$attrs[$attr_name] = $token;
$state = 0;
@@ -1474,195 +1474,195 @@ class Smarty_Compiler extends Smarty {
$this->_syntax_error("'=' cannot be an attribute value", E_USER_ERROR, __FILE__, __LINE__);
break;
}
- $last_token = $token;
+ $last_token = $token;
+ }
+
+ if($state != 0) {
+ if($state == 1) {
+ $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
+ } else {
+ $this->_syntax_error("missing attribute value", E_USER_ERROR, __FILE__, __LINE__);
+ }
}
- if($state != 0) {
- if($state == 1) {
- $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
- } else {
- $this->_syntax_error("missing attribute value", E_USER_ERROR, __FILE__, __LINE__);
- }
- }
-
$this->_parse_vars_props($attrs);
-
+
return $attrs;
}
- /**
- * compile multiple variables and section properties tokens into
- * PHP code
- *
- * @param array $tokens
- */
+ /**
+ * compile multiple variables and section properties tokens into
+ * PHP code
+ *
+ * @param array $tokens
+ */
function _parse_vars_props(&$tokens)
{
- foreach($tokens as $key => $val) {
- $tokens[$key] = $this->_parse_var_props($val);
- }
- }
-
- /**
- * compile single variable and section properties token into
- * PHP code
- *
- * @param string $val
- * @param string $tag_attrs
- * @return string
- */
- function _parse_var_props($val, $tag_attrs = null)
- {
- $val = trim($val);
-
- if(preg_match('!^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(?:' . $this->_mod_regexp . '*)$!', $val)) {
- // $ variable or object
- return $this->_parse_var($val);
- }
- elseif(preg_match('!^' . $this->_db_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
- // double quoted text
- preg_match('!^(' . $this->_db_qstr_regexp . ')('. $this->_mod_regexp . '*)$!', $val, $match);
- $return = $this->_expand_quoted_text($match[1]);
- if($match[2] != '') {
- $this->_parse_modifiers($return, $match[2]);
- }
- return $return;
- }
- elseif(preg_match('!^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
- // single quoted text
- preg_match('!^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$!', $val, $match);
- if($match[2] != '') {
- $this->_parse_modifiers($match[1], $match[2]);
- return $match[1];
- }
- }
- elseif(preg_match('!^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
- // config var
- return $this->_parse_conf_var($val);
- }
- elseif(preg_match('!^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
- // section var
- return $this->_parse_section_prop($val);
- }
- elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
- // literal string
- return $this->_expand_quoted_text('"' . $val .'"');
- }
- return $val;
+ foreach($tokens as $key => $val) {
+ $tokens[$key] = $this->_parse_var_props($val);
+ }
}
- /**
- * expand quoted text with embedded variables
- *
- * @param string $var_expr
+ /**
+ * compile single variable and section properties token into
+ * PHP code
+ *
+ * @param string $val
+ * @param string $tag_attrs
* @return string
- */
+ */
+ function _parse_var_props($val, $tag_attrs = null)
+ {
+ $val = trim($val);
+
+ if(preg_match('!^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(?:' . $this->_mod_regexp . '*)$!', $val)) {
+ // $ variable or object
+ return $this->_parse_var($val);
+ }
+ elseif(preg_match('!^' . $this->_db_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
+ // double quoted text
+ preg_match('!^(' . $this->_db_qstr_regexp . ')('. $this->_mod_regexp . '*)$!', $val, $match);
+ $return = $this->_expand_quoted_text($match[1]);
+ if($match[2] != '') {
+ $this->_parse_modifiers($return, $match[2]);
+ }
+ return $return;
+ }
+ elseif(preg_match('!^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
+ // single quoted text
+ preg_match('!^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$!', $val, $match);
+ if($match[2] != '') {
+ $this->_parse_modifiers($match[1], $match[2]);
+ return $match[1];
+ }
+ }
+ elseif(preg_match('!^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
+ // config var
+ return $this->_parse_conf_var($val);
+ }
+ elseif(preg_match('!^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
+ // section var
+ return $this->_parse_section_prop($val);
+ }
+ elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
+ // literal string
+ return $this->_expand_quoted_text('"' . $val .'"');
+ }
+ return $val;
+ }
+
+ /**
+ * expand quoted text with embedded variables
+ *
+ * @param string $var_expr
+ * @return string
+ */
function _expand_quoted_text($var_expr)
{
- // if contains unescaped $, expand it
- if(preg_match_all('%(?:\`(?_dvar_guts_regexp . '\`)|(?:(?_dvar_guts_regexp . '\`)|(?:(?_parse_var(str_replace('`','',$_var)) . '."', $var_expr);
- }
+ }
$_return = preg_replace('%\.""|(?_output_type = 'php';
+ // inform the calling expression the return type (php, static)
+ $this->_output_type = 'php';
- $_math_vars = preg_split('!('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')!', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE);
- if(count($_math_vars) > 1)
- {
- $_output = "";
- $_complete_var = "";
- // simple check if there is any math, to stop recursion (due to modifiers with "xx % yy" as parameter)
- $_has_math = false;
- foreach($_math_vars as $_k => $_math_var)
- {
- $_math_var = $_math_vars[$_k];
- if(!empty($_math_var))
- {
- // hit a math operator, so process the stuff which came before it
- if(preg_match('!^' . $this->_dvar_math_regexp . '$!', $_math_var))
- {
- $_has_math = true;
- if(!empty($_complete_var))
- {
- $_output .= $this->_parse_var($_complete_var);
- }
+ $_math_vars = preg_split('!('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')!', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE);
+ if(count($_math_vars) > 1)
+ {
+ $_output = "";
+ $_complete_var = "";
+ // simple check if there is any math, to stop recursion (due to modifiers with "xx % yy" as parameter)
+ $_has_math = false;
+ foreach($_math_vars as $_k => $_math_var)
+ {
+ $_math_var = $_math_vars[$_k];
+ if(!empty($_math_var))
+ {
+ // hit a math operator, so process the stuff which came before it
+ if(preg_match('!^' . $this->_dvar_math_regexp . '$!', $_math_var))
+ {
+ $_has_math = true;
+ if(!empty($_complete_var))
+ {
+ $_output .= $this->_parse_var($_complete_var);
+ }
- // just output the math operator to php
- $_output .= $_math_var;
-
- $_complete_var = "";
- }
- else
- {
- // fetch multiple -> (like $foo->bar->baz ) which wouldn't get fetched else, because it would only get $foo->bar and treat the ->baz as "-" ">baz" then
- for($_i = $_k + 1; $_i <= count($_math_vars); $_i += 2)
- {
- // fetch -> because it gets splitted at - and move it back together
- if( /* prevent notice */ (isset($_math_vars[$_i]) && isset($_math_vars[$_i+1])) && ($_math_vars[$_i] === '-' && $_math_vars[$_i+1]{0} === '>'))
- {
- $_math_var .= $_math_vars[$_i].$_math_vars[$_i+1];
- $_math_vars[$_i] = $_math_vars[$_i+1] = '';
- }
- else
- break;
- }
- $_complete_var .= $_math_var;
- }
- }
- }
- if($_has_math)
- {
- if(!empty($_complete_var))
- $_output .= $this->_parse_var($_complete_var);
+ // just output the math operator to php
+ $_output .= $_math_var;
- return $_output;
- }
- }
+ $_complete_var = "";
+ }
+ else
+ {
+ // fetch multiple -> (like $foo->bar->baz ) which wouldn't get fetched else, because it would only get $foo->bar and treat the ->baz as "-" ">baz" then
+ for($_i = $_k + 1; $_i <= count($_math_vars); $_i += 2)
+ {
+ // fetch -> because it gets splitted at - and move it back together
+ if( /* prevent notice */ (isset($_math_vars[$_i]) && isset($_math_vars[$_i+1])) && ($_math_vars[$_i] === '-' && $_math_vars[$_i+1]{0} === '>'))
+ {
+ $_math_var .= $_math_vars[$_i].$_math_vars[$_i+1];
+ $_math_vars[$_i] = $_math_vars[$_i+1] = '';
+ }
+ else
+ break;
+ }
+ $_complete_var .= $_math_var;
+ }
+ }
+ }
+ if($_has_math)
+ {
+ if(!empty($_complete_var))
+ $_output .= $this->_parse_var($_complete_var);
-
- preg_match('!(' . $this->_dvar_num_var_regexp . '*|' . $this->_obj_call_regexp . '|' . $this->_var_regexp . ')(' . $this->_mod_regexp . '*)$!', $var_expr, $match);
+ return $_output;
+ }
+ }
- // prevent cutting of first digit in the number (we _definitly_ got a number if the first char is a digit)
- if(!is_numeric($match[1]{0}))
- $_var_ref = substr($match[1],1);
- else
- $_var_ref = $match[1];
- $modifiers = $match[2];
+ preg_match('!(' . $this->_dvar_num_var_regexp . '*|' . $this->_obj_call_regexp . '|' . $this->_var_regexp . ')(' . $this->_mod_regexp . '*)$!', $var_expr, $match);
-
- if(!empty($this->default_modifiers) && !preg_match('!(^|\|)smarty:nodefaults($|\|)!',$modifiers)) {
- $_default_mod_string = implode('|',(array)$this->default_modifiers);
- $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers;
- }
+ // prevent cutting of first digit in the number (we _definitly_ got a number if the first char is a digit)
+ if(!is_numeric($match[1]{0}))
+ $_var_ref = substr($match[1],1);
+ else
+ $_var_ref = $match[1];
+
+ $modifiers = $match[2];
+
+
+ if(!empty($this->default_modifiers) && !preg_match('!(^|\|)smarty:nodefaults($|\|)!',$modifiers)) {
+ $_default_mod_string = implode('|',(array)$this->default_modifiers);
+ $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers;
+ }
+
+ // get [foo] and .foo and ->foo and (...) pieces
+ preg_match_all('!(?:^\w+)|' . $this->_obj_params_regexp . '|(?:' . $this->_var_bracket_regexp . ')|->\$?\w+|\.\$?\w+|\S+!', $_var_ref, $match);
- // get [foo] and .foo and ->foo and (...) pieces
- preg_match_all('!(?:^\w+)|' . $this->_obj_params_regexp . '|(?:' . $this->_var_bracket_regexp . ')|->\$?\w+|\.\$?\w+|\S+!', $_var_ref, $match);
-
$_indexes = $match[0];
$_var_name = array_shift($_indexes);
-
+
/* Handle $smarty.* variable references as a special case. */
if ($_var_name == 'smarty') {
/*
@@ -1677,18 +1677,18 @@ class Smarty_Compiler extends Smarty {
$_output = "\$this->_smarty_vars['$_var_name']";
}
} elseif(is_numeric($_var_name) && is_numeric($var_expr{0})) {
- // because . is the operator for accessing arrays thru inidizes we need to put it together again for floating point numbers
- if(count($_indexes) > 0)
- {
- $_var_name .= implode("", $_indexes);
- $_indexes = array();
- }
- $_output = $_var_name;
- } else {
+ // because . is the operator for accessing arrays thru inidizes we need to put it together again for floating point numbers
+ if(count($_indexes) > 0)
+ {
+ $_var_name .= implode("", $_indexes);
+ $_indexes = array();
+ }
+ $_output = $_var_name;
+ } else {
$_output = "\$this->_tpl_vars['$_var_name']";
}
- foreach ($_indexes as $_index) {
+ foreach ($_indexes as $_index) {
if ($_index{0} == '[') {
$_index = substr($_index, 1, -1);
if (is_numeric($_index)) {
@@ -1707,10 +1707,10 @@ class Smarty_Compiler extends Smarty {
else
$_output .= "['" . substr($_index, 1) . "']";
} else if (substr($_index,0,2) == '->') {
- if(substr($_index,2,2) == '__') {
- $this->_syntax_error('call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__);
- } elseif($this->security && substr($_index, 2, 1) == '_') {
- $this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
+ if(substr($_index,2,2) == '__') {
+ $this->_syntax_error('call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__);
+ } elseif($this->security && substr($_index, 2, 1) == '_') {
+ $this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
} elseif ($_index{2} == '$') {
if ($this->security) {
$this->_syntax_error('(secure) call to dynamic object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
@@ -1720,41 +1720,41 @@ class Smarty_Compiler extends Smarty {
} else {
$_output .= $_index;
}
- } elseif ($_index{0} == '(') {
- $_index = $this->_parse_parenth_args($_index);
+ } elseif ($_index{0} == '(') {
+ $_index = $this->_parse_parenth_args($_index);
$_output .= $_index;
} else {
$_output .= $_index;
}
}
-
+
$this->_parse_modifiers($_output, $modifiers);
return $_output;
}
- /**
- * parse arguments in function call parenthesis
- *
- * @param string $parenth_args
+ /**
+ * parse arguments in function call parenthesis
+ *
+ * @param string $parenth_args
* @return string
- */
+ */
function _parse_parenth_args($parenth_args)
{
- preg_match_all('!' . $this->_param_regexp . '!',$parenth_args, $match);
- $match = $match[0];
- rsort($match);
- reset($match);
- $orig_vals = $match;
- $this->_parse_vars_props($match);
- return str_replace($orig_vals, $match, $parenth_args);
- }
-
- /**
- * parse configuration variable expression into PHP code
- *
- * @param string $conf_var_expr
- */
+ preg_match_all('!' . $this->_param_regexp . '!',$parenth_args, $match);
+ $match = $match[0];
+ rsort($match);
+ reset($match);
+ $orig_vals = $match;
+ $this->_parse_vars_props($match);
+ return str_replace($orig_vals, $match, $parenth_args);
+ }
+
+ /**
+ * parse configuration variable expression into PHP code
+ *
+ * @param string $conf_var_expr
+ */
function _parse_conf_var($conf_var_expr)
{
$parts = explode('|', $conf_var_expr, 2);
@@ -1770,12 +1770,12 @@ class Smarty_Compiler extends Smarty {
return $output;
}
- /**
- * parse section property expression into PHP code
- *
- * @param string $section_prop_expr
+ /**
+ * parse section property expression into PHP code
+ *
+ * @param string $section_prop_expr
* @return string
- */
+ */
function _parse_section_prop($section_prop_expr)
{
$parts = explode('|', $section_prop_expr, 2);
@@ -1794,13 +1794,13 @@ class Smarty_Compiler extends Smarty {
}
- /**
- * parse modifier chain into PHP code
- *
+ /**
+ * parse modifier chain into PHP code
+ *
* sets $output to parsed modified chain
- * @param string $output
- * @param string $modifier_string
- */
+ * @param string $output
+ * @param string $modifier_string
+ */
function _parse_modifiers(&$output, $modifier_string)
{
preg_match_all('!\|(@?\w+)((?>:(?:'. $this->_qstr_regexp . '|[^|]+))*)!', '|' . $modifier_string, $_match);
@@ -1808,12 +1808,12 @@ class Smarty_Compiler extends Smarty {
for ($_i = 0, $_for_max = count($_modifiers); $_i < $_for_max; $_i++) {
$_modifier_name = $_modifiers[$_i];
-
- if($_modifier_name == 'smarty') {
- // skip smarty modifier
- continue;
- }
-
+
+ if($_modifier_name == 'smarty') {
+ // skip smarty modifier
+ continue;
+ }
+
preg_match_all('!:(' . $this->_qstr_regexp . '|[^:]+)!', $modifier_arg_strings[$_i], $_match);
$_modifier_args = $_match[1];
@@ -1826,7 +1826,7 @@ class Smarty_Compiler extends Smarty {
$this->_add_plugin('modifier', $_modifier_name);
if (empty($this->_plugins['modifier'][$_modifier_name])
- && !$this->_get_plugin_filepath('modifier', $_modifier_name)
+ && !$this->_get_plugin_filepath('modifier', $_modifier_name)
&& function_exists($_modifier_name)) {
if ($this->security && !in_array($_modifier_name, $this->security_settings['MODIFIER_FUNCS'])) {
$this->_trigger_fatal_error("[plugin] (secure mode) modifier '$_modifier_name' is not allowed" , $_tpl_file, $_tpl_line, __FILE__, __LINE__);
@@ -1837,15 +1837,15 @@ class Smarty_Compiler extends Smarty {
$this->_parse_vars_props($_modifier_args);
- if($_modifier_name == 'default') {
- // supress notifications of default modifier vars and args
- if($output{0} == '$') {
- $output = '@' . $output;
- }
- if(isset($_modifier_args[0]) && $_modifier_args[0]{0} == '$') {
- $_modifier_args[0] = '@' . $_modifier_args[0];
- }
- }
+ if($_modifier_name == 'default') {
+ // supress notifications of default modifier vars and args
+ if($output{0} == '$') {
+ $output = '@' . $output;
+ }
+ if(isset($_modifier_args[0]) && $_modifier_args[0]{0} == '$') {
+ $_modifier_args[0] = '@' . $_modifier_args[0];
+ }
+ }
if (count($_modifier_args) > 0)
$_modifier_args = ', '.implode(', ', $_modifier_args);
else
@@ -1863,13 +1863,13 @@ class Smarty_Compiler extends Smarty {
}
- /**
- * add plugin
- *
- * @param string $type
- * @param string $name
- * @param boolean? $delayed_loading
- */
+ /**
+ * add plugin
+ *
+ * @param string $type
+ * @param string $name
+ * @param boolean? $delayed_loading
+ */
function _add_plugin($type, $name, $delayed_loading = null)
{
if (!isset($this->_plugin_info[$type])) {
@@ -1881,28 +1881,28 @@ class Smarty_Compiler extends Smarty {
$delayed_loading);
}
}
-
- /**
- * Compiles references of type $smarty.foo
- *
- * @param string $indexes
+
+ /**
+ * Compiles references of type $smarty.foo
+ *
+ * @param string $indexes
* @return string
- */
+ */
function _compile_smarty_ref(&$indexes)
{
/* Extract the reference name. */
$_ref = substr($indexes[0], 1);
foreach($indexes as $_index_no=>$_index) {
if ($_index{0} != '.' && $_index_no<2 || !preg_match('!^(\.|\[|->)!', $_index)) {
- $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__);
- }
- }
-
+ $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__);
+ }
+ }
+
switch ($_ref) {
case 'now':
$compiled_ref = 'time()';
- $_max_index = 1;
+ $_max_index = 1;
break;
case 'foreach':
@@ -1957,24 +1957,24 @@ class Smarty_Compiler extends Smarty {
case 'template':
$compiled_ref = "'$this->_current_file'";
- $_max_index = 1;
+ $_max_index = 1;
break;
-
- case 'version':
- $compiled_ref = "'$this->_version'";
- $_max_index = 1;
- break;
- case 'const':
+ case 'version':
+ $compiled_ref = "'$this->_version'";
+ $_max_index = 1;
+ break;
+
+ case 'const':
array_shift($indexes);
- $_val = $this->_parse_var_props(substr($indexes[0],1));
- $compiled_ref = '@constant(' . $_val . ')';
- $_max_index = 1;
+ $_val = $this->_parse_var_props(substr($indexes[0],1));
+ $compiled_ref = '@constant(' . $_val . ')';
+ $_max_index = 1;
break;
case 'config':
$compiled_ref = "\$this->_config[0]['vars']";
- $_max_index = 2;
+ $_max_index = 2;
break;
default:
@@ -2004,7 +2004,7 @@ class Smarty_Compiler extends Smarty {
if (isset($this->_plugins[$type][$name])) {
/* plugin loaded */
if (is_array($this->_plugins[$type][$name][0])) {
- return ((is_object($this->_plugins[$type][$name][0][0])) ?
+ return ((is_object($this->_plugins[$type][$name][0][0])) ?
"\$this->_plugins['$type']['$name'][0][0]->" /* method callback */
: (string)($this->_plugins[$type][$name][0][0]).'::' /* class callback */
). $this->_plugins[$type][$name][0][1];
@@ -2012,26 +2012,26 @@ class Smarty_Compiler extends Smarty {
} else {
/* function callback */
return $this->_plugins[$type][$name][0];
-
+
}
} else {
/* plugin not loaded -> auto-loadable-plugin */
return 'smarty_'.$type.'_'.$name;
-
+
}
}
- /**
- * load pre- and post-filters
- */
+ /**
+ * load pre- and post-filters
+ */
function _load_filters()
{
if (count($this->_plugins['prefilter']) > 0) {
foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) {
if ($prefilter === false) {
unset($this->_plugins['prefilter'][$filter_name]);
- $_params = array('plugins' => array(array('prefilter', $filter_name, null, null, false)));
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
+ $_params = array('plugins' => array(array('prefilter', $filter_name, null, null, false)));
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
smarty_core_load_plugins($_params, $this);
}
}
@@ -2040,8 +2040,8 @@ class Smarty_Compiler extends Smarty {
foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) {
if ($postfilter === false) {
unset($this->_plugins['postfilter'][$filter_name]);
- $_params = array('plugins' => array(array('postfilter', $filter_name, null, null, false)));
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
+ $_params = array('plugins' => array(array('postfilter', $filter_name, null, null, false)));
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
smarty_core_load_plugins($_params, $this);
}
}
@@ -2049,21 +2049,21 @@ class Smarty_Compiler extends Smarty {
}
- /**
- * display Smarty syntax error
- *
- * @param string $error_msg
- * @param integer $error_type
- * @param string $file
- * @param integer $line
- */
+ /**
+ * display Smarty syntax error
+ *
+ * @param string $error_msg
+ * @param integer $error_type
+ * @param string $file
+ * @param integer $line
+ */
function _syntax_error($error_msg, $error_type = E_USER_ERROR, $file=null, $line=null)
{
- if(isset($file) && isset($line)) {
- $info = ' ('.basename($file).", line $line)";
- } else {
- $info = null;
- }
+ if(isset($file) && isset($line)) {
+ $info = ' ('.basename($file).", line $line)";
+ } else {
+ $info = null;
+ }
trigger_error('Smarty: [in ' . $this->_current_file . ' line ' .
$this->_current_line_no . "]: syntax error: $error_msg$info", $error_type);
}
@@ -2085,7 +2085,7 @@ class Smarty_Compiler extends Smarty {
. '}\';}';
return $_ret;
}
-
+
/**
* check if the compilation changes from non-cacheable to
@@ -2114,13 +2114,13 @@ class Smarty_Compiler extends Smarty {
*/
function _smarty_sort_length($a, $b)
{
- if($a == $b)
- return 0;
+ if($a == $b)
+ return 0;
- if(strlen($a) == strlen($b))
- return ($a > $b) ? -1 : 1;
+ if(strlen($a) == strlen($b))
+ return ($a > $b) ? -1 : 1;
- return (strlen($a) > strlen($b)) ? -1 : 1;
+ return (strlen($a) > strlen($b)) ? -1 : 1;
}
diff --git a/libs/core/core.assemble_plugin_filepath.php b/libs/core/core.assemble_plugin_filepath.php
index 65204cc7..ec44f8e4 100644
--- a/libs/core/core.assemble_plugin_filepath.php
+++ b/libs/core/core.assemble_plugin_filepath.php
@@ -11,7 +11,7 @@
* @param string $type
* @param string $name
* @return string|false
- */
+ */
function smarty_core_assemble_plugin_filepath($params, &$smarty)
{
@@ -21,7 +21,7 @@ function smarty_core_assemble_plugin_filepath($params, &$smarty)
foreach ((array)$smarty->plugins_dir as $_plugin_dir) {
$_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
-
+
// see if path is relative
if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) {
$_relative_paths[] = $_plugin_dir;
@@ -38,24 +38,24 @@ function smarty_core_assemble_plugin_filepath($params, &$smarty)
}
}
- if($_return === false) {
+ if($_return === false) {
// still not found, try PHP include_path
if(isset($_relative_paths)) {
foreach ((array)$_relative_paths as $_plugin_dir) {
$_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
- $_params = array('file_path' => $_plugin_filepath);
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');
- if(smarty_core_get_include_path($_params, $smarty)) {
- return $_params['new_file_path'];
+ $_params = array('file_path' => $_plugin_filepath);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');
+ if(smarty_core_get_include_path($_params, $smarty)) {
+ return $_params['new_file_path'];
}
}
}
- }
+ }
return $_return;
-}
+}
/* vim: set expandtab: */
diff --git a/libs/core/core.assign_smarty_interface.php b/libs/core/core.assign_smarty_interface.php
index b2b479ac..7e65a73e 100644
--- a/libs/core/core.assign_smarty_interface.php
+++ b/libs/core/core.assign_smarty_interface.php
@@ -18,7 +18,7 @@ function smarty_core_assign_smarty_interface($params, &$smarty)
{
if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) {
return;
- }
+ }
$_globals_map = array('g' => 'HTTP_GET_VARS',
'p' => 'HTTP_POST_VARS',
diff --git a/libs/core/core.create_dir_structure.php b/libs/core/core.create_dir_structure.php
index 914f3ed4..7642e212 100644
--- a/libs/core/core.create_dir_structure.php
+++ b/libs/core/core.create_dir_structure.php
@@ -12,7 +12,7 @@
*/
// $dir
-
+
function smarty_core_create_dir_structure($params, &$smarty)
{
if (!file_exists($params['dir'])) {
@@ -41,13 +41,13 @@ function smarty_core_create_dir_structure($params, &$smarty)
$_new_dir = str_replace('\\', '/', getcwd()).'/';
}
-
+
if($_use_open_basedir = !empty($_open_basedir_ini)) {
$_open_basedirs = explode(';', str_replace('\\', '/', $_open_basedir_ini));
}
}
-
+
/* all paths use "/" only from here */
foreach ($_dir_parts as $_dir_part) {
$_new_dir .= $_dir_part;
@@ -62,7 +62,7 @@ function smarty_core_create_dir_structure($params, &$smarty)
}
}
} else {
- $_make_new_dir = true;
+ $_make_new_dir = true;
}
if ($_make_new_dir && !file_exists($_new_dir) && !@mkdir($_new_dir, $smarty->_dir_perms) && !is_dir($_new_dir)) {
diff --git a/libs/core/core.display_debug_console.php b/libs/core/core.display_debug_console.php
index 9fa4a0f6..c509ff72 100644
--- a/libs/core/core.display_debug_console.php
+++ b/libs/core/core.display_debug_console.php
@@ -16,43 +16,43 @@
*/
function smarty_core_display_debug_console($params, &$smarty)
{
- // we must force compile the debug template in case the environment
- // changed between separate applications.
+ // we must force compile the debug template in case the environment
+ // changed between separate applications.
- if(empty($smarty->debug_tpl)) {
- // set path to debug template from SMARTY_DIR
- $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
- if($smarty->security && is_file($smarty->debug_tpl)) {
- $smarty->secure_dir[] = dirname(realpath($smarty->debug_tpl));
- }
- }
+ if(empty($smarty->debug_tpl)) {
+ // set path to debug template from SMARTY_DIR
+ $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
+ if($smarty->security && is_file($smarty->debug_tpl)) {
+ $smarty->secure_dir[] = dirname(realpath($smarty->debug_tpl));
+ }
+ }
- $_ldelim_orig = $smarty->left_delimiter;
- $_rdelim_orig = $smarty->right_delimiter;
+ $_ldelim_orig = $smarty->left_delimiter;
+ $_rdelim_orig = $smarty->right_delimiter;
- $smarty->left_delimiter = '{';
- $smarty->right_delimiter = '}';
+ $smarty->left_delimiter = '{';
+ $smarty->right_delimiter = '}';
- $_compile_id_orig = $smarty->_compile_id;
- $smarty->_compile_id = null;
+ $_compile_id_orig = $smarty->_compile_id;
+ $smarty->_compile_id = null;
- $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
- if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path))
- {
- ob_start();
- $smarty->_include($_compile_path);
- $_results = ob_get_contents();
- ob_end_clean();
- } else {
- $_results = '';
- }
-
- $smarty->_compile_id = $_compile_id_orig;
+ $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
+ if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path))
+ {
+ ob_start();
+ $smarty->_include($_compile_path);
+ $_results = ob_get_contents();
+ ob_end_clean();
+ } else {
+ $_results = '';
+ }
- $smarty->left_delimiter = $_ldelim_orig;
- $smarty->right_delimiter = $_rdelim_orig;
+ $smarty->_compile_id = $_compile_id_orig;
- return $_results;
+ $smarty->left_delimiter = $_ldelim_orig;
+ $smarty->right_delimiter = $_rdelim_orig;
+
+ return $_results;
}
/* vim: set expandtab: */
diff --git a/libs/core/core.get_include_path.php b/libs/core/core.get_include_path.php
index 2216d13f..eb7188cd 100644
--- a/libs/core/core.get_include_path.php
+++ b/libs/core/core.get_include_path.php
@@ -15,7 +15,7 @@
*/
// $file_path, &$new_file_path
-
+
function smarty_core_get_include_path(&$params, &$smarty)
{
static $_path_array = null;
@@ -37,7 +37,7 @@ function smarty_core_get_include_path(&$params, &$smarty)
}
}
return false;
-}
+}
/* vim: set expandtab: */
diff --git a/libs/core/core.get_microtime.php b/libs/core/core.get_microtime.php
index c7601c2e..f1a28e04 100644
--- a/libs/core/core.get_microtime.php
+++ b/libs/core/core.get_microtime.php
@@ -8,7 +8,7 @@
/**
* Get seconds and microseconds
* @return double
- */
+ */
function smarty_core_get_microtime($params, &$smarty)
{
$mtime = microtime();
diff --git a/libs/core/core.get_php_resource.php b/libs/core/core.get_php_resource.php
index b2f191bf..8121acf8 100644
--- a/libs/core/core.get_php_resource.php
+++ b/libs/core/core.get_php_resource.php
@@ -13,14 +13,14 @@
* @param string $resource_type
* @param $php_resource
* @return boolean
- */
-
+ */
+
function smarty_core_get_php_resource(&$params, &$smarty)
{
-
- $params['resource_base_path'] = $smarty->trusted_dir;
- $smarty->_parse_resource_name($params, $smarty);
-
+
+ $params['resource_base_path'] = $smarty->trusted_dir;
+ $smarty->_parse_resource_name($params, $smarty);
+
/*
* Find out if the resource exists.
*/
@@ -29,17 +29,17 @@ function smarty_core_get_php_resource(&$params, &$smarty)
$_readable = false;
if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
$_readable = true;
- } else {
+ } else {
// test for file in include_path
- $_params = array('file_path' => $params['resource_name']);
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');
- if(smarty_core_get_include_path($_params, $smarty)) {
- $_include_path = $_params['new_file_path'];
- $_readable = true;
+ $_params = array('file_path' => $params['resource_name']);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');
+ if(smarty_core_get_include_path($_params, $smarty)) {
+ $_include_path = $_params['new_file_path'];
+ $_readable = true;
}
}
} else if ($params['resource_type'] != 'file') {
- $_template_source = null;
+ $_template_source = null;
$_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0])
&& call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0],
array($params['resource_name'], &$_template_source, &$smarty));
@@ -56,7 +56,7 @@ function smarty_core_get_php_resource(&$params, &$smarty)
if ($_readable) {
if ($smarty->security) {
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_trusted.php');
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_trusted.php');
if (!smarty_core_is_trusted($params, $smarty)) {
$smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted');
return false;
diff --git a/libs/core/core.is_secure.php b/libs/core/core.is_secure.php
index 1a88489e..184e8983 100644
--- a/libs/core/core.is_secure.php
+++ b/libs/core/core.is_secure.php
@@ -12,9 +12,9 @@
* @param string $resource_name
* @return boolean
*/
-
+
// $resource_type, $resource_name
-
+
function smarty_core_is_secure($params, &$smarty)
{
if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) {
diff --git a/libs/core/core.is_trusted.php b/libs/core/core.is_trusted.php
index e20897b4..c90e3ef9 100644
--- a/libs/core/core.is_trusted.php
+++ b/libs/core/core.is_trusted.php
@@ -14,8 +14,8 @@
* @param string $resource_type
* @param string $resource_name
* @return boolean
- */
-
+ */
+
// $resource_type, $resource_name
function smarty_core_is_trusted($params, &$smarty)
diff --git a/libs/core/core.load_plugins.php b/libs/core/core.load_plugins.php
index 2338e9bd..6db1dc51 100644
--- a/libs/core/core.load_plugins.php
+++ b/libs/core/core.load_plugins.php
@@ -9,10 +9,10 @@
* Load requested plugins
*
* @param array $plugins
- */
+ */
+
+// $plugins
-// $plugins
-
function smarty_core_load_plugins($params, &$smarty)
{
diff --git a/libs/core/core.load_resource_plugin.php b/libs/core/core.load_resource_plugin.php
index 857d487b..a7d37d1a 100644
--- a/libs/core/core.load_resource_plugin.php
+++ b/libs/core/core.load_resource_plugin.php
@@ -9,10 +9,10 @@
* load a resource plugin
*
* @param string $type
- */
+ */
+
+// $type
-// $type
-
function smarty_core_load_resource_plugin($params, &$smarty)
{
/*
@@ -26,7 +26,7 @@ function smarty_core_load_resource_plugin($params, &$smarty)
if (isset($_plugin)) {
if (!$_plugin[1] && count($_plugin[0])) {
$_plugin[1] = true;
- foreach ($_plugin[0] as $_plugin_func) {
+ foreach ($_plugin[0] as $_plugin_func) {
if (!is_callable($_plugin_func)) {
$_plugin[1] = false;
break;
diff --git a/libs/core/core.process_cached_inserts.php b/libs/core/core.process_cached_inserts.php
index 21ab4e13..2a4994ff 100644
--- a/libs/core/core.process_cached_inserts.php
+++ b/libs/core/core.process_cached_inserts.php
@@ -10,7 +10,7 @@
*
* @param string $results
* @return string
- */
+ */
function smarty_core_process_cached_inserts($params, &$smarty)
{
preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
@@ -19,8 +19,8 @@ function smarty_core_process_cached_inserts($params, &$smarty)
for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
if ($smarty->debugging) {
- $_params = array();
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
+ $_params = array();
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$debug_start_time = smarty_core_get_microtime($_params, $smarty);
}
@@ -28,13 +28,13 @@ function smarty_core_process_cached_inserts($params, &$smarty)
$name = $args['name'];
if (isset($args['script'])) {
- $_params = array('resource_name' => $smarty->_dequote($args['script']));
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php');
- if(!smarty_core_get_php_resource($_params, $smarty)) {
- return false;
- }
- $resource_type = $_params['resource_type'];
- $php_resource = $_params['php_resource'];
+ $_params = array('resource_name' => $smarty->_dequote($args['script']));
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php');
+ if(!smarty_core_get_php_resource($_params, $smarty)) {
+ return false;
+ }
+ $resource_type = $_params['resource_type'];
+ $php_resource = $_params['php_resource'];
if ($resource_type == 'file') {
@@ -49,8 +49,8 @@ function smarty_core_process_cached_inserts($params, &$smarty)
$params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']);
if ($smarty->debugging) {
- $_params = array();
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
+ $_params = array();
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$smarty->_smarty_debug_info[] = array('type' => 'insert',
'filename' => 'insert_'.$name,
'depth' => $smarty->_inclusion_depth,
diff --git a/libs/core/core.process_compiled_include.php b/libs/core/core.process_compiled_include.php
index b1b66d77..3e1d4c15 100644
--- a/libs/core/core.process_compiled_include.php
+++ b/libs/core/core.process_compiled_include.php
@@ -13,7 +13,7 @@
* @param string $cached_source
* @return string
*/
-
+
function smarty_core_process_compiled_include($params, &$smarty)
{
$_cache_including = $smarty->_cache_including;
diff --git a/libs/core/core.read_cache_file.php b/libs/core/core.read_cache_file.php
index 29e5930f..2ba4157b 100644
--- a/libs/core/core.read_cache_file.php
+++ b/libs/core/core.read_cache_file.php
@@ -14,10 +14,10 @@
* @param string $compile_id
* @param string $results
* @return boolean
- */
-
+ */
+
// $tpl_file, $cache_id, $compile_id, &$results
-
+
function smarty_core_read_cache_file(&$params, &$smarty)
{
static $content_cache = array();
@@ -68,7 +68,7 @@ function smarty_core_read_cache_file(&$params, &$smarty)
}
if ($smarty->compile_check) {
- $_params = array('get_source' => false, 'quiet'=>true);
+ $_params = array('get_source' => false, 'quiet'=>true);
foreach (array_keys($_cache_info['template']) as $_template_dep) {
$_params['resource_name'] = $_template_dep;
if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
@@ -93,7 +93,7 @@ function smarty_core_read_cache_file(&$params, &$smarty)
if (empty($smarty->_cache_serials[$_include_file_path])) {
$smarty->_include($_include_file_path, true);
}
-
+
if ($smarty->_cache_serials[$_include_file_path] != $_cache_serial) {
/* regenerate */
return false;
diff --git a/libs/core/core.rm_auto.php b/libs/core/core.rm_auto.php
index e162b187..b7cdaf8c 100644
--- a/libs/core/core.rm_auto.php
+++ b/libs/core/core.rm_auto.php
@@ -13,24 +13,24 @@
* @param string $auto_id
* @param integer $exp_time
* @return boolean
- */
-
+ */
+
// $auto_base, $auto_source = null, $auto_id = null, $exp_time = null
-
+
function smarty_core_rm_auto($params, &$smarty)
-{
+{
if (!@is_dir($params['auto_base']))
return false;
if(!isset($params['auto_id']) && !isset($params['auto_source'])) {
- $_params = array(
- 'dirname' => $params['auto_base'],
- 'level' => 0,
- 'exp_time' => $params['exp_time']
- );
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php');
- $_res = smarty_core_rmdir($_params, $smarty);
- } else {
+ $_params = array(
+ 'dirname' => $params['auto_base'],
+ 'level' => 0,
+ 'exp_time' => $params['exp_time']
+ );
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php');
+ $_res = smarty_core_rmdir($_params, $smarty);
+ } else {
$_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']);
if(isset($params['auto_source'])) {
@@ -42,20 +42,20 @@ function smarty_core_rm_auto($params, &$smarty)
$_res = $smarty->_unlink($_tname, $params['exp_time']);
}
} elseif ($smarty->use_sub_dirs) {
- $_params = array(
- 'dirname' => $_tname,
- 'level' => 1,
- 'exp_time' => $params['exp_time']
- );
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php');
- $_res = smarty_core_rmdir($_params, $smarty);
+ $_params = array(
+ 'dirname' => $_tname,
+ 'level' => 1,
+ 'exp_time' => $params['exp_time']
+ );
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php');
+ $_res = smarty_core_rmdir($_params, $smarty);
} else {
// remove matching file names
$_handle = opendir($params['auto_base']);
- $_res = true;
+ $_res = true;
while (false !== ($_filename = readdir($_handle))) {
if($_filename == '.' || $_filename == '..') {
- continue;
+ continue;
} elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
$_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']);
}
diff --git a/libs/core/core.rmdir.php b/libs/core/core.rmdir.php
index 01c6c6bb..38df822c 100644
--- a/libs/core/core.rmdir.php
+++ b/libs/core/core.rmdir.php
@@ -16,24 +16,24 @@
*/
// $dirname, $level = 1, $exp_time = null
-
+
function smarty_core_rmdir($params, &$smarty)
{
if(!isset($params['level'])) { $params['level'] = 1; }
if(!isset($params['exp_time'])) { $params['exp_time'] = null; }
-
+
if($_handle = @opendir($params['dirname'])) {
while (false !== ($_entry = readdir($_handle))) {
if ($_entry != '.' && $_entry != '..') {
if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) {
- $_params = array(
- 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry,
- 'level' => $params['level'] + 1,
- 'exp_time' => $params['exp_time']
- );
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php');
- smarty_core_rmdir($_params, $smarty);
+ $_params = array(
+ 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry,
+ 'level' => $params['level'] + 1,
+ 'exp_time' => $params['exp_time']
+ );
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php');
+ smarty_core_rmdir($_params, $smarty);
}
else {
$smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']);
diff --git a/libs/core/core.run_insert_handler.php b/libs/core/core.run_insert_handler.php
index e6fcef1a..aa391ab3 100644
--- a/libs/core/core.run_insert_handler.php
+++ b/libs/core/core.run_insert_handler.php
@@ -10,13 +10,13 @@
*
* @param array $args
* @return string
- */
+ */
function smarty_core_run_insert_handler($params, &$smarty)
{
-
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
+
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
if ($smarty->debugging) {
- $_params = array();
+ $_params = array();
$_debug_start_time = smarty_core_get_microtime($_params, $smarty);
}
@@ -32,12 +32,12 @@ function smarty_core_run_insert_handler($params, &$smarty)
}
return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5;
} else {
- if (isset($params['args']['script'])) {
- $_params = array('resource_name' => $smarty->_dequote($params['args']['script']));
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php');
- if(!smarty_core_get_php_resource($_params, $smarty)) {
- return false;
- }
+ if (isset($params['args']['script'])) {
+ $_params = array('resource_name' => $smarty->_dequote($params['args']['script']));
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php');
+ if(!smarty_core_get_php_resource($_params, $smarty)) {
+ return false;
+ }
if ($_params['resource_type'] == 'file') {
$smarty->_include($_params['php_resource'], true);
@@ -50,8 +50,8 @@ function smarty_core_run_insert_handler($params, &$smarty)
$_funcname = $smarty->_plugins['insert'][$params['args']['name']][0];
$_content = $_funcname($params['args'], $smarty);
if ($smarty->debugging) {
- $_params = array();
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
+ $_params = array();
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$smarty->_smarty_debug_info[] = array('type' => 'insert',
'filename' => 'insert_'.$params['args']['name'],
'depth' => $smarty->_inclusion_depth,
diff --git a/libs/core/core.smarty_include_php.php b/libs/core/core.smarty_include_php.php
index 83692e18..4b316480 100644
--- a/libs/core/core.smarty_include_php.php
+++ b/libs/core/core.smarty_include_php.php
@@ -14,7 +14,7 @@
* @param boolean $smarty_once uses include_once if this is true
* @param array $smarty_include_vars associative array of vars from
* {include file="blah" var=$var}
- */
+ */
// $file, $assign, $once, $_smarty_include_vars
diff --git a/libs/core/core.write_compiled_include.php b/libs/core/core.write_compiled_include.php
index 622ff23b..9c6a4919 100644
--- a/libs/core/core.write_compiled_include.php
+++ b/libs/core/core.write_compiled_include.php
@@ -13,18 +13,18 @@
* @param integer $template_timestamp
* @return boolean
*/
-
+
function smarty_core_write_compiled_include($params, &$smarty)
{
$_tag_start = 'if \(\$this->caching\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}';
$_tag_end = 'if \(\$this->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
- preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
+ preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
$params['compiled_content'], $_match_source, PREG_SET_ORDER);
// no nocache-parts found: done
if (count($_match_source)==0) return;
-
+
// convert the matched php-code to functions
$_include_compiled = "\n";
-
- $_params = array('filename' => $_compile_path,
+
+ $_params = array('filename' => $_compile_path,
'contents' => $_include_compiled, 'create_dirs' => true);
-
+
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php');
smarty_core_write_file($_params, $smarty);
- return true;
+ return true;
}
diff --git a/libs/core/core.write_compiled_resource.php b/libs/core/core.write_compiled_resource.php
index 9867d0c2..09b50d3b 100644
--- a/libs/core/core.write_compiled_resource.php
+++ b/libs/core/core.write_compiled_resource.php
@@ -12,22 +12,22 @@
* @param string $compiled_content
* @param integer $resource_timestamp
* @return true
- */
+ */
function smarty_core_write_compiled_resource($params, &$smarty)
-{
- if(!@is_writable($smarty->compile_dir)) {
- // compile_dir not writable, see if it exists
- if(!@is_dir($smarty->compile_dir)) {
- $smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
- return false;
- }
- $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR);
- return false;
- }
-
- $_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true);
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php');
- smarty_core_write_file($_params, $smarty);
+{
+ if(!@is_writable($smarty->compile_dir)) {
+ // compile_dir not writable, see if it exists
+ if(!@is_dir($smarty->compile_dir)) {
+ $smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
+ return false;
+ }
+ $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR);
+ return false;
+ }
+
+ $_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php');
+ smarty_core_write_file($_params, $smarty);
touch($params['compile_path'], $params['resource_timestamp']);
return true;
}
diff --git a/libs/core/core.write_file.php b/libs/core/core.write_file.php
index 5f30068a..c92454d4 100644
--- a/libs/core/core.write_file.php
+++ b/libs/core/core.write_file.php
@@ -12,7 +12,7 @@
* @param string $contents
* @param boolean $create_dirs
* @return boolean
- */
+ */
function smarty_core_write_file($params, &$smarty)
{
$_dirname = dirname($params['filename']);
@@ -36,7 +36,7 @@ function smarty_core_write_file($params, &$smarty)
fclose($fd);
if(file_exists($params['filename'])) {
@unlink($params['filename']);
- }
+ }
@rename($_tmp_file, $params['filename']);
@chmod($params['filename'], $smarty->_file_perms);