1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: 12: 13: 14: 15: 16:
17: class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
18: {
19: 20: 21: 22: 23: 24:
25: public $required_attributes = array('file');
26: 27: 28: 29: 30: 31:
32: public $shorttag_order = array('file', 'section');
33: 34: 35: 36: 37: 38:
39: public $optional_attributes = array('section', 'scope');
40:
41: 42: 43: 44: 45: 46: 47: 48:
49: public function compile($args, $compiler)
50: {
51: static $_is_legal_scope = array('local' => true, 'parent' => true, 'root' => true, 'global' => true);
52:
53: $_attr = $this->getAttributes($compiler, $args);
54:
55: if ($_attr['nocache'] === true) {
56: $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
57: }
58:
59:
60: $conf_file = $_attr['file'];
61: if (isset($_attr['section'])) {
62: $section = $_attr['section'];
63: } else {
64: $section = 'null';
65: }
66: $scope = 'local';
67:
68: if (isset($_attr['scope'])) {
69: $_attr['scope'] = trim($_attr['scope'], "'\"");
70: if (isset($_is_legal_scope[$_attr['scope']])) {
71: $scope = $_attr['scope'];
72: } else {
73: $compiler->trigger_template_error('illegal value for "scope" attribute', $compiler->lex->taglineno);
74: }
75: }
76:
77: $_output = "<?php \$_config = new Smarty_Internal_Config($conf_file, \$_smarty_tpl->smarty, \$_smarty_tpl);";
78: $_output .= "\$_config->loadConfigVars($section, '$scope'); ?>";
79:
80: return $_output;
81: }
82: }
83: