application/hub/main/filter/console/.htaccess -text
application/hub/main/filter/console/class_Console -text
application/hub/main/filter/console/class_ConsoleWelcomeTeaserFilter.php -text
+application/hub/main/filter/node/.htaccess -text
+application/hub/main/filter/node/class_Node -text
+application/hub/main/filter/node/class_NodeInitializationFilter.php -text
application/hub/main/listener/.htaccess -text
application/hub/main/listener/class_ -text
application/hub/main/listener/class_BaseListener.php -text
// Get a controller instance as well
$this->controllerInstance = $resolverInstance->resolveController();
- // Handle the request
- $this->controllerInstance->handleRequest($requestInstance, $responseInstance);
- // ----------------------------- Init phase ---------------------------
-
- // The default node-mode is from our configuration
- $nodeMode = $this->getConfigInstance()->readConfig('node_mode');
- die("Until here!\n");
-
- // Prepare a ConsoleRequest class to catch all parameters
- $requestInstance = ObjectFactory::createObjectByName('ConsoleRequest');
-
- // Is the node 'mode' parameter set?
- if ($requestInstance->isRequestElementSet('mode')) {
- // Then use this which overrides the config entry temporarily
- $nodeMode = $requestInstance->getRequestElement('mode');
- } else {
- // Set it for easier re-usage
- $requestInstance->setRequestElement('mode', $nodeMode);
- }
-
- // Now convert the node-mode in a class name
- $className = 'Hub' . $this->convertToClassName($nodeMode) . 'Node';
-
- // And try to instance it
- try {
- // Get an instance
- $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
+ // Get the registry
+ $registryInstance = Registry::getRegistry();
- // Set the app instance
- $nodeInstance->setApplicationInstance($this);
+ // Set this application
+ $registryInstance->addInstance('app', $this);
- // Initialize all filters
- $nodeInstance->initializeFilters();
- } catch (ClassNotFoundException $e) {
- // This exception means, the node mode is invalid.
- // @TODO Can we rewrite this to app_die() ?
- die('Node mode ' . $nodeMode . ' is invalid.' . "\n");
- }
+ // Handle the request
+ $this->controllerInstance->handleRequest($requestInstance, $responseInstance);
+ die("STOP\n");
// ----------------------- Output teaser lines ------------------------
// Output some introducing lines to the console. This should be later
// CFG: NEWS-PROCESS-FILTER
$cfg->setConfigEntry('news_process_filter', "NewsProcessFilter");
+// CFG: NODE-INITIALIZATION-FILTER
+$cfg->setConfigEntry('node_initializer_filter', "NodeInitializationFilter");
+
// CFG: CONSOLE-WELCOME-TEASER-FILTER
$cfg->setConfigEntry('console_welcome_teaser_filter', "ConsoleWelcomeTeaserFilter");
*/
public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
// Add filters
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_initializer_filter'));
$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('console_welcome_teaser_filter'));
}
}
* @todo 0% done
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get node instance
+ $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+ // Sanity-check on it
+ if (is_null($nodeInstance)) {
+ // Throws a FilterChainException to stop further processing
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ } // END - if
+
// Implement this!
- $this->partialStub("Please implement this method.");
+ $this->partialStub('Please implement this method.');
}
}
* @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
+ * @throws FilterChainException If the nodeInstance was not set
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Implement this!
- $this->partialStub("Please implement this method.");
+ // Get node instance
+ $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+ // Sanity-check on it
+ if (is_null($nodeInstance)) {
+ // Throws a FilterChainException to stop further processing
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ } // END - if
+
+ // Now output the teaser
+ $nodeInstance->outputConsoleTeaser();
}
}
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? filter for nodes
+ *
+ * @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 Node???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 createNode???Filter () {
+ // Get a new instance
+ $filterInstance = new Node???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]
+?>
--- /dev/null
+<?php
+/**
+ * A Initialization filter for nodes
+ *
+ * @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 NodeInitializationFilter 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 createNodeInitializationFilter () {
+ // Get a new instance
+ $filterInstance = new NodeInitializationFilter();
+
+ // 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) {
+ // The default node-mode is from our configuration
+ $nodeMode = $this->getConfigInstance()->readConfig('node_mode');
+
+ // Prepare a ConsoleRequest class to catch all parameters
+ $requestInstance = ObjectFactory::createObjectByName('ConsoleRequest');
+
+ // Is the node 'mode' parameter set?
+ if ($requestInstance->isRequestElementSet('mode')) {
+ // Then use this which overrides the config entry temporarily
+ $nodeMode = $requestInstance->getRequestElement('mode');
+ } else {
+ // Set it for easier re-usage
+ $requestInstance->setRequestElement('mode', $nodeMode);
+ }
+
+ // Now convert the node-mode in a class name
+ $className = 'Hub' . $this->convertToClassName($nodeMode) . 'Node';
+
+ // And try to instance it
+ try {
+ // Get an instance
+ $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
+
+ // Get a registry
+ $appInstance = Registry::getRegistry()->getInstance('app');
+
+ // Set the app instance
+ $nodeInstance->setApplicationInstance($appInstance);
+
+ // Initialize all filters
+ $nodeInstance->initializeFilters();
+ } catch (ClassNotFoundException $e) {
+ // This exception means, the node mode is invalid.
+ // @TODO Can we rewrite this to app_die() ?
+ die('Node mode ' . $nodeMode . ' is invalid.' . "\n");
+ }
+
+ // Set the node instance in registry
+ Registry::getRegistry()->addInstance('node', $nodeInstance);
+ }
+}
+
+// [EOF]
+?>
* 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 HubBootNode extends BaseHubNode implements NodeHelper {
+class HubBootNode extends BaseHubNode implements NodeHelper, Registerable {
/**
* Protected constructor
*
* 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 Hub???Node extends BaseHubNode implements NodeHelper {
+class Hub???Node extends BaseHubNode implements NodeHelper, Registerable {
/**
* Protected constructor
*
* 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 HubListNode extends BaseHubNode implements NodeHelper {
+class HubListNode extends BaseHubNode implements NodeHelper, Registerable {
/**
* Protected constructor
*
* 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 HubMasterNode extends BaseHubNode implements NodeHelper {
+class HubMasterNode extends BaseHubNode implements NodeHelper, Registerable {
/**
* Protected constructor
*
* 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 HubRegularNode extends BaseHubNode implements NodeHelper {
+class HubRegularNode extends BaseHubNode implements NodeHelper, Registerable {
/**
* Protected constructor
*