From 36e4d0eb331bd724db0bd23071271d5eaeb37b17 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 1 Sep 2009 22:18:13 +0000 Subject: [PATCH] All XML-parsing-related stuff refactured to new XmlParser class --- .gitattributes | 7 ++ inc/classes/interfaces/parser/.htaccess | 1 + .../interfaces/parser/class_Parseable.php | 36 +++++++ inc/classes/main/class_ | 17 ++- inc/classes/main/class_Base | 2 +- inc/classes/main/helper/class_BaseHelper.php | 3 - inc/classes/main/images/class_BaseImage.php | 12 +-- inc/classes/main/menu/class_BaseMenu.php | 13 ++- inc/classes/main/parser/.htaccess | 1 + inc/classes/main/parser/class_ | 53 +++++++++ inc/classes/main/parser/class_BaseParser.php | 38 +++++++ inc/classes/main/parser/xml/.htaccess | 1 + .../main/parser/xml/class_XmlParser.php | 102 ++++++++++++++++++ .../template/class_BaseTemplateEngine.php | 37 ++----- .../image/class_ImageTemplateEngine.php | 30 +++--- .../mail/class_MailTemplateEngine.php | 4 +- .../menu/class_MenuTemplateEngine.php | 15 +++ inc/config.php | 6 ++ 18 files changed, 316 insertions(+), 62 deletions(-) create mode 100644 inc/classes/interfaces/parser/.htaccess create mode 100644 inc/classes/interfaces/parser/class_Parseable.php create mode 100644 inc/classes/main/parser/.htaccess create mode 100644 inc/classes/main/parser/class_ create mode 100644 inc/classes/main/parser/class_BaseParser.php create mode 100644 inc/classes/main/parser/xml/.htaccess create mode 100644 inc/classes/main/parser/xml/class_XmlParser.php diff --git a/.gitattributes b/.gitattributes index c77e9b41..4f46c621 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/parser/.htaccess @@ -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 index 00000000..61416fff --- /dev/null +++ b/inc/classes/interfaces/parser/class_Parseable.php @@ -0,0 +1,36 @@ + + * @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 . + */ +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); +} + +// +?> diff --git a/inc/classes/main/class_ b/inc/classes/main/class_ index 992c09fb..c5fe84ee 100644 --- a/inc/classes/main/class_ +++ b/inc/classes/main/class_ @@ -1,6 +1,6 @@ * @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 . */ -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] diff --git a/inc/classes/main/class_Base b/inc/classes/main/class_Base index 34a47d02..3ec8f097 100644 --- a/inc/classes/main/class_Base +++ b/inc/classes/main/class_Base @@ -1,6 +1,6 @@ * @version 0.0.0 diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php index 7a0a77b6..ff4646f7 100644 --- a/inc/classes/main/helper/class_BaseHelper.php +++ b/inc/classes/main/helper/class_BaseHelper.php @@ -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; diff --git a/inc/classes/main/images/class_BaseImage.php b/inc/classes/main/images/class_BaseImage.php index 27d768cc..f88988bc 100644 --- a/inc/classes/main/images/class_BaseImage.php +++ b/inc/classes/main/images/class_BaseImage.php @@ -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 diff --git a/inc/classes/main/menu/class_BaseMenu.php b/inc/classes/main/menu/class_BaseMenu.php index dd232514..aedf6c28 100644 --- a/inc/classes/main/menu/class_BaseMenu.php +++ b/inc/classes/main/menu/class_BaseMenu.php @@ -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 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/parser/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/parser/class_ b/inc/classes/main/parser/class_ new file mode 100644 index 00000000..a58f6fd9 --- /dev/null +++ b/inc/classes/main/parser/class_ @@ -0,0 +1,53 @@ + + * @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 . + */ +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 index 00000000..4f83961b --- /dev/null +++ b/inc/classes/main/parser/class_BaseParser.php @@ -0,0 +1,38 @@ + + * @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 . + */ +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 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/parser/xml/.htaccess @@ -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 index 00000000..e21044f7 --- /dev/null +++ b/inc/classes/main/parser/xml/class_XmlParser.php @@ -0,0 +1,102 @@ + + * @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 . + */ +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('
'.htmlentities($content).'
'); + throw new XmlParserException(array($this, $xmlParser), self::EXCEPTION_XML_PARSER_ERROR); + } // END - if + + // Free the parser + xml_parser_free($xmlParser); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php index e94894d4..8a58b46d 100644 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -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('
'.htmlentities($content).'
'); - 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); } } diff --git a/inc/classes/main/template/image/class_ImageTemplateEngine.php b/inc/classes/main/template/image/class_ImageTemplateEngine.php index eb536f84..13192647 100644 --- a/inc/classes/main/template/image/class_ImageTemplateEngine.php +++ b/inc/classes/main/template/image/class_ImageTemplateEngine.php @@ -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: >".$nodeName."<
\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; diff --git a/inc/classes/main/template/mail/class_MailTemplateEngine.php b/inc/classes/main/template/mail/class_MailTemplateEngine.php index 2f69fab3..1d39894b 100644 --- a/inc/classes/main/template/mail/class_MailTemplateEngine.php +++ b/inc/classes/main/template/mail/class_MailTemplateEngine.php @@ -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: >".$nodeName."<
\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; diff --git a/inc/classes/main/template/menu/class_MenuTemplateEngine.php b/inc/classes/main/template/menu/class_MenuTemplateEngine.php index 2d387124..9f179c0f 100644 --- a/inc/classes/main/template/menu/class_MenuTemplateEngine.php +++ b/inc/classes/main/template/menu/class_MenuTemplateEngine.php @@ -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] diff --git a/inc/config.php b/inc/config.php index 84cb5681..65bc3c56 100644 --- a/inc/config.php +++ b/inc/config.php @@ -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); -- 2.39.5