From b6d5129f41ab750f5c67db03b77b83f43a7dc258 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 22 Aug 2012 21:14:29 +0000 Subject: [PATCH] Also loadXmlTemplate() is now very generic (so maybe it can be moved to 'core'?) --- .gitattributes | 1 + .../class_HubAnnouncementHelper.php | 2 +- ...ss_NodeAnnouncementMessageAnswerHelper.php | 2 +- ...NodeRequestNodeListMessageAnswerHelper.php | 2 +- .../connection/class_HubSelfConnectHelper.php | 2 +- .../class_NodeRequestNodeListHelper.php | 2 +- .../class_CruncherTestUnitProducer.php | 2 +- .../class_XmlAnnouncementTemplateEngine.php | 15 --- ...ss_XmlAnnouncementAnswerTemplateEngine.php | 15 --- .../main/template/answer/requests/.htaccess | 1 + ...XmlRequestNodeListAnswerTemplateEngine.php | 124 ++++++++++++++++++ .../template/class_BaseXmlTemplateEngine.php | 7 +- .../class_XmlSelfConnectTemplateEngine.php | 15 --- .../class_XmlObjectRegistryTemplateEngine.php | 15 --- ...lass_XmlCruncherTestUnitTemplateEngine.php | 15 --- ...class_XmlRequestNodeListTemplateEngine.php | 15 --- 16 files changed, 135 insertions(+), 100 deletions(-) create mode 100644 application/hub/main/template/answer/requests/.htaccess create mode 100644 application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php diff --git a/.gitattributes b/.gitattributes index 86ad56c62..4e96e943b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -589,6 +589,7 @@ application/hub/main/template/announcement/.htaccess -text svneol=unset#text/pla application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php svneol=native#text/plain application/hub/main/template/answer/.htaccess -text svneol=unset#text/plain application/hub/main/template/answer/announcement/.htaccess -text svneol=unset#text/plain +application/hub/main/template/answer/requests/.htaccess -text svneol=unset#text/plain application/hub/main/template/connect/.htaccess -text svneol=unset#text/plain application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php svneol=native#text/plain application/hub/main/template/objects/.htaccess -text svneol=unset#text/plain diff --git a/application/hub/main/helper/hub/announcement/class_HubAnnouncementHelper.php b/application/hub/main/helper/hub/announcement/class_HubAnnouncementHelper.php index 1979194b5..6e5768673 100644 --- a/application/hub/main/helper/hub/announcement/class_HubAnnouncementHelper.php +++ b/application/hub/main/helper/hub/announcement/class_HubAnnouncementHelper.php @@ -68,7 +68,7 @@ class HubAnnouncementHelper extends BaseHubHelper implements HelpableHub { $this->setTemplateInstance($templateInstance); // Read the XML descriptor - $this->getTemplateInstance()->loadAnnouncementTemplate(); + $this->getTemplateInstance()->loadXmlTemplate(); // Render the XML content $this->getTemplateInstance()->renderXmlContent(); diff --git a/application/hub/main/helper/hub/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php b/application/hub/main/helper/hub/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php index 67f7f40b1..abd7e024d 100644 --- a/application/hub/main/helper/hub/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php +++ b/application/hub/main/helper/hub/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php @@ -72,7 +72,7 @@ class NodeAnnouncementMessageAnswerHelper extends BaseHubAnswerHelper implements $this->setTemplateInstance($templateInstance); // Read the XML descriptor - $this->getTemplateInstance()->loadAnnouncementAnswerTemplate(); + $this->getTemplateInstance()->loadXmlTemplate(); // Render the XML content $this->getTemplateInstance()->renderXmlContent(); diff --git a/application/hub/main/helper/hub/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php b/application/hub/main/helper/hub/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php index a21c96935..8266cb308 100644 --- a/application/hub/main/helper/hub/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php +++ b/application/hub/main/helper/hub/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php @@ -72,7 +72,7 @@ class NodeRequestNodeListMessageAnswerHelper extends BaseHubAnswerHelper impleme $this->setTemplateInstance($templateInstance); // Read the XML descriptor - $this->getTemplateInstance()->loadRequestNodeListAnswerTemplate(); + $this->getTemplateInstance()->loadXmlTemplate(); // Render the XML content $this->getTemplateInstance()->renderXmlContent(); diff --git a/application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php b/application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php index 4a5847303..2a6c37cd5 100644 --- a/application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php +++ b/application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php @@ -68,7 +68,7 @@ class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub { $this->setTemplateInstance($templateInstance); // Read the XML descriptor - $this->getTemplateInstance()->loadSelfConnectTemplate(); + $this->getTemplateInstance()->loadXmlTemplate(); // Render the XML content $this->getTemplateInstance()->renderXmlContent(); diff --git a/application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php b/application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php index ed31fac0a..8133f9962 100644 --- a/application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php +++ b/application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php @@ -68,7 +68,7 @@ class NodeRequestNodeListHelper extends BaseHubHelper implements HelpableHub { $this->setTemplateInstance($templateInstance); // Read the XML descriptor - $this->getTemplateInstance()->loadRequestNodeListTemplate(); + $this->getTemplateInstance()->loadXmlTemplate(); // Render the XML content $this->getTemplateInstance()->renderXmlContent(); diff --git a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php b/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php index 6629b708a..fb44300a5 100644 --- a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php +++ b/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php @@ -62,7 +62,7 @@ class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer, $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('cruncher_test_unit_producer_template_class'); // Load the template - $templateInstance->loadCruncherTestUnitTemplate('test_unit'); + $templateInstance->loadXmlTemplate('test_unit'); // Render the XML content $templateInstance->renderXmlContent(); diff --git a/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php b/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php index dde53d35e..b230b49d9 100644 --- a/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php +++ b/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php @@ -80,21 +80,6 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com return $templateInstance; } - /** - * Load a specified announcement template into the engine - * - * @param $template The announcement template we shall load which is - * located in 'announcement' by default - * @return void - */ - public function loadAnnouncementTemplate ($template = 'self_announcement') { - // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_announcement_template_type')); - - // Load the special template - $this->loadTemplate($template); - } - /** * Currently not used * diff --git a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php index 6c6134183..62fc3212c 100644 --- a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php +++ b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php @@ -86,21 +86,6 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen return $templateInstance; } - /** - * Load a specified announcement-answer template into the engine - * - * @param $template The announcement-answer template we shall load which is - * located in 'announcement_answer' by default - * @return void - */ - public function loadAnnouncementAnswerTemplate ($template = 'announcement_answer') { - // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_announcement_answer_template_type')); - - // Load the special template - $this->loadTemplate($template); - } - /** * Currently not used * diff --git a/application/hub/main/template/answer/requests/.htaccess b/application/hub/main/template/answer/requests/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/template/answer/requests/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php b/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php new file mode 100644 index 000000000..20f26e490 --- /dev/null +++ b/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php @@ -0,0 +1,124 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This template engine does not make use of setTemplateType() + * + * 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 XmlRequestNodeListAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const ANNOUNCEMENT_DATA_SESSION_ID = 'my-session-id'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init sub-nodes array + $this->subNodes = array( + self::ANNOUNCEMENT_DATA_SESSION_ID, + ); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlRequestNodeListAnswerTemplateEngine () { + // Get a new instance + $templateInstance = new XmlRequestNodeListAnswerTemplateEngine(); + + // Init instance + $templateInstance->initXmlTemplateEngine('node', 'request_node_list_answer'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something useful with this! + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return false; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackerInstance()->getNamed('request_node_list_answer'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getRequestNodeListAnswerCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the announcement-answer + * + * @return void + */ + protected function startRequestNodeListAnswer () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('request_node_list_answer', 'announcement-answer'); + } + + /** + * Finishes the announcement-answer + * + * @return void + */ + protected function finishRequestNodeListAnswer () { + // Pop the last entry + $this->getStackerInstance()->popNamed('request_node_list_answer'); + } +} + +// [EOF] +?> diff --git a/application/hub/main/template/class_BaseXmlTemplateEngine.php b/application/hub/main/template/class_BaseXmlTemplateEngine.php index 04af15dfc..58b990edc 100644 --- a/application/hub/main/template/class_BaseXmlTemplateEngine.php +++ b/application/hub/main/template/class_BaseXmlTemplateEngine.php @@ -129,15 +129,14 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine { /** * Load a specified XML template into the engine * - * @param $template The XML template we shall load * @return void */ - public function loadXmlTemplate ($template) { + public function loadXmlTemplate () { // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry($this->xmlTemplateType . '_template_type')); + $this->setTemplateType($this->getConfigInstance()->getConfigEntry($this->typePrefix . '_' . $this->xmlTemplateType . '_template_type')); // Load the special template - $this->loadTemplate($template); + $this->loadTemplate($this->xmlTemplateType); } /** diff --git a/application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php b/application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php index da8df035e..8396117cf 100644 --- a/application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php +++ b/application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php @@ -68,21 +68,6 @@ class XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements Comp return $templateInstance; } - /** - * Load a specified self-connect template into the engine - * - * @param $template The self-connect template we shall load which is - * located in 'self_connect' by default - * @return void - */ - public function loadSelfConnectTemplate ($template = 'self_connect') { - // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_self_connect_template_type')); - - // Load the special template - $this->loadTemplate($template); - } - /** * Currently not used * diff --git a/application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php b/application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php index 95f5c758d..d6284a895 100644 --- a/application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php +++ b/application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php @@ -81,21 +81,6 @@ class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements C return $templateInstance; } - /** - * Load a specified object_registry template into the engine - * - * @param $template The object_registry template we shall load which is - * located in 'object_registry' by default - * @return void - */ - public function loadObjectRegistryTemplate ($template = 'object_registry') { - // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_object_registry_template_type')); - - // Load the special template - $this->loadTemplate($template); - } - /** * Currently not used * diff --git a/application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php b/application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php index dbea5dd40..ea1e631cf 100644 --- a/application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php +++ b/application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php @@ -71,21 +71,6 @@ class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements return $templateInstance; } - /** - * Load a specified cruncher_test_unit template into the engine - * - * @param $template The cruncher_test_unit template we shall load which is - * located in 'cruncher_test_unit' by default - * @return void - */ - public function loadCruncherTestUnitTemplate ($template) { - // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry('cruncher_test_unit_template_type')); - - // Load the special template - $this->loadTemplate($template); - } - /** * Currently not used * diff --git a/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php b/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php index 376248269..282483428 100644 --- a/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php +++ b/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php @@ -65,21 +65,6 @@ class XmlRequestNodeListTemplateEngine extends BaseXmlTemplateEngine implements return $templateInstance; } - /** - * Load a specified request_node_list template into the engine - * - * @param $template The request_node_list template we shall load which is - * located in 'node_request_node_list' by default - * @return void - */ - public function loadRequestNodeListTemplate ($template = 'node_request_node_list') { - // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_request_node_list_template_type')); - - // Load the special template - $this->loadTemplate($template); - } - /** * Currently not used * -- 2.39.5