]> git.mxchange.org Git - hub.git/commitdiff
Now protected for other filter chain classes
authorRoland Häder <roland@mxchange.org>
Sun, 19 Jul 2009 17:44:45 +0000 (17:44 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 19 Jul 2009 17:44:45 +0000 (17:44 +0000)
17 files changed:
.gitattributes
application/hub/class_ApplicationHelper.php
application/hub/config.php
application/hub/main/commands/console/class_ConsoleMainCommand.php [deleted file]
application/hub/main/commands/console/class_HubConsoleMainCommand.php [new file with mode: 0644]
application/hub/main/controller/.htaccess [new file with mode: 0644]
application/hub/main/controller/console/.htaccess [new file with mode: 0644]
application/hub/main/controller/console/class_HubConsoleDefaultNewsController.php [new file with mode: 0644]
application/hub/main/filter/bootstrap/class_ [new file with mode: 0644]
application/hub/main/filter/bootstrap/class_Bootstrap [deleted file]
application/hub/main/resolver/.htaccess [new file with mode: 0644]
application/hub/main/resolver/command/.htaccess [new file with mode: 0644]
application/hub/main/resolver/command/console/.htaccess [new file with mode: 0644]
application/hub/main/resolver/command/console/class_HubConsoleCommandResolver.php [new file with mode: 0644]
application/hub/main/resolver/controller/.htaccess [new file with mode: 0644]
application/hub/main/resolver/controller/console/.htaccess [new file with mode: 0644]
application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php [new file with mode: 0644]

index 35f40e25bf4830116209a51e81feff036d9e3859..390bf8e40aa7c14703173656308a5732a030114d 100644 (file)
@@ -38,7 +38,7 @@ application/hub/main/class_Base -text
 application/hub/main/class_BaseHubSystem.php -text
 application/hub/main/commands/.htaccess -text
 application/hub/main/commands/console/.htaccess -text
-application/hub/main/commands/console/class_ConsoleMainCommand.php -text
+application/hub/main/commands/console/class_HubConsoleMainCommand.php -text
 application/hub/main/connectors/.htaccess -text
 application/hub/main/connectors/class_BaseConnector.php -text
 application/hub/main/connectors/query/.htaccess -text
@@ -51,12 +51,15 @@ application/hub/main/connectors/queues/class_ -text
 application/hub/main/connectors/queues/class_BaseQueueConnector.php -text
 application/hub/main/connectors/queues/local/.htaccess -text
 application/hub/main/connectors/queues/local/class_LocalQueueConnector.php -text
+application/hub/main/controller/.htaccess -text
+application/hub/main/controller/console/.htaccess -text
+application/hub/main/controller/console/class_HubConsoleDefaultNewsController.php -text
 application/hub/main/database/.htaccess -text
 application/hub/main/database/wrapper/.htaccess -text
 application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php -text
 application/hub/main/filter/.htaccess -text
 application/hub/main/filter/bootstrap/.htaccess -text
-application/hub/main/filter/bootstrap/class_Bootstrap -text
+application/hub/main/filter/bootstrap/class_ -text
 application/hub/main/filter/console/.htaccess -text
 application/hub/main/filter/console/class_Console -text
 application/hub/main/filter/console/class_ConsoleWelcomeTeaserFilter.php -text
@@ -102,6 +105,13 @@ application/hub/main/queues/class_ -text
 application/hub/main/queues/class_BaseQueue.php -text
 application/hub/main/queues/client/.htaccess -text
 application/hub/main/queues/client/class_LocalClientQueue.php -text
+application/hub/main/resolver/.htaccess -text
+application/hub/main/resolver/command/.htaccess -text
+application/hub/main/resolver/command/console/.htaccess -text
+application/hub/main/resolver/command/console/class_HubConsoleCommandResolver.php -text
+application/hub/main/resolver/controller/.htaccess -text
+application/hub/main/resolver/controller/console/.htaccess -text
+application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php -text
 application/hub/main/states/.htaccess -text
 application/hub/main/states/class_ -text
 application/hub/main/states/class_BaseState.php -text
index 0d75b689ebb2ca75a7a0d45d878994b9fe24d4af..7a78ebb171f6fbfacac525ec72a36152f79af8d8 100644 (file)
@@ -178,7 +178,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
                $this->setResponseInstance($responseInstance);
 
                // Get the parameter from the request
-               $commandName = $requestInstance->getRequestElement('page');
+               $commandName = $requestInstance->getRequestElement('command');
 
                // If it is null then get default command
                if (is_null($commandName)) {
@@ -190,7 +190,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
                } // END - if
 
                // Get a resolver
-               $resolverClass = sprintf("%sControllerResolver", $this->convertToClassName($responseType));
+               $resolverClass = sprintf("Hub%sControllerResolver", $this->convertToClassName($responseType));
                $resolverInstance = ObjectFactory::createObjectByName($resolverClass, array($commandName, $this));
 
                // Get a controller instance as well
@@ -206,12 +206,6 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
                $this->controllerInstance->handleRequest($requestInstance, $responseInstance);
                die("STOP\n");
 
-               // ----------------------- Output teaser lines ------------------------
-               // Output some introducing lines to the console. This should be later
-               // be switched off if this is a productive release because it would be
-               // only visible to the logfile.
-               $nodeInstance->outputConsoleTeaser();
-
                // ----------------------- Bootstrapping phase ------------------------
                // Try to bootstrap the node and pass the request instance to it for
                // extra arguments which mostly override config entries or enable special
index 30830bb410d3e69f726f2e04373dfe964364e0b0..48027b29be9238af349d1879a8c0d8fedfd34e18 100644 (file)
@@ -25,7 +25,7 @@
 $cfg = FrameworkConfiguration::getInstance();
 
 // CFG: NODE-LISTEN-ADDR
-$cfg->setConfigEntry('node_listen_addr', "0.0.0.0");
+$cfg->setConfigEntry('node_listen_addr', '0.0.0.0');
 
 // CFG: NODE-TCP-LISTEN-PORT
 $cfg->setConfigEntry('node_tcp_listen_port', 9060);
@@ -34,73 +34,79 @@ $cfg->setConfigEntry('node_tcp_listen_port', 9060);
 $cfg->setConfigEntry('node_udp_listen_port', 9060);
 
 // CFG: NODE-MODE (can be 'regular', 'list', 'master' or 'boot', default is 'regular')
-$cfg->setConfigEntry('node_mode', "regular");
+$cfg->setConfigEntry('node_mode', 'regular');
 
 // CFG: TEMPLATE-ENGINE
-$cfg->setConfigEntry('tpl_engine', "ConsoleOutput");
+$cfg->setConfigEntry('tpl_engine', 'ConsoleOutput');
 
 // CFG: OUTPUT-CLASS
-$cfg->setConfigEntry('output_class', "DebugConsoleOutput");
+$cfg->setConfigEntry('output_class', 'DebugConsoleOutput');
 
 // CFG: DEBUG-CLASS
-$cfg->setConfigEntry('debug_class', "DebugConsoleOutput");
+$cfg->setConfigEntry('debug_class', 'DebugConsoleOutput');
 
 // CFG: NODE-INFO-DB-WRAPPER-CLASS
-$cfg->setConfigEntry('node_info_db_wrapper_class', "NodeInformationDatabaseWrapper");
+$cfg->setConfigEntry('node_info_db_wrapper_class', 'NodeInformationDatabaseWrapper');
 
 // CFG: WEB-CONTENT-TYPE
-$cfg->setConfigEntry('web_content_type', "");
+$cfg->setConfigEntry('web_content_type', '');
 
 // CFG: QUERY-CONNECTOR-CLASS
-$cfg->setConfigEntry('query_connector_class', "LocalQueryConnector");
+$cfg->setConfigEntry('query_connector_class', 'LocalQueryConnector');
 
 // CFG: QUEUE-CONNECTOR-CLASS
-$cfg->setConfigEntry('queue_connector_class', "LocalQueueConnector");
+$cfg->setConfigEntry('queue_connector_class', 'LocalQueueConnector');
 
 // CFG: LISTENER-POOL-CLAS
-$cfg->setConfigEntry('listener_pool_class', "DefaultListenerPool");
+$cfg->setConfigEntry('listener_pool_class', 'DefaultListenerPool');
 
 // CFG: TCP-LISTENER-CLASS
-$cfg->setConfigEntry('tcp_listener_class', "TcpListener");
+$cfg->setConfigEntry('tcp_listener_class', 'TcpListener');
 
 // CFG: UDP-LISTENER-CLASS
-$cfg->setConfigEntry('udp_listener_class', "UdpListener");
+$cfg->setConfigEntry('udp_listener_class', 'UdpListener');
 
 // CFG: HUB-TCP-LISTENER-CLASS
-$cfg->setConfigEntry('hub_tcp_listener_class', "HubTcpListenerDecorator");
+$cfg->setConfigEntry('hub_tcp_listener_class', 'HubTcpListenerDecorator');
 
 // CFG: HUB-UDP-LISTENER-CLASS
-$cfg->setConfigEntry('hub_udp_listener_class', "HubUdpListenerDecorator");
+$cfg->setConfigEntry('hub_udp_listener_class', 'HubUdpListenerDecorator');
 
 // CFG: CLIENT-TCP-LISTENER-CLASS
-$cfg->setConfigEntry('client_tcp_listener_class', "ClientTcpListenerDecorator");
+$cfg->setConfigEntry('client_tcp_listener_class', 'ClientTcpListenerDecorator');
 
 // CFG: CLIENT-UDP-LISTENER-CLASS
-$cfg->setConfigEntry('client_udp_listener_class', "ClientUdpListenerDecorator");
+$cfg->setConfigEntry('client_udp_listener_class', 'ClientUdpListenerDecorator');
 
 // CFG: CLIENT-POOL-CLASS
-$cfg->setConfigEntry('client_pool_class', "DefaultClientPool");
+$cfg->setConfigEntry('client_pool_class', 'DefaultClientPool');
 
 // CFG: DEFAULT-CONSOLE-COMMAND
-$cfg->setConfigEntry('default_console_command', "main");
+$cfg->setConfigEntry('default_console_command', 'main');
 
-// CFG: CONSOLE-CMD-RESOLVER-CLASS
-$cfg->setConfigEntry('console_cmd_resolver_class', "ConsoleCommandResolver");
+// CFG: DEFAULT-HUBCONSOLE-COMMAND
+$cfg->setConfigEntry('default_hubconsole_command', 'main');
+
+// CFG: HUBCONSOLE-CMD-RESOLVER-CLASS
+$cfg->setConfigEntry('hubconsole_cmd_resolver_class', 'HubConsoleCommandResolver');
 
 // CFG: NEWS-DOWNLOAD-FILTER
-$cfg->setConfigEntry('news_download_filter', "NewsDownloadFilter");
+$cfg->setConfigEntry('news_download_filter', 'NewsDownloadFilter');
 
 // CFG: NEWS-PROCESS-FILTER
-$cfg->setConfigEntry('news_process_filter', "NewsProcessFilter");
+$cfg->setConfigEntry('news_process_filter', 'NewsProcessFilter');
 
 // CFG: NODE-INITIALIZATION-FILTER
-$cfg->setConfigEntry('node_initializer_filter', "NodeInitializationFilter");
+$cfg->setConfigEntry('node_initializer_filter', 'NodeInitializationFilter');
 
 // CFG: CONSOLE-WELCOME-TEASER-FILTER
-$cfg->setConfigEntry('console_welcome_teaser_filter', "ConsoleWelcomeTeaserFilter");
+$cfg->setConfigEntry('console_welcome_teaser_filter', 'ConsoleWelcomeTeaserFilter');
+
+// CFG: HUB-BOOTSTRAP-AQUIRE-HUBID-FILTER
+$cfg->setConfigEntry('hub_bootstrap_aquire_hubid_filter', 'HubBootstrapAquireHubIdFilter');
 
 // CFG: NEWS-READER-CLASS
-$cfg->setConfigEntry('news_reader_class', "ConsoleNewsReader");
+$cfg->setConfigEntry('news_reader_class', 'ConsoleNewsReader');
 
 // CFG: NEWS-MAIN-LIMIT
 $cfg->setConfigEntry('news_main_limit', 5);
diff --git a/application/hub/main/commands/console/class_ConsoleMainCommand.php b/application/hub/main/commands/console/class_ConsoleMainCommand.php
deleted file mode 100644 (file)
index be0cbd8..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-<?php
-/**
- * A command for 'main'
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ConsoleMainCommand extends BaseCommand implements Commandable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @param       $resolverInstance       An instance of a command resolver class
-        * @return      $commandInstance        An instance a prepared command class
-        */
-       public final static function createConsoleMainCommand (CommandResolver $resolverInstance) {
-               // Get new instance
-               $commandInstance = new ConsoleMainCommand();
-
-               // Set the application instance
-               $commandInstance->setResolverInstance($resolverInstance);
-
-               // Return the prepared instance
-               return $commandInstance;
-       }
-
-       /**
-        * Executes the given command with given request and response objects
-        *
-        * @param       $requestInstance        An instance of a class with an Requestable interface
-        * @param       $responseInstance       An instance of a class with an Responseable interface
-        * @return      void
-        * @todo        0% done
-        */
-       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
-               $this->partialStub('Unfinished method.');
-       }
-
-       /**
-        * Adds extra filters to the given controller instance
-        *
-        * @param       $controllerInstance             A controller instance
-        * @param       $requestInstance                An instance of a class with an Requestable interface
-        * @return      void
-        */
-       public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
-               // Add filters
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_initializer_filter'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('console_welcome_teaser_filter'));
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/main/commands/console/class_HubConsoleMainCommand.php b/application/hub/main/commands/console/class_HubConsoleMainCommand.php
new file mode 100644 (file)
index 0000000..d89548d
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+/**
+ * A command for 'main'
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class HubConsoleMainCommand extends BaseCommand implements Commandable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $resolverInstance       An instance of a command resolver class
+        * @return      $commandInstance        An instance a prepared command class
+        */
+       public final static function createHubConsoleMainCommand (CommandResolver $resolverInstance) {
+               // Get new instance
+               $commandInstance = new HubConsoleMainCommand();
+
+               // Set the application instance
+               $commandInstance->setResolverInstance($resolverInstance);
+
+               // Return the prepared instance
+               return $commandInstance;
+       }
+
+       /**
+        * Executes the given command with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               $this->partialStub('Unfinished method.');
+       }
+
+       /**
+        * Adds extra filters to the given controller instance
+        *
+        * @param       $controllerInstance             A controller instance
+        * @param       $requestInstance                An instance of a class with an Requestable interface
+        * @return      void
+        */
+       public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+               // Add pre filters
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_initializer_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('console_welcome_teaser_filter'));
+
+               // Add bootstrap filters
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('hub_bootstrap_aquire_hubid_filter'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('hub_bootstrap_gen_sessionid_filter'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('hub_bootstrap_restore_nodelist_filter'));
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/controller/.htaccess b/application/hub/main/controller/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/controller/console/.htaccess b/application/hub/main/controller/console/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/controller/console/class_HubConsoleDefaultNewsController.php b/application/hub/main/controller/console/class_HubConsoleDefaultNewsController.php
new file mode 100644 (file)
index 0000000..8da9f39
--- /dev/null
@@ -0,0 +1,109 @@
+<?php
+/**
+ * The default controller with news for e.g. home or news page
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class HubConsoleDefaultNewsController extends BaseController implements Controller {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $resolverInstance               An instance of a command resolver class
+        * @return      $controllerInstance             A prepared instance of this class
+        */
+       public final static function createHubConsoleDefaultNewsController (CommandResolver $resolverInstance) {
+               // Create the instance
+               $controllerInstance = new HubConsoleDefaultNewsController();
+
+               // Set the command resolver
+               $controllerInstance->setResolverInstance($resolverInstance);
+
+               // Add news filters to this controller
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter'));
+
+               // Return the prepared instance
+               return $controllerInstance;
+       }
+
+       /**
+        * Handles the given request and response
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get the command instance from the resolver by sending a request instance to the resolver
+               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+               // Add more filters by the command
+               $commandInstance->addExtraFilters($this, $requestInstance);
+
+               // Run the pre filters
+               $this->executePreFilters($requestInstance, $responseInstance);
+
+               // This request was valid! :-D
+               $requestInstance->requestIsValid();
+
+               // Execute the command
+               $commandInstance->execute($requestInstance, $responseInstance);
+
+               // Run the pre filters
+               $this->executePostFilters($requestInstance, $responseInstance);
+
+               // Flush the response out
+               $responseInstance->flushBuffer();
+       }
+
+       /**
+        * Add a bootstrap filter
+        *
+        * @param       $filterInstance         A Filterable class
+        * @return      void
+        */
+       public function addBootstrapFilter (Filterable $filterInstance) {
+               $this->addFilter('bootstrap', $filterInstance);
+       }
+
+       /**
+        * Executes all bootstrap filters
+        *
+        * @param       $requestInstance        A Requestable class
+        * @param       $responseInstance       A Responseable class
+        * @return      void
+        */
+       public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) {
+               $this->executeFilters('bootstrap', $requestInstance, $responseInstance);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/bootstrap/class_ b/application/hub/main/filter/bootstrap/class_
new file mode 100644 (file)
index 0000000..58af89d
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * A ??? filter for bootstrapping
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class HubBootstrap???Filter extends BaseFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public final static function createHubBootstrap???Filter () {
+               // Get a new instance
+               $filterInstance = new HubBootstrap???Filter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Implement this!
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/bootstrap/class_Bootstrap b/application/hub/main/filter/bootstrap/class_Bootstrap
deleted file mode 100644 (file)
index 9e509f6..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-/**
- * A ??? filter for bootstrapping
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ???BootstrapFilter extends BaseFilter implements Filterable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this filter class
-        *
-        * @return      $filterInstance         An instance of this filter class
-        */
-       public final static function create???BootstrapFilter () {
-               // Get a new instance
-               $filterInstance = new ???BootstrapFilter();
-
-               // Return the instance
-               return $filterInstance;
-       }
-
-       /**
-        * Executes the filter with given request and response objects
-        *
-        * @param       $requestInstance        An instance of a class with an Requestable interface
-        * @param       $responseInstance       An instance of a class with an Responseable interface
-        * @return      void
-        * @todo        0% done
-        */
-       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
-               // Implement this!
-               $this->partialStub("Please implement this method.");
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/main/resolver/.htaccess b/application/hub/main/resolver/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/resolver/command/.htaccess b/application/hub/main/resolver/command/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/resolver/command/console/.htaccess b/application/hub/main/resolver/command/console/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/resolver/command/console/class_HubConsoleCommandResolver.php b/application/hub/main/resolver/command/console/class_HubConsoleCommandResolver.php
new file mode 100644 (file)
index 0000000..342d1f7
--- /dev/null
@@ -0,0 +1,176 @@
+<?php
+/**
+ * A command resolver for local (non-hubbed) web commands
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class HubConsoleCommandResolver extends BaseCommandResolver implements CommandResolver {
+       /**
+        * Last successfull resolved command
+        */
+       private $lastCommandInstance = null;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set prefix to "HubConsole"
+               $this->setCommandPrefix("HubConsole");
+       }
+
+       /**
+        * Creates an instance of a HubConsole command resolver with a given default command
+        *
+        * @param       $commandName                            The default command we shall execute
+        * @param       $appInstance                            An instance of a manageable application helper class
+        * @return      $resolverInstance                       The prepared command resolver instance
+        * @throws      EmptyVariableException          Thrown if default command is not set
+        * @throws      InvalidCommandException         Thrown if default command is invalid
+        */
+       public final static function createHubConsoleCommandResolver ($commandName, ManageableApplication $appInstance) {
+               // Create the new instance
+               $resolverInstance = new HubConsoleCommandResolver();
+
+               // Is the variable $commandName set and the command is valid?
+               if (empty($commandName)) {
+                       // Then thrown an exception here
+                       throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               } elseif ($resolverInstance->isCommandValid($commandName) === false) {
+                       // Invalid command found
+                       throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
+               }
+
+               // Set the application instance
+               $resolverInstance->setApplicationInstance($appInstance);
+
+               // Return the prepared instance
+               return $resolverInstance;
+       }
+
+       /**
+        * Returns an command instance for a given request class or null if
+        * it was not found
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @return      $commandInstance        An instance of the resolved command
+        * @throws      InvalidCommandException                         Thrown if $commandName is
+        *                                                                                              invalid
+        * @throws      InvalidCommandInstanceException         Thrown if $commandInstance
+        *                                                                                              is an invalid instance
+        */
+       public function resolveCommandByRequest (Requestable $requestInstance) {
+               // Init variables
+               $commandName = '';
+               $commandInstance = null;
+
+               // This goes fine so let's resolve the command
+               $commandName = $requestInstance->getRequestElement('command');
+
+               // Is the command empty? Then fall back to default command
+               if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_console_command');
+
+               // Check if command is valid
+               if ($this->isCommandValid($commandName) === false) {
+                       // This command is invalid!
+                       throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+               } // END - if
+
+               // Get the command
+               $commandInstance = $this->loadCommand($commandName);
+
+               // And validate it
+               if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
+                       // This command has an invalid instance!
+                       throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+               } // END - if
+
+               // Set last command
+               $this->lastCommandInstance = $commandInstance;
+
+               // Return the resolved command instance
+               return $commandInstance;
+       }
+
+       /**
+        * Resolves the command by its direct name and returns an instance of its class
+        *
+        * @param       $commandName            The direct command name we shall resolve
+        * @return      $commandInstance        An instance of the command class
+        * @throws      InvalidCommandException         Thrown if $commandName is invalid
+        */
+       public function resolveCommand ($commandName) {
+               // Initiate the instance variable
+               $commandInstance = null;
+
+               // Is the command empty? Then fall back to default command
+               if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_console_command');
+
+               // Check if command is valid
+               if ($this->isCommandValid($commandName) === false) {
+                       // This command is invalid!
+                       throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+               }
+
+               // Get the command
+               $commandInstance = $this->loadCommand($commandName);
+
+               // Return the instance
+               return $commandInstance;
+       }
+
+       /**
+        * "Loads" a given command and instances it if not yet cached
+        *
+        * @param       $commandName                            A command name we shall look for
+        * @return      $commandInstance                        A loaded command instance
+        * @throws      InvalidCommandException         Thrown if even the default
+        *                                                                              command class is missing (bad!)
+        */
+       private function loadCommand ($commandName) {
+               // Init command instance
+               $commandInstance = null;
+
+               // Create class name
+               $className = 'HubConsole' . $this->convertToClassName($commandName) . 'Command';
+
+               // Create command class name
+               $this->setClassName($className);
+
+               // Is this class loaded?
+               if (!class_exists($this->getClassName())) {
+                       // Class not found, so throw an exception
+                       throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+               } // END - if
+
+               // Initiate the command
+               $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this));
+
+               // Return the result
+               return $commandInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/resolver/controller/.htaccess b/application/hub/main/resolver/controller/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/resolver/controller/console/.htaccess b/application/hub/main/resolver/controller/console/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php b/application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php
new file mode 100644 (file)
index 0000000..7bb04a9
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+/**
+ * A resolver for resolving controllers locally
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class HubConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver {
+       /**
+        * Last successfull resolved controller (name)
+        */
+       private $lastControllerName = '';
+
+       /**
+        * Last successfull resolved controller (instance)
+        */
+       private $lastControllerInstance = null;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set prefix to "HubConsole"
+               $this->setControllerPrefix('HubConsole');
+       }
+
+       /**
+        * Creates an instance of a resolver class with a given command
+        *
+        * @param       $controllerName                         The controller we shall resolve
+        * @param       $appInstance                            An instance of a manageable application helper class
+        * @return      $resolverInstance                       The prepared controller resolver instance
+        * @throws      EmptyVariableException          Thrown if default command is not set
+        * @throws      InvalidControllerException      Thrown if default controller is invalid
+        */
+       public final static function createHubConsoleControllerResolver ($controllerName, ManageableApplication $appInstance) {
+               // Create the new instance
+               $resolverInstance = new HubConsoleControllerResolver();
+
+               // Is the variable $controllerName set and the command is valid?
+               if (empty($controllerName)) {
+                       // Then thrown an exception here
+                       throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               } elseif ($resolverInstance->isControllerValid($controllerName) === false) {
+                       // Invalid command found
+                       throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
+               }
+
+               // Set the application instance
+               $resolverInstance->setApplicationInstance($appInstance);
+
+               // Set command name
+               $resolverInstance->setControllerName($controllerName);
+
+               // Return the prepared instance
+               return $resolverInstance;
+       }
+
+       /**
+        * Resolves the default controller of the given command
+        *
+        * @return      $controllerInstance             A controller instance for the default
+        *                                                                      command
+        * @throws      InvalidControllerInstanceException      Thrown if $controllerInstance
+        *                                                                                              is invalid
+        */
+       public function resolveController () {
+               // Init variables
+               $controllerName = '';
+               $controllerInstance = null;
+
+               // Get the command name 
+               $controllerName = $this->getControllerName();
+
+               // Get the command
+               $controllerInstance = $this->loadController($controllerName);
+
+               // And validate it
+               if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
+                       // This command has an invalid instance!
+                       throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
+               } // END - if
+
+               // Set last controller
+               $this->lastControllerInstance = $controllerInstance;
+
+               // Return the maybe resolved instance
+               return $controllerInstance;
+       }
+}
+
+// [EOF]
+?>