]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php
Updated 'core'.
[hub.git] / application / hub / main / template / answer / announcement / class_XmlAnnouncementAnswerTemplateEngine.php
index 6c613418342cdb2542f63d2a4dafe87efe34e44c..87ed8fa545fe9274b04097ccc5b61448086431ac 100644 (file)
@@ -1,12 +1,12 @@
 <?php
 /**
- * An ??? template engine class for XML templates
+ * An AnnouncementAnswer template engine class for XML templates
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @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
  * 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 XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable {
+class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable {
        /**
         * Some XML nodes must be available for later data extraction
         */
-       const ANNOUNCEMENT_DATA_SESSION_ID    = 'my-session-id';
-       const ANNOUNCEMENT_DATA_NODE_STATUS   = 'my-status';
-       const ANNOUNCEMENT_DATA_EXTERNAL_IP   = 'my-external-ip';
-       const ANNOUNCEMENT_DATA_INTERNAL_IP   = 'my-internal-ip';
-       const ANNOUNCEMENT_DATA_TCP_PORT      = 'my-tcp-port';
-       const ANNOUNCEMENT_DATA_UDP_PORT      = 'my-udp-port';
-       const ANNOUNCEMENT_DATA_ANSWER_STATUS = 'answer-status';
+       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
@@ -44,24 +43,26 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen
                parent::__construct(__CLASS__);
 
                // Init sub-nodes array
-               $this->subNodes = array(
+               $this->setSubNodes(array(
                        // These nodes don't contain any data
                        'my-data',
                        'your-data',
                        // Data from *this* node
-                       self::ANNOUNCEMENT_DATA_EXTERNAL_IP,
-                       self::ANNOUNCEMENT_DATA_INTERNAL_IP,
-                       self::ANNOUNCEMENT_DATA_TCP_PORT,
-                       self::ANNOUNCEMENT_DATA_UDP_PORT,
+                       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-ip',
-                       'your-internal-ip',
+                       'your-external-address',
+                       'your-internal-address',
+                       'your-node-id',
                        'your-session-id',
-                       // Answer status (code)
-                       self::ANNOUNCEMENT_DATA_ANSWER_STATUS
-               );
+                       'your-private-key-hash',
+                       // Answer status (generic field)
+                       self::ANSWER_STATUS,
+               ));
        }
 
        /**
@@ -86,21 +87,6 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen
                return $templateInstance;
        }
 
-       /**
-        * Load a specified announcement-answer template into the engine
-        *
-        * @param       $template       The announcement-answer template we shall load which is
-        *                                              located in 'announcement_answer' by default
-        * @return      void
-        */
-       public function loadAnnouncementAnswerTemplate ($template = 'announcement_answer') {
-               // Set template type
-               $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_announcement_answer_template_type'));
-
-               // Load the special template
-               $this->loadTemplate($template);
-       }
-
        /**
         * Currently not used
         *
@@ -116,14 +102,14 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen
                // Is this string empty?
                if (empty($characters)) {
                        // Then skip it silently
-                       return false;
+                       return;
                } // END - if
 
                /*
                 * Assign the found characters to variable and use the last entry from
                 * stack as the name.
                 */
-               parent::assignVariable($this->getStackerInstance()->getNamed('announcement_answer'), $characters);
+               parent::assignVariable($this->getStackInstance()->getNamed('node_announcement_answer'), $characters);
        }
 
        /**
@@ -142,7 +128,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen
         */
        protected function startAnnouncementAnswer () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'announcement-answer');
+               $this->getStackInstance()->pushNamed('node_announcement_answer', 'announcement-answer');
        }
 
        /**
@@ -152,57 +138,57 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen
         */
        protected function startMyData () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'my-data');
+               $this->getStackInstance()->pushNamed('node_announcement_answer', 'my-data');
        }
 
        /**
-        * Starts the my-external-ip
+        * Starts the my-external-address
         *
         * @return      void
         */
-       protected function startMyExternalIp () {
+       protected function startMyExternalAddress () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_IP);
+               $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS);
        }
 
        /**
-        * Starts the my-internal-ip
+        * Starts the my-internal-address
         *
         * @return      void
         */
-       protected function startMyInternalIp () {
+       protected function startMyInternalAddress () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_IP);
+               $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS);
        }
 
        /**
-        * Starts the my-tcp-port
+        * Starts the my-node-id
         *
         * @return      void
         */
