Caching of XML/email templates finished:
[mailer.git] / inc / xml-functions.php
index c3cfa51b0be8109eeb207bdbfd813cd1462c698b..d0963f4b22f203ee895d4e64a026edd4ebf95b90 100644 (file)
@@ -41,11 +41,11 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Calls back a function based on given XML template data
-function showEntriesByXmlCallback ($template) {
+function showEntriesByXmlCallback ($template, $content = array(), $compileCode = true) {
        // Generate FQFN for with special path
        $FQFN = sprintf("%stemplates/xml/%s%s.xml",
                getPath(),
-               detectExtraTemplatePath($template),
+               detectExtraTemplatePath('xml', $template),
                $template
        );
 
@@ -60,8 +60,20 @@ function showEntriesByXmlCallback ($template) {
 
        // Is it again readable?
        if (isFileReadable($FQFN)) {
-               // Read it
-               $templateContent = readFromFile($FQFN);
+               // Is there cache?
+               if ((!isDebuggingTemplateCache()) && (isTemplateCached('xml', $template))) {
+                       // Evaluate the cache
+                       eval(readTemplateCache('xml', $template));
+               } else {
+                       // Read it
+                       $templateContent = readFromFile($FQFN);
+
+                       // Prepare it for finaly eval() command
+                       $GLOBALS['template_eval']['xml'][$template] = '$templateContent = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($templateContent), false, true, true, $compileCode) . '");';
+
+                       // Eval the code, this does insert any array elements from $content
+                       eval($GLOBALS['template_eval']['xml'][$template]);
+               }
 
                // Init main arrays
                $GLOBALS['__XML_CALLBACKS'] = array(
@@ -87,7 +99,7 @@ function showEntriesByXmlCallback ($template) {
 
 // Adds special elements by calling back another template-depending function
 function addXmlSpecialElements ($template) {
-       // Generate the FQCN (Full-Qualified CallbackName)
+       // Generate the FQCN (Full-Qualified Callback Name)
        $FQCN = 'addXmlSpecial' . capitalizeUnderscoreString($template);
 
        // Is it there?