X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fxml-functions.php;h=e180a49fe9fdd69b9db9de59117d45cb569ca71a;hb=46634b1a5b92119c355e59d0d527a8493e51c133;hp=6c5e5812a4d7bdb88129ceac0a947fba4d69add8;hpb=596c8ab32594401ca84abfbfe35513ddfff31bec;p=mailer.git diff --git a/inc/xml-functions.php b/inc/xml-functions.php index 6c5e5812a4..e180a49fe9 100644 --- a/inc/xml-functions.php +++ b/inc/xml-functions.php @@ -40,8 +40,26 @@ if (!defined('__SECURITY')) { die(); } // END - if +// Init XML system +function initXml () { + // All conditions + $GLOBALS['__XML_CONDITIONS'] = array( + // Equals not + 'NOT-EQUALS' => ' != ', + // Is not + 'IS-NOT' => ' IS NOT ', + // Is + 'IS' => ' IS ', + // Equals + 'EQUALS' => ' = ', + ); +} + // Calls back a function based on given XML template data -function showEntriesByXmlCallback ($template, $content = array(), $compileCode = TRUE) { +function doGenericXmlTemplateCallback ($template, $content = array(), $compileCode = TRUE) { + // Init XML system as sch calls will be only used once per run + initXml(); + // Generate FQFN for with special path $FQFN = sprintf("%stemplates/xml/%s%s.xml", getPath(), @@ -82,6 +100,7 @@ function showEntriesByXmlCallback ($template, $content = array(), $compileCode = ); $GLOBALS['__XML_ARGUMENTS'] = array(); $GLOBALS['__COLUMN_INDEX'] = array(); + $GLOBALS['__XML_CONTENT'] = $content; // Handle it over to the parser parseXmlData($templateContent); @@ -90,7 +109,7 @@ function showEntriesByXmlCallback ($template, $content = array(), $compileCode = addXmlSpecialElements($template); // Call the call-back function - doCallXmlCallbackFunction(); + doCallXmlCallbackFunction($content); } else { // Template not found displayMessage('{%message,XML_TEMPLATE_404=' . $template . '%}'); @@ -170,11 +189,11 @@ function doCallXmlCallbackFunction () { // Is it there? if (!function_exists($callbackName)) { // No, then please add it - reportBug(__FUNCTION__, __LINE__, 'callback=' . $callback . ',function=' . $function . 'arguments()=' . count($GLOBALS['__XML_ARGUMENTS'][$callback]) . ' - execute call-back does not exist.'); + reportBug(__FUNCTION__, __LINE__, 'callback=' . $callback . ',function=' . $function . ',arguments()=' . count($GLOBALS['__XML_ARGUMENTS'][$callback]) . ',content()=' . count($GLOBALS['__XML_CONTENT']) . ' - execute call-back does not exist.'); } // END - if // Call it - call_user_func_array($callbackName, array($function, $GLOBALS['__XML_ARGUMENTS'][$callback], $GLOBALS['__COLUMN_INDEX'][$callback])); + call_user_func_array($callbackName, array($function, $GLOBALS['__XML_ARGUMENTS'][$callback], $GLOBALS['__COLUMN_INDEX'][$callback], $GLOBALS['__XML_CONTENT'])); } // END - foreach } else { // Not found @@ -213,7 +232,7 @@ function xmlCharacterHandler ($resource, $characters) { $characters = trim($characters); // Are there some to handle? - if (strlen($characters) == 0) { + if (empty($characters)) { // Nothing to handle return; } // END - if @@ -257,22 +276,13 @@ function isXmlValueValid ($type, $value) { // Converts given condition into a symbol function convertXmlContion ($condition) { - // Default is an invalid one - $return = '???'; - // Detect the condition again - switch ($condition) { - case 'EQUALS': // Equals - $return = '='; - break; - - default: // Unknown condition - reportBug(__FUNCTION__, __LINE__, 'Condition ' . $condition . ' is unknown/unsupported.'); - break; - } // END - switch + if (!isset($GLOBALS['__XML_CONDITIONS'][$condition])) { + reportBug(__FUNCTION__, __LINE__, 'Condition ' . $condition . ' is unknown/unsupported.'); + } // END - if // Return it - return $return; + return $GLOBALS['__XML_CONDITIONS'][$condition]; } // "Getter" for sql part back from given array @@ -319,7 +329,8 @@ function searchXmlArray ($value, $columns, $childKey) { assert(isset($columnArray[$childKey])); // Now is it what we are looking for? - if ($columnArray[$childKey] == $value) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ',key=' . $key . ',childKey=' . $childKey . ',columnArray=' . $columnArray[$childKey]); + if ($columnArray[$childKey] === $value) { // Remember this match $return = $key;