]> git.mxchange.org Git - mailer.git/blobdiff - inc/xml-functions.php
Continued a bit:
[mailer.git] / inc / xml-functions.php
index 9506a93e815489250b42c03d77a53444f54caa2d..ee135cfcc51c9baec19856651dfa9641dbe71e5e 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Funktionen zum Umgang mit XML-Templates          *
  * -------------------------------------------------------------------- *
- * $Revision::                                                        $ *
- * $Date::                                                            $ *
- * $Tag:: 0.2.1-FINAL                                                 $ *
- * $Author::                                                          $ *
- * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2012 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 *
@@ -61,7 +56,7 @@ function doGenericXmlTemplateCallback ($template, $content = array(), $compileCo
        initXml();
 
        // Generate FQFN for with special path
-       $FQFN = sprintf("%stemplates/xml/%s%s.xml",
+       $FQFN = sprintf('%stemplates/xml/%s%s.xml',
                getPath(),
                detectExtraTemplatePath('xml', $template),
                $template
@@ -70,7 +65,7 @@ function doGenericXmlTemplateCallback ($template, $content = array(), $compileCo
        // Is the file readable?
        if (!isFileReadable($FQFN)) {
                // No, use without extra path
-               $FQFN = sprintf("%stemplates/xml/%s.xml",
+               $FQFN = sprintf('%stemplates/xml/%s.xml',
                        getPath(),
                        $template
                );
@@ -109,7 +104,7 @@ function doGenericXmlTemplateCallback ($template, $content = array(), $compileCo
                addXmlSpecialElements($template);
 
                // Call the call-back function
-               doCallXmlCallbackFunction($content);
+               doCallXmlCallbackFunction();
        } else {
                // Template not found
                displayMessage('{%message,XML_TEMPLATE_404=' . $template . '%}');
@@ -133,14 +128,8 @@ function addXmlSpecialElements ($template) {
 
 // Parses the XML content
 function parseXmlData ($content) {
-       // Is there recode?
-       if (!function_exists('recode')) {
-               // No fallback ATM
-               reportBug(__FUNCTION__, __LINE__, 'PHP extension recode is missing. Please install it.');
-       } // END - if
-
        // Convert HTML entities to UTF-8
-       $content = recode('html..utf8', $content);
+       $decoded = decodeEntities($content);
 
        // Create a new XML parser
        $xmlParser = xml_parser_create();
@@ -156,7 +145,7 @@ function parseXmlData ($content) {
        xml_set_character_data_handler($xmlParser, 'xmlCharacterHandler');
 
        // Now parse the XML tree
-       if (!xml_parse($xmlParser, $content)) {
+       if (!xml_parse($xmlParser, $decoded)) {
                // Error found in XML!
                //* DEBUG: */ die('<pre>'.htmlentities($content).'</pre>');
                reportBug(__FUNCTION__, __LINE__, 'Error found in XML. errorMessage=' . xml_error_string(xml_get_error_code($xmlParser)) . ', line=' . xml_get_current_line_number($xmlParser));
@@ -339,7 +328,7 @@ function getSqlPartFromXmlArray ($columns) {
 // "Getter" for JOIN statement
 function getSqlXmlJoinedTable ($tableJoinType, $tableJoinName, $joinOnLeftTable, $joinOnCondition, $joinOnRightTable) {
        // Are all set?
-       assert((count($tableJoinType) > 0) && (count($tableJoinName) > 0) && (count($joinOnLeftTable) > 0) && (count($joinOnCondition) > 0) && (count($joinOnRightTable) > 0));
+       assert((isFilledArray($tableJoinType)) && (isFilledArray($tableJoinName)) && (isFilledArray($joinOnLeftTable)) && (isFilledArray($joinOnCondition)) && (isFilledArray($joinOnRightTable)));
 
        // Init SQL
        $sql = '';
@@ -374,7 +363,7 @@ function getSqlXmlWhereConditions ($whereColumns, $conditions) {
        $sql = '';
 
        // Are there some conditions?
-       if (count($whereColumns) > 0) {
+       if (isFilledArray($whereColumns)) {
                // Then add these as well
                if (count($whereColumns) == 1) {
                        // One entry found
@@ -388,7 +377,7 @@ function getSqlXmlWhereConditions ($whereColumns, $conditions) {
 
                        // Add the rest
                        $sql .= '`' . $whereColumns[0]['column'] . '`' . $whereColumns[0]['condition'] . chr(39) . $whereColumns[0]['look_for'] . chr(39);
-               } elseif ((count($whereColumns > 1)) && (count($conditions) > 0)) {
+               } elseif ((count($whereColumns > 1)) && (isFilledArray($conditions))) {
                        // More than one "WHERE" + condition found
                        foreach ($whereColumns as $idx => $columnArray) {
                                // Default is WHERE
@@ -397,11 +386,10 @@ function getSqlXmlWhereConditions ($whereColumns, $conditions) {
                                // Is the condition element there?
                                if (isset($conditions[$columnArray['column']])) {
                                        // Assume the condition
-                                       $condition .= ' ' . $conditions[$columnArray['column']] . ' ';
+                                       $condition = ' ' . $conditions[$columnArray['column']] . ' ';
                                } // END - if
 
                                // Add to SQL query
-                               die($sql.'/'.$condition);
                                $sql .= $condition;
 
                                // Table/alias included?
@@ -429,7 +417,7 @@ function getSqlXmlOrderBy ($orderByColumns) {
        $sql = '';
 
        // Are there entries from orderByColumns to add?
-       if (count($orderByColumns) > 0) {
+       if (isFilledArray($orderByColumns)) {
                // Add them as well
                $sql .= ' ORDER BY ';
                foreach ($orderByColumns as $orderByColumn => $array) {