X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fxml-functions.php;h=09373597f1b5e8b1e8aed563caeca0264cfda4e3;hb=e68f2f7b0a55fa31eb7ce5baf844dca40f11abea;hp=04550bc6da6afa1f1901b1efb6bbd93ff1cdc5b4;hpb=9197694ce183b69384a385a6c4a5e16988c7fb09;p=mailer.git diff --git a/inc/xml-functions.php b/inc/xml-functions.php index 04550bc6da..09373597f1 100644 --- a/inc/xml-functions.php +++ b/inc/xml-functions.php @@ -63,6 +63,13 @@ function showEntriesByXmlCallback ($template) { // Read it $templateContent = readFromFile($FQFN); + // Init main arrays + $GLOBALS['__XML_CALLBACKS'] = array( + 'callbacks' => array(), + 'functions' => array() + ); + $GLOBALS['__XML_ARGUMENTS'] = array(); + // Handle it over to the parser parseXmlData($templateContent); @@ -117,6 +124,15 @@ function doCallXmlCallbackFunction () { if ((isset($GLOBALS['__XML_CALLBACKS']['functions'][$callback])) && (isset($GLOBALS['__XML_ARGUMENTS'][$callback]))) { // Run all function callbacks foreach ($GLOBALS['__XML_CALLBACKS']['functions'][$callback] as $function) { + // Trim all function names + $function = trim($function); + + // If the function is empty, simply skip to the (maybe) next one + if (empty($function)) { + // Skip this + continue; + } // END - if + // Now construct the call-back function's name with 'Execute' at the end $callbackName = $callback . 'Execute'; @@ -135,9 +151,9 @@ function doCallXmlCallbackFunction () { } // END - foreach } -// ---------------------------------------------------------------------------- +//----------------------------------------------------------------------------- // Call-back functions for XML parser -// ---------------------------------------------------------------------------- +//----------------------------------------------------------------------------- // Starts an element function startXmlElement ($resource, $element, $attributes) { @@ -178,7 +194,16 @@ function isInvalidXmlType ($type) { $type = strtolower(trim($type)); // Is it found? - return (in_array($type, array('string', 'array', 'bool'))); + return (in_array($type, array('string', 'array', 'bool', 'int', 'callback'))); +} + +// Checks if given condition is valid +function isXmlConditionValid ($condition) { + // Trim and make lower-case + $condition = trim(strtolower($condition)); + + // Is it valid? + return (in_array($condition, array('equals'))); } // Checks if given value is valid/verifyable @@ -196,5 +221,25 @@ function isXmlValueValid ($type, $value) { return call_user_func_array($callbackFunction, array($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 + debug_report_bug(__FUNCTION__, __LINE__, 'Condition ' . $condition . ' is unknown/unsupported.'); + break; + } // END - switch + + // Return it + return $return; +} + // [EOF] ?>