cvs: smarty / NEWS /libs Smarty_Compiler.class.php

[email protected] ("Danilo Buerger") Thu, 01 Mar 2007 18:18:56 -0000
Newsgroups php.smarty.cvs
Message-ID <cvsdanilo1172773136@cvsserver>
danilo		Thu Mar  1 18:18:56 2007 UTC

  Modified files:              
    /smarty	NEWS 
    /smarty/libs	Smarty_Compiler.class.php 
  Log:
  Applied boots clean up patch and removed commented out code.
  Updated NEWS file
  
  
  
http://cvs.php.net/viewvc.cgi/smarty/NEWS?r1=1.551&r2=1.552&diff_format=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.551 smarty/NEWS:1.552
--- smarty/NEWS:1.551	Tue Feb 27 22:22:09 2007
+++ smarty/NEWS	Thu Mar  1 18:18:56 2007
@@ -1,3 +1,4 @@
+- fix php handling (monte, boots, danilo)
 - fix handling of plugin tags directly followed by an else tag (Fahr, danilo)
 - fix handling of $etc in the truncate modifier when $etc is longer
   than $length (Sylvinus, messju)
http://cvs.php.net/viewvc.cgi/smarty/libs/Smarty_Compiler.class.php?r1=1.393&r2=1.394&diff_format=u
Index: smarty/libs/Smarty_Compiler.class.php
diff -u smarty/libs/Smarty_Compiler.class.php:1.393 smarty/libs/Smarty_Compiler.class.php:1.394
--- smarty/libs/Smarty_Compiler.class.php:1.393	Tue Feb 27 11:14:10 2007
+++ smarty/libs/Smarty_Compiler.class.php	Thu Mar  1 18:18:56 2007
@@ -26,7 +26,7 @@
  * @package Smarty
  */
 
-/* $Id: Smarty_Compiler.class.php,v 1.393 2007/02/27 11:14:10 danilo Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.394 2007/03/01 18:18:56 danilo Exp $ */
 
 /**
  * Template compiling class
@@ -240,9 +240,6 @@
         $ldq = preg_quote($this->left_delimiter, '~');
         $rdq = preg_quote($this->right_delimiter, '~');
 
-        /* un-hide hidden xml open tags  */
-        $source_content = preg_replace("~<({$ldq}(.*?){$rdq}\?)~s", '< \\1', $source_content);
-
         // run template source through prefilter functions
         if (count($this->_plugins['prefilter']) > 0) {
             foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) {
@@ -353,7 +350,7 @@
         }
         $compiled_content = '';
         
-        $tmp_id = '{'.md5(uniqid(rand(), true)).'}';
+        $tag_guard = '%%%SMARTYOTG' . md5(uniqid(rand(), true)) . '%%%';
         
         /* Interleave the compiled contents and text blocks to get the final result. */
         for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {
@@ -362,19 +359,19 @@
                 $text_blocks[$i+1] = preg_replace('~^(\r\n|\r|\n)~', '', $text_blocks[$i+1]);
             }
             // replace legit PHP tags with placeholder
-            $text_blocks[$i] = str_replace('<?',$tmp_id,$text_blocks[$i]);
-            $compiled_tags[$i] = str_replace('<?',$tmp_id,$compiled_tags[$i]);
+            $text_blocks[$i] = str_replace('<?', $tag_guard, $text_blocks[$i]);
+            $compiled_tags[$i] = str_replace('<?', $tag_guard, $compiled_tags[$i]);
             
-            $compiled_content .= $text_blocks[$i].$compiled_tags[$i];
+            $compiled_content .= $text_blocks[$i] . $compiled_tags[$i];
         }
-        $compiled_content .= str_replace('<?',$tmp_id,$text_blocks[$i]);
+        $compiled_content .= str_replace('<?', $tag_guard, $text_blocks[$i]);
 
         // escape php tags created by interleaving
-        $compiled_content = str_replace('<?',"<?php echo '<?' ?>\n",$compiled_content);
-        $compiled_content = preg_replace("~(?<!')language\s*=\s*[\"\']?\s*php\s*[\"\']?~","<?php echo 'language=php' ?>\n",$compiled_content);
-        
+        $compiled_content = str_replace('<?', "<?php echo '<?' ?>\n", $compiled_content);
+        $compiled_content = preg_replace("~(?<!')language\s*=\s*[\"\']?\s*php\s*[\"\']?~", "<?php echo 'language=php' ?>\n", $compiled_content);
+
         // recover legit tags
-        $compiled_content = str_replace($tmp_id,'<?',$compiled_content); 
+        $compiled_content = str_replace($tag_guard, '<?', $compiled_content); 
         
         // remove \n from the end of the file, if any
         if (strlen($compiled_content) && (substr($compiled_content, -1) == "\n") ) {
@@ -385,11 +382,6 @@
             $compiled_content = "<?php \$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."'; ?>" . $compiled_content;
         }
 
-/*        
-        // remove unnecessary close/open tags
-        $compiled_content = preg_replace('~\?>\n?<\?php~', '', $compiled_content);
-*/
-        
         // run compiled template through postfilter functions
         if (count($this->_plugins['postfilter']) > 0) {
             foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) {