equal
deleted
inserted
replaced
1 <?php |
|
2 /** |
|
3 * Smarty Plugin Data |
|
4 * This file contains the data object |
|
5 * |
|
6 * @package Smarty |
|
7 * @subpackage Template |
|
8 * @author Uwe Tews |
|
9 */ |
|
10 |
|
11 /** |
|
12 * class for the Smarty data object |
|
13 * The Smarty data object will hold Smarty variables in the current scope |
|
14 * |
|
15 * @package Smarty |
|
16 * @subpackage Template |
|
17 */ |
|
18 class Smarty_Data extends Smarty_Internal_Data { |
|
19 /** |
|
20 * Counter |
|
21 * |
|
22 * @var int |
|
23 */ |
|
24 static $count = 0; |
|
25 |
|
26 /** |
|
27 * Data block name |
|
28 * |
|
29 * @var string |
|
30 */ |
|
31 public $dataObjectName = ''; |
|
32 /** |
|
33 * Smarty object |
|
34 * |
|
35 * @var Smarty |
|
36 */ |
|
37 public $smarty = null; |
|
38 |
|
39 /** |
|
40 * create Smarty data object |
|
41 * |
|
42 * @param Smarty|array $_parent parent template |
|
43 * @param Smarty|Smarty_Internal_Template $smarty global smarty instance |
|
44 * @param string $name optional data block name |
|
45 * |
|
46 * @throws SmartyException |
|
47 */ |
|
48 public function __construct($_parent = null, $smarty = null, $name = null) { |
|
49 self::$count++; |
|
50 $this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count); |
|
51 $this->smarty = $smarty; |
|
52 if (is_object($_parent)) { |
|
53 // when object set up back pointer |
|
54 $this->parent = $_parent; |
|
55 } elseif (is_array($_parent)) { |
|
56 // set up variable values |
|
57 foreach ($_parent as $_key => $_val) { |
|
58 $this->tpl_vars[$_key] = new Smarty_Variable($_val); |
|
59 } |
|
60 } elseif ($_parent != null) { |
|
61 throw new SmartyException("Wrong type for template variables"); |
|
62 } |
|
63 } |
|
64 } |
|