diff options
author | emkael <emkael@tlen.pl> | 2016-12-27 14:47:01 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-12-27 14:47:01 +0100 |
commit | 7085a0c2f7104a56a7e946c43ba0b5736be5f4e7 (patch) | |
tree | 5518c72e3486f41c559be30e514be1917bf5724f /lib/smarty3/sysplugins/smarty_data.php | |
parent | 1a3d783d8957a6adbe49b1765b326805477e7856 (diff) |
* smarty bundled
Diffstat (limited to 'lib/smarty3/sysplugins/smarty_data.php')
-rw-r--r-- | lib/smarty3/sysplugins/smarty_data.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/smarty3/sysplugins/smarty_data.php b/lib/smarty3/sysplugins/smarty_data.php new file mode 100644 index 0000000..b9f5de9 --- /dev/null +++ b/lib/smarty3/sysplugins/smarty_data.php @@ -0,0 +1,68 @@ +<?php +/** + * Smarty Plugin Data + * This file contains the data object + * + * @package Smarty + * @subpackage Template + * @author Uwe Tews + */ + +/** + * 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 +{ + /** + * Counter + * + * @var int + */ + static $count = 0; + + /** + * Data block name + * + * @var string + */ + public $dataObjectName = ''; + + /** + * Smarty object + * + * @var Smarty + */ + public $smarty = null; + + /** + * create Smarty data object + * + * @param Smarty|array $_parent parent template + * @param Smarty|Smarty_Internal_Template $smarty global smarty instance + * @param string $name optional data block name + * + * @throws SmartyException + */ + public function __construct($_parent = null, $smarty = null, $name = null) + { + parent::__construct(); + self::$count ++; + $this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count); + $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); + } + } elseif ($_parent != null) { + throw new SmartyException("Wrong type for template variables"); + } + } +} |