Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 1
<?php
2
 
3
/**
4
 * Smarty Method GetTags
5
 *
6
 * Smarty::getTags() method
7
 *
8
 * @package    Smarty
9
 * @subpackage PluginsInternal
10
 * @author     Uwe Tews
11
 */
12
class Smarty_Internal_Method_GetTags
13
{
14
    /**
15
     * Valid for Smarty and template object
16
     *
17
     * @var int
18
     */
19
    public $objMap = 3;
20
 
21
    /**
22
     * Return array of tag/attributes of all tags used by an template
23
     *
24
     * @api  Smarty::getTags()
25
     * @link http://www.smarty.net/docs/en/api.get.tags.tpl
26
     *
27
     * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
28
     * @param null|string|Smarty_Internal_Template                            $template
29
     *
30
     * @return array of tag/attributes
31
     * @throws \Exception
32
     * @throws \SmartyException
33
     */
34
    public function getTags(Smarty_Internal_TemplateBase $obj, $template = null)
35
    {
36
        /* @var Smarty $smarty */
37
        $smarty = $obj->_getSmartyObj();
38
        if ($obj->_isTplObj() && !isset($template)) {
39
            $tpl = clone $obj;
40
        } elseif (isset($template) && $template->_isTplObj()) {
41
            $tpl = clone $template;
42
        } elseif (isset($template) && is_string($template)) {
43
            /* @var Smarty_Internal_Template $tpl */
44
            $tpl = new $smarty->template_class($template, $smarty);
45
            // checks if template exists
46
            if (!$tpl->source->exists) {
47
                throw new SmartyException("Unable to load template {$tpl->source->type} '{$tpl->source->name}'");
48
            }
49
        }
50
        if (isset($tpl)) {
51
            $tpl->smarty = clone $tpl->smarty;
52
            $tpl->smarty->_cache[ 'get_used_tags' ] = true;
53
            $tpl->_cache[ 'used_tags' ] = array();
54
            $tpl->smarty->merge_compiled_includes = false;
55
            $tpl->smarty->disableSecurity();
56
            $tpl->caching = Smarty::CACHING_OFF;
57
            $tpl->loadCompiler();
58
            $tpl->compiler->compileTemplate($tpl);
59
            return $tpl->_cache[ 'used_tags' ];
60
        }
61
        throw new SmartyException('Missing template specification');
62
    }
63
}