-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmarty.php
executable file
·51 lines (42 loc) · 1.22 KB
/
Smarty.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* Renderer_Smarty
*
* @category Addon
* @package addon.renderer
* @author Ebine Yutaka <[email protected]>
* @copyright 2004-2008 Mori Reo <[email protected]>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
class Renderer_Smarty extends Sabel_View_Renderer
{
private $smarty = null;
public function initialize()
{
require_once ("Smarty/Smarty.class.php");
$smarty = new Smarty();
$smarty->compile_dir = COMPILE_DIR_PATH . DS;
/*
if ((ENVIRONMENT & PRODUCTION) > 0) {
$smarty->caching = 1;
$smarty->cache_dir = CACHE_DIR_PATH . DS;
$smarty->cache_lifetime = 600;
}
*/
$this->smarty = $smarty;
}
public function rendering($_tpl_contents, $_tpl_values, $_tpl_path = null)
{
$smarty = $this->smarty;
if ($_tpl_path === null || !is_file($_tpl_path)) {
$hash = $this->createHash($_tpl_contents);
$_tpl_path = COMPILE_DIR_PATH . DS . $hash;
file_put_contents($_tpl_path, $_tpl_contents);
}
if (!$smarty->is_cached($_tpl_path)) {
$_tpl_values["renderer"] = $this;
$smarty->assign($_tpl_values);
}
return $smarty->fetch($_tpl_path);
}
}