From: Roland Häder Date: Wed, 2 Dec 2020 06:04:10 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7ddfbd1dcec6b308734e5282e86a8f87e837b093;p=hub.git Continued: - introduced new traits - moved BaseXmlTemplateEngine to core framework - convert old array() to "new" [] scheme - updated core frameworks Signed-off-by: Roland Häder --- diff --git a/application/hub/classes/cruncher/class_BaseHubCruncher.php b/application/hub/classes/cruncher/class_BaseHubCruncher.php index cf0762825..949c24b0a 100644 --- a/application/hub/classes/cruncher/class_BaseHubCruncher.php +++ b/application/hub/classes/cruncher/class_BaseHubCruncher.php @@ -174,10 +174,10 @@ abstract class BaseHubCruncher extends BaseHubSystem implements Updateable { $this->bufferInstance = ObjectFactory::createObjectByConfiguredName('cruncher_buffer_stacker_class'); // Initialize common stackers, like in/out - $this->bufferInstance->initStacks(array( + $this->bufferInstance->initStacks([ self::STACKER_NAME_IN_QUEUE, self::STACKER_NAME_OUT_QUEUE - )); + ]); // Output debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRUNCHER: All buffers are now initialized.'); diff --git a/application/hub/classes/decoder/class_BaseDecoder.php b/application/hub/classes/decoder/class_BaseDecoder.php index b6af54381..9849337d6 100644 --- a/application/hub/classes/decoder/class_BaseDecoder.php +++ b/application/hub/classes/decoder/class_BaseDecoder.php @@ -8,7 +8,7 @@ use Org\Shipsimu\Hub\Network\Delivery\Deliverable; // Import framework stuff use Org\Mxchange\CoreFramework\Handler\Handleable; -use Org\Mxchange\CoreFramework\Stacker\Stackable; +use Org\Mxchange\CoreFramework\Traits\Stacker\StackableTrait; /** * A general Decoder class @@ -33,16 +33,14 @@ use Org\Mxchange\CoreFramework\Stacker\Stackable; * along with this program. If not, see . */ abstract class BaseDecoder extends BaseHubSystem { + // Load traits + use StackableTrait; + /** * A network package handler instance */ private $packageHandlerInstance = NULL; - /** - * Instance of the stacker - */ - private $stackInstance = NULL; - /** * Handler instance */ @@ -78,25 +76,6 @@ abstract class BaseDecoder extends BaseHubSystem { return $this->packageHandlerInstance; } - /** - * Setter for stacker instance - * - * @param $stackInstance An instance of an stacker - * @return void - */ - protected final function setStackInstance (Stackable $stackInstance) { - $this->stackInstance = $stackInstance; - } - - /** - * Getter for stacker instance - * - * @return $stackInstance An instance of an stacker - */ - public final function getStackInstance () { - return $this->stackInstance; - } - /** * Setter for handler instance * diff --git a/application/hub/classes/dht/class_BaseDht.php b/application/hub/classes/dht/class_BaseDht.php index 7a663cd12..ffe9e0d3e 100644 --- a/application/hub/classes/dht/class_BaseDht.php +++ b/application/hub/classes/dht/class_BaseDht.php @@ -12,7 +12,7 @@ use Org\Shipsimu\Hub\Helper\Dht\HelpableDht; use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Result\Search\SearchableResult; -use Org\Mxchange\CoreFramework\Stacker\Stackable; +use Org\Mxchange\CoreFramework\Traits\Stacker\StackableTrait; use Org\Mxchange\CoreFramework\Traits\State\StateableTrait; /** @@ -40,6 +40,7 @@ use Org\Mxchange\CoreFramework\Traits\State\StateableTrait; abstract class BaseDht extends BaseHubSystem implements Distributable { // Load traits use StateableTrait; + use StackableTrait; /** * Stacker name for "INSERT" node data @@ -52,11 +53,6 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { */ private $publishHelperInstance = NULL; - /** - * Instance of the stacker - */ - private $stackInstance = NULL; - /** * Protected constructor * @@ -80,25 +76,6 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { DhtStateFactory::createDhtStateInstanceByName('init', $this); } - /** - * Setter for stacker instance - * - * @param $stackInstance An instance of an stacker - * @return void - */ - protected final function setStackInstance (Stackable $stackInstance) { - $this->stackInstance = $stackInstance; - } - - /** - * Getter for stacker instance - * - * @return $stackInstance An instance of an stacker - */ - public final function getStackInstance () { - return $this->stackInstance; - } - /** * Initializes all stackers * @@ -106,10 +83,10 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { */ private function initStacks () { // Initialize all stacker - $this->getStackInstance()->initStacks(array( + $this->getStackInstance()->initStacks([ self::STACKER_NAME_INSERT_NODE, self::STACKER_NAME_PENDING_PUBLISHING, - )); + ]); } /** diff --git a/application/hub/classes/handler/chunks/class_ChunkHandler.php b/application/hub/classes/handler/chunks/class_ChunkHandler.php index a23f91294..26f0e7d40 100644 --- a/application/hub/classes/handler/chunks/class_ChunkHandler.php +++ b/application/hub/classes/handler/chunks/class_ChunkHandler.php @@ -126,11 +126,11 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera // Init all stacker /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CHUNK-HANDLER: Initializing stackInstance=%s ...', $stackInstance->__toString())); - $stackInstance->initStacks(array( + $stackInstance->initStacks([ self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP, self::STACKER_NAME_CHUNKS_WITHOUT_FINAL, self::STACKER_NAME_ASSEMBLED_RAW_DATA - )); + ]); // Set the stacker in this handler $handlerInstance->setStackInstance($stackInstance); diff --git a/application/hub/classes/handler/class_BaseHubHandler.php b/application/hub/classes/handler/class_BaseHubHandler.php index eef5130f4..b9b301a0d 100644 --- a/application/hub/classes/handler/class_BaseHubHandler.php +++ b/application/hub/classes/handler/class_BaseHubHandler.php @@ -15,7 +15,7 @@ use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException; use Org\Mxchange\CoreFramework\Handler\BaseHandler; use Org\Mxchange\CoreFramework\Handler\Handleable; use Org\Mxchange\CoreFramework\Registry\Register; -use Org\Mxchange\CoreFramework\Stacker\Stackable; +use Org\Mxchange\CoreFramework\Traits\Stacker\StackableTrait; /** * A general hub handler @@ -40,6 +40,9 @@ use Org\Mxchange\CoreFramework\Stacker\Stackable; * along with this program. If not, see . */ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInterface { + // Load traits + use StackableTrait; + /** * Listener instance */ @@ -70,11 +73,6 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte */ private $registryInstance = NULL; - /** - * Instance of the stacker - */ - private $stackInstance = NULL; - /** * Protected constructor * @@ -202,23 +200,4 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte return $this->registryInstance; } - /** - * Setter for stacker instance - * - * @param $stackInstance An instance of an stacker - * @return void - */ - protected final function setStackInstance (Stackable $stackInstance) { - $this->stackInstance = $stackInstance; - } - - /** - * Getter for stacker instance - * - * @return $stackInstance An instance of an stacker - */ - public final function getStackInstance () { - return $this->stackInstance; - } - } diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index bd011d371..4bc52231c 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -42,6 +42,7 @@ use Org\Mxchange\CoreFramework\Socket\InvalidSocketException; use Org\Mxchange\CoreFramework\Traits\Crypto\CryptoTrait; use Org\Mxchange\CoreFramework\Traits\Visitor\VisitorTrait; use Org\Mxchange\CoreFramework\Visitor\Visitable; +use Org\Mxchange\CoreFramework\Visitor\Visitor; // Import SPL stuff use \BadMethodCallException; @@ -423,7 +424,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei */ protected function initStacks ($forceReInit = FALSE) { // Initialize all - $this->getStackInstance()->initStacks(array( + $this->getStackInstance()->initStacks([ self::STACKER_NAME_UNDECLARED, self::STACKER_NAME_DECLARED, self::STACKER_NAME_OUTGOING, @@ -434,7 +435,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei self::STACKER_NAME_NEW_MESSAGE, self::STACKER_NAME_PROCESSED_MESSAGE, self::STACKER_NAME_OUTGOING_STREAM - ), $forceReInit); + ], $forceReInit); } /** diff --git a/application/hub/classes/miner/class_BaseHubMiner.php b/application/hub/classes/miner/class_BaseHubMiner.php index 6f6d0fb50..efc25d476 100644 --- a/application/hub/classes/miner/class_BaseHubMiner.php +++ b/application/hub/classes/miner/class_BaseHubMiner.php @@ -190,10 +190,10 @@ abstract class BaseHubMiner extends BaseHubSystem implements Updateable { $this->bufferInstance = ObjectFactory::createObjectByConfiguredName('miner_buffer_stacker_class'); // Initialize common stackers, like in/out - $this->bufferInstance->initStacks(array( + $this->bufferInstance->initStacks([ self::STACKER_NAME_IN_QUEUE, self::STACKER_NAME_OUT_QUEUE - )); + ]); // Output debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MINER: All buffers are now initialized.'); diff --git a/application/hub/classes/package/assembler/class_PackageAssembler.php b/application/hub/classes/package/assembler/class_PackageAssembler.php index b6611b8ad..eb7f3bf62 100644 --- a/application/hub/classes/package/assembler/class_PackageAssembler.php +++ b/application/hub/classes/package/assembler/class_PackageAssembler.php @@ -18,7 +18,7 @@ use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Handler\Handleable; use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Stacker\Stackable; +use Org\Mxchange\CoreFramework\Traits\Stacker\StackableTrait; use Org\Mxchange\CoreFramework\Traits\Stream\Input\InputStreamTrait; use Org\Mxchange\CoreFramework\Utils\String\StringUtils; use Org\Mxchange\CoreFramework\Visitor\Visitable; @@ -53,6 +53,7 @@ use \BadMethodCallException; class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, Visitable { // Load traits use InputStreamTrait; + use StackableTrait; /** * Name for stacker holding raw data of multiple messages @@ -79,11 +80,6 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, */ private $packageHandlerInstance = NULL; - /** - * Instance of the stacker - */ - private $stackInstance = NULL; - /** * Handler instance */ @@ -166,25 +162,6 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, return $this->packageHandlerInstance; } - /** - * Setter for stacker instance - * - * @param $stackInstance An instance of an stacker - * @return void - */ - protected final function setStackInstance (Stackable $stackInstance) { - $this->stackInstance = $stackInstance; - } - - /** - * Getter for stacker instance - * - * @return $stackInstance An instance of an stacker - */ - public final function getStackInstance () { - return $this->stackInstance; - } - /** * Setter for handler instance * diff --git a/application/hub/classes/source/class_BaseUrlSource.php b/application/hub/classes/source/class_BaseUrlSource.php index 3026f5ece..9b521d10b 100644 --- a/application/hub/classes/source/class_BaseUrlSource.php +++ b/application/hub/classes/source/class_BaseUrlSource.php @@ -7,7 +7,7 @@ use Org\Shipsimu\Hub\Crawler\Source\BaseSource; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\Stack\FileStackFactory; -use Org\Mxchange\CoreFramework\Stacker\Stackable; +use Org\Mxchange\CoreFramework\Traits\Stacker\StackableTrait; /** * A general URL source class @@ -32,6 +32,9 @@ use Org\Mxchange\CoreFramework\Stacker\Stackable; * along with this program. If not, see . */ abstract class BaseUrlSource extends BaseSource { + // Load traits + use StackableTrait; + // Stack name for all URLs const STACKER_NAME_URLS = 'urls'; @@ -40,11 +43,6 @@ abstract class BaseUrlSource extends BaseSource { const CRAWL_JOB_ARRAY_DEPTH = 'start_depth'; const CRAWL_JOB_ARRAY_EXTERNAL_DEPTH = 'external_depth'; - /** - * Instance of the stacker - */ - private $stackInstance = NULL; - /** * Protected constructor * @@ -56,25 +54,6 @@ abstract class BaseUrlSource extends BaseSource { parent::__construct($className); } - /** - * Setter for stacker instance - * - * @param $stackInstance An instance of an stacker - * @return void - */ - protected final function setStackInstance (Stackable $stackInstance) { - $this->stackInstance = $stackInstance; - } - - /** - * Getter for stacker instance - * - * @return $stackInstance An instance of an stacker - */ - public final function getStackInstance () { - return $this->stackInstance; - } - /** * Initalizes this source * diff --git a/application/hub/classes/template/announcement/class_XmlAnnouncementTemplateEngine.php b/application/hub/classes/template/announcement/class_XmlAnnouncementTemplateEngine.php deleted file mode 100644 index 3c4ebbf4e..000000000 --- a/application/hub/classes/template/announcement/class_XmlAnnouncementTemplateEngine.php +++ /dev/null @@ -1,368 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const ANNOUNCEMENT_DATA_SESSION_ID = 'session-id'; - const ANNOUNCEMENT_DATA_NODE_ID = 'node-id'; - const ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH = 'private-key-hash'; - const ANNOUNCEMENT_DATA_NODE_STATUS = 'node-status'; - const ANNOUNCEMENT_DATA_NODE_MODE = 'node-mode'; - const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'external-address'; - const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'internal-address'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->setSubNodes(array( - 'announcement-data', - 'listener', - self::ANNOUNCEMENT_DATA_NODE_STATUS, - self::ANNOUNCEMENT_DATA_NODE_MODE, - self::ANNOUNCEMENT_DATA_NODE_ID, - self::ANNOUNCEMENT_DATA_SESSION_ID, - self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH, - self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, - self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, - 'object-type-list', - )); - } - - /** - * 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 createXmlAnnouncementTemplateEngine () { - // Get a new instance - $templateInstance = new XmlAnnouncementTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'announcement'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('node_announcement'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getMenuCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the announcement - * - * @return void - */ - protected function startAnnouncement () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', 'announcement'); - } - - /** - * Starts the announcement data - * - * @return void - */ - protected function startAnnouncementData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', 'announcement-data'); - } - - /** - * Starts the node status - * - * @return void - */ - protected function startNodeStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_STATUS); - } - - /** - * Starts the node-mode - * - * @return void - */ - protected function startNodeMode () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_MODE); - } - - /** - * Starts the listener - * - * @return void - */ - protected function startListener () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', 'listener'); - } - - /** - * Starts the session id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_SESSION_ID); - } - - /** - * Starts the node id - * - * @return void - */ - protected function startNodeId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_ID); - } - - /** - * Starts the private key hash - * - * @return void - */ - protected function startPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH); - } - - /** - * Starts the public ip - * - * @return void - */ - protected function startExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS); - } - - /** - * Starts the private ip - * - * @return void - */ - protected function startInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS); - } - - /** - * Starts the object type list - * - * @return void - */ - protected function startObjectTypeList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', 'object-type-list'); - } - - /** - * Starts the object type - * - * @return void - */ - protected function startObjectType () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', 'object-type'); - } - - /** - * Finishes the object type - * - * @return void - */ - protected function finishObjectType () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the object type list - * - * @return void - */ - protected function finishObjectTypeList () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the private key hash - * - * @return void - */ - protected function finishPrivateKeyHash () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the node id - * - * @return void - */ - protected function finishNodeId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the session id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the private ip - * - * @return void - */ - protected function finishInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the public ip - * - * @return void - */ - protected function finishExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the listener - * - * @return void - */ - protected function finishListener () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the node mode - * - * @return void - */ - protected function finishNodeMode () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the node status - * - * @return void - */ - protected function finishNodeStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the announcement data - * - * @return void - */ - protected function finishAnnouncementData () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the announcement - * - * @return void - */ - protected function finishAnnouncement () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/classes/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php deleted file mode 100644 index 09eb6b1ad..000000000 --- a/application/hub/classes/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php +++ /dev/null @@ -1,416 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const ANNOUNCEMENT_DATA_NODE_ID = 'my-node-id'; - const ANNOUNCEMENT_DATA_SESSION_ID = 'my-session-id'; - const ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH = 'my-private-key-hash'; - const ANNOUNCEMENT_DATA_NODE_STATUS = 'my-status'; - const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'my-external-address'; - const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'my-internal-address'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init sub-nodes array - $this->setSubNodes(array( - // These nodes don't contain any data - 'my-data', - 'your-data', - // Data from *this* node - self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, - self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, - self::ANNOUNCEMENT_DATA_NODE_STATUS, - self::ANNOUNCEMENT_DATA_NODE_ID, - self::ANNOUNCEMENT_DATA_SESSION_ID, - self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH, - // Data from other node - 'your-external-address', - 'your-internal-address', - 'your-node-id', - 'your-session-id', - 'your-private-key-hash', - // Answer status (generic field) - self::ANSWER_STATUS, - )); - } - - /** - * 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 createXmlAnnouncementAnswerTemplateEngine () { - // Get a new instance - $templateInstance = new XmlAnnouncementAnswerTemplateEngine(); - - // Init instance - $templateInstance->initXmlTemplateEngine('node', 'announcement_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; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('node_announcement_answer'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getAnnouncementAnswerCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the announcement-answer - * - * @return void - */ - protected function startAnnouncementAnswer () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'announcement-answer'); - } - - /** - * Starts the my-data - * - * @return void - */ - protected function startMyData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'my-data'); - } - - /** - * Starts the my-external-address - * - * @return void - */ - protected function startMyExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS); - } - - /** - * Starts the my-internal-address - * - * @return void - */ - protected function startMyInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS); - } - - /** - * Starts the my-node-id - * - * @return void - */ - protected function startMyNodeId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_ID); - } - - /** - * Starts the my-session-id - * - * @return void - */ - protected function startMySessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID); - } - - /** - * Starts the my-private-key-hash - * - * @return void - */ - protected function startMyPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH); - } - - /** - * Starts the my-status - * - * @return void - */ - protected function startMyStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS); - } - - /** - * Finishes the my-status - * - * @return void - */ - protected function finishMyStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the my-private-key-hash - * - * @return void - */ - protected function finishMyPrivateKeyhash () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the my-session-id - * - * @return void - */ - protected function finishMySessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the my-node-id - * - * @return void - */ - protected function finishMyNodeId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the my-internal-address - * - * @return void - */ - protected function finishMyInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the my-external-address - * - * @return void - */ - protected function finishMyExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the my-data - * - * @return void - */ - protected function finishMyData () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Starts the your-data - * - * @return void - */ - protected function startYourData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-data'); - } - - /** - * Starts the your-external-address - * - * @return void - */ - protected function startYourExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-external-address'); - } - - /** - * Starts the your-internal-address - * - * @return void - */ - protected function startYourInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-internal-address'); - } - - /** - * Starts the your-session-id - * - * @return void - */ - protected function startYourSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-session-id'); - } - - /** - * Starts the your-node-id - * - * @return void - */ - protected function startYourNodeId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-node-id'); - } - - /** - * Starts the your-private-key-hash - * - * @return void - */ - protected function startYourPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-private-key-hash'); - } - - /** - * Finishes the your-private-key-hash - * - * @return void - */ - protected function finishYourPrivateKeyHash () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the your-node-id - * - * @return void - */ - protected function finishYourNodeId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the your-session-id - * - * @return void - */ - protected function finishYourSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the your-internal-address - * - * @return void - */ - protected function finishYourInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the your-external-address - * - * @return void - */ - protected function finishYourExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the your-data - * - * @return void - */ - protected function finishYourData () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the announcement-answer - * - * @return void - */ - protected function finishAnnouncementAnswer () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/answer/class_ b/application/hub/classes/template/answer/class_ deleted file mode 100644 index 19ad3bb97..000000000 --- a/application/hub/classes/template/answer/class_ +++ /dev/null @@ -1,120 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub 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 Xml???AnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { - /** - * 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 createXml???TemplateEngine () { - // Get a new instance - $templateInstance = new Xml???TemplateEngine(); - - // Init template instannce - $templateInstance->initXmlTemplateEngine('PREFIX', '!!!'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - 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 data with matching variable here - parent::assignVariable($this->getStackInstance()->getNamed('!!!'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function get???CacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the ||| - * - * @return void - */ - protected function start??? () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('!!!', '|||'); - } - - /** - * Finishes the ||| - * - * @return void - */ - protected function finish??? () { - // Pop the last entry - $this->getStackInstance()->popNamed('!!!'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/answer/class_BaseXmlAnswerTemplateEngine.php b/application/hub/classes/template/answer/class_BaseXmlAnswerTemplateEngine.php deleted file mode 100644 index f5f2e3961..000000000 --- a/application/hub/classes/template/answer/class_BaseXmlAnswerTemplateEngine.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 . - */ -abstract class BaseXmlAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Generic 'answer-status' field - */ - const ANSWER_STATUS = 'answer-status'; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct (string $className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Starts the answer-status - * - * @return void - */ - protected function startAnswerStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed($this->getStackerName(), self::ANSWER_STATUS); - } - - /** - * Finishes the answer-status - * - * @return void - */ - protected function finishAnswerStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed($this->getStackerName()); - } - -} diff --git a/application/hub/classes/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php b/application/hub/classes/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php deleted file mode 100644 index 3d15afdc1..000000000 --- a/application/hub/classes/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php +++ /dev/null @@ -1,395 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const DHT_BOOTSTRAP_DATA_SESSION_ID = 'my-session-id'; - const DHT_BOOTSTRAP_DATA_PRIVATE_KEY_HASH = 'my-private-key-hash'; - const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'my-status'; - const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'my-external-address'; - const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'my-internal-address'; - const DHT_BOOTSTRAP_DATA_NODE_LIST = 'dht-nodes-list'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init sub-nodes array - $this->setSubNodes(array( - // These nodes don't contain any data - 'my-data', - 'your-data', - // Data from *this* node - self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, - self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS, - self::DHT_BOOTSTRAP_DATA_NODE_STATUS, - self::DHT_BOOTSTRAP_DATA_SESSION_ID, - // Data from other node - 'your-external-address', - 'your-internal-address', - 'your-session-id', - // Answer status (generic field) - self::ANSWER_STATUS, - // DHT node list - self::DHT_BOOTSTRAP_DATA_NODE_LIST, - )); - } - - /** - * 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 createXmlDhtBootstrapAnswerTemplateEngine () { - // Get a new instance - $templateInstance = new XmlDhtBootstrapAnswerTemplateEngine(); - - // Init instance - $templateInstance->initXmlTemplateEngine('node', 'dht_bootstrap_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; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('node_dht_bootstrap_answer'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getDhtBootstrapAnswerCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the dht_bootstrap-answer - * - * @return void - */ - protected function startDhtBootstrapAnswer () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'dht_bootstrap-answer'); - } - - /** - * Starts the my-data - * - * @return void - */ - protected function startMyData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'my-data'); - } - - /** - * Starts the my-external-address - * - * @return void - */ - protected function startMyExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS); - } - - /** - * Starts the my-internal-address - * - * @return void - */ - protected function startMyInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS); - } - - /** - * Starts the my-session-id - * - * @return void - */ - protected function startMySessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_SESSION_ID); - } - - /** - * Starts the my-private-key-hash - * - * @return void - */ - protected function startMyPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_PRIVATE_KEY_HASH); - } - - /** - * Starts the my-status - * - * @return void - */ - protected function startMyStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_NODE_STATUS); - } - - /** - * Starts the dht-nodes-list - * - * @return void - */ - protected function startDhtNodesList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_NODE_LIST); - } - - /** - * Finishes the dht-nodes-list - * - * @return void - */ - protected function finishDhtNodesList () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the my-status - * - * @return void - */ - protected function finishMyStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the my-private-key-hash - * - * @return void - */ - protected function finishMyPrivateKeyHash () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the my-session-id - * - * @return void - */ - protected function finishMySessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the my-internal-address - * - * @return void - */ - protected function finishMyInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the my-external-address - * - * @return void - */ - protected function finishMyExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the my-data - * - * @return void - */ - protected function finishMyData () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Starts the your-data - * - * @return void - */ - protected function startYourData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-data'); - } - - /** - * Starts the your-external-address - * - * @return void - */ - protected function startYourExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-external-address'); - } - - /** - * Starts the your-internal-address - * - * @return void - */ - protected function startYourInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-internal-address'); - } - - /** - * Starts the your-session-id - * - * @return void - */ - protected function startYourSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-session-id'); - } - - /** - * Starts the your-private-key-hash - * - * @return void - */ - protected function startYourPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-private-key-hash'); - } - - /** - * Finishes the your-private-key-hash - * - * @return void - */ - protected function finishYourPrivateKeyHash () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the your-session-id - * - * @return void - */ - protected function finishYourSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the your-internal-address - * - * @return void - */ - protected function finishYourInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the your-external-address - * - * @return void - */ - protected function finishYourExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the your-data - * - * @return void - */ - protected function finishYourData () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the dht_bootstrap-answer - * - * @return void - */ - protected function finishDhtBootstrapAnswer () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php b/application/hub/classes/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php deleted file mode 100644 index f954b517d..000000000 --- a/application/hub/classes/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php +++ /dev/null @@ -1,183 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { - // Constants for array elements - const REQUEST_DATA_SESSION_ID = 'session-id'; - const REQUEST_DATA_NODE_LIST = 'node-list'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init sub-nodes array - $this->setSubNodes(array( - self::REQUEST_DATA_SESSION_ID, - self::REQUEST_DATA_NODE_LIST, - // Answer status (generic field) - self::ANSWER_STATUS, - )); - } - - /** - * 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'); - - // Get a template instance for list entries (as they are dynamic) - $entriesInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_entries_template_class'); - - // Set it here - $templateInstance->setTemplateInstance($entriesInstance); - - // 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; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('node_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 'request-node-list-answer' - * - * @return void - */ - protected function startRequestNodeListAnswer () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list_answer', 'request-node-list-answer'); - } - - /** - * Starts the session-id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_SESSION_ID); - } - - /** - * Starts the node-list - * - * @return void - */ - protected function startNodeList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_NODE_LIST); - } - - /** - * Finishes the node-list - * - * @return void - */ - protected function finishNodeList () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list_answer'); - } - - /** - * Finishes the session-id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list_answer'); - } - - /** - * Finishes the 'request-node-list-answer' - * - * @return void - */ - protected function finishRequestNodeListAnswer () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list_answer'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/class_ b/application/hub/classes/template/class_ deleted file mode 100644 index 707cea3ae..000000000 --- a/application/hub/classes/template/class_ +++ /dev/null @@ -1,120 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub 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 Xml???TemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * 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 createXml???TemplateEngine () { - // Get a new instance - $templateInstance = new Xml???TemplateEngine(); - - // Init template instannce - $templateInstance->initXmlTemplateEngine('PREFIX', '!!!'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - 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 data with matching variable here - parent::assignVariable($this->getStackInstance()->getNamed('!!!'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function get???CacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the ||| - * - * @return void - */ - protected function start??? () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('!!!', '|||'); - } - - /** - * Finishes the ||| - * - * @return void - */ - protected function finish??? () { - // Pop the last entry - $this->getStackInstance()->popNamed('!!!'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/class_BaseXmlTemplateEngine.php b/application/hub/classes/template/class_BaseXmlTemplateEngine.php deleted file mode 100644 index c9e34b3b4..000000000 --- a/application/hub/classes/template/class_BaseXmlTemplateEngine.php +++ /dev/null @@ -1,373 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 . - */ -abstract class BaseXmlTemplateEngine extends BaseTemplateEngine { - /** - * Main nodes in the XML tree - */ - private $mainNodes = []; - - /** - * Sub nodes in the XML tree - */ - private $subNodes = []; - - /** - * Current main node - */ - private $curr = []; - - /** - * XML template type - */ - private $xmlTemplateType = 'xml'; - - /** - * Type prefix - */ - private $typePrefix = 'xml'; - - /** - * Name of stacker - */ - private $stackerName = ''; - - /** - * Content from dependency - */ - protected $dependencyContent = []; - - /** - * Template engine instance - */ - private $templateInstance = NULL; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct (string $className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Does a generic initialization of the template engine - * - * @param $typePrefix Type prefix - * @param $xmlTemplateType Type of XML template - * @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 - */ - protected function initXmlTemplateEngine ($typePrefix, $xmlTemplateType) { - // Set XML template type and prefix - $this->xmlTemplateType = $xmlTemplateType; - $this->typePrefix = $typePrefix; - - // Get template instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); - - // Determine base path - $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . FrameworkBootstrap::getRequestInstance()->getRequestElement('app') . '/'; - - // Is the base path valid? - if (empty($templateBasePath)) { - // Base path is empty - throw new BasePathIsEmptyException($this, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_string($templateBasePath)) { - // Is not a string - throw new InvalidBasePathStringException(array($this, $templateBasePath), self::EXCEPTION_INVALID_STRING); - } elseif (!is_dir($templateBasePath)) { - // Is not a path - throw new BasePathIsNoDirectoryException(array($this, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($templateBasePath)) { - // Is not readable - throw new BasePathReadProtectedException(array($this, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); - } - - // Set the base path - $this->setTemplateBasePath($templateBasePath); - - // Set template extensions - $this->setRawTemplateExtension(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('raw_template_extension')); - $this->setCodeTemplateExtension(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($typePrefix . '_message_template_extension')); - - // Absolute output path for compiled templates - $this->setCompileOutputPath(sprintf('%s%s', - $templateBasePath, - FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('compile_output_path') - )); - - // Init a variable stacker - $stackInstance = ObjectFactory::createObjectByConfiguredName($typePrefix . '_' . $xmlTemplateType . '_stacker_class'); - - // Set name - $this->stackerName = $typePrefix . '_' . $xmlTemplateType; - - // Init stacker - $stackInstance->initStack($this->stackerName); - - // Set it - $this->setStackInstance($stackInstance); - - // Set it in main nodes - array_push($this->mainNodes, str_replace('_', '-', $xmlTemplateType)); - } - - /** - * Load a specified XML template into the engine - * - * @param $templateName Optional name of template - * @return void - */ - public function loadXmlTemplate ($templateName = '') { - // Is the template name empty? - if (empty($templateName)) { - // Set generic template name - $templateName = $this->typePrefix . '_' . $this->xmlTemplateType . '_template_type'; - } // END - if - - // Set template type - $this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($templateName)); - - // Load the special template - $this->loadTemplate($this->xmlTemplateType); - } - - /** - * 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 stacker name - * - * @return $stackerName Name of stacker of this class - */ - protected final function getStackerName () { - return $this->stackerName; - } - - /** - * Setter for sub node array - * - * @param $subNodes Array with valid sub node names - * @return void - */ - public final function setSubNodes (array $subNodes) { - $this->subNodes = $subNodes; - } - - /** - * Getter for sub node array - * - * @return $subNodes Array with valid sub node names - */ - public final function getSubNodes () { - return $this->subNodes; - } - - /** - * Setter for template engine instances - * - * @param $templateInstance An instance of a template engine class - * @return void - */ - protected final function setTemplateInstance (CompileableTemplate $templateInstance) { - $this->templateInstance = $templateInstance; - } - - /** - * Getter for template engine instances - * - * @return $templateInstance An instance of a template engine class - */ - protected final function getTemplateInstance () { - return $this->templateInstance; - } - - /** - * Read XML variables by calling readVariable() with 'general' as - * variable stack. - * - * @param $key Key to read from - * @return $value Value from variable - */ - public function readXmlData (string $key) { - // Is key parameter valid? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-XML-TEMPLATE-ENGINE: key=%s - CALLED!', $key)); - if (empty($key)) { - // Throw exception - throw new InvalidArgumentException('Parameter key is empty'); - } - - // Read the variable - $value = parent::readVariable($key, 'general'); - - // Is this null? - if (is_null($value)) { - // Bah, needs fixing. - $this->debugInstance(sprintf('[%s:%d]: key=%s returns NULL', __METHOD__, __LINE__, $key)); - } // END - if - - // Return value - return $value; - } - - /** - * Handles the template dependency for given XML node - * - * @param $node The XML node we should load a dependency template - * @param $templateDependency A template to load to satisfy dependencies - * @return void - */ - protected function handleTemplateDependency ($node, $templateDependency) { - // Check that the XML node is not empty - assert(!empty($node)); - - // Is the template dependency set? - if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) { - // Get a temporay template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance($this->typePrefix . '_' . self::convertDashesToUnderscores($node) . '_' . $this->xmlTemplateType . '_template_class'); - - // Then load it - $templateInstance->loadXmlTemplate($templateDependency); - - // Parse the XML content - $templateInstance->renderXmlContent(); - - // Save the parsed raw content in our dependency array - $this->dependencyContent[$node] = $templateInstance->getRawTemplateData(); - } // END - if - } - - /** - * 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 final function startElement ($resource, $element, array $attributes) { - // Initial method name which will never be called... - $methodName = 'init' . StringUtils::convertToClassName($this->xmlTemplateType); - - // Make the element name lower-case - $element = strtolower($element); - - // Is the element a main node? - //* DEBUG: */ echo "START: >".$element."<
\n"; - if (in_array($element, $this->getMainNodes())) { - // Okay, main node found! - $methodName = 'start' . StringUtils::convertToClassName($element); - - // Set it - $this->setCurrMainNode($element); - } elseif (in_array($element, $this->getSubNodes())) { - // Sub node found - $methodName = 'start' . StringUtils::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 final function finishElement ($resource, $nodeName) { - // Make all lower-case - $nodeName = strtolower($nodeName); - - // Does this match with current main node? - //* 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()), XmlParser::EXCEPTION_XML_NODE_MISMATCH); - } // END - if - - // Construct method name - $methodName = 'finish' . StringUtils::convertToClassName($nodeName); - - // Call the corresponding method - //* DEBUG: */ echo "call: ".$methodName."
\n"; - call_user_func_array(array($this, $methodName), array()); - } - -} diff --git a/application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php b/application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php deleted file mode 100644 index 19324f43a..000000000 --- a/application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Data nodes - */ - const SELF_CONNECT_DATA_NODE_ID = 'node-id'; - const SELF_CONNECT_DATA_SESSION_ID = 'session-id'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->setSubNodes(array( - 'self-connect-data', - self::SELF_CONNECT_DATA_NODE_ID, - self::SELF_CONNECT_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 createXmlSelfConnectTemplateEngine () { - // Get a new instance - $templateInstance = new XmlSelfConnectTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', Tagable::TAG_SELF_CONNECT); - - // 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; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name - */ - parent::assignVariable($this->getStackInstance()->getNamed('node_self_connect'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getMenuCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the self_connect - * - * @return void - */ - protected function startSelfConnect () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_self_connect', 'self-connect'); - } - - /** - * Starts the self_connect data - * - * @return void - */ - protected function startSelfConnectData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_self_connect', 'self-connect-data'); - } - - /** - * Starts the node id - * - * @return void - */ - protected function startNodeId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_self_connect', self::SELF_CONNECT_DATA_NODE_ID); - } - - /** - * Starts the session id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_self_connect', self::SELF_CONNECT_DATA_SESSION_ID); - } - - /** - * Finishes the session id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_self_connect'); - } - - /** - * Finishes the node id - * - * @return void - */ - protected function finishNodeId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_self_connect'); - } - - /** - * Finishes the self_connect data - * - * @return void - */ - protected function finishSelfConnectData () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_self_connect'); - } - - /** - * Finishes the self_connect - * - * @return void - */ - protected function finishSelfConnect () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_self_connect'); - } - -} diff --git a/application/hub/classes/template/dht/class_XmlDhtBootstrapTemplateEngine.php b/application/hub/classes/template/dht/class_XmlDhtBootstrapTemplateEngine.php deleted file mode 100644 index 002841fa2..000000000 --- a/application/hub/classes/template/dht/class_XmlDhtBootstrapTemplateEngine.php +++ /dev/null @@ -1,284 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA = 'dht-bootstrap-data'; - const DHT_BOOTSTRAP_DATA_SESSION_ID = 'session-id'; - const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'node-status'; - const DHT_BOOTSTRAP_DATA_NODE_MODE = 'node-mode'; - const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'external-address'; - const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'internal-address'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->setSubNodes(array( - self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA, - 'listener', - self::DHT_BOOTSTRAP_DATA_NODE_STATUS, - self::DHT_BOOTSTRAP_DATA_NODE_MODE, - self::DHT_BOOTSTRAP_DATA_SESSION_ID, - self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, - self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS - )); - } - - /** - * 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 createXmlDhtBootstrapTemplateEngine () { - // Get a new instance - $templateInstance = new XmlDhtBootstrapTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'dht_bootstrap'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('dht_bootstrap'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getMenuCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the dht bootstrap - * - * @return void - */ - protected function startDhtBootstrap () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', 'dht-bootstrap'); - } - - /** - * Starts the dht bootstrap data - * - * @return void - */ - protected function startDhtBootstrapData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA); - } - - /** - * Starts the node status - * - * @return void - */ - protected function startNodeStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_STATUS); - } - - /** - * Starts the node-mode - * - * @return void - */ - protected function startNodeMode () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_MODE); - } - - /** - * Starts the listener - * - * @return void - */ - protected function startListener () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', 'listener'); - } - - /** - * Starts the public ip - * - * @return void - */ - protected function startExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS); - } - - /** - * Starts the private ip - * - * @return void - */ - protected function startInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS); - } - - /** - * Starts the session id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_SESSION_ID); - } - - /** - * Finishes the session id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the private ip - * - * @return void - */ - protected function finishInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the public ip - * - * @return void - */ - protected function finishExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the listener - * - * @return void - */ - protected function finishListener () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the node mode - * - * @return void - */ - protected function finishNodeMode () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the node status - * - * @return void - */ - protected function finishNodeStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the dht bootstrap data - * - * @return void - */ - protected function finishDhtBootstrapData () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the dht bootstrap - * - * @return void - */ - protected function finishDhtBootstrap () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php b/application/hub/classes/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php deleted file mode 100644 index 26e61b94b..000000000 --- a/application/hub/classes/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 XmlRequestNodeListEntryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * 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 createXmlRequestNodeListEntryTemplateEngine () { - // Get a new instance - $templateInstance = new XmlRequestNodeListEntryTemplateEngine(); - - // Init template instannce - $templateInstance->initXmlTemplateEngine('node', 'request_node_list_entry'); - - // 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; - } // END - if - - // Assign data with matching variable here - parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list_entry'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getRequestNodeListEntryCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the request-node-list-entry - * - * @return void - */ - protected function startRequestNodeListEntry () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list_entry', 'request-node-list-entry'); - } - - /** - * Finishes the request-node-list-entry - * - * @return void - */ - protected function finishRequestNodeListEntry () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list_entry'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/objects/class_XmlObjectRegistryTemplateEngine.php b/application/hub/classes/template/objects/class_XmlObjectRegistryTemplateEngine.php deleted file mode 100644 index 65ab2fef9..000000000 --- a/application/hub/classes/template/objects/class_XmlObjectRegistryTemplateEngine.php +++ /dev/null @@ -1,300 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - // Constants - const OBJECT_TYPE_DATA_NAME = 'object-name'; - const OBJECT_TYPE_DATA_RECIPIENT_LIMITATION = 'object-recipient-limitation'; - const OBJECT_TYPE_DATA_MAX_SPREAD = 'object-max-spread'; - const OBJECT_TYPE_DATA_PROTOCOL = 'object-protocol'; - const OBJECT_TYPE_DATA_RECIPIENT_TYPE = 'object-recipient-type'; - - /** - * Instance for the object registry - */ - private $objectRegistryInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init object type registry instance - $this->objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance(); - - // Init sub nodes - $this->setSubNodes(array( - 'object-list', - 'object-list-entry', - self::OBJECT_TYPE_DATA_NAME, - self::OBJECT_TYPE_DATA_RECIPIENT_LIMITATION, - self::OBJECT_TYPE_DATA_MAX_SPREAD, - self::OBJECT_TYPE_DATA_PROTOCOL, - self::OBJECT_TYPE_DATA_RECIPIENT_TYPE - )); - } - - /** - * 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 createXmlObjectRegistryTemplateEngine () { - // Get a new instance - $templateInstance = new XmlObjectRegistryTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'object_registry'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: resource[%s]=%s,characters[%s]=%s - CALLED!', gettype($resource), $resource, gettype($characters), $characters)); - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - // Get current XML node name as an array index - $nodeName = $this->getStackInstance()->getNamed('node_object_registry'); - - // Is the node name self::OBJECT_TYPE_DATA_NAME? - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: Checking nodeName=%s ...', $nodeName)); - if ($nodeName == self::OBJECT_TYPE_DATA_NAME) { - // Output debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: Adding object type ' . $characters . ' to registry.'); - } // END - if - - // Add it to the registry - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: EXIT!'); - $this->objectRegistryInstance->addEntry($nodeName, $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getObjectRegistryCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the object-registry - * - * @return void - */ - protected function startObjectRegistry () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', 'object-registry'); - } - - /** - * Starts the object-list - * - * @param $objectCount Count of all objects - * @return void - * @todo Handle $objectCount - */ - protected function startObjectList ($objectCount) { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', 'object-list'); - } - - /** - * Starts the object-list-entry - * - * @return void - */ - protected function startObjectListEntry () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', 'object-list-entry'); - } - - /** - * Starts the object-name - * - * @return void - */ - protected function startObjectName () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_NAME); - } - - /** - * Starts the object-recipient-limitation - * - * @return void - */ - protected function startObjectRecipientLimitation () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_RECIPIENT_LIMITATION); - } - - /** - * Starts the object-max-spread - * - * @return void - */ - protected function startObjectMaxSpread () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_MAX_SPREAD); - } - - /** - * Starts the object-protocol - * - * @return void - */ - protected function startObjectProtocol () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_PROTOCOL); - } - - /** - * Starts the object-recipient-type - * - * @return void - */ - protected function startObjectRecipientType () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_RECIPIENT_TYPE); - } - - /** - * Finishes the object-recipient-type - * - * @return void - */ - protected function finishObjectRecipientType () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-protocol - * - * @return void - */ - protected function finishObjectProtocol () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-max-spread - * - * @return void - */ - protected function finishObjectMaxSpread () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-recipient-limitation - * - * @return void - */ - protected function finishObjectRecipientLimitation () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-name - * - * @return void - */ - protected function finishObjectName () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-list-entry - * - * @return void - */ - protected function finishObjectListEntry () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-list - * - * @return void - */ - protected function finishObjectList () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-registry - * - * @return void - */ - protected function finishObjectRegistry () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - -} diff --git a/application/hub/classes/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php b/application/hub/classes/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php deleted file mode 100644 index 7d4f0bf6d..000000000 --- a/application/hub/classes/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php +++ /dev/null @@ -1,379 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init sub nodes - $this->setSubNodes(array( - 'meta-data', - 'global-project-identifier', - 'test-unit-created', - 'cipher', - 'cipher-function', - 'cipher-name', - 'unprocessed-data', - 'encrypted-message', - 'cruncher-key-list', - 'cruncher-key', - 'key-id', - 'key-value' - )); - } - - /** - * 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 createXmlCruncherTestUnitTemplateEngine () { - // Get a new instance - $templateInstance = new XmlCruncherTestUnitTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('cruncher', 'test_unit'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - // Assign the found characters to variable and use the last entry from - // stack as the name - parent::assignVariable($this->getStackInstance()->getNamed('cruncher_test_unit'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getCruncherTestUnitCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the test-unit - * - * @return void - */ - protected function startTestUnit () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-test-unit'); - } - - /** - * Starts the meta-data - * - * @return void - */ - protected function startMetaData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'meta-data'); - } - - /** - * Starts the global-project-identifier - * - * @return void - */ - protected function startGlobalProjectIdentifier () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'global-project-identifier'); - } - - /** - * Finishes the global-project-identifier - * - * @return void - */ - protected function finishGlobalProjectIdentifier () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Starts the test-unit-created - * - * @return void - */ - protected function startTestUnitCreated () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'test-unit-created'); - } - - /** - * Finishes the test-unit-created - * - * @return void - */ - protected function finishTestUnitCreated () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Starts the cipher - * - * @return void - */ - protected function startCipher () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher'); - } - - /** - * Starts the cipher-function - * - * @return void - */ - protected function startCipherFunction () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher-function'); - } - - /** - * Finishes the cipher-function - * - * @return void - */ - protected function finishCipherFunction () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Starts the cipher-name - * - * @return void - */ - protected function startCipherName () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher-name'); - } - - /** - * Finishes the cipher-name - * - * @return void - */ - protected function finishCipherName () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Finishes the cipher - * - * @return void - */ - protected function finishCipher () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Finishes the meta-data - * - * @return void - */ - protected function finishMetaData () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Starts the unprocessed-data - * - * @return void - */ - protected function startUnprocessedData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'unprocessed-data'); - } - - /** - * Starts the encrypted-message - * - * @return void - */ - protected function startEncryptedMessage () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'encrypted-message'); - } - - /** - * Finishes the encrypted-message - * - * @return void - */ - protected function finishEncryptedMessage () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Starts the cruncher-key-list - * - * @param $keyCount Count of keys in this test unit - * @return void - * @todo Handle $keyCount - */ - protected function startCruncherKeyList ($keyCount) { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-key-list'); - } - - /** - * Starts the cruncher-key - * - * @return void - */ - protected function startCruncherKey () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-key'); - } - - /** - * Starts the key-id - * - * @return void - */ - protected function startKeyId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'key-id'); - } - - /** - * Finishes the key-id - * - * @return void - */ - protected function finishKeyId () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Starts the key-value - * - * @return void - */ - protected function startKeyValue () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'key-value'); - } - - /** - * Finishes the key-value - * - * @return void - */ - protected function finishKeyValue () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Finishes the cruncher-key - * - * @return void - */ - protected function finishCruncherKey () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Finishes the cruncher-key-list - * - * @return void - */ - protected function finishCruncherKeyList () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Finishes the unprocessed-data - * - * @return void - */ - protected function finishUnprocessedData () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Finishes the test-unit - * - * @return void - */ - protected function finishTestUnit () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/publish/class_XmlDhtPublishEntryTemplateEngine.php b/application/hub/classes/template/publish/class_XmlDhtPublishEntryTemplateEngine.php deleted file mode 100644 index ab3a6aa55..000000000 --- a/application/hub/classes/template/publish/class_XmlDhtPublishEntryTemplateEngine.php +++ /dev/null @@ -1,368 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const PUBLISH_DATA_NODE_ID = 'node-id'; - const PUBLISH_DATA_SESSION_ID = 'session-id'; - const PUBLISH_DATA_NODE_STATUS = 'node-status'; - const PUBLISH_DATA_NODE_MODE = 'node-mode'; - const PUBLISH_DATA_EXTERNAL_ADDRESS = 'external-address'; - const PUBLISH_DATA_PRIVATE_KEY_HASH = 'private-key-hash'; - const PUBLISH_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->setSubNodes(array( - 'publish-data', - 'listener', - self::PUBLISH_DATA_NODE_STATUS, - self::PUBLISH_DATA_NODE_MODE, - self::PUBLISH_DATA_PRIVATE_KEY_HASH, - self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES, - self::PUBLISH_DATA_NODE_ID, - self::PUBLISH_DATA_SESSION_ID, - self::PUBLISH_DATA_EXTERNAL_ADDRESS, - 'object-type-list', - )); - } - - /** - * 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 createXmlDhtPublishEntryTemplateEngine () { - // Get a new instance - $templateInstance = new XmlDhtPublishEntryTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'dht_publish'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('dht_publish'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getMenuCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the publish - * - * @return void - */ - protected function startPublish () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'publish'); - } - - /** - * Starts the publish data - * - * @return void - */ - protected function startPublishData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'publish-data'); - } - - /** - * Starts the node status - * - * @return void - */ - protected function startNodeStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_STATUS); - } - - /** - * Starts the node-mode - * - * @return void - */ - protected function startNodeMode () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_MODE); - } - - /** - * Starts the listener - * - * @return void - */ - protected function startListener () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'listener'); - } - - /** - * Starts accepted object types - * - * @return void - */ - protected function startAcceptedObjectTypes () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES); - } - - /** - * Starts hash from private key - * - * @return void - */ - protected function startPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_PRIVATE_KEY_HASH); - } - - /** - * Starts the node id - * - * @return void - */ - protected function startNodeId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_ID); - } - - /** - * Starts the session id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_SESSION_ID); - } - - /** - * Starts the public ip - * - * @return void - */ - protected function startExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_EXTERNAL_ADDRESS); - } - - /** - * Starts the object type list - * - * @return void - */ - protected function startObjectTypeList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'object-type-list'); - } - - /** - * Starts the object type - * - * @return void - */ - protected function startObjectType () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'object-type'); - } - - /** - * Finishes the object type - * - * @return void - */ - protected function finishObjectType () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the object type list - * - * @return void - */ - protected function finishObjectTypeList () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the session id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the node id - * - * @return void - */ - protected function finishNodeId () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the public ip - * - * @return void - */ - protected function finishExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes hash from private key - * - * @return void - */ - protected function finishPrivateKeyHash () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes accepted object types - * - * @return void - */ - protected function finishAcceptedObjectTypes () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the listener - * - * @return void - */ - protected function finishListener () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the node mode - * - * @return void - */ - protected function finishNodeMode () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the node status - * - * @return void - */ - protected function finishNodeStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the publish data - * - * @return void - */ - protected function finishPublishData () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the publish - * - * @return void - */ - protected function finishPublish () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/requests/class_XmlRequestNodeListTemplateEngine.php b/application/hub/classes/template/requests/class_XmlRequestNodeListTemplateEngine.php deleted file mode 100644 index c1baf3a90..000000000 --- a/application/hub/classes/template/requests/class_XmlRequestNodeListTemplateEngine.php +++ /dev/null @@ -1,172 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.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 XmlRequestNodeListTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - // Constants for array elements - const REQUEST_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types'; - const REQUEST_DATA_SESSION_ID = 'session-id'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init sub nodes - $this->setSubNodes(array( - self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, - self::REQUEST_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 createXmlRequestNodeListTemplateEngine () { - // Get a new instance - $templateInstance = new XmlRequestNodeListTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'request_node_list'); - - // 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; - } // END - if - - // Assign data with matching variable here - parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getRequestNodeListCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the node-request-node-list - * - * @return void - */ - protected function startRequestNodeList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list', 'node-request-node-list'); - } - - /** - * Starts the accepted-object-types - * - * @return void - */ - protected function startAcceptedObjectTypes () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list', self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES); - } - - /** - * Starts the session-id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list', self::REQUEST_DATA_SESSION_ID); - } - - /** - * Finishes the session-id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list'); - } - - /** - * Finishes the accepted-object-types - * - * @return void - */ - protected function finishAcceptedObjectTypes () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list'); - } - - /** - * Finishes the node-request-node-list - * - * @return void - */ - protected function finishRequestNodeList () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php b/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php new file mode 100644 index 000000000..272dac68a --- /dev/null +++ b/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php @@ -0,0 +1,368 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const ANNOUNCEMENT_DATA_SESSION_ID = 'session-id'; + const ANNOUNCEMENT_DATA_NODE_ID = 'node-id'; + const ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH = 'private-key-hash'; + const ANNOUNCEMENT_DATA_NODE_STATUS = 'node-status'; + const ANNOUNCEMENT_DATA_NODE_MODE = 'node-mode'; + const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'external-address'; + const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'internal-address'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->setSubNodes(array( + 'announcement-data', + 'listener', + self::ANNOUNCEMENT_DATA_NODE_STATUS, + self::ANNOUNCEMENT_DATA_NODE_MODE, + self::ANNOUNCEMENT_DATA_NODE_ID, + self::ANNOUNCEMENT_DATA_SESSION_ID, + self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH, + self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, + self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, + 'object-type-list', + )); + } + + /** + * 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 createXmlAnnouncementTemplateEngine () { + // Get a new instance + $templateInstance = new XmlAnnouncementTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'announcement'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('node_announcement'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the announcement + * + * @return void + */ + protected function startAnnouncement () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', 'announcement'); + } + + /** + * Starts the announcement data + * + * @return void + */ + protected function startAnnouncementData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', 'announcement-data'); + } + + /** + * Starts the node status + * + * @return void + */ + protected function startNodeStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_STATUS); + } + + /** + * Starts the node-mode + * + * @return void + */ + protected function startNodeMode () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_MODE); + } + + /** + * Starts the listener + * + * @return void + */ + protected function startListener () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', 'listener'); + } + + /** + * Starts the session id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_SESSION_ID); + } + + /** + * Starts the node id + * + * @return void + */ + protected function startNodeId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_ID); + } + + /** + * Starts the private key hash + * + * @return void + */ + protected function startPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH); + } + + /** + * Starts the public ip + * + * @return void + */ + protected function startExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS); + } + + /** + * Starts the private ip + * + * @return void + */ + protected function startInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS); + } + + /** + * Starts the object type list + * + * @return void + */ + protected function startObjectTypeList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', 'object-type-list'); + } + + /** + * Starts the object type + * + * @return void + */ + protected function startObjectType () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', 'object-type'); + } + + /** + * Finishes the object type + * + * @return void + */ + protected function finishObjectType () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the object type list + * + * @return void + */ + protected function finishObjectTypeList () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the private key hash + * + * @return void + */ + protected function finishPrivateKeyHash () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the node id + * + * @return void + */ + protected function finishNodeId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the session id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the private ip + * + * @return void + */ + protected function finishInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the public ip + * + * @return void + */ + protected function finishExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the listener + * + * @return void + */ + protected function finishListener () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the node mode + * + * @return void + */ + protected function finishNodeMode () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the node status + * + * @return void + */ + protected function finishNodeStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the announcement data + * + * @return void + */ + protected function finishAnnouncementData () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the announcement + * + * @return void + */ + protected function finishAnnouncement () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php new file mode 100644 index 000000000..09eb6b1ad --- /dev/null +++ b/application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php @@ -0,0 +1,416 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const ANNOUNCEMENT_DATA_NODE_ID = 'my-node-id'; + const ANNOUNCEMENT_DATA_SESSION_ID = 'my-session-id'; + const ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH = 'my-private-key-hash'; + const ANNOUNCEMENT_DATA_NODE_STATUS = 'my-status'; + const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'my-external-address'; + const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'my-internal-address'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init sub-nodes array + $this->setSubNodes(array( + // These nodes don't contain any data + 'my-data', + 'your-data', + // Data from *this* node + self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, + self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, + self::ANNOUNCEMENT_DATA_NODE_STATUS, + self::ANNOUNCEMENT_DATA_NODE_ID, + self::ANNOUNCEMENT_DATA_SESSION_ID, + self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH, + // Data from other node + 'your-external-address', + 'your-internal-address', + 'your-node-id', + 'your-session-id', + 'your-private-key-hash', + // Answer status (generic field) + self::ANSWER_STATUS, + )); + } + + /** + * 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 createXmlAnnouncementAnswerTemplateEngine () { + // Get a new instance + $templateInstance = new XmlAnnouncementAnswerTemplateEngine(); + + // Init instance + $templateInstance->initXmlTemplateEngine('node', 'announcement_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; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('node_announcement_answer'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getAnnouncementAnswerCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the announcement-answer + * + * @return void + */ + protected function startAnnouncementAnswer () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'announcement-answer'); + } + + /** + * Starts the my-data + * + * @return void + */ + protected function startMyData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'my-data'); + } + + /** + * Starts the my-external-address + * + * @return void + */ + protected function startMyExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS); + } + + /** + * Starts the my-internal-address + * + * @return void + */ + protected function startMyInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS); + } + + /** + * Starts the my-node-id + * + * @return void + */ + protected function startMyNodeId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_ID); + } + + /** + * Starts the my-session-id + * + * @return void + */ + protected function startMySessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID); + } + + /** + * Starts the my-private-key-hash + * + * @return void + */ + protected function startMyPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH); + } + + /** + * Starts the my-status + * + * @return void + */ + protected function startMyStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS); + } + + /** + * Finishes the my-status + * + * @return void + */ + protected function finishMyStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the my-private-key-hash + * + * @return void + */ + protected function finishMyPrivateKeyhash () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the my-session-id + * + * @return void + */ + protected function finishMySessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the my-node-id + * + * @return void + */ + protected function finishMyNodeId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the my-internal-address + * + * @return void + */ + protected function finishMyInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the my-external-address + * + * @return void + */ + protected function finishMyExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the my-data + * + * @return void + */ + protected function finishMyData () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Starts the your-data + * + * @return void + */ + protected function startYourData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-data'); + } + + /** + * Starts the your-external-address + * + * @return void + */ + protected function startYourExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-external-address'); + } + + /** + * Starts the your-internal-address + * + * @return void + */ + protected function startYourInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-internal-address'); + } + + /** + * Starts the your-session-id + * + * @return void + */ + protected function startYourSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-session-id'); + } + + /** + * Starts the your-node-id + * + * @return void + */ + protected function startYourNodeId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-node-id'); + } + + /** + * Starts the your-private-key-hash + * + * @return void + */ + protected function startYourPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-private-key-hash'); + } + + /** + * Finishes the your-private-key-hash + * + * @return void + */ + protected function finishYourPrivateKeyHash () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the your-node-id + * + * @return void + */ + protected function finishYourNodeId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the your-session-id + * + * @return void + */ + protected function finishYourSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the your-internal-address + * + * @return void + */ + protected function finishYourInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the your-external-address + * + * @return void + */ + protected function finishYourExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the your-data + * + * @return void + */ + protected function finishYourData () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the announcement-answer + * + * @return void + */ + protected function finishAnnouncementAnswer () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/xml/answer/class_ b/application/hub/classes/template/xml/answer/class_ new file mode 100644 index 000000000..19ad3bb97 --- /dev/null +++ b/application/hub/classes/template/xml/answer/class_ @@ -0,0 +1,120 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub 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 Xml???AnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { + /** + * 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 createXml???TemplateEngine () { + // Get a new instance + $templateInstance = new Xml???TemplateEngine(); + + // Init template instannce + $templateInstance->initXmlTemplateEngine('PREFIX', '!!!'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + 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 data with matching variable here + parent::assignVariable($this->getStackInstance()->getNamed('!!!'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function get???CacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the ||| + * + * @return void + */ + protected function start??? () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('!!!', '|||'); + } + + /** + * Finishes the ||| + * + * @return void + */ + protected function finish??? () { + // Pop the last entry + $this->getStackInstance()->popNamed('!!!'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/xml/answer/class_BaseXmlAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/class_BaseXmlAnswerTemplateEngine.php new file mode 100644 index 000000000..4d5eea307 --- /dev/null +++ b/application/hub/classes/template/xml/answer/class_BaseXmlAnswerTemplateEngine.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 . + */ +abstract class BaseXmlAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Generic 'answer-status' field + */ + const ANSWER_STATUS = 'answer-status'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct (string $className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Starts the answer-status + * + * @return void + */ + protected function startAnswerStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed($this->getStackerName(), self::ANSWER_STATUS); + } + + /** + * Finishes the answer-status + * + * @return void + */ + protected function finishAnswerStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed($this->getStackerName()); + } + +} diff --git a/application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php new file mode 100644 index 000000000..3d15afdc1 --- /dev/null +++ b/application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php @@ -0,0 +1,395 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const DHT_BOOTSTRAP_DATA_SESSION_ID = 'my-session-id'; + const DHT_BOOTSTRAP_DATA_PRIVATE_KEY_HASH = 'my-private-key-hash'; + const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'my-status'; + const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'my-external-address'; + const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'my-internal-address'; + const DHT_BOOTSTRAP_DATA_NODE_LIST = 'dht-nodes-list'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init sub-nodes array + $this->setSubNodes(array( + // These nodes don't contain any data + 'my-data', + 'your-data', + // Data from *this* node + self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, + self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS, + self::DHT_BOOTSTRAP_DATA_NODE_STATUS, + self::DHT_BOOTSTRAP_DATA_SESSION_ID, + // Data from other node + 'your-external-address', + 'your-internal-address', + 'your-session-id', + // Answer status (generic field) + self::ANSWER_STATUS, + // DHT node list + self::DHT_BOOTSTRAP_DATA_NODE_LIST, + )); + } + + /** + * 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 createXmlDhtBootstrapAnswerTemplateEngine () { + // Get a new instance + $templateInstance = new XmlDhtBootstrapAnswerTemplateEngine(); + + // Init instance + $templateInstance->initXmlTemplateEngine('node', 'dht_bootstrap_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; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('node_dht_bootstrap_answer'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getDhtBootstrapAnswerCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the dht_bootstrap-answer + * + * @return void + */ + protected function startDhtBootstrapAnswer () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'dht_bootstrap-answer'); + } + + /** + * Starts the my-data + * + * @return void + */ + protected function startMyData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'my-data'); + } + + /** + * Starts the my-external-address + * + * @return void + */ + protected function startMyExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS); + } + + /** + * Starts the my-internal-address + * + * @return void + */ + protected function startMyInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS); + } + + /** + * Starts the my-session-id + * + * @return void + */ + protected function startMySessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_SESSION_ID); + } + + /** + * Starts the my-private-key-hash + * + * @return void + */ + protected function startMyPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_PRIVATE_KEY_HASH); + } + + /** + * Starts the my-status + * + * @return void + */ + protected function startMyStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_NODE_STATUS); + } + + /** + * Starts the dht-nodes-list + * + * @return void + */ + protected function startDhtNodesList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_NODE_LIST); + } + + /** + * Finishes the dht-nodes-list + * + * @return void + */ + protected function finishDhtNodesList () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the my-status + * + * @return void + */ + protected function finishMyStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the my-private-key-hash + * + * @return void + */ + protected function finishMyPrivateKeyHash () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the my-session-id + * + * @return void + */ + protected function finishMySessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the my-internal-address + * + * @return void + */ + protected function finishMyInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the my-external-address + * + * @return void + */ + protected function finishMyExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the my-data + * + * @return void + */ + protected function finishMyData () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Starts the your-data + * + * @return void + */ + protected function startYourData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-data'); + } + + /** + * Starts the your-external-address + * + * @return void + */ + protected function startYourExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-external-address'); + } + + /** + * Starts the your-internal-address + * + * @return void + */ + protected function startYourInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-internal-address'); + } + + /** + * Starts the your-session-id + * + * @return void + */ + protected function startYourSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-session-id'); + } + + /** + * Starts the your-private-key-hash + * + * @return void + */ + protected function startYourPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-private-key-hash'); + } + + /** + * Finishes the your-private-key-hash + * + * @return void + */ + protected function finishYourPrivateKeyHash () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the your-session-id + * + * @return void + */ + protected function finishYourSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the your-internal-address + * + * @return void + */ + protected function finishYourInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the your-external-address + * + * @return void + */ + protected function finishYourExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the your-data + * + * @return void + */ + protected function finishYourData () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the dht_bootstrap-answer + * + * @return void + */ + protected function finishDhtBootstrapAnswer () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php new file mode 100644 index 000000000..f954b517d --- /dev/null +++ b/application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php @@ -0,0 +1,183 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { + // Constants for array elements + const REQUEST_DATA_SESSION_ID = 'session-id'; + const REQUEST_DATA_NODE_LIST = 'node-list'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init sub-nodes array + $this->setSubNodes(array( + self::REQUEST_DATA_SESSION_ID, + self::REQUEST_DATA_NODE_LIST, + // Answer status (generic field) + self::ANSWER_STATUS, + )); + } + + /** + * 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'); + + // Get a template instance for list entries (as they are dynamic) + $entriesInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_entries_template_class'); + + // Set it here + $templateInstance->setTemplateInstance($entriesInstance); + + // 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; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('node_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 'request-node-list-answer' + * + * @return void + */ + protected function startRequestNodeListAnswer () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list_answer', 'request-node-list-answer'); + } + + /** + * Starts the session-id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_SESSION_ID); + } + + /** + * Starts the node-list + * + * @return void + */ + protected function startNodeList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_NODE_LIST); + } + + /** + * Finishes the node-list + * + * @return void + */ + protected function finishNodeList () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list_answer'); + } + + /** + * Finishes the session-id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list_answer'); + } + + /** + * Finishes the 'request-node-list-answer' + * + * @return void + */ + protected function finishRequestNodeListAnswer () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list_answer'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/xml/class_ b/application/hub/classes/template/xml/class_ new file mode 100644 index 000000000..707cea3ae --- /dev/null +++ b/application/hub/classes/template/xml/class_ @@ -0,0 +1,120 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub 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 Xml???TemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * 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 createXml???TemplateEngine () { + // Get a new instance + $templateInstance = new Xml???TemplateEngine(); + + // Init template instannce + $templateInstance->initXmlTemplateEngine('PREFIX', '!!!'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + 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 data with matching variable here + parent::assignVariable($this->getStackInstance()->getNamed('!!!'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function get???CacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the ||| + * + * @return void + */ + protected function start??? () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('!!!', '|||'); + } + + /** + * Finishes the ||| + * + * @return void + */ + protected function finish??? () { + // Pop the last entry + $this->getStackInstance()->popNamed('!!!'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php b/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php new file mode 100644 index 000000000..eaf2ec1b8 --- /dev/null +++ b/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php @@ -0,0 +1,196 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Data nodes + */ + const SELF_CONNECT_DATA_NODE_ID = 'node-id'; + const SELF_CONNECT_DATA_SESSION_ID = 'session-id'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->setSubNodes(array( + 'self-connect-data', + self::SELF_CONNECT_DATA_NODE_ID, + self::SELF_CONNECT_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 createXmlSelfConnectTemplateEngine () { + // Get a new instance + $templateInstance = new XmlSelfConnectTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', Tagable::TAG_SELF_CONNECT); + + // 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; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name + */ + parent::assignVariable($this->getStackInstance()->getNamed('node_self_connect'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the self_connect + * + * @return void + */ + protected function startSelfConnect () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_self_connect', 'self-connect'); + } + + /** + * Starts the self_connect data + * + * @return void + */ + protected function startSelfConnectData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_self_connect', 'self-connect-data'); + } + + /** + * Starts the node id + * + * @return void + */ + protected function startNodeId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_self_connect', self::SELF_CONNECT_DATA_NODE_ID); + } + + /** + * Starts the session id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_self_connect', self::SELF_CONNECT_DATA_SESSION_ID); + } + + /** + * Finishes the session id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_self_connect'); + } + + /** + * Finishes the node id + * + * @return void + */ + protected function finishNodeId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_self_connect'); + } + + /** + * Finishes the self_connect data + * + * @return void + */ + protected function finishSelfConnectData () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_self_connect'); + } + + /** + * Finishes the self_connect + * + * @return void + */ + protected function finishSelfConnect () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_self_connect'); + } + +} diff --git a/application/hub/classes/template/xml/dht/class_XmlDhtBootstrapTemplateEngine.php b/application/hub/classes/template/xml/dht/class_XmlDhtBootstrapTemplateEngine.php new file mode 100644 index 000000000..ea51a1f55 --- /dev/null +++ b/application/hub/classes/template/xml/dht/class_XmlDhtBootstrapTemplateEngine.php @@ -0,0 +1,284 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA = 'dht-bootstrap-data'; + const DHT_BOOTSTRAP_DATA_SESSION_ID = 'session-id'; + const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'node-status'; + const DHT_BOOTSTRAP_DATA_NODE_MODE = 'node-mode'; + const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'external-address'; + const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'internal-address'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->setSubNodes(array( + self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA, + 'listener', + self::DHT_BOOTSTRAP_DATA_NODE_STATUS, + self::DHT_BOOTSTRAP_DATA_NODE_MODE, + self::DHT_BOOTSTRAP_DATA_SESSION_ID, + self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, + self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS + )); + } + + /** + * 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 createXmlDhtBootstrapTemplateEngine () { + // Get a new instance + $templateInstance = new XmlDhtBootstrapTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'dht_bootstrap'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('dht_bootstrap'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the dht bootstrap + * + * @return void + */ + protected function startDhtBootstrap () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', 'dht-bootstrap'); + } + + /** + * Starts the dht bootstrap data + * + * @return void + */ + protected function startDhtBootstrapData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA); + } + + /** + * Starts the node status + * + * @return void + */ + protected function startNodeStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_STATUS); + } + + /** + * Starts the node-mode + * + * @return void + */ + protected function startNodeMode () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_MODE); + } + + /** + * Starts the listener + * + * @return void + */ + protected function startListener () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', 'listener'); + } + + /** + * Starts the public ip + * + * @return void + */ + protected function startExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS); + } + + /** + * Starts the private ip + * + * @return void + */ + protected function startInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS); + } + + /** + * Starts the session id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_SESSION_ID); + } + + /** + * Finishes the session id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the private ip + * + * @return void + */ + protected function finishInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the public ip + * + * @return void + */ + protected function finishExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the listener + * + * @return void + */ + protected function finishListener () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the node mode + * + * @return void + */ + protected function finishNodeMode () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the node status + * + * @return void + */ + protected function finishNodeStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the dht bootstrap data + * + * @return void + */ + protected function finishDhtBootstrapData () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the dht bootstrap + * + * @return void + */ + protected function finishDhtBootstrap () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php b/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php new file mode 100644 index 000000000..aff38500b --- /dev/null +++ b/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php @@ -0,0 +1,121 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 XmlRequestNodeListEntryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * 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 createXmlRequestNodeListEntryTemplateEngine () { + // Get a new instance + $templateInstance = new XmlRequestNodeListEntryTemplateEngine(); + + // Init template instannce + $templateInstance->initXmlTemplateEngine('node', 'request_node_list_entry'); + + // 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; + } // END - if + + // Assign data with matching variable here + parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list_entry'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getRequestNodeListEntryCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the request-node-list-entry + * + * @return void + */ + protected function startRequestNodeListEntry () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list_entry', 'request-node-list-entry'); + } + + /** + * Finishes the request-node-list-entry + * + * @return void + */ + protected function finishRequestNodeListEntry () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list_entry'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php b/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php new file mode 100644 index 000000000..5edc06dbd --- /dev/null +++ b/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php @@ -0,0 +1,300 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + // Constants + const OBJECT_TYPE_DATA_NAME = 'object-name'; + const OBJECT_TYPE_DATA_RECIPIENT_LIMITATION = 'object-recipient-limitation'; + const OBJECT_TYPE_DATA_MAX_SPREAD = 'object-max-spread'; + const OBJECT_TYPE_DATA_PROTOCOL = 'object-protocol'; + const OBJECT_TYPE_DATA_RECIPIENT_TYPE = 'object-recipient-type'; + + /** + * Instance for the object registry + */ + private $objectRegistryInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init object type registry instance + $this->objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance(); + + // Init sub nodes + $this->setSubNodes(array( + 'object-list', + 'object-list-entry', + self::OBJECT_TYPE_DATA_NAME, + self::OBJECT_TYPE_DATA_RECIPIENT_LIMITATION, + self::OBJECT_TYPE_DATA_MAX_SPREAD, + self::OBJECT_TYPE_DATA_PROTOCOL, + self::OBJECT_TYPE_DATA_RECIPIENT_TYPE + )); + } + + /** + * 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 createXmlObjectRegistryTemplateEngine () { + // Get a new instance + $templateInstance = new XmlObjectRegistryTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'object_registry'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: resource[%s]=%s,characters[%s]=%s - CALLED!', gettype($resource), $resource, gettype($characters), $characters)); + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + // Get current XML node name as an array index + $nodeName = $this->getStackInstance()->getNamed('node_object_registry'); + + // Is the node name self::OBJECT_TYPE_DATA_NAME? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: Checking nodeName=%s ...', $nodeName)); + if ($nodeName == self::OBJECT_TYPE_DATA_NAME) { + // Output debug message + /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: Adding object type ' . $characters . ' to registry.'); + } // END - if + + // Add it to the registry + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: EXIT!'); + $this->objectRegistryInstance->addEntry($nodeName, $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getObjectRegistryCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the object-registry + * + * @return void + */ + protected function startObjectRegistry () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', 'object-registry'); + } + + /** + * Starts the object-list + * + * @param $objectCount Count of all objects + * @return void + * @todo Handle $objectCount + */ + protected function startObjectList ($objectCount) { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', 'object-list'); + } + + /** + * Starts the object-list-entry + * + * @return void + */ + protected function startObjectListEntry () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', 'object-list-entry'); + } + + /** + * Starts the object-name + * + * @return void + */ + protected function startObjectName () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_NAME); + } + + /** + * Starts the object-recipient-limitation + * + * @return void + */ + protected function startObjectRecipientLimitation () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_RECIPIENT_LIMITATION); + } + + /** + * Starts the object-max-spread + * + * @return void + */ + protected function startObjectMaxSpread () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_MAX_SPREAD); + } + + /** + * Starts the object-protocol + * + * @return void + */ + protected function startObjectProtocol () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_PROTOCOL); + } + + /** + * Starts the object-recipient-type + * + * @return void + */ + protected function startObjectRecipientType () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_RECIPIENT_TYPE); + } + + /** + * Finishes the object-recipient-type + * + * @return void + */ + protected function finishObjectRecipientType () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-protocol + * + * @return void + */ + protected function finishObjectProtocol () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-max-spread + * + * @return void + */ + protected function finishObjectMaxSpread () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-recipient-limitation + * + * @return void + */ + protected function finishObjectRecipientLimitation () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-name + * + * @return void + */ + protected function finishObjectName () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-list-entry + * + * @return void + */ + protected function finishObjectListEntry () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-list + * + * @return void + */ + protected function finishObjectList () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-registry + * + * @return void + */ + protected function finishObjectRegistry () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + +} diff --git a/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php b/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php new file mode 100644 index 000000000..36b805bb2 --- /dev/null +++ b/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php @@ -0,0 +1,379 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init sub nodes + $this->setSubNodes(array( + 'meta-data', + 'global-project-identifier', + 'test-unit-created', + 'cipher', + 'cipher-function', + 'cipher-name', + 'unprocessed-data', + 'encrypted-message', + 'cruncher-key-list', + 'cruncher-key', + 'key-id', + 'key-value' + )); + } + + /** + * 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 createXmlCruncherTestUnitTemplateEngine () { + // Get a new instance + $templateInstance = new XmlCruncherTestUnitTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('cruncher', 'test_unit'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + // Assign the found characters to variable and use the last entry from + // stack as the name + parent::assignVariable($this->getStackInstance()->getNamed('cruncher_test_unit'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getCruncherTestUnitCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the test-unit + * + * @return void + */ + protected function startTestUnit () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-test-unit'); + } + + /** + * Starts the meta-data + * + * @return void + */ + protected function startMetaData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'meta-data'); + } + + /** + * Starts the global-project-identifier + * + * @return void + */ + protected function startGlobalProjectIdentifier () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'global-project-identifier'); + } + + /** + * Finishes the global-project-identifier + * + * @return void + */ + protected function finishGlobalProjectIdentifier () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Starts the test-unit-created + * + * @return void + */ + protected function startTestUnitCreated () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'test-unit-created'); + } + + /** + * Finishes the test-unit-created + * + * @return void + */ + protected function finishTestUnitCreated () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Starts the cipher + * + * @return void + */ + protected function startCipher () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher'); + } + + /** + * Starts the cipher-function + * + * @return void + */ + protected function startCipherFunction () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher-function'); + } + + /** + * Finishes the cipher-function + * + * @return void + */ + protected function finishCipherFunction () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Starts the cipher-name + * + * @return void + */ + protected function startCipherName () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher-name'); + } + + /** + * Finishes the cipher-name + * + * @return void + */ + protected function finishCipherName () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Finishes the cipher + * + * @return void + */ + protected function finishCipher () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Finishes the meta-data + * + * @return void + */ + protected function finishMetaData () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Starts the unprocessed-data + * + * @return void + */ + protected function startUnprocessedData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'unprocessed-data'); + } + + /** + * Starts the encrypted-message + * + * @return void + */ + protected function startEncryptedMessage () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'encrypted-message'); + } + + /** + * Finishes the encrypted-message + * + * @return void + */ + protected function finishEncryptedMessage () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Starts the cruncher-key-list + * + * @param $keyCount Count of keys in this test unit + * @return void + * @todo Handle $keyCount + */ + protected function startCruncherKeyList ($keyCount) { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-key-list'); + } + + /** + * Starts the cruncher-key + * + * @return void + */ + protected function startCruncherKey () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-key'); + } + + /** + * Starts the key-id + * + * @return void + */ + protected function startKeyId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'key-id'); + } + + /** + * Finishes the key-id + * + * @return void + */ + protected function finishKeyId () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Starts the key-value + * + * @return void + */ + protected function startKeyValue () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'key-value'); + } + + /** + * Finishes the key-value + * + * @return void + */ + protected function finishKeyValue () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Finishes the cruncher-key + * + * @return void + */ + protected function finishCruncherKey () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Finishes the cruncher-key-list + * + * @return void + */ + protected function finishCruncherKeyList () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Finishes the unprocessed-data + * + * @return void + */ + protected function finishUnprocessedData () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Finishes the test-unit + * + * @return void + */ + protected function finishTestUnit () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/xml/publish/class_XmlDhtPublishEntryTemplateEngine.php b/application/hub/classes/template/xml/publish/class_XmlDhtPublishEntryTemplateEngine.php new file mode 100644 index 000000000..4f818bf75 --- /dev/null +++ b/application/hub/classes/template/xml/publish/class_XmlDhtPublishEntryTemplateEngine.php @@ -0,0 +1,368 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const PUBLISH_DATA_NODE_ID = 'node-id'; + const PUBLISH_DATA_SESSION_ID = 'session-id'; + const PUBLISH_DATA_NODE_STATUS = 'node-status'; + const PUBLISH_DATA_NODE_MODE = 'node-mode'; + const PUBLISH_DATA_EXTERNAL_ADDRESS = 'external-address'; + const PUBLISH_DATA_PRIVATE_KEY_HASH = 'private-key-hash'; + const PUBLISH_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->setSubNodes(array( + 'publish-data', + 'listener', + self::PUBLISH_DATA_NODE_STATUS, + self::PUBLISH_DATA_NODE_MODE, + self::PUBLISH_DATA_PRIVATE_KEY_HASH, + self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES, + self::PUBLISH_DATA_NODE_ID, + self::PUBLISH_DATA_SESSION_ID, + self::PUBLISH_DATA_EXTERNAL_ADDRESS, + 'object-type-list', + )); + } + + /** + * 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 createXmlDhtPublishEntryTemplateEngine () { + // Get a new instance + $templateInstance = new XmlDhtPublishEntryTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'dht_publish'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('dht_publish'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the publish + * + * @return void + */ + protected function startPublish () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'publish'); + } + + /** + * Starts the publish data + * + * @return void + */ + protected function startPublishData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'publish-data'); + } + + /** + * Starts the node status + * + * @return void + */ + protected function startNodeStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_STATUS); + } + + /** + * Starts the node-mode + * + * @return void + */ + protected function startNodeMode () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_MODE); + } + + /** + * Starts the listener + * + * @return void + */ + protected function startListener () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'listener'); + } + + /** + * Starts accepted object types + * + * @return void + */ + protected function startAcceptedObjectTypes () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES); + } + + /** + * Starts hash from private key + * + * @return void + */ + protected function startPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_PRIVATE_KEY_HASH); + } + + /** + * Starts the node id + * + * @return void + */ + protected function startNodeId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_ID); + } + + /** + * Starts the session id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_SESSION_ID); + } + + /** + * Starts the public ip + * + * @return void + */ + protected function startExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_EXTERNAL_ADDRESS); + } + + /** + * Starts the object type list + * + * @return void + */ + protected function startObjectTypeList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'object-type-list'); + } + + /** + * Starts the object type + * + * @return void + */ + protected function startObjectType () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'object-type'); + } + + /** + * Finishes the object type + * + * @return void + */ + protected function finishObjectType () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the object type list + * + * @return void + */ + protected function finishObjectTypeList () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the session id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the node id + * + * @return void + */ + protected function finishNodeId () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the public ip + * + * @return void + */ + protected function finishExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes hash from private key + * + * @return void + */ + protected function finishPrivateKeyHash () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes accepted object types + * + * @return void + */ + protected function finishAcceptedObjectTypes () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the listener + * + * @return void + */ + protected function finishListener () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the node mode + * + * @return void + */ + protected function finishNodeMode () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the node status + * + * @return void + */ + protected function finishNodeStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the publish data + * + * @return void + */ + protected function finishPublishData () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the publish + * + * @return void + */ + protected function finishPublish () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php b/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php new file mode 100644 index 000000000..84f1f95aa --- /dev/null +++ b/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php @@ -0,0 +1,172 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 XmlRequestNodeListTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + // Constants for array elements + const REQUEST_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types'; + const REQUEST_DATA_SESSION_ID = 'session-id'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init sub nodes + $this->setSubNodes(array( + self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, + self::REQUEST_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 createXmlRequestNodeListTemplateEngine () { + // Get a new instance + $templateInstance = new XmlRequestNodeListTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'request_node_list'); + + // 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; + } // END - if + + // Assign data with matching variable here + parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getRequestNodeListCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the node-request-node-list + * + * @return void + */ + protected function startRequestNodeList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list', 'node-request-node-list'); + } + + /** + * Starts the accepted-object-types + * + * @return void + */ + protected function startAcceptedObjectTypes () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list', self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES); + } + + /** + * Starts the session-id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list', self::REQUEST_DATA_SESSION_ID); + } + + /** + * Finishes the session-id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list'); + } + + /** + * Finishes the accepted-object-types + * + * @return void + */ + protected function finishAcceptedObjectTypes () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list'); + } + + /** + * Finishes the node-request-node-list + * + * @return void + */ + protected function finishRequestNodeList () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list'); + } +} + +// [EOF] +?> diff --git a/core b/core index 575accd32..a535464e9 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 575accd328d27eccb2bf3caddb564b291e0780df +Subproject commit a535464e99d3baa2b50830bdf57074db2f14340a