-       protected function startMyTcpPort () {
+       protected function startMyNodeId () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_TCP_PORT);
+               $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_ID);
        }
 
        /**
-        * Starts the my-udp-port
+        * Starts the my-session-id
         *
         * @return      void
         */
-       protected function startMyUdpPort () {
+       protected function startMySessionId () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_UDP_PORT);
+               $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID);
        }
 
        /**
-        * Starts the my-session-id
+        * Starts the my-private-key-hash
         *
         * @return      void
         */
-       protected function startMySessionId () {
+       protected function startMyPrivateKeyHash () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID);
+               $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH);
        }
 
        /**
@@ -212,7 +198,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen
         */
        protected function startMyStatus () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS);
+               $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS);
        }
 
        /**
@@ -222,57 +208,57 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen
         */
        protected function finishMyStatus () {
                // Pop the last entry
-               $this->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
-        * Finishes the my-session-id
+        * Finishes the my-private-key-hash
         *
         * @return      void
         */
-       protected function finishMySessionId () {
+       protected function finishMyPrivateKeyhash () {
                // Pop the last entry
-               $this->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
-        * Finishes the my-udp-port
+        * Finishes the my-session-id
         *
         * @return      void
         */
-       protected function finishMyUdpPort () {
+       protected function finishMySessionId () {
                // Pop the last entry
-               $this->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
-        * Finishes the my-tcp-port
+        * Finishes the my-node-id
         *
         * @return      void
         */
-       protected function finishMyTcpPort () {
+       protected function finishMyNodeId () {
                // Pop the last entry
-               $this->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
-        * Finishes the my-internal-ip
+        * Finishes the my-internal-address
         *
         * @return      void
         */
-       protected function finishMyInternalIp () {
+       protected function finishMyInternalAddress () {
                // Pop the last entry
-               $this->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
-        * Finishes the my-external-ip
+        * Finishes the my-external-address
         *
         * @return      void
         */
-       protected function finishMyExternalIp () {
+       protected function finishMyExternalAddress () {
                // Pop the last entry
-               $this->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
@@ -282,7 +268,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen
         */
        protected function finishMyData () {
                // Pop the last entry
-               $this->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
@@ -292,27 +278,27 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen
         */
        protected function startYourData () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'your-data');
+               $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-data');
        }
 
        /**
-        * Starts the your-external-ip
+        * Starts the your-external-address
         *
         * @return      void
         */
-       protected function startYourExternalIp () {
+       protected function startYourExternalAddress () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'your-external-ip');
+               $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-external-address');
        }
 
        /**
-        * Starts the your-internal-ip
+        * Starts the your-internal-address
         *
         * @return      void
         */
-       protected function startYourInternalIp () {
+       protected function startYourInternalAddress () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'your-internal-ip');
+               $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-internal-address');
        }
 
        /**
@@ -322,67 +308,87 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen
         */
        protected function startYourSessionId () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'your-session-id');
+               $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-session-id');
        }
 
        /**
-        * Finishes the your-session-id
+        * Starts the your-node-id
         *
         * @return      void
         */
-       protected function finishYourSessionId () {
+       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->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
-        * Finishes the your-internal-ip
+        * Finishes the your-node-id
         *
         * @return      void
         */
-       protected function finishYourInternalIp () {
+       protected function finishYourNodeId () {
                // Pop the last entry
-               $this->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
-        * Finishes the your-external-ip
+        * Finishes the your-session-id
         *
         * @return      void
         */
-       protected function finishYourExternalIp () {
+       protected function finishYourSessionId () {
                // Pop the last entry
-               $this->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
-        * Finishes the your-data
+        * Finishes the your-internal-address
         *
         * @return      void
         */
-       protected function finishYourData () {
+       protected function finishYourInternalAddress () {
                // Pop the last entry
-               $this->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
-        * Starts the answer-status
+        * Finishes the your-external-address
         *
         * @return      void
         */
-       protected function startAnswerStatus () {
-               // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_ANSWER_STATUS);
+       protected function finishYourExternalAddress () {
+               // Pop the last entry
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
-        * Finishes the answer-status
+        * Finishes the your-data
         *
         * @return      void
         */
-       protected function finishAnswerStatus () {
+       protected function finishYourData () {
                // Pop the last entry
-               $this->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
        /**
@@ -392,7 +398,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen
         */
        protected function finishAnnouncementAnswer () {
                // Pop the last entry
-               $this->getStackerInstance()->popNamed('announcement_answer');
+               $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 }