]> git.mxchange.org Git - mailer.git/blobdiff - inc/xml-functions.php
The content in these columns were to long
[mailer.git] / inc / xml-functions.php
index 10c3d95e96d9e27956c9ef3d8ff14b596cedeec5..6c5e5812a4d7bdb88129ceac0a947fba4d69add8 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,14 +99,14 @@ 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?
        if (function_exists($FQCN)) {
                // Call it
                call_user_func($FQCN);
-       } else {
+       } elseif (isDebugModeEnabled()) {
                // This callback function is only optional
                logDebugMessage(__FUNCTION__, __LINE__, 'Call-back function ' . $FQCN . ' for template ' . $template . ' does not exist.');
        }
@@ -102,7 +114,7 @@ function addXmlSpecialElements ($template) {
 
 // Parses the XML content
 function parseXmlData ($content) {
-       // Do we have recode?
+       // Is there recode?
        if (!function_exists('recode')) {
                // No fallback ATM
                reportBug('PHP extension recode is missing. Please install it.');
@@ -115,7 +127,7 @@ function parseXmlData ($content) {
        $xmlParser = xml_parser_create();
 
        // Force case-folding to on
-       xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, true);
+       xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, TRUE);
 
        // Set UTF-8
        xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
@@ -139,7 +151,7 @@ function parseXmlData ($content) {
 function doCallXmlCallbackFunction () {
        // Loop through all added entries
        foreach ($GLOBALS['__XML_CALLBACKS']['callbacks'] as $callback) {
-               // Do we have the entry?
+               // Is there the entry?
                if ((isset($GLOBALS['__XML_CALLBACKS']['functions'][$callback])) && (isset($GLOBALS['__XML_ARGUMENTS'][$callback]))) {
                        // Run all function callbacks
                        foreach ($GLOBALS['__XML_CALLBACKS']['functions'][$callback] as $function) {
@@ -200,7 +212,7 @@ function xmlCharacterHandler ($resource, $characters) {
        // Trim spaces away
        $characters = trim($characters);
 
-       // Do we have some to handle?
+       // Are there some to handle?
        if (strlen($characters) == 0) {
                // Nothing to handle
                return;
@@ -273,7 +285,7 @@ function getSqlPartFromXmlArray ($columns) {
                // Init SQL part
                $sqlPart = '';
 
-               // Do we have a table/alias
+               // Is there a table/alias
                if (!empty($columnArray['table'])) {
                        // Pre-add it
                        $sqlPart .= $columnArray['table'] . '.';
@@ -299,7 +311,7 @@ function getSqlPartFromXmlArray ($columns) {
 // Searches in given XML array for value and returns the parent index
 function searchXmlArray ($value, $columns, $childKey) {
        // Default is not found
-       $return = false;
+       $return = FALSE;
 
        // Walk through whole array
        foreach ($columns as $key => $columnArray) {