/** * Methode to compile a Smarty template * * @param $template template object to compile * @return bool true if compiling succeeded, false if it failed */ public function compileSource($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->getConfigSource() . "\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); // $parser->PrintTrace(); // get tokens from lexer and parse them while ($lex->yylex()) { // 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 = serialize($this->config_data); if (!$this->compile_error) { return true; } else { // compilation error return false; } }
/** * Methode to compile a Smarty template * * @param $template template object to compile * @return bool true if compiling succeeded, false if it failed */ public function compileSource($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->getConfigSource() . "\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 (isset($this->smarty->_parserdebug)) { $parser->PrintTrace(); } // get tokens from lexer and parse them while ($lex->yylex()) { if (isset($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) . '; ?>'; }
/** * 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); $parser = new Smarty_Internal_Configfileparser($lex, $this); if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('ASCII'); } else { $mbEncoding = null; } 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); if ($mbEncoding) { mb_internal_encoding($mbEncoding); } $config->compiled_config = '<?php $_config_vars = ' . var_export($this->config_data, true) . '; ?>'; }