]> git.mxchange.org Git - mailer.git/blobdiff - inc/callback-functions.php
Continued a bit:
[mailer.git] / inc / callback-functions.php
index 821bbd4dafc3fbab80a69eca80ac126c26e36fc0..9ce22d67cfa74a181422e39fec43ceb3ddc83987 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Call-Back-Funktionen fuer XML-Templates          *
  * -------------------------------------------------------------------- *
- * $Revision::                                                        $ *
- * $Date::                                                            $ *
- * $Tag:: 0.2.1-FINAL                                                 $ *
- * $Author::                                                          $ *
- * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2016 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -43,7 +38,7 @@ if (!defined('__SECURITY')) {
 // Handles the XML node 'admin-entry-meta-data'
 function doXmlAdminEntryMetaData ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes));
        } // END - if
@@ -52,7 +47,7 @@ function doXmlAdminEntryMetaData ($resource, $attributes) {
 // Handles the XML node 'member-entry-meta-data'
 function doXmlMemberEntryMetaData ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes));
        } // END - if
@@ -118,7 +113,7 @@ function doXmlDatabaseTable ($resource, $attributes) {
 // Handles the XML node 'database-column-list'
 function doXmlDatabaseColumnList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } // END - if
@@ -172,7 +167,7 @@ function doXmlDatabaseColumnListEntry ($resource, $attributes) {
 // Handles the XML node 'callback-function-list'
 function doXmlCallbackFunctionList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } // END - if
@@ -214,7 +209,7 @@ function doXmlCallbackFunctionListEntry ($resource, $attributes) {
 // Handles the XML node 'extra-parameter-list'
 function doXmlExtraParameterList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } // END - if
@@ -256,7 +251,7 @@ function doXmlExtraParameterListEntry ($resource, $attributes) {
 // Handles the XML node 'time-columns-list'
 function doXmlTimeColumnsList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } // END - if
@@ -298,7 +293,7 @@ function doXmlTimeColumnsListEntry ($resource, $attributes) {
 // Handles the XML node 'extra-parameter-member-list'
 function doXmlExtraParameterMemberList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['member_list'])) {
@@ -310,7 +305,7 @@ function doXmlExtraParameterMemberList ($resource, $attributes) {
 // Handles the XML node 'extra-parameter-reload-list'
 function doXmlExtraParameterReloadList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['reload_list'])) {
@@ -322,7 +317,7 @@ function doXmlExtraParameterReloadList ($resource, $attributes) {
 // Handles the XML node 'extra-parameter-waiting-list'
 function doXmlExtraParameterWaitingList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['waiting_list'])) {
@@ -424,7 +419,7 @@ function doXmlExtraParameterWaitingListEntry ($resource, $attributes) {
 // Handles the XML node 'extra-parameter-added-list'
 function doXmlExtraParameterAddedList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['added_list'])) {
@@ -466,7 +461,7 @@ function doXmlExtraParameterAddedListEntry ($resource, $attributes) {
 // Handles the XML node 'extra-parameter-created-list'
 function doXmlExtraParameterCreatedList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['created_list'])) {
@@ -538,7 +533,7 @@ function doXmlStatusChangeColumn ($resource, $attributes) {
 // Handles the XML node 'status-change-list'
 function doXmlStatusChangeList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
@@ -740,7 +735,7 @@ function doXmlCacheFile ($resource, $attributes) {
 // Handles the XML node 'admin-list-data'
 function doXmlAdminListData ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes));
        } // END - if
@@ -749,7 +744,7 @@ function doXmlAdminListData ($resource, $attributes) {
 // Handles the XML node 'member-list-data'
 function doXmlMemberListData ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes));
        } // END - if
@@ -758,7 +753,7 @@ function doXmlMemberListData ($resource, $attributes) {
 // Handles the XML node 'data-tables'
 function doXmlDataTables ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes));
        } // END - if
@@ -803,7 +798,7 @@ function doXmlDataTable ($resource, $attributes) {
 // Handles the XML node 'table-join-condition'
 function doXmlTableJoinCondition ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes));
        } // END - if
@@ -855,7 +850,7 @@ function doXmlTableJoinName ($resource, $attributes) {
 // Handles the XML node 'join-on'
 function doXmlJoinOn ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes));
        } // END - if
