summaryrefslogtreecommitdiff
path: root/lib/smarty3/sysplugins/smarty_internal_config_file_compiler.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/smarty3/sysplugins/smarty_internal_config_file_compiler.php')
-rw-r--r--lib/smarty3/sysplugins/smarty_internal_config_file_compiler.php54
1 files changed, 32 insertions, 22 deletions
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 "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n";
+ echo "<br>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 =
"<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
"\n";
- $template_header .= " compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
-
+ $template_header .= " compiled from '{$this->template->source->filepath}' */ ?>\n";
$code = '<?php $_smarty_tpl->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)) {