1
|
|
|
<?php |
2
|
|
|
//require_once('smarty/Smarty.class.php'); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Extended Smarty class |
6
|
|
|
* |
7
|
|
|
* @deprecated Use Fwlib\Bridge\Smarty |
8
|
|
|
* @package fwolflib |
9
|
|
|
* @subpackage class.smarty-fl |
10
|
|
|
* @copyright Copyright 2013, Fwolf |
11
|
|
|
* @author Fwolf <[email protected]> |
12
|
|
|
* @license http://www.gnu.org/licenses/lgpl.html LGPL v3 |
13
|
|
|
* @since 2013-01-18 |
14
|
|
|
*/ |
15
|
|
|
class SmartyFl extends Smarty { |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* constructor |
20
|
|
|
*/ |
21
|
|
|
public function __construct () { |
22
|
|
|
parent::__construct(); |
23
|
|
|
|
24
|
|
|
// Delimiter |
25
|
|
|
$this->left_delimiter = '{'; |
26
|
|
|
$this->right_delimiter = '}'; |
27
|
|
|
|
28
|
|
|
$this->use_sub_dirs = true; |
29
|
|
|
|
30
|
|
|
} // end of func __construct |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Prepend to config_dir array |
35
|
|
|
* |
36
|
|
|
* @param string|array $config_dir |
37
|
|
|
* @param string $key |
38
|
|
|
* @return $this |
39
|
|
|
*/ |
40
|
|
View Code Duplication |
public function addConfigDirPrepend ($config_dir, $key = '') { |
|
|
|
|
41
|
|
|
$ar_tpl = $this->getConfigDir(); |
42
|
|
|
if (is_string($ar_tpl)) |
43
|
|
|
$ar_tpl = array($ar_tpl); |
44
|
|
|
|
45
|
|
|
if (is_string($config_dir)) { |
46
|
|
|
$config_dir = array($key => $config_dir); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$ar_tpl = array_merge($config_dir, $ar_tpl); |
50
|
|
|
$this->setConfigDir($ar_tpl); |
51
|
|
|
|
52
|
|
|
return $this; |
53
|
|
|
} // end of func addConfigDirPrepend |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Prepend to plugins_dir array |
58
|
|
|
* |
59
|
|
|
* @param string|array $plugins_dir |
60
|
|
|
* @param string $key |
61
|
|
|
* @return $this |
62
|
|
|
*/ |
63
|
|
View Code Duplication |
public function addPluginsDirPrepend ($plugins_dir, $key = '') { |
|
|
|
|
64
|
|
|
$ar_tpl = $this->getPluginsDir(); |
65
|
|
|
if (is_string($ar_tpl)) |
66
|
|
|
$ar_tpl = array($ar_tpl); |
67
|
|
|
|
68
|
|
|
if (is_string($plugins_dir)) { |
69
|
|
|
$plugins_dir = array($key => $plugins_dir); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
$ar_tpl = array_merge($plugins_dir, $ar_tpl); |
73
|
|
|
$this->setPluginsDir($ar_tpl); |
74
|
|
|
|
75
|
|
|
return $this; |
76
|
|
|
} // end of func addPluginsDirPrepend |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Prepend to template_dir array |
81
|
|
|
* |
82
|
|
|
* @param string|array $template_dir |
83
|
|
|
* @param string $key |
84
|
|
|
* @return $this |
85
|
|
|
*/ |
86
|
|
View Code Duplication |
public function addTemplateDirPrepend ($template_dir, $key = '') { |
|
|
|
|
87
|
|
|
$ar_tpl = $this->getTemplateDir(); |
88
|
|
|
if (is_string($ar_tpl)) |
89
|
|
|
$ar_tpl = array($ar_tpl); |
90
|
|
|
|
91
|
|
|
if (is_string($template_dir)) { |
92
|
|
|
$template_dir = array($key => $template_dir); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
$ar_tpl = array_merge($template_dir, $ar_tpl); |
96
|
|
|
$this->setTemplateDir($ar_tpl); |
97
|
|
|
|
98
|
|
|
return $this; |
99
|
|
|
} // end of func addTemplateDirPrepend |
100
|
|
|
|
101
|
|
|
|
102
|
|
|
} // end of class SmartyFl |
103
|
|
|
?> |
|
|
|
|
104
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.