Initial repo created
[timetracker.git] / WEB-INF / lib / smarty / sysplugins / smarty_internal_compile_config_load.php
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 /**
14  * Smarty Internal Plugin Compile Config Load Class
15  */
16 class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase {
17         // attribute definitions
18     public $required_attributes = array('file');
19     public $shorttag_order = array('file','section');
20     public $optional_attributes = array('section', 'scope'); 
21
22     /**
23      * Compiles code for the {config_load} tag
24      * 
25      * @param array $args array with attributes from parser
26      * @param object $compiler compiler object
27      * @return string compiled code
28      */
29     public function compile($args, $compiler)
30     {
31         $this->compiler = $compiler;
32         // check and get attributes
33         $_attr = $this->_get_attributes($args);
34         
35         if ($_attr['nocache'] === true) {
36                 $this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno);
37         }
38
39          
40         // save posible attributes
41         $conf_file = $_attr['file'];
42         if (isset($_attr['section'])) {
43             $section = $_attr['section'];
44         } else {
45             $section = 'null';
46         } 
47         $scope = 'local';
48         // scope setup
49         if (isset($_attr['scope'])) {
50             $_attr['scope'] = trim($_attr['scope'], "'\"");
51             if (in_array($_attr['scope'],array('local','parent','root','global'))) {
52                 $scope = $_attr['scope'];
53            } else {
54                 $this->compiler->trigger_template_error('illegal value for "scope" attribute', $this->compiler->lex->taglineno);
55            } 
56         } 
57         // create config object
58         $_output = "<?php  \$_config = new Smarty_Internal_Config($conf_file, \$_smarty_tpl->smarty, \$_smarty_tpl);";
59         $_output .= "\$_config->loadConfigVars($section, '$scope'); ?>";
60         return $_output;
61     } 
62
63
64 ?>