3 * Smarty Internal Plugin Compile Config Load
4 * Compiles the {config load} tag
12 * Smarty Internal Plugin Compile Config Load Class
15 * @subpackage Compiler
17 class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
20 * Attribute definition: Overwrites base class.
23 * @see Smarty_Internal_CompileBase
25 public $required_attributes = array('file');
28 * Attribute definition: Overwrites base class.
31 * @see Smarty_Internal_CompileBase
33 public $shorttag_order = array('file', 'section');
36 * Attribute definition: Overwrites base class.
39 * @see Smarty_Internal_CompileBase
41 public $optional_attributes = array('section', 'scope');
44 * Attribute definition: Overwrites base class.
47 * @see Smarty_Internal_CompileBase
49 public $option_flags = array('nocache', 'noscope');
56 public $valid_scopes = array('local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
57 'root' => Smarty::SCOPE_ROOT, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
58 'smarty' => Smarty::SCOPE_SMARTY, 'global' => Smarty::SCOPE_SMARTY);
61 * Compiles code for the {config_load} tag
63 * @param array $args array with attributes from parser
64 * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
66 * @return string compiled code
67 * @throws \SmartyCompilerException
69 public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
71 // check and get attributes
72 $_attr = $this->getAttributes($compiler, $args);
74 if ($_attr[ 'nocache' ] === true) {
75 $compiler->trigger_template_error('nocache option not allowed', null, true);
78 // save possible attributes
79 $conf_file = $_attr[ 'file' ];
80 if (isset($_attr[ 'section' ])) {
81 $section = $_attr[ 'section' ];
86 if ($_attr[ 'noscope' ]) {
89 $_scope = $compiler->convertScope($_attr, $this->valid_scopes);
92 // create config object
94 "<?php\n\$_smarty_tpl->smarty->ext->configLoad->_loadConfigFile(\$_smarty_tpl, {$conf_file}, {$section}, {$_scope});\n?>\n";