Хранилища Subversion ant

Редакция

Содержимое файла | Последнее изменение | Открыть журнал | RSS

Редакция Автор № строки Строка
304 alex-w 1
<?php
2
 
3
/**
4
* Smarty Internal Plugin Compile Config Load
5
*
6
* Compiles the {config load} tag
7
*
8
* @package Smarty
9
* @subpackage Compiler
10
* @author Uwe Tews
11
*/
12
/**
13
* Smarty Internal Plugin Compile Config Load Class
14
*/
15
class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase {
16
    /**
17
    * Compiles code for the {config_load} tag
18
    *
19
    * @param array $args array with attributes from parser
20
    * @param object $compiler compiler object
21
    * @return string compiled code
22
    */
23
    public function compile($args, $compiler)
24
    {
25
        $this->compiler = $compiler;
26
        $this->required_attributes = array('file');
27
        $this->optional_attributes = array('section', 'scope');
28
        // check and get attributes
29
        $_attr = $this->_get_attributes($args);
30
        // save posible attributes
31
        $conf_file = $_attr['file'];
32
        if (isset($_attr['section'])) {
33
            $section = $_attr['section'];
34
        } else {
35
            $section = 'null';
36
        }
37
        $scope = '$_smarty_tpl->smarty';
38
        if (isset($_attr['scope'])) {
39
            if ($_attr['scope'] == '\'local\'') {
40
                $scope = '$_smarty_tpl';
41
            } elseif ($_attr['scope'] == '\'parent\'') {
42
                $scope = '$_smarty_tpl->parent';
43
            }
44
        }
45
        // create config object
46
        $_output = "<?php \$_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Config');";
47
        $_output .= "\$_config = new Smarty_Internal_Config($conf_file, \$_smarty_tpl->smarty);";
48
        $_output .= "\$_config->loadConfigVars($section, $scope); ?>";
49
        return $_output;
50
    }
51
}
52
 
53
?>