/** * Method to compile a Smarty template. * * @param Smarty_Internal_Config $config config object * @return bool true if compiling succeeded, false if it failed */ public function compileSource(Smarty_Internal_Config $config) { /* here is where the compiling takes place. Smarty tags in the templates are replaces with PHP code, then written to compiled files. */ $this->config = $config; // get config file source $_content = $config->source->content . "\n"; // on empty template just return if ($_content == '') { return true; } // init the lexer/parser to compile the config file $lex = new Smarty_Internal_Configfilelexer($_content, $this->smarty); $parser = new Smarty_Internal_Configfileparser($lex, $this); if ($this->smarty->_parserdebug) { $parser->PrintTrace(); } // get tokens from lexer and parse them while ($lex->yylex()) { if ($this->smarty->_parserdebug) { echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n"; } $parser->doParse($lex->token, $lex->value); } // finish parsing process $parser->doParse(0, 0); $config->compiled_config = '<?php $_config_vars = ' . var_export($this->config_data, true) . '; ?>'; }
public function compileSource(Smarty_Internal_Config $config) { $this->config = $config; $_content = $config->source->content . "\n"; if ($_content == '') { return true; } $lex = new Smarty_Internal_Configfilelexer($_content, $this->smarty); $parser = new Smarty_Internal_Configfileparser($lex, $this); if ($this->smarty->_parserdebug) { $parser->PrintTrace(); } while ($lex->yylex()) { if ($this->smarty->_parserdebug) { echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n"; } $parser->doParse($lex->token, $lex->value); } $parser->doParse(0, 0); $config->compiled_config = '<?php $_config_vars = ' . var_export($this->config_data, true) . '; ?>'; }