]> git.mxchange.org Git - hub.git/commitdiff
Added template class for entries in a request-node-list
authorRoland Häder <roland@mxchange.org>
Sun, 26 Aug 2012 19:45:38 +0000 (19:45 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 26 Aug 2012 19:45:38 +0000 (19:45 +0000)
.gitattributes
application/hub/config.php
application/hub/main/discovery/package/class_PackageRecipientDiscovery.php
application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php
application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php
application/hub/main/template/class_
application/hub/main/template/class_BaseXmlTemplateEngine.php
application/hub/main/template/entries/.htaccess [new file with mode: 0644]
application/hub/main/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php [new file with mode: 0644]
application/hub/templates/xml/entries/.htaccess [new file with mode: 0644]

index db223fb786b537f1413b812d594db028ec39f210..6c3e40acaced7d0176a3cd5a5d015109bb214ca9 100644 (file)
@@ -619,6 +619,7 @@ application/hub/main/template/answer/announcement/.htaccess -text svneol=unset#t
 application/hub/main/template/answer/requests/.htaccess -text svneol=unset#text/plain
 application/hub/main/template/connect/.htaccess -text svneol=unset#text/plain
 application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php svneol=native#text/plain
+application/hub/main/template/entries/.htaccess -text svneol=unset#text/plain
 application/hub/main/template/objects/.htaccess -text svneol=unset#text/plain
 application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php svneol=native#text/plain
 application/hub/main/template/producer/.htaccess svneol=native#text/plain
@@ -660,6 +661,7 @@ application/hub/templates/xml/cruncher/.htaccess svneol=native#text/plain
 application/hub/templates/xml/cruncher/producer/.htaccess svneol=native#text/plain
 application/hub/templates/xml/cruncher/producer/test_unit.xml svneol=native#text/plain
 application/hub/templates/xml/cruncher/producer/work_unit.xml svneol=native#text/plain
+application/hub/templates/xml/entries/.htaccess -text svneol=unset#text/plain
 application/hub/templates/xml/node/.htaccess -text svneol=unset#text/plain
 application/hub/templates/xml/node/node_status.xml svneol=native#text/plain
 application/hub/templates/xml/object_registry/.htaccess -text svneol=unset#text/plain
index a2af391d4ec4d5e7638dbad601fcc562b87abce7..0e8a403bd510ce19c8cdd4e9c5e34c1831d94994 100644 (file)
@@ -255,6 +255,9 @@ $cfg->setConfigEntry('node_request_node_list_template_class', 'XmlRequestNodeLis
 // CFG: NODE-REQUEST-NODE-LIST-ANSWER-TEMPLATE-CLASS
 $cfg->setConfigEntry('node_request_node_list_answer_template_class', 'XmlRequestNodeListAnswerTemplateEngine');
 
+// CFG: NODE-REQUEST-NODE-LIST-ENTRIES-TEMPLATE-CLASS
+$cfg->setConfigEntry('node_request_node_list_entries_template_class', 'XmlRequestNodeListEntryTemplateEngine');
+
 // CFG: NODE-MESSAGE-TEMPLATE-EXTENSION
 $cfg->setConfigEntry('node_message_template_extension', '.xml');
 
index 4deb44a3788354eb25e7a73acce6a8419c257fe0..896f5b4c6bcc50b5ab1b8ac3b5edcce440ac100f 100644 (file)
@@ -64,7 +64,7 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
                        // All upper hubs, these are currently the bootstrap nodes and later on prepended list-nodes
                        case NetworkPackage::NETWORK_TARGET_UPPER_NODES:
                                // Get all bootstrap nodes
-                               foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $node) {
+                               foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $ipPort) {
                                        // Is maximum reached?
                                        if ($this->getListInstance()->count() == $this->getConfigInstance()->getConfigEntry('package_recipient_max_count')) {
                                                // Debug message
@@ -75,10 +75,10 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
                                        } // END - if
 
                                        // Debug message
-                                       /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DISCOVERY: Adding node ' . $node . ' as recipient.');
+                                       /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DISCOVERY: Adding node ' . $ipPort . ' as recipient.');
 
                                        // Add the entry
-                                       $this->getListInstance()->addEntry('ip_port', $node);
+                                       $this->getListInstance()->addEntry('ip_port', $ipPort);
                                } // END - foreach
                                break;
 
index 7fbaa465e58943f73fc29fd5b0792f3711e16869..0e2239426e6035cd5008300e6582d4894629d14f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * An ??? template engine class for XML templates
+ * An AnnouncementAnswer template engine class for XML templates
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
index 0f3373647f712204f68afd4ee3a2aeca480f9113..f44b8091c6c69e24560ca6f03d7d09d03827757d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * An ??? template engine class for XML templates
+ * A RequestNodeListAnswer template engine class for XML templates
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -34,7 +34,6 @@ class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlTemplateEngine imple
 
                // Init sub-nodes array
                $this->subNodes = array(
-                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES,
                        XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID,
                );
        }
@@ -57,6 +56,12 @@ class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlTemplateEngine imple
                // 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;
        }
index ec23392a29e475965c6fa79527f5b343cf611dfb..da2a17cfcca8436a29fcbefefc115f0248bdb114 100644 (file)
@@ -62,7 +62,6 @@ class Xml???TemplateEngine extends BaseXmlTemplateEngine implements CompileableT
         * @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
@@ -74,10 +73,8 @@ class Xml???TemplateEngine extends BaseXmlTemplateEngine implements CompileableT
                        return false;
                } // END - if
 
-               // Get current XML node name as an array index
-               $nodeName = $this->getStackerInstance()->getNamed('!!!');
-
-               $this->partialStub('TODO: Do something with the gathered data.');
+               // Assign data with matching variable here
+               parent::assignVariable($this->getStackerInstance()->getNamed('!!!'), $characters);
        }
 
        /**
index ba1b9b8b8355e1cabf42693345350eed476a2770..d46c5a1b36988c6ffaff249a5566a8ff3fdc0cd4 100644 (file)
@@ -206,10 +206,13 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine {
         * @return      void
         */
        protected function handleTemplateDependency ($node, $templateDependency) {
+               // Check that 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 . '__' . $this->xmlTemplateType . '_template_class');
+                       $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance($this->typePrefix . '_' . $this->convertDashesToUnderscores($node) . '_' . $this->xmlTemplateType . '_template_class');
 
                        // Then load it
                        $templateInstance->loadXmlTemplate($templateDependency);
diff --git a/application/hub/main/template/entries/.htaccess b/application/hub/main/template/entries/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php b/application/hub/main/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php
new file mode 100644 (file)
index 0000000..0f88fc8
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+/**
+ * An RequestNodeListEntry template engine class for XML templates
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ * @todo               This template engine does not make use of setTemplateType()
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+die('YOU NEED TO REPLACE RequestNodeListEntry, request_node_list_entry AND request-node-list-entry IN THIS CLASS BEFORE YOU CAN USE IT.');
+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 false;
+               } // END - if
+
+               // Assign data with matching variable here
+               parent::assignVariable($this->getStackerInstance()->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->getStackerInstance()->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->getStackerInstance()->popNamed('node_request_node_list_entry');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/templates/xml/entries/.htaccess b/application/hub/templates/xml/entries/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all