application/hub/main/handler/chunks/.htaccess -text svneol=unset#text/plain
application/hub/main/handler/chunks/class_ChunkHandler.php svneol=native#text/plain
application/hub/main/handler/class_ svneol=native#text/plain
+application/hub/main/handler/class_BaseDataHandler.php svneol=native#text/plain
application/hub/main/handler/class_BaseHandler.php svneol=native#text/plain
application/hub/main/handler/message-types/.htaccess -text svneol=unset#text/plain
application/hub/main/handler/message-types/anouncement/.htaccess -text svneol=unset#text/plain
application/hub/main/helper/hub/class_BaseHubHelper.php svneol=native#text/plain
application/hub/main/helper/hub/connection/.htaccess -text svneol=unset#text/plain
application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php svneol=native#text/plain
+application/hub/main/helper/hub/requests/.htaccess -text svneol=unset#text/plain
+application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php svneol=native#text/plain
application/hub/main/helper/messages/.htaccess svneol=native#text/plain
application/hub/main/helper/messages/class_BaseMessageHelper.php svneol=native#text/plain
application/hub/main/helper/messages/crypto/.htaccess svneol=native#text/plain
application/hub/main/template/producer/.htaccess svneol=native#text/plain
application/hub/main/template/producer/test_units/.htaccess svneol=native#text/plain
application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php svneol=native#text/plain
+application/hub/main/template/requests/.htaccess -text svneol=unset#text/plain
application/hub/main/template/work_units/.htaccess svneol=native#text/plain
application/hub/main/tools/.htaccess -text svneol=unset#text/plain
application/hub/main/tools/class_HubTools.php svneol=native#text/plain
application/hub/templates/xml/node/node_status.xml svneol=native#text/plain
application/hub/templates/xml/object_registry/.htaccess -text svneol=unset#text/plain
application/hub/templates/xml/object_registry/object_registry.xml svneol=native#text/plain
+application/hub/templates/xml/requests/.htaccess -text svneol=unset#text/plain
+application/hub/templates/xml/requests/node_request_node_list.xml svneol=native#text/plain
application/hub/templates/xml/self_connect/.htaccess -text svneol=unset#text/plain
application/hub/templates/xml/self_connect/self_connect.xml svneol=native#text/plain
db/.htaccess -text svneol=unset#text/plain
// CFG: NODE-ANSWER-MESSAGE-ANNOUNCEMENT-HELPER-CLASS
$cfg->setConfigEntry('node_answer_message_announcement_helper_class', 'NodeAnnouncementMessageAnswerHelper');
+// CFG: NODE-NEXT-ANNOUNCEMENT-ANSWER-OKAY-HELPER-CLASS
+$cfg->setConfigEntry('node_next_announcement_answer_okay_helper_class', 'NodeRequestNodeListHelper');
+
// CFG: NEWS-READER-CLASS
$cfg->setConfigEntry('news_reader_class', 'ConsoleNewsReader');
// CFG: NODE-ANNOUNCEMENT-ANSWER-TEMPLATE-CLASS
$cfg->setConfigEntry('node_announcement_answer_template_class', 'XmlAnnouncementAnswerTemplateEngine');
+// CFG: NODE-REQUEST-NODE-LIST-TEMPLATE-CLASS
+$cfg->setConfigEntry('node_request_node_list_template_class', 'XmlRequestNodeListTemplateEngine');
+
// CFG: NODE-MESSAGE-TEMPLATE-EXTENSION
$cfg->setConfigEntry('node_message_template_extension', '.xml');
// CFG: NODE-SELF-CONNECT-TEMPLATE-TYPE
$cfg->setConfigEntry('node_self_connect_template_type', 'xml/self_connect');
+// CFG: NODE-REQUEST-NODE-LIST-TEMPLATE-TYPE
+$cfg->setConfigEntry('node_request_node_list_template_type', 'xml/requests');
+
// CFG: NODE-SELF-CONNECT-STACKER-CLASS
$cfg->setConfigEntry('node_self_connect_stacker_class', 'FiLoStacker');
+// CFG: NODE-REQUEST-NODE_LIST-STACKER-CLASS
+$cfg->setConfigEntry('node_request_node_list_stacker_class', 'FiLoStacker');
+
// CFG: NODE-OBJECT-REGISTRY-TEMPLATE-CLASS
$cfg->setConfigEntry('node_object_registry_template_class', 'XmlObjectRegistryTemplateEngine');
// CFG: STACKER-SELF-CONNECT-MAX-SIZE
$cfg->setConfigEntry('stacker_self_connect_max_size', 10);
+// CFG: STACKER-NODE-REQUEST-NODE-LIST-MAX_SIZE
+$cfg->setConfigEntry('stacker_node_request_node_list_max_size', 10);
+
// CFG: STACKER-UNDECLARED-MAX-SIZE
$cfg->setConfigEntry('stacker_package_undeclared_max_size', 10000);
// We do some rudimentary checks but this might be a bit ugly
switch ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]) {
// All upper hubs, these are currently the bootstrap nodes and later on prepended list-nodes
- case NetworkPackage::NETWORK_TARGET_UPPER_HUBS:
+ case NetworkPackage::NETWORK_TARGET_UPPER_NODES:
// Get all bootstrap nodes
foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $node) {
// Is maximum reached?
parent::__construct(__CLASS__);
// Set handler name
- $this->setHandlerName('answer_okay');
+ $this->setHandlerName('announcement_answer_okay');
}
/**
// Prepare next message
$this->prepareNextMessage($messageData, $packageInstance);
}
+
+ /**
+ * Initializes configuration data from given message data array
+ *
+ * @param $messageData An array with all message data
+ * @return void
+ */
+ protected function initMessageConfigurationData (array $messageData) {
+ $this->partialStub('messageData=' . print_r($messageData, true));
+ }
+
+ /**
+ * Removes configuration data with given message data array from global
+ * configuration
+ *
+ * @param $messageData An array with all message data
+ * @return void
+ */
+ protected function removeMessageConfigurationData (array $messageData) {
+ $this->partialStub('messageData=' . print_r($messageData, true));
+ }
}
// [EOF]
parent::__construct(__CLASS__);
// Set handler name
- $this->setHandlerName('answer_===');
+ $this->setHandlerName('|||_answer_===');
}
/**
* 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 BaseAnserStatusHandler extends BaseHandler {
- /**
- * Last exception instance from database layer or NULL (default)
- */
- private $lastException = NULL;
-
+abstract class BaseAnserStatusHandler extends BaseDataHandler {
/**
* Protected constructor
*
parent::__construct($className);
}
- /**
- * Getter for last exception
- *
- * @return $lastException Last thrown exception
- */
- protected final function getLastException () {
- return $this->lastException;
- }
-
/**
* Adds all required elements from given array into data set instance
*
$dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $messageData[XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_ANSWER_STATUS]);
$dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_MESSAGE_TYPE , $messageData[NetworkPackage::MESSAGE_ARRAY_TYPE]);
}
-
- /**
- * Prepares the next message
- *
- * @param $messageData An array with all message data
- * @param $packageInstance An instance of a Deliverable instance
- * @return void
- */
- protected function prepareNextMessage (array $messageData, Deliverable $packageInstance) {
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Going to send next message ...');
-
- // Get a helper instance based on this handler's name
- $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData));
-
- // Load descriptor XML
- $helperInstance->loadDescriptorXml();
-
- /*
- * Set missing (temporary) configuration data, mostly it needs to be
- * copied from message data array.
- */
- $this->initMessageConfigurationData($messageData);
-
- // Compile any configuration variables
- $helperInstance->getTemplateInstance()->compileConfigInVariables();
-
- // Get node instance
- $nodeInstance = Registry::getRegistry()->getInstance('node');
-
- // Deliver the package
- $helperInstance->sendPackage($nodeInstance);
-
- /*
- * Remove temporary configuration
- */
- $this->removeMessageConfigurationData($messageData);
-
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Next message has been prepared.');
- }
}
// [EOF]
--- /dev/null
+<?php
+/**
+ * A general data Handler
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub 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/>.
+ */
+abstract class BaseDataHandler extends BaseHandler {
+ /**
+ * Last exception instance from database layer or NULL (default)
+ */
+ private $lastException = NULL;
+
+ /**
+ * Array with search criteria elements
+ */
+ protected $searchData = array();
+
+ /**
+ * Array with all data XML nodes (which hold the actual data) and their values
+ */
+ protected $messageDataElements = array();
+
+ /**
+ * Array for translating message data elements (other node's data mostly)
+ * into configuration elements.
+ */
+ protected $messageToConfig = array();
+
+ /**
+ * Array for copying configuration entries
+ */
+ protected $configCopy = array();
+
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+ /**
+ * Getter for last exception
+ *
+ * @return $lastException Last thrown exception
+ */
+ protected final function getLastException () {
+ return $this->lastException;
+ }
+
+ /**
+ * Setter for last exception
+ *
+ * @param $lastException Last thrown exception
+ * @return void
+ */
+ protected final function setLastException (FrameworkException $exceptionInstance = NULL) {
+ $this->lastException = $exceptionInstance;
+ }
+
+ /**
+ * Prepares a message as answer for given message data for delivery.
+ *
+ * @param $messageData An array with all message data
+ * @param $packageInstance An instance of a Deliverable instance
+ * @return void
+ */
+ protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) {
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Going to send an answer message ...');
+
+ // Get a helper instance based on this handler's name
+ $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData));
+
+ // Load descriptor XML
+ $helperInstance->loadDescriptorXml();
+
+ /*
+ * Set missing (temporary) configuration data, mostly it needs to be
+ * copied from message data array.
+ */
+ $this->initMessageConfigurationData($messageData);
+
+ // Compile any configuration variables
+ $helperInstance->getTemplateInstance()->compileConfigInVariables();
+
+ // Get node instance
+ $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+ // Deliver the package
+ $helperInstance->sendPackage($nodeInstance);
+
+ /*
+ * Remove temporary configuration
+ */
+ $this->removeMessageConfigurationData($messageData);
+
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Answer message has been prepared.');
+ }
+
+ /**
+ * Prepares the next message
+ *
+ * @param $messageData An array with all message data
+ * @param $packageInstance An instance of a Deliverable instance
+ * @return void
+ */
+ protected function prepareNextMessage (array $messageData, Deliverable $packageInstance) {
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Going to send next message ...');
+
+ // Get a helper instance based on this handler's name
+ $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData));
+
+ // Load descriptor XML
+ $helperInstance->loadDescriptorXml();
+
+ /*
+ * Set missing (temporary) configuration data, mostly it needs to be
+ * copied from message data array.
+ */
+ $this->initMessageConfigurationData($messageData);
+
+ // Compile any configuration variables
+ $helperInstance->getTemplateInstance()->compileConfigInVariables();
+
+ // Get node instance
+ $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+ // Deliver the package
+ $helperInstance->sendPackage($nodeInstance);
+
+ /*
+ * Remove temporary configuration
+ */
+ $this->removeMessageConfigurationData($messageData);
+
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Next message has been prepared.');
+ }
+
+ /**
+ * Initializes configuration data from given message data array
+ *
+ * @param $messageData An array with all message data
+ * @return void
+ */
+ abstract protected function initMessageConfigurationData (array $messageData);
+
+ /**
+ * Removes configuration data with given message data array from global
+ * configuration
+ *
+ * @param $messageData An array with all message data
+ * @return void
+ */
+ abstract protected function removeMessageConfigurationData (array $messageData);
+}
+
+// [EOF]
+?>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-abstract class BaseMessageHandler extends BaseHandler {
- /**
- * Array with search criteria elements
- */
- protected $searchData = array();
-
- /**
- * Array with all data XML nodes (which hold the actual data) and their values
- */
- protected $messageDataElements = array();
-
- /**
- * Array for translating message data elements (other node's data mostly)
- * into configuration elements.
- */
- protected $messageToConfig = array();
-
- /**
- * Array for copying configuration entries
- */
- protected $configCopy = array();
-
- /**
- * Last exception instance from database layer or NULL (default)
- */
- private $lastException = NULL;
-
+abstract class BaseMessageHandler extends BaseDataHandler {
/**
* Protected constructor
*
parent::__construct($className);
}
- /**
- * Getter for last exception
- *
- * @return $lastException Last thrown exception
- */
- protected final function getLastException () {
- return $this->lastException;
- }
-
/**
* "Getter" for a translated last exception as a status code
*
$statusCode = self::MESSAGE_STATUS_CODE_OKAY;
// Is the last exception not NULL?
- if ($this->lastException instanceof FrameworkException) {
+ if ($this->getLastException() instanceof FrameworkException) {
// "Determine" the right status code (may differ from exception to exception)
- $this->debugInstance('lastException=' . $this->lastException->__toString() . ',message=' . $this->lastException->getMessage() . ' is not finished!');
+ $this->debugInstance('lastException=' . $this->getLastException()->__toString() . ',message=' . $this->getLastException()->getMessage() . ' is not finished!');
} // END - if
// Return the status code
}
// Save last exception
- $this->lastException = $wrapperInstance->getLastException();
- }
-
- /**
- * Prepares a message as answer for given message data for delivery.
- *
- * @param $messageData An array with all message data
- * @param $packageInstance An instance of a Deliverable instance
- * @return void
- */
- protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) {
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Going to send an answer message ...');
-
- // Get a helper instance based on this handler's name
- $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData));
-
- // Load descriptor XML
- $helperInstance->loadDescriptorXml();
-
- /*
- * Set missing (temporary) configuration data, mostly it needs to be
- * copied from message data array.
- */
- $this->initMessageConfigurationData($messageData);
-
- // Compile any configuration variables
- $helperInstance->getTemplateInstance()->compileConfigInVariables();
-
- // Get node instance
- $nodeInstance = Registry::getRegistry()->getInstance('node');
-
- // Deliver the package
- $helperInstance->sendPackage($nodeInstance);
-
- /*
- * Remove temporary configuration
- */
- $this->removeMessageConfigurationData($messageData);
-
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Answer message has been prepared.');
+ $this->setLastException($wrapperInstance->getLastException());
}
-
- /**
- * Initializes configuration data from given message data array
- *
- * @param $messageData An array with all message data
- * @return void
- */
- abstract protected function initMessageConfigurationData (array $messageData);
-
- /**
- * Removes configuration data with given message data array from global
- * configuration
- *
- * @param $messageData An array with all message data
- * @return void
- */
- abstract protected function removeMessageConfigurationData (array $messageData);
}
// [EOF]
parent::__construct(__CLASS__);
// Set recipient type
- $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_HUBS);
+ $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_NODES);
}
/**
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? hub helper class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 Find an interface for hub helper
+ *
+ * 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 NodeRequestNodeListHelper extends BaseHubHelper implements HelpableHub {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set recipient type
+ $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_NODES);
+ }
+
+ /**
+ * Creates the helper class
+ *
+ * @return $helperInstance A prepared instance of this helper
+ */
+ public final static function createNodeRequestNodeListHelper () {
+ // Get new instance
+ $helperInstance = new NodeRequestNodeListHelper();
+
+ // Return the prepared instance
+ return $helperInstance;
+ }
+
+ /**
+ * Loads the descriptor XML file
+ *
+ * @return void
+ */
+ public function loadDescriptorXml () {
+ // Debug message
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to request node list...');
+
+ // Get a XML template instance
+ $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_template_class');
+
+ // Set it for later use
+ $this->setTemplateInstance($templateInstance);
+
+ // Read the XML descriptor
+ $this->getTemplateInstance()->loadRequestNodeListTemplate();
+
+ // Render the XML content
+ $this->getTemplateInstance()->renderXmlContent();
+ }
+
+ /**
+ * Do the helped attempt by delivering a package to ourselfs
+ *
+ * @param $nodeInstance An instance of a NodeHelper class
+ * @return void
+ */
+ public function sendPackage (NodeHelper $nodeInstance) {
+ // Sanity check: Is the node in the approx. state? (active)
+ $nodeInstance->getStateInstance()->validateNodeStateIsActive();
+
+ // Compile the template, this inserts the loaded node data into the gaps.
+ $this->getTemplateInstance()->compileTemplate();
+
+ // Get a singleton network package instance
+ $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
+
+ // Next, feed the content in. The network package class is a pipe-through class.
+ $packageInstance->enqueueRawDataFromTemplate($this);
+ }
+}
+
+// [EOF]
+?>
const PACKAGE_RECIPIENT_SEPARATOR = ':';
/**
- * Network target (alias): 'upper hubs'
+ * Network target (alias): 'upper nodes'
*/
- const NETWORK_TARGET_UPPER_HUBS = 'upper';
+ const NETWORK_TARGET_UPPER_NODES = 'upper';
/**
* Network target (alias): 'self'
* located in '!!!' by default
* @return void
*/
- public function load???Template ($template) {
+ public function load???Template ($template = '!!!') {
// Set template type
$this->setTemplateType($this->getConfigInstance()->getConfigEntry('!!!_template_type'));
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An ??? template engine class for XML templates
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class XmlRequestNodeListTemplateEngine extends BaseTemplateEngine implements CompileableTemplate, Registerable {
+ /**
+ * Main nodes in the XML tree
+ */
+ private $mainNodes = array(
+ 'node-request-node-list'
+ );
+
+ /**
+ * Sub nodes in the XML tree
+ */
+ private $subNodes = array(
+ );
+
+ /**
+ * Current main node
+ */
+ private $curr = array();
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * 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 createXmlRequestNodeListTemplateEngine () {
+ // Get a new instance
+ $templateInstance = new XmlRequestNodeListTemplateEngine();
+
+ // Get application instance from registry
+ $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+ // Determine base path
+ $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/';
+
+ // Is the base path valid?
+ if (empty($templateBasePath)) {
+ // Base path is empty
+ throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif (!is_string($templateBasePath)) {
+ // Is not a string
+ throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
+ } elseif (!is_dir($templateBasePath)) {
+ // Is not a path
+ throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
+ } elseif (!is_readable($templateBasePath)) {
+ // Is not readable
+ throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
+ }
+
+ // Set the base path
+ $templateInstance->setTemplateBasePath($templateBasePath);
+
+ // Set template extensions
+ $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension'));
+ $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('node_message_template_extension'));
+
+ // Absolute output path for compiled templates
+ $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path'));
+
+ // Init a variable stacker
+ $stackerInstance = ObjectFactory::createObjectByConfiguredName('node_request_node_list_stacker_class');
+
+ // Set it
+ $templateInstance->setStackerInstance($stackerInstance);
+
+ // Return the prepared instance
+ 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);
+ }
+
+ /**
+ * Getter for current main node
+ *
+ * @return $currMainNode Current main node
+ */
+ public final function getCurrMainNode () {
+ return $this->curr['main_node'];
+ }
+
+ /**
+ * Setter for current main node
+ *
+ * @param $element Element name to set as current main node
+ * @return $currMainNode Current main node
+ */
+ private final function setCurrMainNode ($element) {
+ $this->curr['main_node'] = (string) $element;
+ }
+
+ /**
+ * Getter for main node array
+ *
+ * @return $mainNodes Array with valid main node names
+ */
+ public final function getMainNodes () {
+ return $this->mainNodes;
+ }
+
+ /**
+ * Getter for sub node array
+ *
+ * @return $subNodes Array with valid sub node names
+ */
+ public final function getSubNodes () {
+ return $this->subNodes;
+ }
+
+ /**
+ * Handles the start element of an XML resource
+ *
+ * @param $resource XML parser resource (currently ignored)
+ * @param $element The element we shall handle
+ * @param $attributes All attributes
+ * @return void
+ * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found
+ */
+ public function startElement ($resource, $element, array $attributes) {
+ // Initial method name which will never be called...
+ $methodName = 'initNodeRequestNodeList';
+
+ // Make the element name lower-case
+ $element = strtolower($element);
+
+ // Is the element a main node?
+ //* DEBUG: */ echo "START: >".$element."<<br />\n";
+ if (in_array($element, $this->getMainNodes())) {
+ // Okay, main node found!
+ $methodName = 'start' . $this->convertToClassName($element);
+
+ // Set it
+ $this->setCurrMainNode($element);
+ } elseif (in_array($element, $this->getSubNodes())) {
+ // Sub node found
+ $methodName = 'start' . $this->convertToClassName($element);
+ } else {
+ // Invalid node name found
+ throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN);
+ }
+
+ // Call method
+ call_user_func_array(array($this, $methodName), $attributes);
+ }
+
+ /**
+ * Ends the main or sub node by sending out the gathered data
+ *
+ * @param $resource An XML resource pointer (currently ignored)
+ * @param $nodeName Name of the node we want to finish
+ * @return void
+ * @throws XmlNodeMismatchException If current main node mismatches the closing one
+ */
+ public function endElement ($resource, $nodeName) {
+ // Make all lower-case
+ $nodeName = strtolower($nodeName);
+
+ // Does this match with current main node?
+ //* DEBUG: */ echo "END: >".$nodeName."<<br />\n";
+ if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
+ // Did not match!
+ throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH);
+ } // END - if
+
+ // Construct method name
+ $methodName = 'finish' . $this->convertToClassName($nodeName);
+
+ // Call the corresponding method
+ //* DEBUG: */ echo "call: ".$methodName."<br />\n";
+ call_user_func_array(array($this, $methodName), array());
+ }
+
+ /**
+ * 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
+
+ // Get current XML node name as an array index
+ $nodeName = $this->getStackerInstance()->getNamed('node_request_node_list');
+
+ $this->partialStub('TODO: Do something with the gathered data.');
+ }
+
+ /**
+ * Getter for cache file (FQFN)
+ *
+ * @return $fqfn Full-qualified file name of the menu cache
+ */
+ public function getNodeRequestNodeListCacheFqfn () {
+ $this->partialStub('Please implement this method.');
+ }
+
+ /**
+ * Starts the node-request-node-list
+ *
+ * @return void
+ */
+ private function startNodeRequestNodeList () {
+ // Push the node name on the stacker
+ $this->getStackerInstance()->pushNamed('node_request_node_list', 'node-request-node-list');
+ }
+
+ /**
+ * Finishes the node-request-node-list
+ *
+ * @return void
+ */
+ private function finishNodeRequestNodeList () {
+ // Pop the last entry
+ $this->getStackerInstance()->popNamed('node_request_node_list');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+An XML for requesting a node list, to specify which node data shall be
+transmitted.
+
+@author Roland Haeder <webmaster@ship-simu.org>
+@version 0.0.0
+@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub 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/>
+//-->
+<node-request-node-list>
+</node-request-node-list>