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');
27 * Attribute definition: Overwrites base class.
30 * @see Smarty_Internal_CompileBase
32 public $shorttag_order = array('file', 'section');
34 * Attribute definition: Overwrites base class.
37 * @see Smarty_Internal_CompileBase
39 public $optional_attributes = array('section', 'scope');
42 * Compiles code for the {config_load} tag
44 * @param array $args array with attributes from parser
45 * @param object $compiler compiler object
47 * @return string compiled code
49 public function compile($args, $compiler)
51 static $_is_legal_scope = array('local' => true, 'parent' => true, 'root' => true, 'global' => true);
52 // check and get attributes
53 $_attr = $this->getAttributes($compiler, $args);
55 if ($_attr['nocache'] === true) {
56 $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
59 // save possible attributes
60 $conf_file = $_attr['file'];
61 if (isset($_attr['section'])) {
62 $section = $_attr['section'];
68 if (isset($_attr['scope'])) {
69 $_attr['scope'] = trim($_attr['scope'], "'\"");
70 if (isset($_is_legal_scope[$_attr['scope']])) {
71 $scope = $_attr['scope'];
73 $compiler->trigger_template_error('illegal value for "scope" attribute', $compiler->lex->taglineno);
76 // create config object
77 $_output = "<?php \$_config = new Smarty_Internal_Config($conf_file, \$_smarty_tpl->smarty, \$_smarty_tpl);";
78 $_output .= "\$_config->loadConfigVars($section, '$scope'); ?>";