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(),
$templateContent = readFromFile($FQFN);
// Prepare it for finaly eval() command
- $GLOBALS['template_eval']['xml'][$template] = '$templateContent = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($templateContent), false, true, true, $compileCode) . '");';
+ $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]);
$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');
// 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
// 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) {
assert(isset($columnArray[$childKey]));
// Now is it what we are looking for?
- if ($columnArray[$childKey] == $value) {
+ if ($columnArray[$childKey] === $value) {
// Remember this match
$return = $key;