From eab8a101e7a3fcbb41e01a574985e06c5a3775de Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 18 Oct 2018 02:40:38 +0200 Subject: Updating Smarty --- .../smarty_internal_config_file_compiler.php | 54 +++++++++++++--------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'lib/smarty3/sysplugins/smarty_internal_config_file_compiler.php') diff --git a/lib/smarty3/sysplugins/smarty_internal_config_file_compiler.php b/lib/smarty3/sysplugins/smarty_internal_config_file_compiler.php index 1afb92c..a842fa8 100644 --- a/lib/smarty3/sysplugins/smarty_internal_config_file_compiler.php +++ b/lib/smarty3/sysplugins/smarty_internal_config_file_compiler.php @@ -97,46 +97,59 @@ class Smarty_Internal_Config_File_Compiler * @param Smarty_Internal_Template $template * * @return bool true if compiling succeeded, false if it failed + * @throws \SmartyException */ public function compileTemplate(Smarty_Internal_Template $template) { $this->template = $template; $this->template->compiled->file_dependency[ $this->template->source->uid ] = - array($this->template->source->filepath, $this->template->source->getTimeStamp(), - $this->template->source->type); + array( + $this->template->source->filepath, + $this->template->source->getTimeStamp(), + $this->template->source->type + ); if ($this->smarty->debugging) { - if (!isset( $this->smarty->_debug)) { - $this->smarty->_debug = new Smarty_Internal_Debug(); + if (!isset($this->smarty->_debug)) { + $this->smarty->_debug = new Smarty_Internal_Debug(); } $this->smarty->_debug->start_compile($this->template); } // init the lexer/parser to compile the config file - /* @var Smarty_Internal_ConfigFileLexer $lex */ - $lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) . "\n", - $this); - /* @var Smarty_Internal_ConfigFileParser $parser */ - $parser = new $this->parser_class($lex, $this); - - if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { + /* @var Smarty_Internal_ConfigFileLexer $this ->lex */ + $this->lex = new $this->lexer_class( + str_replace( + array( + "\r\n", + "\r" + ), + "\n", + $template->source->getContent() + ) . "\n", + $this + ); + /* @var Smarty_Internal_ConfigFileParser $this ->parser */ + $this->parser = new $this->parser_class($this->lex, $this); + if (function_exists('mb_internal_encoding') + && function_exists('ini_get') + && ((int)ini_get('mbstring.func_overload')) & 2 + ) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('ASCII'); } else { $mbEncoding = null; } - if ($this->smarty->_parserdebug) { - $parser->PrintTrace(); + $this->parser->PrintTrace(); } // get tokens from lexer and parse them - while ($lex->yylex()) { + while ($this->lex->yylex()) { if ($this->smarty->_parserdebug) { - echo "
Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n"; + echo "
Parsing {$this->parser->yyTokenName[$this->lex->token]} Token {$this->lex->value} Line {$this->lex->line} \n"; } - $parser->doParse($lex->token, $lex->value); + $this->parser->doParse($this->lex->token, $this->lex->value); } // finish parsing process - $parser->doParse(0, 0); - + $this->parser->doParse(0, 0); if ($mbEncoding) { mb_internal_encoding($mbEncoding); } @@ -147,8 +160,7 @@ class Smarty_Internal_Config_File_Compiler $template_header = "template->source->filepath . "\" */ ?>\n"; - + $template_header .= " compiled from '{$this->template->source->filepath}' */ ?>\n"; $code = 'smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' . var_export($this->config_data, true) . '); ?>'; return $template_header . $this->template->smarty->ext->_codeFrame->create($this->template, $code); @@ -166,8 +178,6 @@ class Smarty_Internal_Config_File_Compiler */ public function trigger_config_file_error($args = null) { - $this->lex = Smarty_Internal_Configfilelexer::instance(); - $this->parser = Smarty_Internal_Configfileparser::instance(); // get config source line which has error $line = $this->lex->line; if (isset($args)) { -- cgit v1.2.3