5 * @subpackage plugins
\r
9 * Extract non-cacheable parts out of compiled template and write it
\r
11 * @param string $compile_path
\r
12 * @param string $template_compiled
\r
13 * @param integer $template_timestamp
\r
17 function smarty_core_write_compiled_include($params, &$smarty)
\r
19 $_tag_start = 'if \(\$this->caching\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}';
\r
20 $_tag_end = 'if \(\$this->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
\r
22 preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
\r
23 $params['compiled_content'], $_match_source, PREG_SET_ORDER);
\r
25 // no nocache-parts found: done
\r
26 if (count($_match_source)==0) return;
\r
28 // convert the matched php-code to functions
\r
29 $_include_compiled = "<?php /* funky header here */\n\n";
\r
31 $_compile_path = $params['include_file_path'];
\r
33 $smarty->_cache_serials[$_compile_path] = $params['cache_serial'];
\r
34 $_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$params['cache_serial']."';\n\n?>";
\r
36 $_include_compiled .= $params['plugins_code'];
\r
37 $_include_compiled .= "<?php";
\r
38 for ($_i = 0, $_for_max = count($_match_source); $_i < $_for_max; $_i++) {
\r
39 $_match =& $_match_source[$_i];
\r
40 $_include_compiled .= "
\r
41 function _smarty_tplfunc_$_match[2]_$_match[3](&\$this)
\r
48 $_include_compiled .= "\n\n?>\n";
\r
50 $_params = array('filename' => $_compile_path,
\r
51 'contents' => $_include_compiled, 'create_dirs' => true);
\r
53 require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php');
\r
54 smarty_core_write_file($_params, $smarty);
\r