4 * Smarty Internal Plugin Compile Config Load
6 * Compiles the {config load} tag
14 * Smarty Internal Plugin Compile Config Load Class
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');
23 * Compiles code for the {config_load} tag
25 * @param array $args array with attributes from parser
26 * @param object $compiler compiler object
27 * @return string compiled code
29 public function compile($args, $compiler)
31 $this->compiler = $compiler;
32 // check and get attributes
33 $_attr = $this->_get_attributes($args);
35 if ($_attr['nocache'] === true) {
36 $this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno);
40 // save posible attributes
41 $conf_file = $_attr['file'];
42 if (isset($_attr['section'])) {
43 $section = $_attr['section'];
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'];
54 $this->compiler->trigger_template_error('illegal value for "scope" attribute', $this->compiler->lex->taglineno);
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'); ?>";