All XML-parsing-related stuff refactured to new XmlParser class
authorRoland Häder <roland@mxchange.org>
Tue, 1 Sep 2009 22:18:13 +0000 (22:18 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 1 Sep 2009 22:18:13 +0000 (22:18 +0000)
18 files changed:
.gitattributes
inc/classes/interfaces/parser/.htaccess [new file with mode: 0644]
inc/classes/interfaces/parser/class_Parseable.php [new file with mode: 0644]
inc/classes/main/class_
inc/classes/main/class_Base
inc/classes/main/helper/class_BaseHelper.php
inc/classes/main/images/class_BaseImage.php
inc/classes/main/menu/class_BaseMenu.php
inc/classes/main/parser/.htaccess [new file with mode: 0644]
inc/classes/main/parser/class_ [new file with mode: 0644]
inc/classes/main/parser/class_BaseParser.php [new file with mode: 0644]
inc/classes/main/parser/xml/.htaccess [new file with mode: 0644]
inc/classes/main/parser/xml/class_XmlParser.php [new file with mode: 0644]
inc/classes/main/template/class_BaseTemplateEngine.php
inc/classes/main/template/image/class_ImageTemplateEngine.php
inc/classes/main/template/mail/class_MailTemplateEngine.php
inc/classes/main/template/menu/class_MenuTemplateEngine.php
inc/config.php

index c77e9b4..4f46c62 100644 (file)
@@ -174,6 +174,8 @@ inc/classes/interfaces/mailer/.htaccess -text
 inc/classes/interfaces/mailer/class_DeliverableMail.php -text
 inc/classes/interfaces/menu/.htaccess -text
 inc/classes/interfaces/menu/class_RenderableMenu.php -text
+inc/classes/interfaces/parser/.htaccess -text
+inc/classes/interfaces/parser/class_Parseable.php -text
 inc/classes/interfaces/points/.htaccess -text
 inc/classes/interfaces/points/class_BookablePoints.php -text
 inc/classes/interfaces/reader/.htaccess -text
@@ -405,6 +407,11 @@ inc/classes/main/menu/class_BaseMenu.php -text
 inc/classes/main/output/.htaccess -text
 inc/classes/main/output/class_ConsoleOutput.php -text
 inc/classes/main/output/class_WebOutput.php -text
+inc/classes/main/parser/.htaccess -text
+inc/classes/main/parser/class_ -text
+inc/classes/main/parser/class_BaseParser.php -text
+inc/classes/main/parser/xml/.htaccess -text
+inc/classes/main/parser/xml/class_XmlParser.php -text
 inc/classes/main/points/.htaccess -text
 inc/classes/main/points/class_UserPoints.php -text
 inc/classes/main/reader/.htaccess -text
diff --git a/inc/classes/interfaces/parser/.htaccess b/inc/classes/interfaces/parser/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/parser/class_Parseable.php b/inc/classes/interfaces/parser/class_Parseable.php
new file mode 100644 (file)
index 0000000..61416ff
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/**
+ * A Parseable interface
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Parseable extends FrameworkInterface {
+       /**
+        * Parses the given XML content
+        *
+        * @param       $content        Valid XML content
+        * @return      void
+        * @throws      XmlParserException      If an XML error was found
+        */
+       function parseXmlContent ($content);
+}
+
+//
+?>
index 992c09f..c5fe84e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * 
+ * A ??? !!! class
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class  extends BaseFrameworkSystem {
+class ???!!! extends Base!!! implements CompileableTemplate {
        /**
         * Protected constructor
         *
@@ -31,6 +31,19 @@ class  extends BaseFrameworkSystem {
                // Call parent constructor
                parent::__construct(__CLASS__);
        }
+
+       /**
+        * Creates an instance of the class !!! and prepares it for usage
+        *
+        * @param       $appInstance    A manageable application
+        * @return      $///Instance    An instance of !!!
+       public final static function create???!!! (ManageableApplication $appInstance) {
+               // Get a new instance
+               $///Instance = new ???!!!();
+
+               // Return the prepared instance
+               return $///Instance;
+       }
 }
 
 // [EOF]
index 34a47d0..3ec8f09 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * A general 
+ * A general ???
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
index 7a0a77b..ff4646f 100644 (file)
@@ -63,9 +63,6 @@ class BaseHelper extends BaseFrameworkSystem {
        private $totalCounter = 0;
 
        // Exception constants
-       const EXCEPTION_XML_PARSER_ERROR             = 0x1e0;
-       const EXCEPTION_XML_NODE_UNKNOWN             = 0x1e1;
-       const EXCEPTION_XML_NODE_MISMATCH            = 0x1e2;
        const EXCEPTION_GROUP_NOT_OPENED             = 0x1e3;
        const EXCEPTION_GROUP_ALREADY_FOUND          = 0x1e4;
        const EXCEPTION_SUB_GROUP_ALREADY_FOUND      = 0x1e5;
index 27d768c..f88988b 100644 (file)
@@ -78,7 +78,7 @@ class BaseImage extends BaseFrameworkSystem implements Registerable {
        /**
         * Groupable image strings?
         */
-       private $groupable = "single";
+       private $groupable = 'single';
 
        /**
         * Protected constructor
@@ -205,7 +205,7 @@ class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @return      void
         */
        public function initBackgroundColor () {
-               $this->colorMode = "backgroundColor";
+               $this->colorMode = 'backgroundColor';
        }
 
        /**
@@ -224,7 +224,7 @@ class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @return      void
         */
        public function initForegroundColor () {
-               $this->colorMode = "foregroundColor";
+               $this->colorMode = 'foregroundColor';
        }
 
        /**
@@ -244,7 +244,7 @@ class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @return      void
         * @todo        Find something usefull for this method.
         */
-       public function initImageString ($groupable = "single") {
+       public function initImageString ($groupable = 'single') {
                $this->groupable = $groupable;
        }
 
@@ -485,7 +485,7 @@ class BaseImage extends BaseFrameworkSystem implements Registerable {
                $foreColor = imagecolorallocate($this->getImageResource(), $red, $green, $blue);
 
                switch ($this->groupable) {
-                       case "single": // Single image string
+                       case 'single': // Single image string
                                // Compile image string
                                $imageString = $templateInstance->compileRawCode($this->getString());
 
@@ -501,7 +501,7 @@ class BaseImage extends BaseFrameworkSystem implements Registerable {
                                imagestring($this->getImageResource(), $size, $x, $y, $imageString, $foreColor);
                                break;
 
-                       case "groupable": // More than one string allowed
+                       case 'groupable': // More than one string allowed
                                // Walk through all groups
                                foreach ($templateInstance->getVariableGroups() as $group => $set) {
                                        // Set the group
index dd23251..aedf6c2 100644 (file)
@@ -46,15 +46,22 @@ class BaseMenu extends BaseFrameworkSystem {
                // Set it for later use
                $this->setTemplateInstance($templateInstance);
 
-               // Something is not yet ready
-               $this->partialStub('Please implement this method.');
+               // Load the base (XML) template for generating menus
+               $this->getTemplateInstance()->loadMenuTemplate('base_menu');
+
+               // Get the prepared content
+               $menuContent = $this->getTemplateInstance()->getRawTemplateData();
+
+               // Render it here
+               $this->getTemplateInstance()->renderXmlContent($menuContent);
+               die('!OK');
        }
 
        /**
         * Transfers the rendered menu to a given templatex engine by assigning
         * the rendered content with a template variable.
         *
-        * @2param      $templateInstance       An instance of a CompileableTemplate class
+        * @param       $templateInstance       An instance of a CompileableTemplate class
         * @return      void
         */
        public function transferContentToTemplateEngine (CompileableTemplate $templateInstance) {
diff --git a/inc/classes/main/parser/.htaccess b/inc/classes/main/parser/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/parser/class_ b/inc/classes/main/parser/class_
new file mode 100644 (file)
index 0000000..a58f6fd
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/**
+ * A ??? Parser class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Parser extends BaseParser implements Parseable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of the class Parser and prepares it for usage
+        *
+        * @param       $templateInstance       A CompileableTemplate instance
+        * @return      $parserInstance         An instance of this parser
+       public final static function create???Parser (CompileableTemplate $templateInstance) {
+               // Get a new instance
+               $parserInstance = new ???Parser();
+
+               // Set the template instance
+               $parserInstance->setTemplateInstance($templateInstance);
+
+               // Return the prepared instance
+               return $parserInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/parser/class_BaseParser.php b/inc/classes/main/parser/class_BaseParser.php
new file mode 100644 (file)
index 0000000..4f83961
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * A general Parser
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseParser extends BaseFrameworkSystem {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/parser/xml/.htaccess b/inc/classes/main/parser/xml/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/parser/xml/class_XmlParser.php b/inc/classes/main/parser/xml/class_XmlParser.php
new file mode 100644 (file)
index 0000000..e21044f
--- /dev/null
@@ -0,0 +1,102 @@
+<?php
+/**
+ * A Xml Parser class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class XmlParser extends BaseParser implements Parseable {
+       // Exception constants
+       const EXCEPTION_XML_PARSER_ERROR             = 0x1e0;
+       const EXCEPTION_XML_NODE_UNKNOWN             = 0x1e1;
+       const EXCEPTION_XML_NODE_MISMATCH            = 0x1e2;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of the class Parser and prepares it for usage
+        *
+        * @param       $templateInstance       A CompileableTemplate instance
+        * @return      $parserInstance         An instance of this parser
+        */
+       public final static function createXmlParser (CompileableTemplate $templateInstance) {
+               // Get a new instance
+               $parserInstance = new XmlParser();
+
+               // Set the template instance
+               $parserInstance->setTemplateInstance($templateInstance);
+
+               // Return the prepared instance
+               return $parserInstance;
+       }
+
+       /**
+        * Parses the given XML content
+        *
+        * @param       $content        Valid XML content
+        * @return      void
+        * @throws      XmlParserException      If an XML error was found
+        */
+       public function parseXmlContent ($content) {
+               // Convert all to UTF8
+               if (function_exists('recode')) {
+                       $content = recode("html..utf8", $content);
+               } else {
+                       // @TODO We need to find a fallback solution here
+                       $this->partialStub('Cannot find recode extension!');
+               } // END - if
+
+               // Get an XML parser
+               $xmlParser = xml_parser_create();
+
+               // Force case-folding to on
+               xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, true);
+
+               // Get template instance
+               $templateInstance = $this->getTemplateInstance();
+
+               // Set object
+               xml_set_object($xmlParser, $templateInstance);
+
+               // Set handler call-backs
+               xml_set_element_handler($xmlParser, 'startElement', 'endElement');
+               xml_set_character_data_handler($xmlParser, 'characterHandler');
+
+               // Now parse the XML tree
+               if (!xml_parse($xmlParser, $content)) {
+                       // Error found in XML!
+                       //* DEBUG: */ die('<pre>'.htmlentities($content).'</pre>');
+                       throw new XmlParserException(array($this, $xmlParser), self::EXCEPTION_XML_PARSER_ERROR);
+               } // END - if
+
+               // Free the parser
+               xml_parser_free($xmlParser);
+       }
+}
+
+// [EOF]
+?>
index e94894d..8a58b46 100644 (file)
@@ -950,6 +950,8 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         * @param       $template       The email template we shall load which is located in
         *                                              'emails' by default
         * @return      void
+        * @deprecated
+        * @see         See loadCodeTemplate()
         */
        public function loadEmailTemplate ($template) {
                // Set template type
@@ -1289,43 +1291,18 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         * @return      void
         * @throws      XmlParserException      If an XML error was found
         */
-       public final function renderXmlContent ($content = null) {
+       public function renderXmlContent ($content = null) {
                // Is the content set?
                if (is_null($content)) {
                        // Get current content
                        $content = $this->getRawTemplateData();
                } // END - if
 
-               // Convert all to UTF8
-               if (function_exists('recode')) {
-                       $content = recode("html..utf8", $content);
-               } else {
-                       // @TODO We need to find a fallback solution here
-                       $this->partialStub('Cannot find recode extension!');
-               } // END - if
-
-               // Get an XML parser
-               $xmlParser = xml_parser_create();
-
-               // Force case-folding to on
-               xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, true);
-
-               // Set object
-               xml_set_object($xmlParser, $this);
-
-               // Set handler call-backs
-               xml_set_element_handler($xmlParser, 'startElement', 'endElement');
-               xml_set_character_data_handler($xmlParser, 'characterHandler');
-
-               // Now parse the XML tree
-               if (!xml_parse($xmlParser, $content)) {
-                       // Error found in XML!
-                       //* DEBUG: */ die('<pre>'.htmlentities($content).'</pre>');
-                       throw new XmlParserException(array($this, $xmlParser), BaseHelper::EXCEPTION_XML_PARSER_ERROR);
-               } // END - if
+               // Get a XmlParser instance
+               $parserInstance = ObjectFactory::createObjectByConfiguredName('xml_parser_class', array($this));
 
-               // Free the parser
-               xml_parser_free($xmlParser);
+               // Parse the XML document
+               $parserInstance->parseXmlContent($content);
        }
 }
 
index eb536f8..1319264 100644 (file)
@@ -85,49 +85,49 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
         */
        public final static function createImageTemplateEngine (ManageableApplication $appInstance) {
                // Get a new instance
-               $tplInstance = new ImageTemplateEngine();
+               $templateInstance = new ImageTemplateEngine();
 
                // Get language and file I/O instances from application
                $langInstance = $appInstance->getLanguageInstance();
                $ioInstance = $appInstance->getFileIoInstance();
 
                // Determine base path
-               $templateBasePath = $tplInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
+               $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
 
                // Is the base path valid?
                if (empty($templateBasePath)) {
                        // Base path is empty
-                       throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+                       throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } elseif (!is_string($templateBasePath)) {
                        // Is not a string
-                       throw new InvalidBasePathStringException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
+                       throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
                } elseif (!is_dir($templateBasePath)) {
                        // Is not a path
-                       throw new BasePathIsNoDirectoryException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
+                       throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
                } elseif (!is_readable($templateBasePath)) {
                        // Is not readable
-                       throw new BasePathReadProtectedException(array($tplInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
+                       throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
                }
 
                // Get configuration instance
                $configInstance = FrameworkConfiguration::getInstance();
 
                // Set the base path
-               $tplInstance->setTemplateBasePath($templateBasePath);
+               $templateInstance->setTemplateBasePath($templateBasePath);
 
                // Set the language and IO instances
-               $tplInstance->setLanguageInstance($langInstance);
-               $tplInstance->setFileIoInstance($ioInstance);
+               $templateInstance->setLanguageInstance($langInstance);
+               $templateInstance->setFileIoInstance($ioInstance);
 
                // Set template extensions
-               $tplInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
-               $tplInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
+               $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
+               $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
 
                // Absolute output path for compiled templates
-               $tplInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
+               $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
 
                // Return the prepared instance
-               return $tplInstance;
+               return $templateInstance;
        }
 
        /**
@@ -183,7 +183,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
                        $methodName = 'setImageProperty' . $this->convertToClassName($element);
                } elseif ($element != 'image') {
                        // Invalid node name found
-                       throw new InvalidXmlNodeException(array($this, $element, $attributes), BaseHelper::EXCEPTION_XML_NODE_UNKNOWN);
+                       throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN);
                }
 
                // Call method
@@ -207,7 +207,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
                //* DEBUG: */ echo "END: &gt;".$nodeName."&lt;<br />\n";
                if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
                        // Did not match!
-                       throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), BaseHelper::EXCEPTION_XML_NODE_MISMATCH);
+                       throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH);
                } elseif (in_array($nodeName, $this->getSubNodes())) {
                        // Silently ignore sub nodes
                        return;
index 2f69fab..1d39894 100644 (file)
@@ -169,7 +169,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                        $methodName = 'setEmailProperty' . $this->convertToClassName($element);
                } elseif ($element != 'text-mail') {
                        // Invalid node name found
-                       throw new InvalidXmlNodeException(array($this, $element, $attributes), BaseHelper::EXCEPTION_XML_NODE_UNKNOWN);
+                       throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN);
                }
 
                // Call method
@@ -193,7 +193,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                //* DEBUG: */ echo "END: &gt;".$nodeName."&lt;<br />\n";
                if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
                        // Did not match!
-                       throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), BaseHelper::EXCEPTION_XML_NODE_MISMATCH);
+                       throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH);
                } elseif (in_array($nodeName, $this->getSubNodes())) {
                        // Silently ignore sub nodes
                        return;
index 2d38712..9f179c0 100644 (file)
@@ -90,6 +90,21 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                // Return the prepared instance
                return $tplInstance;
        }
