mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
removed tabs from the main and the core/*.php files
This commit is contained in:
@@ -37,273 +37,273 @@
|
||||
* @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;
|
||||
/**
|
||||
* 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();
|
||||
/** @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);
|
||||
}
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
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 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 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;
|
||||
}
|
||||
/**
|
||||
* 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"]);
|
||||
}
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* 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"]);
|
||||
}
|
||||
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();
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
/**
|
||||
* 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);
|
||||
$contents = fread($fp, filesize($config_file));
|
||||
fclose($fp);
|
||||
|
||||
if($this->fix_newlines) {
|
||||
// fix mac/dos formatted newlines
|
||||
$contents = preg_replace('!\r\n?!',"\n",$contents);
|
||||
}
|
||||
if($this->fix_newlines) {
|
||||
// fix mac/dos formatted newlines
|
||||
$contents = preg_replace('!\r\n?!',"\n",$contents);
|
||||
}
|
||||
|
||||
$config_data = array();
|
||||
$config_data = array();
|
||||
|
||||
/* Get global variables first. */
|
||||
if ($contents{0} != '[' && preg_match("/^(.*?)(\n\[|\Z)/s", $contents, $match))
|
||||
$config_data["vars"] = $this->_parse_config_block($match[1]);
|
||||
/* 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]);
|
||||
}
|
||||
/* 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;
|
||||
$this->_config_data[$config_file] = $config_data;
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**#@+ @access private */
|
||||
/**#@+ @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);
|
||||
}
|
||||
/* 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);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array &$container
|
||||
@@ -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 ($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 (!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
|
||||
*/
|
||||
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);
|
||||
}
|
||||
/**#@-*/
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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'),
|
||||
@@ -313,13 +313,13 @@ 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
|
||||
*/
|
||||
@@ -657,33 +657,33 @@ class Smarty
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -697,16 +697,16 @@ class Smarty
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -887,7 +887,7 @@ class Smarty
|
||||
*/
|
||||
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);
|
||||
}
|
||||
@@ -910,7 +910,7 @@ class Smarty
|
||||
*/
|
||||
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);
|
||||
}
|
||||
@@ -933,7 +933,7 @@ class Smarty
|
||||
*/
|
||||
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);
|
||||
}
|
||||
@@ -958,8 +958,8 @@ class Smarty
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -986,21 +986,21 @@ class Smarty
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1018,12 +1018,12 @@ class Smarty
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1076,15 +1076,15 @@ class Smarty
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1095,7 +1095,7 @@ class Smarty
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1108,12 +1108,12 @@ class Smarty
|
||||
*/
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1125,11 +1125,11 @@ class Smarty
|
||||
*/
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1183,8 +1183,8 @@ 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');
|
||||
$_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) {
|
||||
@@ -1273,13 +1273,13 @@ class Smarty
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
@@ -1357,8 +1357,8 @@ class Smarty
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1367,15 +1367,15 @@ 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
|
||||
@@ -1413,9 +1413,9 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1461,13 +1461,13 @@ class Smarty
|
||||
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'];
|
||||
$_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)) {
|
||||
@@ -1477,9 +1477,9 @@ class Smarty
|
||||
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 {
|
||||
@@ -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,8 +1548,8 @@ class Smarty
|
||||
|
||||
}
|
||||
|
||||
return $_results;
|
||||
}
|
||||
return $_results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the compile path for this 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -38,21 +38,21 @@ 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;
|
||||
}
|
||||
|
@@ -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',
|
||||
|
@@ -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 = '';
|
||||
}
|
||||
$_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;
|
||||
$smarty->_compile_id = $_compile_id_orig;
|
||||
|
||||
$smarty->left_delimiter = $_ldelim_orig;
|
||||
$smarty->right_delimiter = $_rdelim_orig;
|
||||
$smarty->left_delimiter = $_ldelim_orig;
|
||||
$smarty->right_delimiter = $_rdelim_orig;
|
||||
|
||||
return $_results;
|
||||
return $_results;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
@@ -18,8 +18,8 @@
|
||||
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.
|
||||
@@ -31,15 +31,15 @@ function smarty_core_get_php_resource(&$params, &$smarty)
|
||||
$_readable = true;
|
||||
} 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');
|
||||
$_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;
|
||||
$_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;
|
||||
|
@@ -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,
|
||||
|
@@ -23,12 +23,12 @@ function smarty_core_rm_auto($params, &$smarty)
|
||||
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');
|
||||
$_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']);
|
||||
@@ -42,17 +42,17 @@ 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;
|
||||
|
@@ -27,13 +27,13 @@ function smarty_core_rmdir($params, &$smarty)
|
||||
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']);
|
||||
|
@@ -14,9 +14,9 @@
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ 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;
|
||||
}
|
||||
$_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,
|
||||
|
@@ -47,12 +47,12 @@ $_match[4]
|
||||
}
|
||||
$_include_compiled .= "\n\n?>\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;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -15,19 +15,19 @@
|
||||
*/
|
||||
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;
|
||||
}
|
||||
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);
|
||||
$_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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user