diff options
Diffstat (limited to 'lib/smarty3/sysplugins/smarty_internal_method_configload.php')
-rw-r--r-- | lib/smarty3/sysplugins/smarty_internal_method_configload.php | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/lib/smarty3/sysplugins/smarty_internal_method_configload.php b/lib/smarty3/sysplugins/smarty_internal_method_configload.php index 2a38b18..2e62548 100644 --- a/lib/smarty3/sysplugins/smarty_internal_method_configload.php +++ b/lib/smarty3/sysplugins/smarty_internal_method_configload.php @@ -25,12 +25,12 @@ class Smarty_Internal_Method_ConfigLoad * @link http://www.smarty.net/docs/en/api.config.load.tpl * * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data - * @param string $config_file filename - * @param mixed $sections array of section names, single + * @param string $config_file filename + * @param mixed $sections array of section names, single * section or null * * @return \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template - * @throws \SmartyException + * @throws \Exception */ public function configLoad(Smarty_Internal_Data $data, $config_file, $sections = null) { @@ -45,28 +45,26 @@ class Smarty_Internal_Method_ConfigLoad * @link http://www.smarty.net/docs/en/api.config.load.tpl * * @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data - * @param string $config_file filename - * @param mixed $sections array of section names, single + * @param string $config_file filename + * @param mixed $sections array of section names, single * section or null * @param int $scope scope into which config variables * shall be loaded * - * @return \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template - * @throws \SmartyException + * @throws \Exception */ public function _loadConfigFile(Smarty_Internal_Data $data, $config_file, $sections = null, $scope = 0) { /* @var \Smarty $smarty */ - $smarty = isset($data->smarty) ? $data->smarty : $data; + $smarty = $data->_getSmartyObj(); /* @var \Smarty_Internal_Template $confObj */ - $confObj = new Smarty_Internal_Template($config_file, $smarty, $data); + $confObj = new Smarty_Internal_Template($config_file, $smarty, $data, null, null, null, null, true); $confObj->caching = Smarty::CACHING_OFF; - $confObj->source = Smarty_Template_Config::load($confObj); $confObj->source->config_sections = $sections; $confObj->source->scope = $scope; $confObj->compiled = Smarty_Template_Compiled::load($confObj); $confObj->compiled->render($confObj); - if ($data->_objType == 2) { + if ($data->_isTplObj()) { $data->compiled->file_dependency[ $confObj->source->uid ] = array($confObj->source->filepath, $confObj->source->getTimeStamp(), $confObj->source->type); } @@ -76,28 +74,28 @@ class Smarty_Internal_Method_ConfigLoad * load config variables into template object * * @param \Smarty_Internal_Template $tpl - * @param array $new_config_vars - * + * @param array $new_config_vars */ public function _loadConfigVars(Smarty_Internal_Template $tpl, $new_config_vars) { $this->_assignConfigVars($tpl->parent->config_vars, $tpl, $new_config_vars); $tagScope = $tpl->source->scope; if ($tagScope >= 0) { - if ($tagScope == Smarty::SCOPE_LOCAL) { + if ($tagScope === Smarty::SCOPE_LOCAL) { $this->_updateVarStack($tpl, $new_config_vars); $tagScope = 0; if (!$tpl->scope) { return; } } - if ($tpl->parent->_objType == 2 && ($tagScope || $tpl->parent->scope)) { + if ($tpl->parent->_isTplObj() && ($tagScope || $tpl->parent->scope)) { $mergedScope = $tagScope | $tpl->scope; if ($mergedScope) { // update scopes + /* @var \Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data $ptr */ foreach ($tpl->smarty->ext->_updateScope->_getAffectedScopes($tpl->parent, $mergedScope) as $ptr) { $this->_assignConfigVars($ptr->config_vars, $tpl, $new_config_vars); - if ($tagScope && $ptr->_objType == 2 && isset($tpl->_cache[ 'varStack' ])) { + if ($tagScope && $ptr->_isTplObj() && isset($tpl->_cache[ 'varStack' ])) { $this->_updateVarStack($tpl, $new_config_vars); } } @@ -109,9 +107,9 @@ class Smarty_Internal_Method_ConfigLoad /** * Assign all config variables in given scope * - * @param array $config_vars config variables in scope + * @param array $config_vars config variables in scope * @param \Smarty_Internal_Template $tpl - * @param array $new_config_vars loaded config variables + * @param array $new_config_vars loaded config variables */ public function _assignConfigVars(&$config_vars, Smarty_Internal_Template $tpl, $new_config_vars) { @@ -120,19 +118,19 @@ class Smarty_Internal_Method_ConfigLoad if ($tpl->smarty->config_overwrite || !isset($config_vars[ $variable ])) { $config_vars[ $variable ] = $value; } else { - $config_vars[ $variable ] = array_merge((array) $config_vars[ $variable ], (array) $value); + $config_vars[ $variable ] = array_merge((array)$config_vars[ $variable ], (array)$value); } } // scan sections $sections = $tpl->source->config_sections; if (!empty($sections)) { - foreach ((array) $sections as $tpl_section) { + foreach ((array)$sections as $tpl_section) { if (isset($new_config_vars[ 'sections' ][ $tpl_section ])) { foreach ($new_config_vars[ 'sections' ][ $tpl_section ][ 'vars' ] as $variable => $value) { if ($tpl->smarty->config_overwrite || !isset($config_vars[ $variable ])) { $config_vars[ $variable ] = $value; } else { - $config_vars[ $variable ] = array_merge((array) $config_vars[ $variable ], (array) $value); + $config_vars[ $variable ] = array_merge((array)$config_vars[ $variable ], (array)$value); } } } @@ -151,22 +149,22 @@ class Smarty_Internal_Method_ConfigLoad $i = 0; while (isset($tpl->_cache[ 'varStack' ][ $i ])) { $this->_assignConfigVars($tpl->_cache[ 'varStack' ][ $i ][ 'config' ], $tpl, $config_vars); - $i ++; + $i++; } } /** * gets a config variable value * - * @param \Smarty_Internal_Template $tpl template object - * @param string $varName the name of the config variable - * @param bool $errorEnable + * @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data + * @param string $varName the name of the config variable + * @param bool $errorEnable * - * @return mixed the value of the config variable + * @return null|string the value of the config variable */ - public function _getConfigVariable(Smarty_Internal_Template $tpl, $varName, $errorEnable = true) + public function _getConfigVariable(Smarty_Internal_Data $data, $varName, $errorEnable = true) { - $_ptr = $tpl; + $_ptr = $data; while ($_ptr !== null) { if (isset($_ptr->config_vars[ $varName ])) { // found it, return it @@ -175,7 +173,7 @@ class Smarty_Internal_Method_ConfigLoad // not found, try at parent $_ptr = $_ptr->parent; } - if ($tpl->smarty->error_unassigned && $errorEnable) { + if ($data->smarty->error_unassigned && $errorEnable) { // force a notice $x = $$varName; } |