]> git.mxchange.org Git - friendica.git/blobdiff - library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php
reverting tinymce changes, updating smarty to 3.1.19
[friendica.git] / library / Smarty / libs / sysplugins / smarty_internal_config_file_compiler.php
index b16a6940d338e103e3db82efcd2aca3b82bc0e2d..11731043997048001246d91df2d0df7fe04359c1 100644 (file)
@@ -1,23 +1,22 @@
 <?php
 /**
  * Smarty Internal Plugin Config File Compiler
- *
  * This is the config file compiler class. It calls the lexer and parser to
  * perform the compiling.
  *
- * @package Smarty
+ * @package    Smarty
  * @subpackage Config
- * @author Uwe Tews
+ * @author     Uwe Tews
  */
 
 /**
  * Main config file compiler class
  *
- * @package Smarty
+ * @package    Smarty
  * @subpackage Config
  */
-class Smarty_Internal_Config_File_Compiler {
-
+class Smarty_Internal_Config_File_Compiler
+{
     /**
      * Lexer object
      *
@@ -69,7 +68,8 @@ class Smarty_Internal_Config_File_Compiler {
      * Method to compile a Smarty template.
      *
      * @param  Smarty_Internal_Config $config config object
-     * @return bool true if compiling succeeded, false if it failed
+     *
+     * @return bool                   true if compiling succeeded, false if it failed
      */
     public function compileSource(Smarty_Internal_Config $config)
     {
@@ -84,28 +84,46 @@ class Smarty_Internal_Config_File_Compiler {
             return true;
         }
         // init the lexer/parser to compile the config file
-        $lex = new Smarty_Internal_Configfilelexer($_content, $this->smarty);
+        $lex = new Smarty_Internal_Configfilelexer($_content, $this);
         $parser = new Smarty_Internal_Configfileparser($lex, $this);
-        if ($this->smarty->_parserdebug) $parser->PrintTrace();
+
+        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";
+            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) . '; ?>';
     }
 
     /**
      * display compiler error messages without dying
-     *
      * If parameter $args is empty it is a parser detected syntax error.
-     * In this case the parser is called to obtain information about exspected tokens.
-     *
+     * In this case the parser is called to obtain information about expected tokens.
      * If parameter $args contains a string this is used as error message
      *
      * @param string $args individual error message or null
+     *
+     * @throws SmartyCompilerException
      */
     public function trigger_config_file_error($args = null)
     {
@@ -117,12 +135,12 @@ class Smarty_Internal_Config_File_Compiler {
             // $line--;
         }
         $match = preg_split("/\n/", $this->lex->data);
-        $error_text = "Syntax error in config file '{$this->config->source->filepath}' on line {$line} '{$match[$line-1]}' ";
+        $error_text = "Syntax error in config file '{$this->config->source->filepath}' on line {$line} '{$match[$line - 1]}' ";
         if (isset($args)) {
             // individual error message
             $error_text .= $args;
         } else {
-            // exspected token from parser
+            // expected token from parser
             foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
                 $exp_token = $this->parser->yyTokenName[$token];
                 if (isset($this->lex->smarty_token_names[$exp_token])) {
@@ -138,7 +156,4 @@ class Smarty_Internal_Config_File_Compiler {
         }
         throw new SmartyCompilerException($error_text);
     }
-
 }
-
-?>
\ No newline at end of file