aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty/libs/sysplugins/smarty_internal_data.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2015-12-06 20:12:05 +0100
committerMario Vavti <mario@mariovavti.com>2015-12-06 20:12:05 +0100
commitc23ce16cafb826c8bb4fe7aaf2a5525b29052b23 (patch)
tree2230b03cfa6b74f3898b57bee647bc6276fd5a53 /library/Smarty/libs/sysplugins/smarty_internal_data.php
parent78a70fed2f7cf9a53e6e4fab516b00cece12fbf0 (diff)
downloadvolse-hubzilla-c23ce16cafb826c8bb4fe7aaf2a5525b29052b23.tar.gz
volse-hubzilla-c23ce16cafb826c8bb4fe7aaf2a5525b29052b23.tar.bz2
volse-hubzilla-c23ce16cafb826c8bb4fe7aaf2a5525b29052b23.zip
update smarty library - seems to bring some performance improvement
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_internal_data.php')
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_data.php242
1 files changed, 35 insertions, 207 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_data.php b/library/Smarty/libs/sysplugins/smarty_internal_data.php
index 9e16f10c0..2ca0f31da 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_data.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_data.php
@@ -55,12 +55,12 @@ class Smarty_Internal_Data
if (is_array($tpl_var)) {
foreach ($tpl_var as $_key => $_val) {
if ($_key != '') {
- $this->tpl_vars[$_key] = new Smarty_variable($_val, $nocache);
+ $this->tpl_vars[$_key] = new Smarty_Variable($_val, $nocache);
}
}
} else {
if ($tpl_var != '') {
- $this->tpl_vars[$tpl_var] = new Smarty_variable($value, $nocache);
+ $this->tpl_vars[$tpl_var] = new Smarty_Variable($value, $nocache);
}
}
@@ -79,7 +79,7 @@ class Smarty_Internal_Data
public function assignGlobal($varname, $value = null, $nocache = false)
{
if ($varname != '') {
- Smarty::$global_tpl_vars[$varname] = new Smarty_variable($value, $nocache);
+ Smarty::$global_tpl_vars[$varname] = new Smarty_Variable($value, $nocache);
$ptr = $this;
while ($ptr instanceof Smarty_Internal_Template) {
$ptr->tpl_vars[$varname] = clone Smarty::$global_tpl_vars[$varname];
@@ -102,8 +102,8 @@ class Smarty_Internal_Data
public function assignByRef($tpl_var, &$value, $nocache = false)
{
if ($tpl_var != '') {
- $this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache);
- $this->tpl_vars[$tpl_var]->value = & $value;
+ $this->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
+ $this->tpl_vars[$tpl_var]->value = &$value;
}
return $this;
@@ -127,8 +127,8 @@ class Smarty_Internal_Data
if ($_key != '') {
if (!isset($this->tpl_vars[$_key])) {
$tpl_var_inst = $this->getVariable($_key, null, true, false);
- if ($tpl_var_inst instanceof Undefined_Smarty_Variable) {
- $this->tpl_vars[$_key] = new Smarty_variable(null, $nocache);
+ if ($tpl_var_inst instanceof Smarty_Undefined_Variable) {
+ $this->tpl_vars[$_key] = new Smarty_Variable(null, $nocache);
} else {
$this->tpl_vars[$_key] = clone $tpl_var_inst;
}
@@ -149,8 +149,8 @@ class Smarty_Internal_Data
if ($tpl_var != '' && isset($value)) {
if (!isset($this->tpl_vars[$tpl_var])) {
$tpl_var_inst = $this->getVariable($tpl_var, null, true, false);
- if ($tpl_var_inst instanceof Undefined_Smarty_Variable) {
- $this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache);
+ if ($tpl_var_inst instanceof Smarty_Undefined_Variable) {
+ $this->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
} else {
$this->tpl_vars[$tpl_var] = clone $tpl_var_inst;
}
@@ -184,17 +184,17 @@ class Smarty_Internal_Data
{
if ($tpl_var != '' && isset($value)) {
if (!isset($this->tpl_vars[$tpl_var])) {
- $this->tpl_vars[$tpl_var] = new Smarty_variable();
+ $this->tpl_vars[$tpl_var] = new Smarty_Variable();
}
if (!is_array($this->tpl_vars[$tpl_var]->value)) {
settype($this->tpl_vars[$tpl_var]->value, 'array');
}
if ($merge && is_array($value)) {
foreach ($value as $_key => $_val) {
- $this->tpl_vars[$tpl_var]->value[$_key] = & $value[$_key];
+ $this->tpl_vars[$tpl_var]->value[$_key] = &$value[$_key];
}
} else {
- $this->tpl_vars[$tpl_var]->value[] = & $value;
+ $this->tpl_vars[$tpl_var]->value[] = &$value;
}
}
@@ -205,7 +205,7 @@ class Smarty_Internal_Data
* Returns a single or all template variables
*
* @param string $varname variable name or null
- * @param object $_ptr optional pointer to data object
+ * @param object $_ptr optional pointer to data object
* @param boolean $search_parents include parent templates?
*
* @return string variable value or or array of variables
@@ -292,9 +292,7 @@ class Smarty_Internal_Data
public function configLoad($config_file, $sections = null)
{
// load Config class
- $config = new Smarty_Internal_Config($config_file, $this->smarty, $this);
- $config->loadConfigVars($sections);
-
+ Smarty_Internal_Extension_Config::configLoad($this, $config_file, $sections);
return $this;
}
@@ -329,12 +327,13 @@ class Smarty_Internal_Data
// found it, return it
return Smarty::$global_tpl_vars[$variable];
}
- if ($this->smarty->error_unassigned && $error_enable) {
+ $smarty = isset($this->smarty) ? $this->smarty : $this;
+ if ($smarty->error_unassigned && $error_enable) {
// force a notice
$x = $$variable;
}
- return new Undefined_Smarty_Variable;
+ return new Smarty_Undefined_Variable;
}
/**
@@ -347,49 +346,7 @@ class Smarty_Internal_Data
*/
public function getConfigVariable($variable, $error_enable = true)
{
- $_ptr = $this;
- while ($_ptr !== null) {
- if (isset($_ptr->config_vars[$variable])) {
- // found it, return it
- return $_ptr->config_vars[$variable];
- }
- // not found, try at parent
- $_ptr = $_ptr->parent;
- }
- if ($this->smarty->error_unassigned && $error_enable) {
- // force a notice
- $x = $$variable;
- }
-
- return null;
- }
-
- /**
- * gets a stream variable
- *
- * @param string $variable the stream of the variable
- *
- * @throws SmartyException
- * @return mixed the value of the stream variable
- */
- public function getStreamVariable($variable)
- {
- $_result = '';
- $fp = fopen($variable, 'r+');
- if ($fp) {
- while (!feof($fp) && ($current_line = fgets($fp)) !== false) {
- $_result .= $current_line;
- }
- fclose($fp);
-
- return $_result;
- }
-
- if ($this->smarty->error_unassigned) {
- throw new SmartyException('Undefined stream variable "' . $variable . '"');
- } else {
- return null;
- }
+ return Smarty_Internal_Extension_Config::getConfigVariable($this, $variable, $error_enable = true);
}
/**
@@ -402,28 +359,7 @@ class Smarty_Internal_Data
*/
public function getConfigVars($varname = null, $search_parents = true)
{
- $_ptr = $this;
- $var_array = array();
- while ($_ptr !== null) {
- if (isset($varname)) {
- if (isset($_ptr->config_vars[$varname])) {
- return $_ptr->config_vars[$varname];
- }
- } else {
- $var_array = array_merge($_ptr->config_vars, $var_array);
- }
- // not found, try at parent
- if ($search_parents) {
- $_ptr = $_ptr->parent;
- } else {
- $_ptr = null;
- }
- }
- if (isset($varname)) {
- return '';
- } else {
- return $var_array;
- }
+ return Smarty_Internal_Extension_Config::getConfigVars($this, $varname, $search_parents);
}
/**
@@ -435,142 +371,34 @@ class Smarty_Internal_Data
*/
public function clearConfig($varname = null)
{
- if (isset($varname)) {
- unset($this->config_vars[$varname]);
- } else {
- $this->config_vars = array();
- }
-
- return $this;
+ return Smarty_Internal_Extension_Config::clearConfig($this, $varname);
}
-}
-
-/**
- * class for the Smarty data object
- * The Smarty data object will hold Smarty variables in the current scope
- *
- * @package Smarty
- * @subpackage Template
- */
-class Smarty_Data extends Smarty_Internal_Data
-{
- /**
- * Smarty object
- *
- * @var Smarty
- */
- public $smarty = null;
/**
- * create Smarty data object
+ * gets a stream variable
*
- * @param Smarty|array $_parent parent template
- * @param Smarty|Smarty_Internal_Template $smarty global smarty instance
+ * @param string $variable the stream of the variable
*
* @throws SmartyException
+ * @return mixed the value of the stream variable
*/
- public function __construct($_parent = null, $smarty = null)
+ public function getStreamVariable($variable)
{
- $this->smarty = $smarty;
- if (is_object($_parent)) {
- // when object set up back pointer
- $this->parent = $_parent;
- } elseif (is_array($_parent)) {
- // set up variable values
- foreach ($_parent as $_key => $_val) {
- $this->tpl_vars[$_key] = new Smarty_variable($_val);
+ $_result = '';
+ $fp = fopen($variable, 'r+');
+ if ($fp) {
+ while (!feof($fp) && ($current_line = fgets($fp)) !== false) {
+ $_result .= $current_line;
}
- } elseif ($_parent != null) {
- throw new SmartyException("Wrong type for template variables");
- }
- }
-}
-
-/**
- * class for the Smarty variable object
- * This class defines the Smarty variable object
- *
- * @package Smarty
- * @subpackage Template
- */
-class Smarty_Variable
-{
- /**
- * template variable
- *
- * @var mixed
- */
- public $value = null;
- /**
- * if true any output of this variable will be not cached
- *
- * @var boolean
- */
- public $nocache = false;
- /**
- * the scope the variable will have (local,parent or root)
- *
- * @var int
- */
- public $scope = Smarty::SCOPE_LOCAL;
-
- /**
- * create Smarty variable object
- *
- * @param mixed $value the value to assign
- * @param boolean $nocache if true any output of this variable will be not cached
- * @param int $scope the scope the variable will have (local,parent or root)
- */
- public function __construct($value = null, $nocache = false, $scope = Smarty::SCOPE_LOCAL)
- {
- $this->value = $value;
- $this->nocache = $nocache;
- $this->scope = $scope;
- }
-
- /**
- * <<magic>> String conversion
- *
- * @return string
- */
- public function __toString()
- {
- return (string) $this->value;
- }
-}
+ fclose($fp);
-/**
- * class for undefined variable object
- * This class defines an object for undefined variable handling
- *
- * @package Smarty
- * @subpackage Template
- */
-class Undefined_Smarty_Variable
-{
- /**
- * Returns FALSE for 'nocache' and NULL otherwise.
- *
- * @param string $name
- *
- * @return bool
- */
- public function __get($name)
- {
- if ($name == 'nocache') {
- return false;
+ return $_result;
+ }
+ $smarty = isset($this->smarty) ? $this->smarty : $this;
+ if ($smarty->error_unassigned) {
+ throw new SmartyException('Undefined stream variable "' . $variable . '"');
} else {
return null;
}
}
-
- /**
- * Always returns an empty string.
- *
- * @return string
- */
- public function __toString()
- {
- return "";
- }
}