/** * assigns values to template variables by reference * * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data * @param string $tpl_var the template variable name * @param $value * @param boolean $nocache if true any output of this variable will be not cached * * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty */ public function assignByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $nocache) { if ($tpl_var != '') { $data->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache); $data->tpl_vars[$tpl_var]->value =& $value; if ($data->_isTplObj() && $data->scope) { $data->ext->_updateScope->_updateScope($data, $tpl_var); } } return $data; }
/** * load a config file, optionally load just selected sections * * @api Smarty::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 * section or null * @param int $scope scope into which config variables * shall be loaded * * @return \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template * @throws \SmartyException */ public function _loadConfigFile(Smarty_Internal_Data $data, $config_file, $sections = null, $scope = 0) { /* @var \Smarty $smarty */ $smarty = $data->_getSmartyObj(); /* @var \Smarty_Internal_Template $confObj */ $confObj = new Smarty_Internal_Template($config_file, $smarty, $data, null, null, null, null, true); $confObj->caching = Smarty::CACHING_OFF; $confObj->source->config_sections = $sections; $confObj->source->scope = $scope; $confObj->compiled = Smarty_Template_Compiled::load($confObj); $confObj->compiled->render($confObj); if ($data->_isTplObj()) { $data->compiled->file_dependency[$confObj->source->uid] = array($confObj->source->filepath, $confObj->source->getTimeStamp(), $confObj->source->type); } }
/** * appends values to template variables by reference * * @api Smarty::appendByRef() * @link http://www.smarty.net/docs/en/api.append.by.ref.tpl * * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data * @param string $tpl_var the template variable name * @param mixed &$value the referenced value to append * @param bool $merge flag if array elements shall be merged * * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty */ public static function appendByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $merge = false) { if ($tpl_var != '' && isset($value)) { if (!isset($data->tpl_vars[$tpl_var])) { $data->tpl_vars[$tpl_var] = new Smarty_Variable(); } if (!is_array($data->tpl_vars[$tpl_var]->value)) { settype($data->tpl_vars[$tpl_var]->value, 'array'); } if ($merge && is_array($value)) { foreach ($value as $_key => $_val) { $data->tpl_vars[$tpl_var]->value[$_key] =& $value[$_key]; } } else { $data->tpl_vars[$tpl_var]->value[] =& $value; } if ($data->_isTplObj() && $data->scope) { $data->ext->_updateScope->_updateScope($data, $tpl_var); } } return $data; }