+
+       /**
+        * Load a specified menu template into the engine
+        *
+        * @param       $template       The menu template we shall load which is
+        *                                              located in 'menu' by default
+        * @return      void
+        */
+       public function loadMenuTemplate ($template) {
+               // Set template type
+               $this->setTemplateType($this->getConfigInstance()->getConfigEntry('menu_template_type'));
+
+               // Load the special template
+               $this->loadTemplate($template);
+       }
 }
 
 // [EOF]
index 84cb568..65bc3c5 100644 (file)
@@ -110,6 +110,9 @@ $cfg->setConfigEntry('code_template_type', 'code');
 // CFG: IMAGE-TEMPLATE-TYPE
 $cfg->setConfigEntry('image_template_type', 'image');
 
+// CFG: MENU-TEMPLATE-TYPE
+$cfg->setConfigEntry('menu_template_type', 'menu');
+
 // CFG: OUTPUT-CLASS
 $cfg->setConfigEntry('output_class', 'WebOutput');
 
@@ -245,6 +248,9 @@ $cfg->setConfigEntry('image_cmd_code_captcha_resolver_class', 'ImageCommandResol
 // CFG: MAILER-CLASS
 $cfg->setConfigEntry('mailer_class', 'DebugMailer');
 
+// CFG: XML-PARSER-CLASS
+$cfg->setConfigEntry('xml_parser_class', 'XmlParser');
+
 // CFG: MATH-PRIME
 $cfg->setConfigEntry('math_prime', 591623);