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