4124f355043d505bd682ad4d385b64cffae61993
[atutor.git] / mods / phpdoc2 / PhpDocumentor / phpDocumentor / Smarty-2.6.0 / libs / core / core.write_compiled_include.php
1 <?php\r
2 /**\r
3  * Smarty plugin\r
4  * @package Smarty\r
5  * @subpackage plugins\r
6  */\r
7 \r
8 /**\r
9  * Extract non-cacheable parts out of compiled template and write it\r
10  *\r
11  * @param string $compile_path\r
12  * @param string $template_compiled\r
13  * @param integer $template_timestamp\r
14  * @return boolean\r
15  */\r
16 \r
17 function smarty_core_write_compiled_include($params, &$smarty)\r
18 {\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
21 \r
22     preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',\r
23                    $params['compiled_content'], $_match_source, PREG_SET_ORDER);\r
24 \r
25     // no nocache-parts found: done\r
26     if (count($_match_source)==0) return;\r
27 \r
28     // convert the matched php-code to functions\r
29     $_include_compiled = "<?php /* funky header here */\n\n";\r
30 \r
31     $_compile_path = $params['include_file_path'];\r
32 \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
35 \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
42 {\r
43 $_match[4]\r
44 }\r
45 \r
46 ";\r
47     }\r
48     $_include_compiled .= "\n\n?>\n";\r
49 \r
50     $_params = array('filename' => $_compile_path,\r
51                      'contents' => $_include_compiled, 'create_dirs' => true);\r
52 \r
53     require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php');\r
54     smarty_core_write_file($_params, $smarty);\r
55     return true;\r
56 }\r
57 \r
58 \r
59 ?>\r