1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/piwigo_ynh.git synced 2024-09-03 20:06:03 +02:00
piwigo_ynh/sources/include/smarty/libs/sysplugins/smarty_internal_data.php

241 lines
8 KiB
PHP
Raw Normal View History

2014-07-06 13:21:10 +02:00
<?php
/**
* Smarty Internal Plugin Data
2016-08-27 21:53:29 +02:00
* This file contains the basic classes and methods for template and variable creation
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @package Smarty
2014-07-06 13:21:10 +02:00
* @subpackage Template
2016-08-27 21:53:29 +02:00
* @author Uwe Tews
2014-07-06 13:21:10 +02:00
*/
/**
2016-08-27 21:53:29 +02:00
* Base class with template and variable methods
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @package Smarty
2014-07-06 13:21:10 +02:00
* @subpackage Template
2016-08-27 21:53:29 +02:00
*
* @method mixed getConfigVars(string $varName = null, bool $searchParents = true)
* @method mixed getStreamVariable(string $variable)
* @method Smarty_Internal_Data clearAssign(mixed $tpl_var)
* @method Smarty_Internal_Data clearAllAssign()
* @method Smarty_Internal_Data clearConfig(string $varName = null)
* @method Smarty_Internal_Data configLoad(string $config_file, mixed $sections = null, string $scope = 'local')
* @property int $scope
2014-07-06 13:21:10 +02:00
*/
2016-08-27 21:53:29 +02:00
class Smarty_Internal_Data
{
/**
* This object type (Smarty = 1, template = 2, data = 4)
*
* @var int
*/
public $_objType = 4;
2014-07-06 13:21:10 +02:00
/**
* name of class used for templates
*
* @var string
*/
public $template_class = 'Smarty_Internal_Template';
2016-08-27 21:53:29 +02:00
2014-07-06 13:21:10 +02:00
/**
* template variables
*
2016-08-27 21:53:29 +02:00
* @var Smarty_Variable[]
2014-07-06 13:21:10 +02:00
*/
public $tpl_vars = array();
2016-08-27 21:53:29 +02:00
2014-07-06 13:21:10 +02:00
/**
* parent template (if any)
*
2016-08-27 21:53:29 +02:00
* @var Smarty|Smarty_Internal_Template|Smarty_Internal_Data
2014-07-06 13:21:10 +02:00
*/
public $parent = null;
2016-08-27 21:53:29 +02:00
2014-07-06 13:21:10 +02:00
/**
* configuration settings
*
2016-08-27 21:53:29 +02:00
* @var string[]
2014-07-06 13:21:10 +02:00
*/
public $config_vars = array();
/**
2016-08-27 21:53:29 +02:00
* extension handler
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @var Smarty_Internal_Extension_Handler
2014-07-06 13:21:10 +02:00
*/
2016-08-27 21:53:29 +02:00
public $ext = null;
2014-07-06 13:21:10 +02:00
/**
2016-08-27 21:53:29 +02:00
* Smarty_Internal_Data constructor.
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* Install extension handler
2014-07-06 13:21:10 +02:00
*/
2016-08-27 21:53:29 +02:00
public function __construct()
2014-07-06 13:21:10 +02:00
{
2016-08-27 21:53:29 +02:00
$this->ext = new Smarty_Internal_Extension_Handler();
$this->ext->objType = $this->_objType;
2014-07-06 13:21:10 +02:00
}
/**
2016-08-27 21:53:29 +02:00
* assigns a Smarty variable
*
* @param array|string $tpl_var the template variable name(s)
* @param mixed $value the value to assign
* @param boolean $nocache if true any output of this variable will be not cached
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
* chaining
2014-07-06 13:21:10 +02:00
*/
2016-08-27 21:53:29 +02:00
public function assign($tpl_var, $value = null, $nocache = false)
2014-07-06 13:21:10 +02:00
{
if (is_array($tpl_var)) {
foreach ($tpl_var as $_key => $_val) {
if ($_key != '') {
2016-08-27 21:53:29 +02:00
$this->tpl_vars[$_key] = new Smarty_Variable($_val, $nocache);
if ($this->_objType == 2 && $this->scope) {
$this->ext->_updateScope->updateScope($this, $_key);
2014-07-06 13:21:10 +02:00
}
}
}
} else {
2016-08-27 21:53:29 +02:00
if ($tpl_var != '') {
$this->tpl_vars[$tpl_var] = new Smarty_Variable($value, $nocache);
if ($this->_objType == 2 && $this->scope) {
$this->ext->_updateScope->updateScope($this, $tpl_var);
2014-07-06 13:21:10 +02:00
}
}
}
return $this;
}
/**
2016-08-27 21:53:29 +02:00
* appends values to template variables
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @api Smarty::append()
* @link http://www.smarty.net/docs/en/api.append.tpl
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @param array|string $tpl_var the template variable name(s)
* @param mixed $value the value to append
* @param bool $merge flag if array elements shall be merged
* @param bool $nocache if true any output of this variable will
* be not cached
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
2014-07-06 13:21:10 +02:00
*/
2016-08-27 21:53:29 +02:00
public function append($tpl_var, $value = null, $merge = false, $nocache = false)
2014-07-06 13:21:10 +02:00
{
2016-08-27 21:53:29 +02:00
return $this->ext->append->append($this, $tpl_var, $value, $merge, $nocache);
2014-07-06 13:21:10 +02:00
}
/**
2016-08-27 21:53:29 +02:00
* assigns a global Smarty variable
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02: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
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
2014-07-06 13:21:10 +02:00
*/
2016-08-27 21:53:29 +02:00
public function assignGlobal($varName, $value = null, $nocache = false)
2014-07-06 13:21:10 +02:00
{
2016-08-27 21:53:29 +02:00
return $this->ext->assignGlobal->assignGlobal($this, $varName, $value, $nocache);
2014-07-06 13:21:10 +02:00
}
/**
2016-08-27 21:53:29 +02:00
* appends values to template variables by reference
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02: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
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
2014-07-06 13:21:10 +02:00
*/
2016-08-27 21:53:29 +02:00
public function appendByRef($tpl_var, &$value, $merge = false)
2014-07-06 13:21:10 +02:00
{
2016-08-27 21:53:29 +02:00
return $this->ext->appendByRef->appendByRef($this, $tpl_var, $value, $merge);
2014-07-06 13:21:10 +02:00
}
/**
2016-08-27 21:53:29 +02:00
* assigns values to template variables by reference
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02: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
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
2014-07-06 13:21:10 +02:00
*/
2016-08-27 21:53:29 +02:00
public function assignByRef($tpl_var, &$value, $nocache = false)
2014-07-06 13:21:10 +02:00
{
2016-08-27 21:53:29 +02:00
return $this->ext->assignByRef->assignByRef($this, $tpl_var, $value, $nocache);
2014-07-06 13:21:10 +02:00
}
/**
2016-08-27 21:53:29 +02:00
* Returns a single or all template variables
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @api Smarty::getTemplateVars()
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @param string $varName variable name or null
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
* @param bool $searchParents include parent templates?
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @return mixed variable value or or array of variables
2014-07-06 13:21:10 +02:00
*/
2016-08-27 21:53:29 +02:00
public function getTemplateVars($varName = null, Smarty_Internal_Data $_ptr = null, $searchParents = true)
2014-07-06 13:21:10 +02:00
{
2016-08-27 21:53:29 +02:00
return $this->ext->getTemplateVars->getTemplateVars($this, $varName, $_ptr, $searchParents);
2014-07-06 13:21:10 +02:00
}
/**
2016-08-27 21:53:29 +02:00
* gets the object of a Smarty variable
*
* @param string $variable the name of the Smarty variable
* @param Smarty_Internal_Data $_ptr optional pointer to data object
* @param boolean $searchParents search also in parent data
* @param bool $error_enable
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @return Smarty_Variable|Smarty_Undefined_Variable the object of the variable
* @deprecated since 3.1.28 please use Smarty_Internal_Data::getTemplateVars() instead.
2014-07-06 13:21:10 +02:00
*/
2016-08-27 21:53:29 +02:00
public function getVariable($variable = null, Smarty_Internal_Data $_ptr = null, $searchParents = true, $error_enable = true){
return $this->ext->getTemplateVars->_getVariable($this, $variable, $_ptr, $searchParents, $error_enable);
2014-07-06 13:21:10 +02:00
}
2016-08-27 21:53:29 +02:00
2014-07-06 13:21:10 +02:00
/**
2016-08-27 21:53:29 +02:00
* Follow the parent chain an merge template and config variables
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @param \Smarty_Internal_Data|null $data
2014-07-06 13:21:10 +02:00
*/
2016-08-27 21:53:29 +02:00
public function _mergeVars(Smarty_Internal_Data $data = null)
2014-07-06 13:21:10 +02:00
{
2016-08-27 21:53:29 +02:00
if (isset($data)) {
if (!empty($this->tpl_vars)) {
$data->tpl_vars = array_merge($this->tpl_vars, $data->tpl_vars);
}
if (!empty($this->config_vars)) {
$data->config_vars = array_merge($this->config_vars, $data->config_vars);
}
2014-07-06 13:21:10 +02:00
} else {
2016-08-27 21:53:29 +02:00
$data = $this;
}
if (isset($this->parent)) {
$this->parent->_mergeVars($data);
2014-07-06 13:21:10 +02:00
}
}
/**
2016-08-27 21:53:29 +02:00
* Handle unknown class methods
2014-07-06 13:21:10 +02:00
*
2016-08-27 21:53:29 +02:00
* @param string $name unknown method-name
* @param array $args argument array
*
* @return mixed
* @throws SmartyException
2014-07-06 13:21:10 +02:00
*/
2016-08-27 21:53:29 +02:00
public function __call($name, $args)
2014-07-06 13:21:10 +02:00
{
2016-08-27 21:53:29 +02:00
return $this->ext->_callExternalMethod($this, $name, $args);
2014-07-06 13:21:10 +02:00
}
}