4 * This file contains the data object
12 * class for the Smarty data object
13 * The Smarty data object will hold Smarty variables in the current scope
16 * @subpackage Template
18 class Smarty_Data extends Smarty_Internal_Data
32 public $dataObjectName = '';
39 public $smarty = null;
42 * create Smarty data object
44 * @param Smarty|array $_parent parent template
45 * @param Smarty|Smarty_Internal_Template $smarty global smarty instance
46 * @param string $name optional data block name
48 * @throws SmartyException
50 public function __construct($_parent = null, $smarty = null, $name = null)
52 parent::__construct();
54 $this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count);
55 $this->smarty = $smarty;
56 if (is_object($_parent)) {
57 // when object set up back pointer
58 $this->parent = $_parent;
59 } elseif (is_array($_parent)) {
60 // set up variable values
61 foreach ($_parent as $_key => $_val) {
62 $this->tpl_vars[ $_key ] = new Smarty_Variable($_val);
64 } elseif ($_parent != null) {
65 throw new SmartyException("Wrong type for template variables");