phpDocumentor Smarty
plugins
[ class tree: Smarty ] [ index: Smarty ] [ all elements ]

Source for file core.write_compiled_include.php

Documentation is available at core.write_compiled_include.php

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7.  
  8. /**
  9.  * Extract non-cacheable parts out of compiled template and write it
  10.  *
  11.  * @param string $compile_path 
  12.  * @param string $template_compiled 
  13.  * @param integer $template_timestamp 
  14.  * @return boolean 
  15.  */
  16.  
  17. function smarty_core_write_compiled_include($params&$smarty)
  18. {
  19.     $_tag_start 'if \(\$this->caching\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}';
  20.     $_tag_end   'if \(\$this->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
  21.  
  22.     preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
  23.                    $params['compiled_content']$_match_sourcePREG_SET_ORDER);
  24.  
  25.     // no nocache-parts found: done
  26.     if (count($_match_source)==0return;
  27.  
  28.     // convert the matched php-code to functions
  29.     $_include_compiled "<?php /* funky header here */\n\n";
  30.  
  31.     $_compile_path $params['include_file_path'];
  32.  
  33.     $smarty->_cache_serials[$_compile_path$params['cache_serial'];
  34.     $_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$params['cache_serial']."';\n\n?>";
  35.  
  36.     $_include_compiled .= $params['plugins_code'];
  37.     $_include_compiled .= "<?php";
  38.     for ($_i 0$_for_max count($_match_source)$_i $_for_max$_i++{
  39.         $_match =$_match_source[$_i];
  40.         $_include_compiled .= "
  41. function _smarty_tplfunc_$_match[2]_$_match[3](&\$this)
  42. {
  43. $_match[4]
  44. }
  45.  
  46. ";
  47.     }
  48.     $_include_compiled .= "\n\n?>\n";
  49.  
  50.     $_params array('filename' => $_compile_path,
  51.                      'contents' => $_include_compiled'create_dirs' => true);
  52.  
  53.     require_once(SMARTY_DIR 'core' DIRECTORY_SEPARATOR 'core.write_file.php');
  54.     smarty_core_write_file($_params$smarty);
  55.     return true;
  56. }
  57.  
  58.  
  59. ?>

Documentation generated on Tue, 24 Oct 2006 09:22:00 -0500 by phpDocumentor 1.3.1