2009-03-22 16:09:05 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* Smarty Internal Plugin Data
|
2014-06-06 02:40:04 +00:00
|
|
|
* This file contains the basic classes and methods for template and variable creation
|
2011-05-14 11:11:52 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2011-09-16 14:19:56 +00:00
|
|
|
* @subpackage Template
|
2014-06-06 02:40:04 +00:00
|
|
|
* @author Uwe Tews
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2009-03-22 16:09:05 +00:00
|
|
|
|
|
|
|
/**
|
2014-06-06 02:40:04 +00:00
|
|
|
* Base class with template and variable methods
|
2011-09-16 14:19:56 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2011-09-16 14:19:56 +00:00
|
|
|
* @subpackage Template
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2013-07-14 22:15:45 +00:00
|
|
|
class Smarty_Internal_Data
|
|
|
|
{
|
2011-09-16 14:19:56 +00:00
|
|
|
/**
|
|
|
|
* name of class used for templates
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2009-09-29 22:58:54 +00:00
|
|
|
public $template_class = 'Smarty_Internal_Template';
|
2015-07-12 07:03:55 +02:00
|
|
|
|
2011-09-16 14:19:56 +00:00
|
|
|
/**
|
|
|
|
* template variables
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $tpl_vars = array();
|
2015-07-12 07:03:55 +02:00
|
|
|
|
2011-09-16 14:19:56 +00:00
|
|
|
/**
|
|
|
|
* parent template (if any)
|
|
|
|
*
|
|
|
|
* @var Smarty_Internal_Template
|
|
|
|
*/
|
|
|
|
public $parent = null;
|
2015-07-12 07:03:55 +02:00
|
|
|
|
2011-09-16 14:19:56 +00:00
|
|
|
/**
|
|
|
|
* configuration settings
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $config_vars = array();
|
2009-08-18 16:53:33 +00:00
|
|
|
|
2015-07-12 07:03:55 +02:00
|
|
|
/**
|
|
|
|
* universal cache
|
|
|
|
*
|
|
|
|
* @var array()
|
|
|
|
*/
|
|
|
|
public $_cache = array();
|
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* assigns a Smarty variable
|
2011-05-14 11:11:52 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @param array|string $tpl_var the template variable name(s)
|
|
|
|
* @param mixed $value the value to assign
|
|
|
|
* @param boolean $nocache if true any output of this variable will be not cached
|
|
|
|
*
|
2015-07-12 07:03:55 +02:00
|
|
|
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
|
|
|
* chaining
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2010-11-11 21:34:36 +00:00
|
|
|
public function assign($tpl_var, $value = null, $nocache = false)
|
2009-03-22 16:09:05 +00:00
|
|
|
{
|
|
|
|
if (is_array($tpl_var)) {
|
|
|
|
foreach ($tpl_var as $_key => $_val) {
|
|
|
|
if ($_key != '') {
|
2015-01-06 01:18:58 +01:00
|
|
|
$this->tpl_vars[$_key] = new Smarty_Variable($_val, $nocache);
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-22 16:09:05 +00:00
|
|
|
} else {
|
|
|
|
if ($tpl_var != '') {
|
2015-01-06 01:18:58 +01:00
|
|
|
$this->tpl_vars[$tpl_var] = new Smarty_Variable($value, $nocache);
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-04 16:18:24 +00:00
|
|
|
|
2011-09-27 12:36:50 +00:00
|
|
|
return $this;
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2011-09-16 14:19:56 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* assigns a global Smarty variable
|
2011-05-14 11:11:52 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @param string $varname the global variable name
|
|
|
|
* @param mixed $value the value to assign
|
|
|
|
* @param boolean $nocache if true any output of this variable will be not cached
|
|
|
|
*
|
2015-07-12 07:03:55 +02:00
|
|
|
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
|
|
|
* chaining
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2010-02-06 22:11:10 +00:00
|
|
|
public function assignGlobal($varname, $value = null, $nocache = false)
|
2009-03-22 16:09:05 +00:00
|
|
|
{
|
|
|
|
if ($varname != '') {
|
2015-01-06 01:18:58 +01:00
|
|
|
Smarty::$global_tpl_vars[$varname] = new Smarty_Variable($value, $nocache);
|
2012-11-20 02:06:20 +00:00
|
|
|
$ptr = $this;
|
|
|
|
while ($ptr instanceof Smarty_Internal_Template) {
|
|
|
|
$ptr->tpl_vars[$varname] = clone Smarty::$global_tpl_vars[$varname];
|
|
|
|
$ptr = $ptr->parent;
|
|
|
|
}
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2011-10-04 16:18:24 +00:00
|
|
|
|
2011-09-27 12:36:50 +00:00
|
|
|
return $this;
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2014-06-06 02:40:04 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* assigns values to template variables by reference
|
2011-05-14 11:11:52 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @param string $tpl_var the template variable name
|
|
|
|
* @param $value
|
|
|
|
* @param boolean $nocache if true any output of this variable will be not cached
|
|
|
|
*
|
2015-07-12 07:03:55 +02:00
|
|
|
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
|
|
|
* chaining
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2010-11-11 21:34:36 +00:00
|
|
|
public function assignByRef($tpl_var, &$value, $nocache = false)
|
2009-03-22 16:09:05 +00:00
|
|
|
{
|
2009-10-11 20:23:00 +00:00
|
|
|
if ($tpl_var != '') {
|
2015-01-06 01:18:58 +01:00
|
|
|
$this->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
|
2015-01-02 12:11:21 +01:00
|
|
|
$this->tpl_vars[$tpl_var]->value = &$value;
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2011-10-04 16:18:24 +00:00
|
|
|
|
2011-09-27 12:36:50 +00:00
|
|
|
return $this;
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2010-11-11 21:34:36 +00:00
|
|
|
|
2010-06-08 20:45:18 +00:00
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* appends values to template variables
|
2011-05-14 11:11:52 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @param array|string $tpl_var the template variable name(s)
|
|
|
|
* @param mixed $value the value to append
|
|
|
|
* @param boolean $merge flag if array elements shall be merged
|
|
|
|
* @param boolean $nocache if true any output of this variable will be not cached
|
|
|
|
*
|
2015-07-12 07:03:55 +02:00
|
|
|
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
|
|
|
* chaining
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2010-11-11 21:34:36 +00:00
|
|
|
public function append($tpl_var, $value = null, $merge = false, $nocache = false)
|
2009-03-22 16:09:05 +00:00
|
|
|
{
|
2015-06-28 05:22:19 +02:00
|
|
|
Smarty_Internal_Extension_Append::append($this, $tpl_var, $value, $merge, $nocache);
|
2011-09-27 12:36:50 +00:00
|
|
|
return $this;
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2009-04-12 22:26:02 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* appends values to template variables by reference
|
2011-05-14 11:11:52 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @param string $tpl_var the template variable name
|
|
|
|
* @param mixed &$value the referenced value to append
|
|
|
|
* @param boolean $merge flag if array elements shall be merged
|
|
|
|
*
|
2015-07-12 07:03:55 +02:00
|
|
|
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
|
|
|
* chaining
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2010-02-06 22:11:10 +00:00
|
|
|
public function appendByRef($tpl_var, &$value, $merge = false)
|
2009-03-22 16:09:05 +00:00
|
|
|
{
|
2015-06-28 05:22:19 +02:00
|
|
|
Smarty_Internal_Extension_Append::appendByRef($this, $tpl_var, $value, $merge);
|
2011-09-27 12:36:50 +00:00
|
|
|
return $this;
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
|
|
|
|
2010-02-08 17:31:15 +00:00
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* Returns a single or all template variables
|
2011-05-14 11:11:52 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @param string $varname variable name or null
|
2015-01-02 12:11:21 +01:00
|
|
|
* @param object $_ptr optional pointer to data object
|
2013-07-14 22:15:45 +00:00
|
|
|
* @param boolean $search_parents include parent templates?
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return string variable value or or array of variables
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2011-09-16 14:19:56 +00:00
|
|
|
public function getTemplateVars($varname = null, $_ptr = null, $search_parents = true)
|
2010-02-08 17:31:15 +00:00
|
|
|
{
|
2015-06-28 04:44:16 +02:00
|
|
|
return Smarty_Internal_Extension_GetVars::getTemplateVars($this, $varname, $_ptr, $search_parents);
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2010-06-18 15:10:35 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* clear the given assigned template variable.
|
2011-05-14 11:11:52 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @param string|array $tpl_var the template variable(s) to clear
|
|
|
|
*
|
2015-07-12 07:03:55 +02:00
|
|
|
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
|
|
|
* chaining
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2010-02-06 22:11:10 +00:00
|
|
|
public function clearAssign($tpl_var)
|
2009-03-22 16:09:05 +00:00
|
|
|
{
|
|
|
|
if (is_array($tpl_var)) {
|
|
|
|
foreach ($tpl_var as $curr_var) {
|
|
|
|
unset($this->tpl_vars[$curr_var]);
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2009-03-22 16:09:05 +00:00
|
|
|
} else {
|
|
|
|
unset($this->tpl_vars[$tpl_var]);
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2011-10-04 16:18:24 +00:00
|
|
|
|
2011-09-27 12:36:50 +00:00
|
|
|
return $this;
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2009-03-22 16:09:05 +00:00
|
|
|
|
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* clear all the assigned template variables.
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2015-07-12 07:03:55 +02:00
|
|
|
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
|
|
|
* chaining
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2010-02-06 22:11:10 +00:00
|
|
|
public function clearAllAssign()
|
2009-03-22 16:09:05 +00:00
|
|
|
{
|
|
|
|
$this->tpl_vars = array();
|
2013-07-14 22:15:45 +00:00
|
|
|
|
2011-09-27 12:36:50 +00:00
|
|
|
return $this;
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2009-03-22 16:09:05 +00:00
|
|
|
|
2009-11-05 18:22:40 +00:00
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* load a config file, optionally load just selected sections
|
2011-05-14 11:11:52 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @param string $config_file filename
|
|
|
|
* @param mixed $sections array of section names, single section or null
|
|
|
|
*
|
2015-07-12 07:03:55 +02:00
|
|
|
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
|
|
|
* chaining
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2010-02-06 22:11:10 +00:00
|
|
|
public function configLoad($config_file, $sections = null)
|
2011-05-14 11:11:52 +00:00
|
|
|
{
|
2009-11-05 18:22:40 +00:00
|
|
|
// load Config class
|
2015-01-02 12:11:21 +01:00
|
|
|
Smarty_Internal_Extension_Config::configLoad($this, $config_file, $sections);
|
2011-09-27 12:36:50 +00:00
|
|
|
return $this;
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2009-11-05 18:22:40 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* gets the object of a Smarty variable
|
2011-05-14 11:11:52 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @param string $variable the name of the Smarty variable
|
|
|
|
* @param object $_ptr optional pointer to data object
|
|
|
|
* @param boolean $search_parents search also in parent data
|
2014-06-06 02:40:04 +00:00
|
|
|
* @param bool $error_enable
|
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return object the object of the variable
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2011-09-16 14:19:56 +00:00
|
|
|
public function getVariable($variable, $_ptr = null, $search_parents = true, $error_enable = true)
|
2009-03-22 16:09:05 +00:00
|
|
|
{
|
2015-06-28 04:44:16 +02:00
|
|
|
return Smarty_Internal_Extension_GetVars::getVariable($this, $variable, $_ptr, $search_parents, $error_enable);
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2011-09-16 14:19:56 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* gets a config variable
|
2011-05-14 11:11:52 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @param string $variable the name of the config variable
|
2014-06-06 02:40:04 +00:00
|
|
|
* @param bool $error_enable
|
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return mixed the value of the config variable
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2011-09-16 14:19:56 +00:00
|
|
|
public function getConfigVariable($variable, $error_enable = true)
|
2009-03-22 16:09:05 +00:00
|
|
|
{
|
2015-01-02 12:11:21 +01:00
|
|
|
return Smarty_Internal_Extension_Config::getConfigVariable($this, $variable, $error_enable = true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a single or all config variables
|
|
|
|
*
|
|
|
|
* @param string $varname variable name or null
|
|
|
|
* @param bool $search_parents
|
|
|
|
*
|
|
|
|
* @return string variable value or or array of variables
|
|
|
|
*/
|
|
|
|
public function getConfigVars($varname = null, $search_parents = true)
|
|
|
|
{
|
|
|
|
return Smarty_Internal_Extension_Config::getConfigVars($this, $varname, $search_parents);
|
|
|
|
}
|
2013-07-14 22:15:45 +00:00
|
|
|
|
2015-01-02 12:11:21 +01:00
|
|
|
/**
|
|
|
|
* Deassigns a single or all config variables
|
|
|
|
*
|
|
|
|
* @param string $varname variable name or null
|
|
|
|
*
|
2015-07-12 07:03:55 +02:00
|
|
|
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
|
|
|
* chaining
|
2015-01-02 12:11:21 +01:00
|
|
|
*/
|
|
|
|
public function clearConfig($varname = null)
|
|
|
|
{
|
|
|
|
return Smarty_Internal_Extension_Config::clearConfig($this, $varname);
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
2010-11-18 18:58:53 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-06-18 15:10:35 +00:00
|
|
|
* gets a stream variable
|
2011-05-14 11:11:52 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @param string $variable the stream of the variable
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
|
|
|
* @throws SmartyException
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return mixed the value of the stream variable
|
2010-06-18 15:10:35 +00:00
|
|
|
*/
|
2009-04-18 14:46:29 +00:00
|
|
|
public function getStreamVariable($variable)
|
|
|
|
{
|
2015-06-28 05:00:27 +02:00
|
|
|
return Smarty_Internal_Extension_GetStreamVar::getStreamVariable($this, $variable);
|
2011-05-14 11:11:52 +00:00
|
|
|
}
|
|
|
|
}
|