PageRenderTime 98ms CodeModel.GetById 93ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/vendor/smarty3/lib/libs/sysplugins/smarty_internal_compile_config_load.php

http://zoop.googlecode.com/
PHP | 53 lines | 28 code | 3 blank | 22 comment | 6 complexity | 851a45b5d7e8d301c182d504aa7ea440 MD5 | raw file
 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*/
15class 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
46        // create config object
47        $_output = "<?php  \$_config = new Smarty_Internal_Config($conf_file, \$_smarty_tpl->smarty, \$_smarty_tpl);";
48        $_output .= "\$_config->loadConfigVars($section, $scope); ?>";
49        return $_output;
50    } 
51} 
52
53?>