Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 1
<?php
2
 
3
/**
4
 * Smarty Method MustCompile
5
 *
6
 * Smarty_Internal_Template::mustCompile() method
7
 *
8
 * @package    Smarty
9
 * @subpackage PluginsInternal
10
 * @author     Uwe Tews
11
 */
12
class Smarty_Internal_Method_MustCompile
13
{
14
    /**
15
     * Valid for template object
16
     *
17
     * @var int
18
     */
19
    public $objMap = 2;
20
 
21
    /**
22
     * Returns if the current template must be compiled by the Smarty compiler
23
     * It does compare the timestamps of template source and the compiled templates and checks the force compile
24
     * configuration
25
     *
26
     * @param \Smarty_Internal_Template $_template
27
     *
28
     * @return bool
29
     * @throws \SmartyException
30
     */
31
    public function mustCompile(Smarty_Internal_Template $_template)
32
    {
33
        if (!$_template->source->exists) {
34
            if ($_template->_isSubTpl()) {
35
                $parent_resource = " in '$_template->parent->template_resource}'";
36
            } else {
37
                $parent_resource = '';
38
            }
39
            throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}");
40
        }
41
        if ($_template->mustCompile === null) {
42
            $_template->mustCompile = (!$_template->source->handler->uncompiled &&
43
                                       ($_template->smarty->force_compile || $_template->source->handler->recompiled ||
44
                                        !$_template->compiled->exists || ($_template->compile_check &&
45
                                                                          $_template->compiled->getTimeStamp() <
46
                                                                          $_template->source->getTimeStamp())));
47
        }
48
        return $_template->mustCompile;
49
    }
50
}