+++ /dev/null
-<?php
-/**
- * An PublishEntry template engine class for XML templates
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 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 <http://www.gnu.org/licenses/>.
- */
-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]
-?>