From fa10e0945ecd45bfe78a2c8fb015a43092b4944b Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 10 Dec 2015 14:02:22 +0100 Subject: bug #385 update to smarty-3.1.28-dev (from Github) --- .../smarty_internal_compile_config_load.php | 73 ++++++++++++++-------- 1 file changed, 46 insertions(+), 27 deletions(-) (limited to 'include/smarty/libs/sysplugins/smarty_internal_compile_config_load.php') diff --git a/include/smarty/libs/sysplugins/smarty_internal_compile_config_load.php b/include/smarty/libs/sysplugins/smarty_internal_compile_config_load.php index deaa052c5..d2e50a08f 100644 --- a/include/smarty/libs/sysplugins/smarty_internal_compile_config_load.php +++ b/include/smarty/libs/sysplugins/smarty_internal_compile_config_load.php @@ -1,22 +1,21 @@ true, 'parent' => true, 'root' => true, 'global' => true, + 'smarty' => true, 'tpl_root' => true); /** * Compiles code for the {config_load} tag * - * @param array $args array with attributes from parser - * @param object $compiler compiler object + * @param array $args array with attributes from parser + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object + * * @return string compiled code + * @throws \SmartyCompilerException */ - public function compile($args, $compiler) + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) { - static $_is_legal_scope = array('local' => true,'parent' => true,'root' => true,'global' => true); // check and get attributes $_attr = $this->getAttributes($compiler, $args); if ($_attr['nocache'] === true) { - $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno); + $compiler->trigger_template_error('nocache option not allowed', null, true); } - - // save posible attributes + // save possible attributes $conf_file = $_attr['file']; if (isset($_attr['section'])) { $section = $_attr['section']; } else { $section = 'null'; } - $scope = 'local'; - // scope setup + $_scope = Smarty::SCOPE_LOCAL; if (isset($_attr['scope'])) { $_attr['scope'] = trim($_attr['scope'], "'\""); - if (isset($_is_legal_scope[$_attr['scope']])) { - $scope = $_attr['scope']; - } else { - $compiler->trigger_template_error('illegal value for "scope" attribute', $compiler->lex->taglineno); - } + if (!isset($this->valid_scopes[$_attr['scope']])) { + $compiler->trigger_template_error("illegal value '{$_attr['scope']}' for \"scope\" attribute", null, true); + } + if ($_attr['scope'] != 'local') { + if ($_attr['scope'] == 'parent') { + $_scope = Smarty::SCOPE_PARENT; + } elseif ($_attr['scope'] == 'root') { + $_scope = Smarty::SCOPE_ROOT; + } elseif ($_attr['scope'] == 'global') { + $_scope = Smarty::SCOPE_GLOBAL; + } elseif ($_attr['scope'] == 'smarty') { + $_scope = Smarty::SCOPE_SMARTY; + } elseif ($_attr['scope'] == 'tpl_root') { + $_scope = Smarty::SCOPE_TPL_ROOT; + } + $_scope += (isset($_attr['bubble_up']) && $_attr['bubble_up'] == 'false') ? 0 : Smarty::SCOPE_BUBBLE_UP; + } } + // create config object - $_output = "smarty, \$_smarty_tpl);"; - $_output .= "\$_config->loadConfigVars($section, '$scope'); ?>"; + $_output = + "smarty->ext->configLoad->_loadConfigFile(\$_smarty_tpl, {$conf_file}, {$section}, {$_scope});\n?>\n"; + return $_output; } - } - -?> \ No newline at end of file -- cgit v1.2.3