File size: 961 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<?php
namespace Maveriks\Pattern\Mvc;

use Maveriks\Util\Common;

class SmartyView extends View
{
    protected $smarty;

    public function __construct($tpl = '')
    {
        parent::__construct($tpl);
        require_once PATH_THIRDPARTY . 'smarty/libs/Smarty.class.php'; //

        $this->smarty = new \Smarty();
        $this->smarty->compile_dir  = defined('PATH_SMARTY_C')? PATH_SMARTY_C : sys_get_temp_dir();
        $this->smarty->cache_dir    = defined('PATH_SMARTY_CACHE')? PATH_SMARTY_CACHE : sys_get_temp_dir();

        if (! is_dir($this->smarty->compile_dir)) {
            Common::mk_dir($this->smarty->compile_dir);
        }
        if (! is_dir($this->smarty->cache_dir)) {
            Common::mk_dir($this->smarty->cache_dir);
        }
    }

    public function assign($name, $value)
    {
        $this->smarty->assign($name, $value);
    }

    public function render()
    {
        $this->smarty->display($this->getTpl());
    }
}