diff --git a/gosa-core/include/smarty/sysplugins/smarty_internal_data.php b/gosa-core/include/smarty/sysplugins/smarty_internal_data.php
index 5baf3b76dc719817a32f4c1ac1fecb2972a50b48..167262694bf70bc216244217cbafb6f45c0e2ba3 100644 (file)
<?php
+
/**
* Smarty Internal Plugin Data
*
* This file contains the basic classes and methodes for template and variable creation
*
* @package Smarty
- * @subpackage Template
+ * @subpackage Templates
* @author Uwe Tews
*/
/**
* Base class with template and variable methodes
- *
- * @package Smarty
- * @subpackage Template
*/
class Smarty_Internal_Data {
-
- /**
- * name of class used for templates
- *
- * @var string
- */
+ // class used for templates
public $template_class = 'Smarty_Internal_Template';
- /**
- * template variables
- *
- * @var array
- */
- public $tpl_vars = array();
- /**
- * parent template (if any)
- *
- * @var Smarty_Internal_Template
- */
- public $parent = null;
- /**
- * configuration settings
- *
- * @var array
- */
- public $config_vars = array();
/**
* 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
+ * @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
* @param boolean $scope the scope the variable will have (local,parent or root)
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
*/
public function assign($tpl_var, $value = null, $nocache = false)
{
$this->tpl_vars[$tpl_var] = new Smarty_variable($value, $nocache);
}
}
-
- return $this;
}
-
/**
* assigns a global Smarty variable
*
* @param string $varname the global variable name
- * @param mixed $value the value to assign
+ * @param mixed $value the value to assign
* @param boolean $nocache if true any output of this variable will be not cached
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
*/
public function assignGlobal($varname, $value = null, $nocache = false)
{
if ($varname != '') {
Smarty::$global_tpl_vars[$varname] = new Smarty_variable($value, $nocache);
}
-
- return $this;
}
/**
* assigns values to template variables by reference
* @param string $tpl_var the template variable name
* @param mixed $ &$value the referenced value to assign
* @param boolean $nocache if true any output of this variable will be not cached
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
*/
public function assignByRef($tpl_var, &$value, $nocache = false)
{
$this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache);
$this->tpl_vars[$tpl_var]->value = &$value;
}
-
- return $this;
}
+ /**
+ * wrapper function for Smarty 2 BC
+ *
+ * @param string $tpl_var the template variable name
+ * @param mixed $ &$value the referenced value to assign
+ */
+ public function assign_by_ref($tpl_var, &$value)
+ {
+ if($this->smarty->deprecation_notices)
+ trigger_error("function call 'assign_by_ref' is unknown or deprecated, use 'assignByRef'", E_USER_NOTICE);
+ $this->assignByRef($tpl_var, $value);
+ }
/**
* appends values to template variables
*
- * @param array|string $tpl_var the template variable name(s)
- * @param mixed $value the value to append
- * @param boolean $merge flag if array elements shall be merged
+ * @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
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
*/
public function append($tpl_var, $value = null, $merge = false, $nocache = false)
{
}
}
}
-
- return $this;
}
/**
* appends values to template variables by reference
*
* @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
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
+ * @param mixed $ &$value the referenced value to append
+ * @param boolean $merge flag if array elements shall be merged
*/
public function appendByRef($tpl_var, &$value, $merge = false)
{
if (!isset($this->tpl_vars[$tpl_var])) {
$this->tpl_vars[$tpl_var] = new Smarty_variable();
}
- if (!is_array($this->tpl_vars[$tpl_var]->value)) {
+ if (!@is_array($this->tpl_vars[$tpl_var]->value)) {
settype($this->tpl_vars[$tpl_var]->value, 'array');
}
if ($merge && is_array($value)) {
$this->tpl_vars[$tpl_var]->value[] = &$value;
}
}
-
- return $this;
}
+ /**
+ *
+ * @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
+ */
+ public function append_by_ref($tpl_var, &$value, $merge = false)
+ {
+ if($this->smarty->deprecation_notices)
+ trigger_error("function call 'append_by_ref' is unknown or deprecated, use 'appendByRef'", E_USER_NOTICE);
+ $this->appendByRef($tpl_var, $value, $merge);
+ }
/**
* Returns a single or all template variables
*
- * @param string $varname variable name or null
- * @param string $_ptr optional pointer to data object
- * @param boolean $search_parents include parent templates?
+ * @param string $varname variable name or null
* @return string variable value or or array of variables
*/
- public function getTemplateVars($varname = null, $_ptr = null, $search_parents = true)
+ function getTemplateVars($varname = null, $_ptr = null, $search_parents = true)
{
if (isset($varname)) {
$_var = $this->getVariable($varname, $_ptr, $search_parents, false);
/**
* clear the given assigned template variable.
*
- * @param string|array $tpl_var the template variable(s) to clear
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
+ * @param string $ |array $tpl_var the template variable(s) to clear
*/
public function clearAssign($tpl_var)
{
} else {
unset($this->tpl_vars[$tpl_var]);
}
-
- return $this;
}
/**
* clear all the assigned template variables.
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
*/
public function clearAllAssign()
{
$this->tpl_vars = array();
- return $this;
}
/**
* load a config file, optionally load just selected sections
*
* @param string $config_file filename
- * @param mixed $sections array of section names, single section or null
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
+ * @param mixed $sections array of section names, single section or null
*/
public function configLoad($config_file, $sections = null)
{
// load Config class
$config = new Smarty_Internal_Config($config_file, $this->smarty, $this);
$config->loadConfigVars($sections);
- return $this;
}
/**
* gets the object of a Smarty variable
*
- * @param string $variable the name of the Smarty variable
- * @param object $_ptr optional pointer to data object
+ * @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
* @return object the object of the variable
*/
- public function getVariable($variable, $_ptr = null, $search_parents = true, $error_enable = true)
+ public function getVariable($_variable, $_ptr = null, $search_parents = true, $error_enable = true)
{
if ($_ptr === null) {
$_ptr = $this;
} while ($_ptr !== null) {
- if (isset($_ptr->tpl_vars[$variable])) {
+ if (isset($_ptr->tpl_vars[$_variable])) {
// found it, return it
- return $_ptr->tpl_vars[$variable];
+ return $_ptr->tpl_vars[$_variable];
}
// not found, try at parent
if ($search_parents) {
$_ptr = null;
}
}
- if (isset(Smarty::$global_tpl_vars[$variable])) {
+ if (isset(Smarty::$global_tpl_vars[$_variable])) {
// found it, return it
- return Smarty::$global_tpl_vars[$variable];
+ return Smarty::$global_tpl_vars[$_variable];
}
if ($this->smarty->error_unassigned && $error_enable) {
- // force a notice
- $x = $$variable;
+ throw new SmartyException('Undefined Smarty variable "' . $_variable . '"');
+ } else {
+ if ($error_enable) {
+ // force a notice
+ $x = $$_variable;
+ }
+ return new Undefined_Smarty_Variable;
}
- return new Undefined_Smarty_Variable;
}
-
/**
* gets a config variable
*
* @param string $variable the name of the config variable
* @return mixed the value of the config variable
*/
- public function getConfigVariable($variable, $error_enable = true)
+ public function getConfigVariable($_variable)
{
$_ptr = $this;
while ($_ptr !== null) {
- if (isset($_ptr->config_vars[$variable])) {
+ if (isset($_ptr->config_vars[$_variable])) {
// found it, return it
- return $_ptr->config_vars[$variable];
+ 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;
+ if ($this->smarty->error_unassigned) {
+ throw new SmartyException('Undefined config variable "' . $_variable . '"');
+ } else {
+ // force a notice
+ $x = $$_variable;
+ return null;
}
- return null;
}
/**
public function getStreamVariable($variable)
{
$_result = '';
- $fp = fopen($variable, 'r+');
- if ($fp) {
+ if ($fp = fopen($variable, 'r+')) {
while (!feof($fp) && ($current_line = fgets($fp)) !== false ) {
$_result .= $current_line;
}
* @param string $varname variable name or null
* @return string variable value or or array of variables
*/
- public function getConfigVars($varname = null, $search_parents = true)
+ function getConfigVars($varname = null, $search_parents = true)
{
+ // var_dump($this);
$_ptr = $this;
$var_array = array();
while ($_ptr !== null) {
- if (isset($varname)) {
- if (isset($_ptr->config_vars[$varname])) {
- return $_ptr->config_vars[$varname];
+ if (isset($varname)) {
+ if (isset($_ptr->config_vars[$varname])) {
+ return $_ptr->config_vars[$varname];
}
} else {
- $var_array = array_merge($_ptr->config_vars, $var_array);
- }
+ $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 '';
+ return '';
} else {
return $var_array;
}
* Deassigns a single or all config variables
*
* @param string $varname variable name or null
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
*/
- public function clearConfig($varname = null)
+ function clearConfig($varname = null)
{
if (isset($varname)) {
unset($this->config_vars[$varname]);
+ return;
} else {
$this->config_vars = array();
+ return;
}
- return $this;
}
}
*
* The Smarty data object will hold Smarty variables in the current scope
*
- * @package Smarty
- * @subpackage Template
+ * @param object $parent tpl_vars next higher level of Smarty variables
*/
class Smarty_Data extends Smarty_Internal_Data {
-
- /**
- * Smarty object
- *
- * @var Smarty
- */
+ // array of variable objects
+ public $tpl_vars = array();
+ // back pointer to parent object
+ public $parent = null;
+ // config vars
+ public $config_vars = array();
+ // Smarty object
public $smarty = null;
-
/**
* create Smarty data object
- *
- * @param Smarty|array $_parent parent template
- * @param Smarty $smarty global smarty instance
*/
public function __construct ($_parent = null, $smarty = 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;
-
+ // template variable
+ public $value;
+ public $nocache;
+ public $scope;
/**
* create Smarty variable object
*
- * @param mixed $value the value to assign
+ * @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)
+ * @param boolean $scope the scope the variable will have (local,parent or root)
*/
- public function __construct($value = null, $nocache = false, $scope = Smarty::SCOPE_LOCAL)
+ 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()
+ public function __toString ()
{
- return (string) $this->value;
+ return $this->value;
}
-
}
/**
* 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)
+ // return always false
+ public function __get ($name)
{
if ($name == 'nocache') {
return false;
return null;
}
}
-
- /**
- * Always returns an empty string.
- *
- * @return string
- */
- public function __toString()
- {
- return "";
- }
-
}
?>
\ No newline at end of file