Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 1
<?php
2
/**
3
 * Smarty Resource Plugin
4
 *
5
 * @package    Smarty
6
 * @subpackage TemplateResources
7
 * @author     Rodney Rehm
8
 */
9
 
10
/**
11
 * Smarty Resource Plugin
12
 * Base implementation for resource plugins that don't compile cache
13
 *
14
 * @package    Smarty
15
 * @subpackage TemplateResources
16
 */
17
abstract class Smarty_Resource_Recompiled extends Smarty_Resource
18
{
19
    /**
20
     * Flag that it's an recompiled resource
21
     *
22
     * @var bool
23
     */
24
    public $recompiled = true;
25
 
26
    /**
27
     * Resource does implement populateCompiledFilepath() method
28
     *
29
     * @var bool
30
     */
31
    public $hasCompiledHandler = true;
32
 
33
    /**
34
     * compile template from source
35
     *
36
     * @param Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
37
     *
38
     * @throws Exception
39
     */
40
    public function process(Smarty_Internal_Template $_smarty_tpl)
41
    {
42
        $compiled = &$_smarty_tpl->compiled;
43
        $compiled->file_dependency = array();
44
        $compiled->includes = array();
45
        $compiled->nocache_hash = null;
46
        $compiled->unifunc = null;
47
        $level = ob_get_level();
48
        ob_start();
49
        $_smarty_tpl->loadCompiler();
50
        // call compiler
51
        try {
52
            eval('?>' . $_smarty_tpl->compiler->compileTemplate($_smarty_tpl));
53
        } catch (Exception $e) {
54
            unset($_smarty_tpl->compiler);
55
            while (ob_get_level() > $level) {
56
                ob_end_clean();
57
            }
58
            throw $e;
59
        }
60
        // release compiler object to free memory
61
        unset($_smarty_tpl->compiler);
62
        ob_get_clean();
63
        $compiled->timestamp = time();
64
        $compiled->exists = true;
65
    }
66
 
67
    /**
68
     * populate Compiled Object with compiled filepath
69
     *
70
     * @param Smarty_Template_Compiled $compiled  compiled object
71
     * @param Smarty_Internal_Template $_template template object
72
     *
73
     * @return void
74
     */
75
    public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template)
76
    {
77
        $compiled->filepath = false;
78
        $compiled->timestamp = false;
79
        $compiled->exists = false;
80
    }
81
 
82
    /*
83
       * Disable timestamp checks for recompiled resource.
84
       *
85
       * @return bool
86
       */
87
    /**
88
     * @return bool
89
     */
90
    public function checkTimestamps()
91
    {
92
        return false;
93
    }
94
}