1: | <?php
|
2: |
|
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: |
|
12: | class Smarty_Internal_Method_Literals
|
13: | {
|
14: | |
15: | |
16: | |
17: | |
18: |
|
19: | public $objMap = 3;
|
20: |
|
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: |
|
30: | public function getLiterals(Smarty_Internal_TemplateBase $obj)
|
31: | {
|
32: | $smarty = $obj->_getSmartyObj();
|
33: | return (array)$smarty->literals;
|
34: | }
|
35: |
|
36: | |
37: | |
38: | |
39: | |
40: | |
41: | |
42: | |
43: | |
44: | |
45: | |
46: | |
47: |
|
48: | public function addLiterals(Smarty_Internal_TemplateBase $obj, $literals = null)
|
49: | {
|
50: | if (isset($literals)) {
|
51: | $this->set($obj->_getSmartyObj(), (array)$literals);
|
52: | }
|
53: | return $obj;
|
54: | }
|
55: |
|
56: | |
57: | |
58: | |
59: | |
60: | |
61: | |
62: | |
63: | |
64: | |
65: | |
66: | |
67: |
|
68: | public function setLiterals(Smarty_Internal_TemplateBase $obj, $literals = null)
|
69: | {
|
70: | $smarty = $obj->_getSmartyObj();
|
71: | $smarty->literals = array();
|
72: | if (!empty($literals)) {
|
73: | $this->set($smarty, (array)$literals);
|
74: | }
|
75: | return $obj;
|
76: | }
|
77: |
|
78: | |
79: | |
80: | |
81: | |
82: | |
83: | |
84: | |
85: | |
86: |
|
87: | private function set(Smarty $smarty, $literals)
|
88: | {
|
89: | $literals = array_combine($literals, $literals);
|
90: | $error = isset($literals[ $smarty->left_delimiter ]) ? array($smarty->left_delimiter) : array();
|
91: | $error = isset($literals[ $smarty->right_delimiter ]) ? $error[] = $smarty->right_delimiter : $error;
|
92: | if (!empty($error)) {
|
93: | throw new SmartyException(
|
94: | 'User defined literal(s) "' . $error .
|
95: | '" may not be identical with left or right delimiter'
|
96: | );
|
97: | }
|
98: | $smarty->literals = array_merge((array)$smarty->literals, (array)$literals);
|
99: | }
|
100: | }
|
101: | |