Index: trunk/core/kernel/parser/template_parser.php =================================================================== diff -u -r1745 -r1780 --- trunk/core/kernel/parser/template_parser.php (.../template_parser.php) (revision 1745) +++ trunk/core/kernel/parser/template_parser.php (.../template_parser.php) (revision 1780) @@ -142,20 +142,20 @@ function AppendCompiledFunction($f_name, $f_body) { + $real_name = 'f_'.abs(crc32($this->TemplateName)).'_'.$f_name; if (defined('EXPERIMENTAL_PRE_PARSE')) { + // if such function already compiled if ( isset($this->Application->CompiledFunctions[$f_name]) || - function_exists($f_name) - ) { + function_exists($real_name) + ) + { if (!isset($this->Application->CompiledFunctions[$f_name])) { - $real_name = $f_name.'_'; + $real_name = $real_name.'_'; } else { $real_name = $this->Application->CompiledFunctions[$f_name].'_'; } } - else { - $real_name = $f_name; - } $this->CompiledBuffer .= 'if (!function_exists(\''.$real_name.'\')) {'."\n"; @@ -313,6 +313,23 @@ } } + function CheckDir($dir) + { + if (file_exists($dir)) { + return; + } + else { + $segments = explode('/', $dir); + $cur_path = ''; + foreach ($segments as $segment) { + $cur_path .= '/'.$segment; + if (!file_exists($cur_path)) { + mkdir($cur_path); + } + } + } + } + function Parse($template, $name='unknown', $pre_parse = 1) { $this->Template = $template; @@ -324,6 +341,10 @@ if (defined('EXPERIMENTAL_PRE_PARSE') && $pre_parse) { $template_cache =& $this->Application->recallObject('TemplatesCache'); $fname = $template_cache->GetRealFilename($this->TemplateName).'.php'; + + $fname = str_replace(DOC_ROOT.BASE_PATH, DOC_ROOT.BASE_PATH.'/kernel/cache', $fname); + $this->CheckDir(dirname($fname)); + $tname = $template_cache->GetRealFilename($this->TemplateName).'.tpl'; if (file_exists($fname) && filemtime($fname) > filemtime($tname)) {