diff --git a/library/smarty/libs/sysplugins/smarty_internal_function_call_handler.php b/library/smarty/libs/sysplugins/smarty_internal_function_call_handler.php new file mode 100644 --- /dev/null +++ b/library/smarty/libs/sysplugins/smarty_internal_function_call_handler.php @@ -0,0 +1,69 @@ +properties['tpl_function'][$_name]; + if (is_file($funcParam['compiled_filepath'])) { + // read compiled file + $code = file_get_contents($funcParam['compiled_filepath']); + // grab template function + if (preg_match("/\/\* {$_function} \*\/([\S\s]*?)\/\*\/ {$_function} \*\//", $code, $match)) { + // grab source info from file dependency + preg_match("/\s*'{$funcParam['uid']}'([\S\s]*?)\),/", $code, $match1); + unset($code); + $output = ''; + // make PHP function known + eval($match[0]); + if (function_exists($_function)) { + // search cache file template + $tplPtr = $_smarty_tpl; + while (!isset($tplPtr->cached) && isset($tplPtr->parent)) { + $tplPtr = $tplPtr->parent; + } + // add template function code to cache file + if (isset($tplPtr->cached)) { + $cache = $tplPtr->cached; + $content = $cache->read($tplPtr); + if ($content) { + // check if we must update file dependency + if (!preg_match("/'{$funcParam['uid']}'([\S\s]*?)'nocache_hash'/", $content, $match2)) { + $content = preg_replace("/('file_dependency'([\S\s]*?)\()/", "\\1{$match1[0]}", $content); + } + $cache->write($tplPtr, $content . "\n"); + } + } + return true; + } + } + } + return false; + } +}