@@ -958,7 +953,7 @@ function doXmlJoinOnCondition ($resource, $attributes) {
 // Handles the XML node 'select-data-from-list'
 function doXmlSelectDataFromList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_table'])) {
@@ -1012,7 +1007,7 @@ function doXmlSelectDataFromListEntry ($resource, $attributes) {
 // Handles the XML node 'where-select-from-list'
 function doXmlWhereSelectFromList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_table'])) {
@@ -1102,7 +1097,7 @@ function doXmlWhereCondition ($resource, $attributes) {
 // Handles the XML node 'order-by-list'
 function doXmlOrderByList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_table'])) {
@@ -1210,7 +1205,7 @@ function doXmlListRowTemplate ($resource, $attributes) {
 // Handles the XML node 'column-callback-list'
 function doXmlColumnCallbackList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_table'])) {
@@ -1225,7 +1220,7 @@ function doXmlColumnCallbackList ($resource, $attributes) {
 // Handles the XML node 'column-callback-list-entry'
 function doXmlColumnCallbackListEntry ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_callback_list'])) {
@@ -1270,7 +1265,7 @@ function doXmlColumnCallbackData ($resource, $attributes) {
 // Handles the XML node 'callback-extra-parameter-list'
 function doXmlCallbackExtraParameterList ($resource, $attributes) {
        // There should be no attributes
-       if (count($attributes) > 0) {
+       if (isFilledArray($attributes)) {
                // Please don't add any attributes to foo-list nodes
                reportBug(__FUNCTION__, __LINE__, 'Expected 1 attributes because this is a named foo-list node, got ' . count($attributes));
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_callback_list'])) {
@@ -1290,7 +1285,7 @@ function doXmlCallbackExtraParameterListEntry ($resource, $attributes) {
        // There are three attributes, by default
        if (count($attributes) != 3) {
                // Not the right count
-               reportBug(__FUNCTION__, __LINE__, 'Expected 5 attributes, got ' . count($attributes));
+               reportBug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
        } elseif (!isset($attributes['COLUMN'])) {
                // 'COLUMN' not found
                reportBug(__FUNCTION__, __LINE__, 'Required attribute COLUMN not found.');
@@ -1300,15 +1295,18 @@ function doXmlCallbackExtraParameterListEntry ($resource, $attributes) {
        } elseif (!isInvalidXmlType($attributes['TYPE'])) {
                // No valid type
                reportBug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
-       } elseif (!isset($attributes['VALUE'])) {
+       } elseif ((!isset($attributes['VALUE'])) && (!isset($attributes['DATA']))) {
                // 'VALUE' not found
-               reportBug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
-       } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
+               reportBug(__FUNCTION__, __LINE__, 'Required attribute VALUE/DATA not found.');
+       } elseif ((isset($attributes['VALUE'])) && (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE']))) {
                // 'VALUE' not valid/verifyable
                reportBug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
        } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['__EXTRA_PARAMETER'])) {
-               // doXmlCallbackFunction is missing
+               // doXmlCallbackFunction/__EXTRA_PARAMETER is missing
                reportBug(__FUNCTION__, __LINE__, 'Required XML node callback-function/__EXTRA_PARAMETER not included around this node. Please fix your XML.');
+       } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_column_list'])) {
+               // doXmlCallbackFunction/data_column_list is missing
+               reportBug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data_column_list not included around this node.');
        }
 
        // Add the entry to the array
@@ -1320,7 +1318,7 @@ function doXmlNoEntryFoundMessage ($resource, $attributes) {
        // There are two attributes, by default
        if (count($attributes) != 2) {
                // Not the right count
-               reportBug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
+               reportBug(__FUNCTION__, __LINE__, 'Expected 2 attributes, got ' . count($attributes));
        } elseif (!isset($attributes['VALUE'])) {
                // 'VALUE' not found
                reportBug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
@@ -1509,9 +1507,16 @@ function addXmlValueToCallbackAttributes ($element, $attributes, $extraKey = '',
                );
                //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',NAME[' . gettype($attributes['NAME']) . ']=' . $attributes['NAME'] . ' - TYPE-COLUMN! (COLUMN=' . $attributes['COLUMN'] . ')');
                $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][count($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element])] = $array;
-       } elseif (isset($attributes['COLUMN'])) {
+       } elseif ((isset($attributes['COLUMN'])) && (isset($attributes['VALUE']))) {
                // COLUMN/VALUE detected
-               //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ',COLUMN[' . gettype($attributes['COLUMN']) . ']=' . $attributes['COLUMN'] . ' - COLUMN!');
+               //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ',COLUMN[' . gettype($attributes['COLUMN']) . ']=' . $attributes['COLUMN'] . ' - COLUMN/VALUE!');
+               if (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['COLUMN']])) {
+                       $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['COLUMN']] = array();
+               } // END - if
+               $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['COLUMN']][count($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['COLUMN']])] = $attributes['VALUE'];
+       } elseif ((isset($attributes['COLUMN'])) && (isset($attributes['DATA']))) {
+               // COLUMN/DATA detected
+               //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',DATA[' . gettype($attributes['DATA']) . ']=' . $attributes['DATA'] . ',COLUMN[' . gettype($attributes['COLUMN']) . ']=' . $attributes['COLUMN'] . ' - COLUMN/DATA!');
                if (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['COLUMN']])) {
                        $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['COLUMN']] = array();
                } // END - if
@@ -1530,10 +1535,13 @@ function addXmlValueToCallbackAttributes ($element, $attributes, $extraKey = '',
        } elseif (isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['NAME']])) {
                // Already created
                reportBug(__FUNCTION__, __LINE__, 'NAME=' . $attributes['NAME'] . ' already addded to ' . $element . ' attributes=<pre>' . print_r($attributes, TRUE) . '</pre>');
-       } else {
-               // Use from NAME
+       } elseif ((isset($attributes['NAME'])) && (isset($attributes['VALUE']))) {
+               // Use from NAME/VALUE
                //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',NAME=' . $attributes['NAME'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NAME!');
                $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['NAME']] = $attributes['VALUE'];
+       } else {
+               // Unknown stage
+               reportBug(__FUNCTION__, __LINE__, 'Unexpected stage detected. element=' . $element . ',attributes()=' . count($attributes));
        }
        //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',key=' . $key . ' - EXIT!');
 }