--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ *
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 ???Action extends BaseCityAction implements Commandable, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this action
+ *
+ * @param $resolverInstance An instance of an action resolver
+ * @return $actionInstance An instance of this action class
+ */
+ public final static function create???Action (ActionResolver $resolverInstance) {
+ // Get a new instance
+ $actionInstance = new ???Action();
+
+ // Return the instance
+ return $actionInstance;
+ }
+
+ /**
+ * Executes the 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) {
+ // Call parent execute method
+ parent::execute($requestInstance, $responseInstance);
+
+ // Add your code here
+ $this->partialStub("You have to implement me.");
+ }
+
+ /**
+ * 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
+ * @todo Add some filters here
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Call parent addExtraFilters method
+ parent::addExtraFilters($controllerInstance, $requestInstance);
+
+ // Unfinished method
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A general action class for city
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 BaseCityAction extends BaseAction {
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+ /**
+ * Executes the 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
+ */
+ protected function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Add code here executed with every action
+ }
+
+ /**
+ * 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
+ * @todo Add some filters here
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Unfinished method
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An action for the city map page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 HtmlCityLoginCityMapAction extends BaseCityAction implements Commandable, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this action
+ *
+ * @param $resolverInstance An instance of an action resolver
+ * @return $actionInstance An instance of this action class
+ */
+ public static final function createHtmlCityLoginCityMapAction (ActionResolver $resolverInstance) {
+ // Get a new instance
+ $actionInstance = new HtmlCityLoginCityMapAction();
+
+ // Set the resolver instance
+ $actionInstance->setResolverInstance($resolverInstance);
+
+ // Return the instance
+ return $actionInstance;
+ }
+
+ /**
+ * Executes the 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 Maybe add more here?
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Call parent execute method
+ parent::execute($requestInstance, $responseInstance);
+ }
+
+ /**
+ * 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
+ * @todo Add some filters here
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Unfinished method
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An action for the government page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 HtmlCityLoginGovernmentAction extends BaseCityAction implements Commandable, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this action
+ *
+ * @param $resolverInstance An instance of an action resolver
+ * @return $actionInstance An instance of this action class
+ */
+ public static final function createHtmlCityLoginGovernmentAction (ActionResolver $resolverInstance) {
+ // Get a new instance
+ $actionInstance = new HtmlCityLoginGovernmentAction();
+
+ // Set the resolver instance
+ $actionInstance->setResolverInstance($resolverInstance);
+
+ // Return the instance
+ return $actionInstance;
+ }
+
+ /**
+ * Executes the 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 Maybe add more here?
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Call parent execute method
+ parent::execute($requestInstance, $responseInstance);
+ }
+
+ /**
+ * 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
+ * @todo Add some filters here
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Unfinished method
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An action for logout
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 HtmlCityLoginLogoutAction extends BaseCityAction implements Commandable, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this action
+ *
+ * @param $resolverInstance An instance of an action resolver
+ * @return $actionInstance An instance of this action class
+ */
+ public static final function createHtmlCityLoginLogoutAction (ActionResolver $resolverInstance) {
+ // Get a new instance
+ $actionInstance = new HtmlCityLoginLogoutAction();
+
+ // Set the resolver instance
+ $actionInstance->setResolverInstance($resolverInstance);
+
+ // Return the instance
+ return $actionInstance;
+ }
+
+ /**
+ * Executes the 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) {
+ // Call parent execute method
+ parent::execute($requestInstance, $responseInstance);
+
+ // Add your code here
+ }
+
+ /**
+ * 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) {
+ // Check for user status by default
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An action for profile (editing) page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 HtmlCityLoginProfileAction extends BaseCityAction implements Commandable, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this action
+ *
+ * @param $resolverInstance An instance of an action resolver
+ * @return $actionInstance An instance of this action class
+ */
+ public static final function createHtmlCityLoginProfileAction (ActionResolver $resolverInstance) {
+ // Get a new instance
+ $actionInstance = new HtmlCityLoginProfileAction();
+
+ // Set the resolver instance
+ $actionInstance->setResolverInstance($resolverInstance);
+
+ // Return the instance
+ return $actionInstance;
+ }
+
+ /**
+ * Executes the 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) {
+ // Call parent execute method
+ parent::execute($requestInstance, $responseInstance);
+
+ // Add your code here...
+ }
+
+ /**
+ * 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
+ * @todo Add some filters here
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Check for user status by default
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An action for status problem handling
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 HtmlCityLoginStatusProblemAction extends BaseCityAction implements Commandable, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this action
+ *
+ * @param $resolverInstance An instance of an action resolver
+ * @return $actionInstance An instance of this action class
+ */
+ public static final function createHtmlCityLoginStatusProblemAction (ActionResolver $resolverInstance) {
+ // Get a new instance
+ $actionInstance = new HtmlCityLoginStatusProblemAction();
+
+ // Set the resolver instance
+ $actionInstance->setResolverInstance($resolverInstance);
+
+ // Return the instance
+ return $actionInstance;
+ }
+
+ /**
+ * Executes the 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) {
+ // Call parent method
+ parent::execute($requestInstance, $responseInstance);
+
+ // Add your code
+ }
+
+ /**
+ * 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
+ * @todo Add some filters here
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Check for user status by default
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An action for the welcome page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 HtmlCityLoginWelcomeAction extends BaseCityAction implements Commandable, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this action
+ *
+ * @param $resolverInstance An instance of an action resolver
+ * @return $actionInstance An instance of this action class
+ */
+ public static final function createHtmlCityLoginWelcomeAction (ActionResolver $resolverInstance) {
+ // Get a new instance
+ $actionInstance = new HtmlCityLoginWelcomeAction();
+
+ // Set the resolver instance
+ $actionInstance->setResolverInstance($resolverInstance);
+
+ // Return the instance
+ return $actionInstance;
+ }
+
+ /**
+ * Executes the 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 Maybe add more here?
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Call parent execute method
+ parent::execute($requestInstance, $responseInstance);
+ }
+
+ /**
+ * 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
+ * @todo Add some filters here
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Unfinished method
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A hub-node class for the '???' mode
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 Simulation???CityDaemon extends BaseCity implements CityHelper, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this hub-node class
+ *
+ * @param $requestInstance An instance of a Requestable class
+ * @return $nodeInstance An instance of this hub-node class
+ */
+ public final static function createSimulation???CityDaemon (Requestable $requestInstance) {
+ // Get a new instance
+ $nodeInstance = new Simulation???CityDaemon();
+
+ // Set the request instance
+ $nodeInstance->setRequestInstance($requestInstance);
+
+ // Return the instance
+ return $nodeInstance;
+ }
+
+ /**
+ * Method to "bootstrap" the node. This step does also apply provided
+ * command-line arguments stored in the request instance. The regular node
+ * should communicate with the bootstrap-nodes at this point.
+ *
+ * @return void
+ * @todo Implement this method
+ */
+ public function doBootstrapping () {
+ // Call generic (parent) bootstrapping method first
+ parent::doGenericBootstrapping();
+ $this->partialStub('Please implement this method.');
+ }
+
+ /**
+ * Initializes hub-specific queues
+ *
+ * @return void
+ * @todo Implement this method
+ */
+ public function initQueues () {
+ $this->partialStub('Please implement this method.');
+ }
+
+ /**
+ * Add some node-specific filters
+ *
+ * @return void
+ */
+ public function addExtraCityFilters () {
+ // Add some filters here
+ }
+
+ /**
+ * Adds extra tasks to the given handler for this node
+ *
+ * @param $handlerInstance An instance of a HandleableTask class
+ * @return void
+ * @todo 0% done
+ */
+ public function addExtraTasks (HandleableTask $handlerInstance) {
+ $this->partialStub('Please add some tasks or empty this method.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A general City class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 BaseCityDaemon extends BaseCitySystem implements Updateable, AddableCriteria {
+ /**
+ * City types
+ */
+ const CITY_TYPE_DEFAULT = 'default';
+ const CITY_TYPE_TESTING = 'testing';
+
+ /**
+ * Whether this City is active (default: FALSE)
+ */
+ private $isActive = FALSE;
+
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+
+ // Get a wrapper instance
+ $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class');
+
+ // Set it here
+ $this->setWrapperInstance($wrapperInstance);
+
+ // Get a crypto instance
+ $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
+
+ // Set it here
+ $this->setCryptoInstance($cryptoInstance);
+
+ // Add own instance to registry
+ Registry::getRegistry()->addInstance('city', $this);
+
+ // Init state which sets the state to 'init'
+ $this->initState();
+ }
+
+ /**
+ * Initializes the City's state which sets it to 'init'
+ *
+ * @return void
+ */
+ private function initState() {
+ // Get the state factory and create the initial state.
+ CityStateFactory::createCityStateInstanceByName('init');
+ }
+
+ /**
+ * Outputs the console teaser. This should only be executed on startup or
+ * full restarts. This method generates some space around the teaser.
+ *
+ * @return void
+ */
+ public function outputConsoleTeaser () {
+ // Get the app instance (for shortening our code)
+ $app = $this->getApplicationInstance();
+
+ // Output all lines
+ self::createDebugInstance(__CLASS__)->debugOutput(' ');
+ self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - ' . $this->getRequestInstance()->getRequestElement('mode') . ' daemon starting');
+ self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2015 City Developer Team');
+ self::createDebugInstance(__CLASS__)->debugOutput(' ');
+ self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.');
+ self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain');
+ self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.');
+ self::createDebugInstance(__CLASS__)->debugOutput(' ');
+ }
+
+ /**
+ * Adds City data elements to a given dataset instance
+ *
+ * @param $criteriaInstance An instance of a storeable criteria
+ * @param $requestInstance An instance of a Requestable class
+ * @return void
+ */
+ public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) {
+ // Make sure the request instance is set as it is not optional.
+ assert($requestInstance instanceof Requestable);
+
+ // Add City number and type
+ $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID , 1);
+ $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_MODE, $requestInstance->getRequestElement('mode'));
+
+ // Add the City id
+ $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID, $this->getCityId());
+
+ // Add the session id if acquired
+ if ($this->getSessionId() != '') {
+ $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_SESSION_ID, $this->getSessionId());
+ } // END - if
+
+ // Add the private key if acquired
+ if ($this->getPrivateKey() != '') {
+ $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY, base64_encode($this->getPrivateKey()));
+ $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $this->getPrivateKeyHash());
+ } // END - if
+
+ // Add own external and internal addresses as UNLs
+ $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL, CityTools::determineOwnInternalAddress());
+ $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL, CityTools::determineOwnExternalAddress());
+ }
+
+ /**
+ * Updates a given field with new value
+ *
+ * @param $fieldName Field to update
+ * @param $fieldValue New value to store
+ * @return void
+ * @throws DatabaseUpdateSupportException If this class does not support database updates
+ * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem
+ */
+ public function updateDatabaseField ($fieldName, $fieldValue) {
+ // Unfinished
+ $this->partialStub('Unfinished!');
+ return;
+
+ // Get a critieria instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Add search criteria
+ $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+ $searchInstance->setLimit(1);
+
+ // Now get another criteria
+ $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class');
+
+ // Add criteria entry which we shall update
+ $updateInstance->addCriteria($fieldName, $fieldValue);
+
+ // Add the search criteria for searching for the right entry
+ $updateInstance->setSearchInstance($searchInstance);
+
+ // Set wrapper class name
+ $updateInstance->setWrapperConfigEntry('user_db_wrapper_class');
+
+ // Remember the update in database result
+ $this->getResultInstance()->add2UpdateQueue($updateInstance);
+ }
+
+ /**
+ * Activates the City by doing some final preparation and setting
+ * $CityIsActive to TRUE.
+ *
+ * @param $requestInstance A Requestable class
+ * @param $responseInstance A Responseable class
+ * @return void
+ */
+ public function activateCityDaemon (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get the controller here
+ $controllerInstance = Registry::getRegistry()->getInstance('controller');
+
+ // Run all filters for the City activation
+ $controllerInstance->executeActivationFilters($requestInstance, $responseInstance);
+
+ // Make sure the city's state is 'init'
+ $this->getStateInstance()->validateCityStateIsInit();
+
+ // ----------------------- Last step from here ------------------------
+ // Activate the city daemon. This is ALWAYS the last step in this method
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getStateInstance()->__toString() . ' - Activating ...');
+ $this->getStateInstance()->citySimulationIsActivated();
+ // ---------------------- Last step until here ------------------------
+ }
+
+ /**
+ * Getter for isActive attribute
+ *
+ * @return $isActive Whether the City is active
+ */
+ public final function isCityActive () {
+ return $this->isActive;
+ }
+
+ /**
+ * Enables (default) or disables isActive flag
+ *
+ * @param $isActive Whether the City is active
+ * @return void
+ */
+ public final function enableIsActive ($isActive = TRUE) {
+ $this->isActive = (bool) $isActive;
+ }
+
+ /**
+ * Updates/refreshes City data (e.g. status).
+ *
+ * @return void
+ * @todo Find more to do here
+ */
+ public function updateCityData () {
+ // Set some dummy configuration entries, e.g. city_status
+ $this->getConfigInstance()->setConfigEntry('city_status', $this->getStateInstance()->getStateName());
+ }
+
+ /**
+ * Adds all required elements from given array into data set instance
+ *
+ * @param $dataSetInstance An instance of a StoreableCriteria class
+ * @param $CityData An array with valid City data
+ * @return void
+ */
+ public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $cityData) {
+ // Add all data the array provides
+ foreach (CityInformationDatabaseWrapper::getAllElements() as $element) {
+ // Is the element there?
+ if (isset($cityData[$element])) {
+ // Add it
+ $dataSetInstance->addCriteria($element, $cityData[$element]);
+ } else {
+ // Output warning message
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY[' . __METHOD__ . ':' . __LINE__ . ']: addArrayToDataSet(): Element ' . $element . ' not found in CityData array.');
+ }
+ } // END - foreac
+ }
+
+ /**
+ * Initializes the city daemon
+ *
+ * @return void
+ * @todo 0% done
+ */
+ public function bootstrapInitCityDaemon () {
+ $this->partialStub('Please add something here.');
+ }
+
+ /**
+ * Checks whether at least one map requires expansion
+ *
+ * @return $requiresExpansion Whether a map requires expansion
+ */
+ public function isMapPendingExpansion () {
+ // Get sections manager
+ $sectionsInstance = ManagerFactory::createManagerByType('city_sections');
+
+ // Call it's method and return value
+ return $sectionsInstance->isMapPendingExpansion();
+ }
+
+ /**
+ * Expands any found map that requires expansion
+ *
+ * @return void
+ */
+ public function expandMaps () {
+ // Get sections manager
+ $sectionsInstance = ManagerFactory::createManagerByType('city_sections');
+
+ // Call it's method and return value
+ $sectionsInstance->expandMaps();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * The default city daemon
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 SimulationDefaultCityDaemon extends BaseCityDaemon implements CityHelper, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this hub-node class
+ *
+ * @param $requestInstance An instance of a Requestable class
+ * @return $nodeInstance An instance of this hub-node class
+ */
+ public static final function createSimulationDefaultCityDaemon (Requestable $requestInstance) {
+ // Get a new instance
+ $nodeInstance = new SimulationDefaultCityDaemon();
+
+ // Set the request instance
+ $nodeInstance->setRequestInstance($requestInstance);
+
+ // Return the instance
+ return $nodeInstance;
+ }
+
+ /**
+ * Method to "bootstrap" the city simulation. This step does also apply
+ * provided command-line arguments stored in the request instance.
+ *
+ * @return void
+ * @todo Implement this method
+ */
+ public function doBootstrapping () {
+ $this->partialStub();
+ }
+
+ /**
+ * Add some node-specific filters
+ *
+ * @return void
+ */
+ public function addExtraCityFilters () {
+ // Get the application instance from registry
+ $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+ // Get the controller from the application
+ $controllerInstance = $applicationInstance->getControllerInstance();
+
+ // Foo task
+ // @TODO $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('city_foo_task_filter'));
+
+ // @TODO Add some filters here
+ $this->partialStub('Add some filters here.');
+ }
+
+ /**
+ * Adds extra tasks to the given handler for this node
+ *
+ * @param $handlerInstance An instance of a HandleableTask class
+ * @return void
+ * @todo 0% done
+ */
+ public function addExtraTasks (HandleableTask $handlerInstance) {
+ $this->partialStub('Please add some tasks or empty this method.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A ???
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 ??? extends BaseFrameworkSystem implements === {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $!!!Instance An instance of a === class
+ */
+ public final static function create??? () {
+ // Get new instance
+ $!!!Instance = new ???();
+
+ // Return the prepared instance
+ return $!!!Instance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A general ??? class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 Base??? extends BaseCitySystem {
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A general city (simulation) system class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 BaseCitySystem extends BaseFrameworkSystem {
+ // Exception codes
+ const EXCEPTION_UNSUPPORTED_ERROR_HANDLER = 0x900;
+ const EXCEPTION_BASE64_ENCODING_NOT_MODULO_4 = 0x901;
+
+ // Message status codes
+ const MESSAGE_STATUS_CODE_OKAY = 'OKAY';
+
+ /**
+ * An instance of a city
+ */
+ private $cityInstance = NULL;
+
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+ /**
+ * Getter for city instance
+ *
+ * @return $cityInstance An instance of a city city
+ */
+ public final function getCityInstance () {
+ return $this->cityInstance;
+ }
+
+ /**
+ * Setter for city instance
+ *
+ * @param $cityInstance An instance of a city city
+ * @return void
+ */
+ protected final function setCityInstance (CityHelper $cityInstance) {
+ $this->cityInstance = $cityInstance;
+ }
+
+ /**
+ * "Getter" for a printable state name
+ *
+ * @return $stateName Name of the city's state in a printable format
+ */
+ public final function getPrintableState () {
+ // Default is 'null'
+ $stateName = 'null';
+
+ // Get the state instance
+ $stateInstance = $this->getStateInstance();
+
+ // Is it an instance of Stateable?
+ if ($stateInstance instanceof Stateable) {
+ // Then use that state name
+ $stateName = $stateInstance->getStateName();
+ } // END - if
+
+ // Return result
+ return $stateName;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A command for the 'daemon' routine
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityConsoleDaemonCommand 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 static final function createCityConsoleDaemonCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new CityConsoleDaemonCommand();
+
+ // 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 ~10% done?
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get a registry and the application instance from it
+ $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+ /*
+ * ----------------------- Bootstrapping phase ------------------------
+ * Try to bootstrap the city and pass the request instance to it for
+ * extra arguments which mostly override config entries or enable special
+ * features within the hub (none is ready at this development stage)
+ */
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...');
+ $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance);
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.');
+
+ // Get city instance
+ $cityInstance = CityDaemonFactory::createCityDaemonInstance();
+
+ // Add some city-specific filters, e.g. announcement
+ $cityInstance->addExtraCityFilters();
+
+ /*
+ * -------------------------- City activation --------------------------
+ * Activates the city daemon by doing some final preparation steps and
+ * setting the attribute $cityIsActive to TRUE.
+ */
+ $cityInstance->activateCityDaemon($requestInstance, $responseInstance);
+
+ // Get task handler instance
+ $handlerInstance = Registry::getRegistry()->getInstance('task_handler');
+
+ // Debug message
+ self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---');
+
+ /*
+ * ----------------------------- Main loop ----------------------------
+ * This is the main loop. Queried calls should come back here very fast
+ * so the whole application runs on nice speed. This while-loop goes
+ * until the application is no longer active or all tasks are killed.
+ */
+ while (($cityInstance->isCityActive()) && ($handlerInstance->hasTasksLeft())) {
+ // Handle all tasks here
+ $handlerInstance->handleTasks();
+ } // END - while
+
+ // Debug message
+ self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---');
+ }
+
+ /**
+ * 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
+ * @todo ~10% done
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Add pre filters
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_php_requirements_filter'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_initializer_filter'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_welcome_teaser_filter'));
+
+ // Add bootstrap filters
+ $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_bootstrap_init_daemon_filter'));
+
+ // Add city activation filters
+ $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_activation_task_handler_initializer_filter'));
+
+ // Add shutdown filters, you may want to shutdown the task handler as last one.
+ $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_shutdown_task_handler_filter'));
+
+ // This is the last generic shutdown filter
+ $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_shutdown_city_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A command for guest logins
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlCityGuestLoginCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this command and sets the resolver instance
+ *
+ * @param $resolverInstance An instance of a command resolver
+ * @return $commandInstance The created command instance
+ */
+ public static final function createCityHtmlCityGuestLoginCommand (CommandResolver $resolverInstance) {
+ // Get a new instance
+ $commandInstance = new CityHtmlCityGuestLoginCommand();
+
+ // Set the resolver instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * Executes the 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // First get a GuestLogin instance
+ $loginInstance = ObjectFactory::createObjectByConfiguredName('guest_login_class');
+
+ // First set request and response instance
+ $loginInstance->setRequestInstance($requestInstance);
+
+ // Encrypt the password
+ $loginInstance->encryptPassword('passwd');
+
+ // Do the login here
+ $loginInstance->doLogin($requestInstance, $responseInstance);
+
+ // Was the login fine? Then redirect here
+ if ($loginInstance->ifLoginWasSuccessfull()) {
+ // Try to redirect here
+ try {
+ // Redirect...
+ $responseInstance->redirectToConfiguredUrl('app_login');
+
+ // Exit here
+ exit();
+ } catch (FrameworkException $e) {
+ // Something went wrong here!
+ $responseInstance->addFatalMessage($e->getMessage());
+ }
+ } else {
+ // Attach error message to the response
+ $responseInstance->addFatalMessage('failed_user_login');
+ }
+ }
+
+ /**
+ * 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
+ * @todo Add more filters
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Add username verifier filter
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_guest_verifier_filter'));
+
+ // Add password verifier filter
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('passwd_guest_verifier_filter'));
+
+ // Add CAPTCHA verifier code
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_guest_verifier_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for the city map
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlCityMapCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this command and sets the resolver instance
+ *
+ * @param $resolverInstance An instance of a command resolver
+ * @return $commandInstance The created command instance
+ */
+ public static final function createCityHtmlCityMapCommand (CommandResolver $resolverInstance) {
+ // Get a new instance
+ $commandInstance = new CityHtmlCityMapCommand();
+
+ // Set the resolver instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * Executes the 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // First get a UserRegistration instance
+ $managerInstance = ManagerFactory::createManagerByType('city');
+
+ // First set request and response instance
+ $managerInstance->setRequestInstance($requestInstance);
+ $managerInstance->setResponseInstance($responseInstance);
+
+ // Is there already a city the user has founded?
+ if ($managerInstance->isCityAlreadyFounded()) {
+ // Found 2nd,3rd,... city
+ $managerInstance->foundNewCity();
+ } else {
+ // Found first city
+ $managerInstance->foundFirstCity();
+ }
+
+ // Redirect or login after registration
+ $managerInstance->doPostAction();
+ }
+
+ /**
+ * 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
+ * @todo Add some more pre/post filters to the controller
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Add user auth filter (we don't need an update of the user here because it will be redirected)
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter'));
+
+ // Validate user status ('confirmed' no guest)
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
+
+ // Check if city name is already used
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_name_verifier_filter'));
+
+ // Validate ...
+ //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_validator_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for registration form (POST) handling
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlCityRegisterCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this command and sets the resolver instance
+ *
+ * @param $resolverInstance An instance of a command resolver
+ * @return $commandInstance The created command instance
+ */
+ public static final function createCityHtmlCityRegisterCommand (CommandResolver $resolverInstance) {
+ // Get a new instance
+ $commandInstance = new CityHtmlCityRegisterCommand();
+
+ // Set the resolver instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * Executes the 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // First get a UserRegistration instance
+ $registerInstance = ObjectFactory::createObjectByConfiguredName('user_registration_class');
+
+ // First set request and response instance
+ $registerInstance->setRequestInstance($requestInstance);
+ $registerInstance->setResponseInstance($responseInstance);
+
+ // Encrypt the password
+ $registerInstance->encryptPassword('pass1');
+
+ // Do things before registration
+ $registerInstance->doPreRegistration();
+
+ // Register the new user
+ $registerInstance->registerNewUser();
+
+ /*
+ * Do things after registration like notifying partner pages or queueing
+ * them for notification
+ */
+ $registerInstance->doPostRegistration();
+
+ // Redirect or login after registration
+ $registerInstance->doPostAction();
+ }
+
+ /**
+ * 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
+ * @todo Add some more pre/post filters to the controller
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Validate email address (if configured: check on double email addresses)
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_validator_filter'));
+
+ // Validate username and check if it does not exist
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_validator_filter'));
+
+ // Validate if username is "guest" and not taken
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_is_guest_filter'));
+
+ // Validate if password is set
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_validator_filter'));
+
+ // Check if rules where accepted
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('rules_accepted_filter'));
+
+ // Validate CAPTCHA input
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_register_verifier_filter'));
+
+ // Validate birthday
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('birthday_register_verifier_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for user login
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlCityUserLoginCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this command and sets the resolver instance
+ *
+ * @param $resolverInstance An instance of a command resolver
+ * @return $commandInstance The created command instance
+ */
+ public static final function createCityHtmlCityUserLoginCommand (CommandResolver $resolverInstance) {
+ // Get a new instance
+ $commandInstance = new CityHtmlCityUserLoginCommand();
+
+ // Set the resolver instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * Executes the 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // First get a UserLogin instance
+ $loginInstance = ObjectFactory::createObjectByConfiguredName('user_login_class');
+
+ // First set request and response instance
+ $loginInstance->setRequestInstance($requestInstance);
+
+ // Encrypt the password
+ $loginInstance->encryptPassword('pass');
+
+ // Do the login here
+ $loginInstance->doLogin($requestInstance, $responseInstance);
+
+ // Was the login fine? Then redirect here
+ if ($loginInstance->ifLoginWasSuccessfull()) {
+ // Try to redirect here
+ try {
+ // Redirect...
+ $responseInstance->redirectToConfiguredUrl('app_login');
+
+ // Exit here
+ exit();
+ } catch (FrameworkException $e) {
+ // Something went wrong here!
+ $responseInstance->addFatalMessage($e->getMessage());
+ }
+ } else {
+ // Attach error message to the response
+ $responseInstance->addFatalMessage('failed_user_login');
+ }
+ }
+
+ /**
+ * 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
+ * @todo Add more filters
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Which login type do we have?
+ switch ($this->getConfigInstance()->getConfigEntry('login_type')) {
+ case 'username': // Login via username
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter'));
+ break;
+
+ case 'email': // Login via email
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_verifier_filter'));
+ break;
+
+ default: // Wether username or email is set
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_email_verifier_filter'));
+ break;
+ }
+
+ // Password verifier filter
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_verifier_filter'));
+
+ // Add filter for CAPTCHA
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_user_verifier_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for the confirmation link handling
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlConfirmCommand 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 static final function createCityHtmlConfirmCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new CityHtmlConfirmCommand();
+
+ // 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get the application instance
+ $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
+
+ // Prepare a template instance
+ $templateInstance = $this->prepareTemplateInstance($applicationInstance);
+
+ // Assign application data with template engine
+ $templateInstance->assignApplicationData($applicationInstance);
+
+ // Assign base URL
+ $templateInstance->assignConfigVariable('base_url');
+
+ // Load the master template
+ $masterTemplate = $applicationInstance->buildMasterTemplateName();
+
+ // Load header template
+ $templateInstance->loadCodeTemplate('header');
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('header', 'header');
+
+ // Load footer template
+ $templateInstance->loadCodeTemplate('footer');
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('footer', 'footer');
+
+ // Load the home template
+ $templateInstance->loadCodeTemplate('confirm_link');
+
+ // Assign the home template with the master template as a content ... ;)
+ $templateInstance->assignTemplateWithVariable('confirm_link', 'main_content');
+
+ // Load the master template
+ $templateInstance->loadCodeTemplate($masterTemplate);
+
+ // Set title
+ $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_confirm_link_title'));
+
+ // Get user instance
+ try {
+ $userInstance = Registry::getRegistry()->getInstance('user');
+ } catch (NullPointerException $e) {
+ // Not found user, e.g. when the user is somehow invalid
+ $responseInstance->redirectToConfiguredUrl('html_cmd_user_is_null');
+ }
+
+ // Set username
+ $templateInstance->assignVariable('username', $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USERNAME));
+
+ // Construct the menu in every command. We could do this in BaseCommand class. But this means
+ // *every* command has a navigation system and that is want we don't want.
+ $menuInstance = ObjectFactory::createObjectByConfiguredName('confirm_menu_class', array($applicationInstance));
+
+ // Render the menu
+ $menuInstance->renderMenu();
+
+ // Transfer it to the template engine instance
+ $menuInstance->transferContentToTemplateEngine($templateInstance);
+
+ /*
+ * ... and all variables. This should be merged together in a pattern
+ * to make things easier. A cache mechanism should be added between
+ * these two calls to cache compiled templates.
+ */
+ $templateInstance->compileVariables();
+
+ // Get the content back from the template engine and put it in response class
+ $templateInstance->transferToResponse($responseInstance);
+ }
+
+ /**
+ * 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) {
+ // Empty for now
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for the form processor
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlDoFormCommand 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 static final function createCityHtmlDoFormCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new CityHtmlDoFormCommand();
+
+ // 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Should never be reached...
+ $this->debugBackTrace('This should never be reached.');
+ }
+
+ /**
+ * 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) {
+ // Empty for now
+ }
+
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for the 'main' routine
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlHomeCommand 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 static final function createCityHtmlHomeCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new CityHtmlHomeCommand();
+
+ // 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // This command doesn't handle any POST requests, so only handle get request
+ if ($requestInstance->isPostRequestMethod()) {
+ // Don't handle this here
+ $response->sendRequestMethodNotAllowed();
+
+ // Bail out
+ exit();
+ } // END - if
+
+ /*
+ * This is a generic HTML request, this means that a regular page with
+ * header, menu, content and footer shall be send to the client.
+ */
+ $this->sendGenericGetResponse($requestInstance, $responseInstance);
+ }
+
+ /**
+ * 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
+ * @todo 0% done
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Add pre filters
+ //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_php_requirements_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for the login area (member/gamer area)
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlLoginAreaCommand extends BaseCommand implements Commandable {
+ /**
+ * Name of the action
+ */
+ private $actionName = '';
+
+ /**
+ * 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 static final function createCityHtmlLoginAreaCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new CityHtmlLoginAreaCommand();
+
+ // Set the application instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Load general data like user status and such
+ $commandInstance->prepareCommand();
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * Prepares some general data which shall be displayed on every page
+ *
+ * @return void
+ * @todo Add some stuff here: Some personal data, app/game related data
+ */
+ protected function prepareCommand () {
+ }
+
+ /**
+ * 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get the action instance from registry
+ $actionInstance = Registry::getRegistry()->getInstance('action');
+
+ // Do we have an action here?
+ if ($actionInstance instanceof PerformableAction) {
+ // Execute the action (shall not output anything, see below why)
+ $actionInstance->execute($requestInstance, $responseInstance);
+ } // END - if
+
+ // Get the application instance
+ $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
+
+ // Prepare a template instance
+ $templateInstance = $this->prepareTemplateInstance($applicationInstance);
+
+ // Assign base URL
+ $templateInstance->assignConfigVariable('base_url');
+
+ // Assign all the application's data with template variables
+ $templateInstance->assignApplicationData($applicationInstance);
+
+ // Load the master template
+ $masterTemplate = $applicationInstance->buildMasterTemplateName();
+
+ // Load header template
+ $templateInstance->loadCodeTemplate('header');
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('header', 'header');
+
+ // Load footer template
+ $templateInstance->loadCodeTemplate('footer');
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('footer', 'footer');
+
+ // Load the matching template
+ $templateInstance->loadCodeTemplate('action_' . $this->actionName);
+
+ // Assign the template with the master template as a content ... ;)
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('action_' . $this->actionName, 'login_content');
+
+ // Load main template
+ $templateInstance->loadCodeTemplate('login_main');
+
+ // Assign the main template with the master template as a content ... ;)
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('login_main', 'main_content');
+
+ // Load the master template
+ $templateInstance->loadCodeTemplate($masterTemplate);
+
+ // Set title
+ $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage($this->actionName . '_title'));
+
+ // Construct the menu in every command. We could do this in BaseCommand class. But this means
+ // *every* command has a navigation system and that is want we don't want.
+ $menuInstance = ObjectFactory::createObjectByConfiguredName('login_area_menu_class', array($applicationInstance));
+
+ // Render the menu
+ $menuInstance->renderMenu();
+
+ // Transfer it to the template engine instance
+ $menuInstance->transferContentToTemplateEngine($templateInstance);
+
+ /*
+ * ... and all variables. This should be merged together in a pattern
+ * to make things easier. A cache mechanism should be added between
+ * these two calls to cache compiled templates.
+ */
+ $templateInstance->compileVariables();
+
+ // Get the content back from the template engine and put it in response class
+ $templateInstance->transferToResponse($responseInstance);
+ }
+
+ /**
+ * Adds extra filters to the given controller instance. An corresponding action class must now exist!
+ *
+ * @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) {
+ // Default is no action
+ $actionInstance = NULL;
+
+ // Get registry
+ $registryInstance = Registry::getRegistry();
+
+ // Get our application instance from the registry
+ $applicationInstance = $registryInstance->getInstance('application');
+
+ // Default action is the one from configuration
+ $this->actionName = $this->convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . $this->getConfigInstance()->getConfigEntry('login_default_action');
+
+ // Get "action" from request
+ $actReq = $requestInstance->getRequestElement('action');
+
+ // Do we have a "action" parameter set?
+ if ((is_string($actReq)) && (!empty($actReq))) {
+ // Then use it with prefix
+ $this->actionName = $this->convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . $actReq;
+ } // END - if
+
+ // Get application instance
+ $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
+
+ // Get a resolver
+ $actionResolver = HtmlActionResolver::createHtmlActionResolver($this->actionName, $applicationInstance);
+
+ // Resolve the action
+ $actionInstance = $actionResolver->resolveAction();
+
+ // Add more action-specific filters
+ $actionInstance->addExtraFilters($controllerInstance, $requestInstance);
+
+ // Remember this action in registry
+ Registry::getRegistry()->addInstance('action', $actionInstance);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for the login form
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlLoginCommand extends BaseCommand implements Commandable, Registerable {
+ /**
+ * 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 static final function createCityHtmlLoginCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new CityHtmlLoginCommand();
+
+ // 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Set request instance as extra instance
+ Registry::getRegistry()->addInstance('extra', $this);
+
+ // Get the application instance
+ $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
+
+ // Prepare a template instance
+ $templateInstance = $this->prepareTemplateInstance($applicationInstance);
+
+ // Assign application data with template engine
+ $templateInstance->assignApplicationData($applicationInstance);
+
+ // Assign base URL
+ $templateInstance->assignConfigVariable('base_url');
+
+ // Load the master template
+ $masterTemplate = $applicationInstance->buildMasterTemplateName();
+
+ // Load header template
+ $templateInstance->loadCodeTemplate('header');
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('header', 'header');
+
+ // Load footer template
+ $templateInstance->loadCodeTemplate('footer');
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('footer', 'footer');
+
+ // Load the home template
+ $templateInstance->loadCodeTemplate('login_form');
+
+ // Assign the home template with the master template as a content ... ;)
+ $templateInstance->assignTemplateWithVariable('login_form', 'main_content');
+
+ // Load the master template
+ $templateInstance->loadCodeTemplate($masterTemplate);
+
+ // Set title
+ $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_login_title'));
+
+ // Construct the menu in every command. We could do this in BaseCommand class. But this means
+ // *every* command has a navigation system and that is want we don't want.
+ $menuInstance = ObjectFactory::createObjectByConfiguredName('login_menu_class', array($applicationInstance));
+
+ // Render the menu
+ $menuInstance->renderMenu();
+
+ // Transfer it to the template engine instance
+ $menuInstance->transferContentToTemplateEngine($templateInstance);
+
+ /*
+ * ... and all variables. This should be merged together in a pattern
+ * to make things easier. A cache mechanism should be added between
+ * these two calls to cache compiled templates.
+ */
+ $templateInstance->compileVariables();
+
+ // Get the content back from the template engine and put it in response class
+ $templateInstance->transferToResponse($responseInstance);
+ }
+
+ /**
+ * 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) {
+ // Empty for now
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for the login failed page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlLoginFailedCommand 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 static final function createCityHtmlLoginFailedCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new CityHtmlLoginFailedCommand();
+
+ // 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get the application instance
+ $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
+
+ // Prepare a template instance
+ $templateInstance = $this->prepareTemplateInstance($applicationInstance);
+
+ // Assign application data with template engine
+ $templateInstance->assignApplicationData($applicationInstance);
+
+ // Load the master template
+ $masterTemplate = $applicationInstance->buildMasterTemplateName();
+
+ // Load header template
+ $templateInstance->loadCodeTemplate('header');
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('header', 'header');
+
+ // Load footer template
+ $templateInstance->loadCodeTemplate('footer');
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('footer', 'footer');
+
+ // Load the login_failed template
+ $templateInstance->loadCodeTemplate('login_failed');
+
+ // Assign the login_failed template with the master template as a content ... ;)
+ $templateInstance->assignTemplateWithVariable('login_failed', 'main_content');
+
+ // Load the master template
+ $templateInstance->loadCodeTemplate($masterTemplate);
+
+ // Set title
+ $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('login_failed_title'));
+
+ // Assign base URL
+ $templateInstance->assignConfigVariable('base_url');
+
+ // Construct the menu in every command. We could do this in BaseCommand class. But this means
+ // *every* command has a navigation system and that is want we don't want.
+ $menuInstance = ObjectFactory::createObjectByConfiguredName('login_failed_menu_class', array($applicationInstance));
+
+ // Render the menu
+ $menuInstance->renderMenu();
+
+ // Transfer it to the template engine instance
+ $menuInstance->transferContentToTemplateEngine($templateInstance);
+
+ /*
+ * ... and all variables. This should be merged together in a pattern
+ * to make things easier. A cache mechanism should be added between
+ * these two calls to cache compiled templates.
+ */
+ $templateInstance->compileVariables();
+
+ // Get the content back from the template engine and put it in response class
+ $templateInstance->transferToResponse($responseInstance);
+ }
+
+ /**
+ * 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) {
+ // Empty for now
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for logout
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlLogoutCommand 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 static final function createCityHtmlLogoutCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new CityHtmlLogoutCommand();
+
+ // 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get an auth instance for checking and updating the auth cookies
+ $authInstance = ObjectFactory::createObjectByConfiguredName('auth_method_class', array($responseInstance));
+
+ // Set request instance
+ $authInstance->setRequestInstance($requestInstance);
+
+ // Destroy the auth data
+ $authInstance->destroyAuthData();
+
+ // Redirect to "logout done" page
+ $responseInstance->redirectToConfiguredUrl('logout_done');
+
+ // Exit here
+ exit();
+ }
+
+ /**
+ * 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) {
+ // Empty for now
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for registration handling
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlRegisterCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this command and sets the resolver instance
+ *
+ * @param $resolverInstance An instance of a command resolver
+ * @return $commandInstance The created command instance
+ */
+ public static final function createCityHtmlRegisterCommand (CommandResolver $resolverInstance) {
+ // Get a new instance
+ $commandInstance = new CityHtmlRegisterCommand();
+
+ // Set the resolver instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * Executes the 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ /*
+ * This is a generic HTML request, this means that a regular page with
+ * header, menu, content and footer shall be send to the client.
+ */
+ $this->sendGenericGetResponse($requestInstance, $responseInstance, '_form');
+ }
+
+ /**
+ * 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
+ * @todo Add some more pre/post filters to the controller
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command class for resending the confirmation link
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlResendLinkCommand 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 static final function createCityHtmlResendLinkCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new CityHtmlResendLinkCommand();
+
+ // 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get user instance from registry
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Get an application instance
+ $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
+
+ // Get a RNG instance (Random Number Generator)
+ $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
+
+ // Generate a pseudo-random string
+ $randomString = $rngInstance->randomString(255);
+
+ // Get a crypto instance
+ $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
+
+ // Hash and encrypt the string
+ $hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString));
+
+ // Update the user class
+ $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, $hashedString);
+
+ // Re-set config entry to mailer engine
+ $this->getConfigInstance()->setConfigEntry('html_template_class', $this->getConfigInstance()->getConfigEntry('mail_template_class'));
+
+ // Prepare the template engine
+ $templateInstance = $this->prepareTemplateInstance($applicationInstance);
+
+ // Assign the application data with the template engine
+ $templateInstance->assignApplicationData($applicationInstance);
+
+ // Get a mailer class
+ $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance, $applicationInstance, 'resend_link'));
+
+ // Set this mailer in our template engine
+ $templateInstance->setMailerInstance($mailerInstance);
+
+ // Add template variables we shall get
+ $mailerInstance->addConfigTemplateVariable('base_url');
+ $mailerInstance->addConfigTemplateVariable('admin_email');
+ $mailerInstance->addValueTemplateVariable('confirm_hash');
+ $mailerInstance->addValueTemplateVariable('username');
+ $mailerInstance->addValueTemplateVariable('email');
+
+ // Add the value instance for the confirmation hash
+ $mailerInstance->addValueInstance('confirm_hash', $userInstance);
+ $mailerInstance->addValueInstance('username', $userInstance);
+ $mailerInstance->addValueInstance('email', $userInstance);
+
+ // Add the recipient
+ $mailerInstance->addRecipientByUserInstance($userInstance);
+
+ // Use subject line from template
+ $mailerInstance->useSubjectFromTemplate();
+
+ // Send the email out
+ $mailerInstance->deliverEmail($responseInstance);
+
+ // Send out notification to admin (depends on settings)
+ $mailerInstance->sendAdminNotification($responseInstance);
+ }
+
+ /**
+ * 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) {
+ // Filter for checking if account is unconfirmed
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for the login failed page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 HtmlLogoutDoneCommand 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 static final function createHtmlLogoutDoneCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new HtmlLogoutDoneCommand();
+
+ // 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get the application instance
+ $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
+
+ // Prepare a template instance
+ $templateInstance = $this->prepareTemplateInstance($applicationInstance);
+
+ // Assign application data
+ $templateInstance->assignApplicationData($applicationInstance);
+
+ // Load the master template
+ $masterTemplate = $applicationInstance->buildMasterTemplateName();
+
+ // Load header template
+ $templateInstance->loadCodeTemplate('header');
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('header', 'header');
+
+ // Load footer template
+ $templateInstance->loadCodeTemplate('footer');
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('footer', 'footer');
+
+ // Load the logout_done template
+ $templateInstance->loadCodeTemplate('logout_done');
+
+ // Assign the logout_done template with the master template as a content ... ;)
+ $templateInstance->assignTemplateWithVariable('logout_done', 'main_content');
+
+ // Load the master template
+ $templateInstance->loadCodeTemplate($masterTemplate);
+
+ // Set title
+ $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('logout_done_title'));
+
+ // Assign base URL
+ $templateInstance->assignConfigVariable('base_url');
+
+ // Construct the menu in every command. We could do this in BaseCommand class. But this means
+ // *every* command has a navigation system and that is want we don't want.
+ $menuInstance = ObjectFactory::createObjectByConfiguredName('logout_menu_class', array($applicationInstance));
+
+ // Render the menu
+ $menuInstance->renderMenu();
+
+ // Transfer it to the template engine instance
+ $menuInstance->transferContentToTemplateEngine($templateInstance);
+
+ /*
+ * ... and all variables. This should be merged together in a pattern
+ * to make things easier. A cache mechanism should be added between
+ * these two calls to cache compiled templates.
+ */
+ $templateInstance->compileVariables();
+
+ // Get the content back from the template engine and put it in response class
+ $templateInstance->transferToResponse($responseInstance);
+ }
+
+ /**
+ * 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) {
+ // Empty for now
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * The default controller with news for e.g. home or news page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityConsoleDefaultNewsController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (array('bootstrap', 'activation','shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ */
+ public static final function createCityConsoleDefaultNewsController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new CityConsoleDefaultNewsController();
+
+ // 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);
+ }
+
+ /**
+ * Add a city activation filter
+ *
+ * @param $filterInstance A Filterable class
+ * @return void
+ */
+ public function addActivationFilter (Filterable $filterInstance) {
+ $this->addFilter('activation', $filterInstance);
+ }
+
+ /**
+ * Executes all city activation filters
+ *
+ * @param $requestInstance A Requestable class
+ * @param $responseInstance A Responseable class
+ * @return void
+ */
+ public function executeActivationFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->executeFilters('activation', $requestInstance, $responseInstance);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * Controller for confirmation link
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlConfirmController 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
+ * @todo Add some filters to this controller
+ */
+ public static final function createCityHtmlConfirmController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new CityHtmlConfirmController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // Add filters for handling confirmation code and username
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('confirm_code_verifier_filter'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_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) {
+ // Generic pre-post command execution
+ $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * The default controller with news for e.g. home or news page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlDefaultNewsController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (array('shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ */
+ public static final function createCityHtmlDefaultNewsController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new CityHtmlDefaultNewsController();
+
+ // 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) {
+ // Generic pre-post command execution
+ $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * Controller for login form with password reminder and maybe enabled
+ * "guest-login" button
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlLoginController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (array('shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ * @todo Add some filters to this controller
+ */
+ public static final function createCityHtmlLoginController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new CityHtmlLoginController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // 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) {
+ // Generic pre-post command execution
+ $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A controller for login failed page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlLoginFailedController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (array('shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ */
+ public static final function createCityHtmlLoginFailedController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new CityHtmlLoginFailedController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // 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
+ $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+ // This request was valid! :-D
+ $requestInstance->requestIsValid();
+
+ // Execute the command
+ $commandInstance->execute($requestInstance, $responseInstance);
+
+ // Flush the response out
+ $responseInstance->flushBuffer();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * The default controller for logout page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ * @todo This controller shall still provide some headlines for sidebars
+ *
+ * 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 CityHtmlLogoutController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (array('shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ */
+ public static final function createCityHtmlLogoutController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new CityHtmlLogoutController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // Add user auth filter (we don't need an update of the user here because it will be redirected)
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter'));
+
+ // User status filter
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_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
+ $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+ // This request was valid! :-D
+ $requestInstance->requestIsValid();
+
+ // Execute the command
+ $commandInstance->execute($requestInstance, $responseInstance);
+
+ // Flush the response out
+ $responseInstance->flushBuffer();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * Controller for logout done page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlLogoutDoneController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (array('shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ * @todo Add some filters to this controller
+ */
+ public static final function createCityHtmlLogoutDoneController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new CityHtmlLogoutDoneController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // 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) {
+ // Generic pre-post command execution
+ $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * Controller for register form
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlRegisterController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (array('shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ * @todo Add some filters to this controller
+ */
+ public static final function createCityHtmlRegisterController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new CityHtmlRegisterController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // 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) {
+ // Generic pre-post command execution
+ $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A controller for handling sent forms
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlDoFormController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (array('shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a resolver class
+ * @return $controllerInstance A prepared instance of this class
+ */
+ public static final function createCityHtmlDoFormController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new CityHtmlDoFormController();
+
+ // Set resolver instance
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // We need the controller instance in resolver class so set it here
+ $resolverInstance->setControllerInstance($controllerInstance);
+
+ // 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 "form action"
+ $formAction = $requestInstance->getRequestElement('form');
+
+ // Get command instance from resolver
+ $commandInstance = $this->getResolverInstance()->resolveCommand($formAction);
+
+ // Add more filters by the command
+ $commandInstance->addExtraFilters($this, $requestInstance);
+
+ // Try to run the pre filters, if auth exceptions come through redirect here
+ try {
+ // Run the pre filters
+ $this->executePreFilters($requestInstance, $responseInstance);
+ } catch (UserAuthorizationException $e) {
+ // Redirect to main page
+ $responseInstance->redirectToConfiguredUrl('login_failed');
+
+ // Exit here
+ exit();
+ }
+
+ /*
+ * Is the request still valid? Post filters shall only be executed of
+ * the request is valid
+ */
+ if ($requestInstance->isRequestValid()) {
+ // Execute the command
+ $commandInstance->execute($requestInstance, $responseInstance);
+
+ // Execute *very* generic ppost filters
+ $this->executePostFilters($requestInstance, $responseInstance);
+ } // END - if
+
+ // Flush the buffer out
+ $responseInstance->flushBuffer();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * Controller for login area with news
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlLoginAreaController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (array('shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ * @todo Add some morer filters to this controller
+ */
+ public static final function createCityHtmlLoginAreaController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new CityHtmlLoginAreaController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // User auth filter
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter'));
+
+ // User update filter
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_filter'));
+
+ // News fetcher filter
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter'));
+
+ // News proccess/display-preparation
+ $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) {
+ /*
+ * Generic execute of the command: pre and post filters with redirect
+ * but request becomes valid after pre-filters run.
+ */
+ $this->genericHanleRequestLoginAreaFailedRedirect($requestInstance, $responseInstance);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A database wrapper for city informations
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityInformationDatabaseWrapper extends BaseDatabaseWrapper implements CityInformationWrapper, Registerable {
+ // Constants for database table names
+ const DB_TABLE_CITY_INFORMATION = 'city_data';
+
+ // Constants for database column names
+ const DB_COLUMN_CITY_ID = 'city_id';
+ const DB_COLUMN_CITY_MODE = 'city_mode';
+ const DB_COLUMN_CITY_NAME = 'city_name';
+ const DB_COLUMN_CITY_USER_ID = 'city_user_id';
+ const DB_COLUMN_CITY_REGION_ID = 'city_region_id';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this database wrapper by a provided user class
+ *
+ * @return $wrapperInstance An instance of the created wrapper class
+ */
+ public static final function createCityInformationDatabaseWrapper () {
+ // Get a new instance
+ $wrapperInstance = new CityInformationDatabaseWrapper();
+
+ // Set (primary!) table name
+ $wrapperInstance->setTableName(self::DB_TABLE_CITY_INFORMATION);
+
+ // Return the instance
+ return $wrapperInstance;
+ }
+
+ /**
+ * Checks whether there is an entry for given city instance
+ *
+ * @param $cityInstance An instance of a CityHelper class
+ * @return $isFound Whether a city id has been found for this city
+ */
+ public function ifCityDataIsFound (CityHelper $cityInstance) {
+ // Now get a search criteria instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Search for the city number one which is hard-coded the default
+ $searchInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID , 1);
+ $searchInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_MODE, $cityInstance->getRequestInstance()->getRequestElement('mode'));
+ $searchInstance->setLimit(1);
+
+ // Get a result back
+ $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+ // Set result instance in city instance
+ $cityInstance->setResultInstance($resultInstance);
+
+ // Is it valid?
+ $isFound = $resultInstance->next();
+
+ // Return it
+ return $isFound;
+ }
+
+ /**
+ * 'Registers' a new city id along with data provided in the city instance.
+ * This may sound confusing but avoids double code very nicely...
+ *
+ * @param $cityInstance A city instance
+ * @param $requestInstance An instance of a Requestable class
+ * @return void
+ */
+ public function registerCityId (BaseCityDaemon $cityInstance, Requestable $requestInstance) {
+ // Get a dataset instance
+ $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_CITY_INFORMATION));
+
+ // Set the primary key
+ $dataSetInstance->setUniqueKey(self::DB_COLUMN_CITY_ID);
+
+ // Add registration elements to the dataset
+ $cityInstance->addElementsToDataSet($dataSetInstance, $requestInstance);
+
+ // "Insert" this dataset instance completely into the database
+ $this->queryInsertDataSet($dataSetInstance);
+ }
+
+ /**
+ * Removes non-public data from given array.
+ *
+ * @param $data An array with possible non-public data that needs to be removed.
+ * @return $data A cleaned up array with only public data.
+ */
+ public function removeNonPublicDataFromArray(array $data) {
+ // Currently call only inner method
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...');
+ $data = parent::removeNonPublicDataFromArray($data);
+
+ // Return cleaned data
+ return $data;
+ }
+
+ /**
+ * Checks whether the user has already founded a city
+ *
+ * @return $hasFounded Whether the user has already founded a city
+ */
+ public function ifUserHasFoundedCity () {
+ // Get user instance
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Now get a search criteria instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Search for user's cities
+ $searchInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_USER_ID, $userInstance->getUserId());
+
+ // Get a result back
+ $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+ // Get city manager instance
+ $managerInstance = ManagerFactory::createManagerByType('city');
+
+ // Set result instance
+ $managerInstance->setResultInstance($resultInstance);
+
+ // Has it been founded?
+ $hasFounded = $resultInstance->next();
+
+ // Return result
+ return $hasFounded;
+ }
+
+ /**
+ * Checks whether the given city name is taken
+ *
+ * @para $cityName Name of city
+ * @return $isTaken Whether the given city name is taken
+ */
+ public function ifCityExists ($cityName) {
+ // Now get a search criteria instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Search for the city number one which is hard-coded the default
+ $searchInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_NAME, $cityName);
+ $searchInstance->setLimit(1);
+
+ // Get a result back
+ $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+ // Check it
+ $isTaken = $resultInstance->valid();
+
+ // Get manger instance
+ $managerInstance = ManagerFactory::createManagerByType('city');
+
+ // Set result instance
+ $managerInstance->setResultInstance($resultInstance);
+
+ // Return result
+ return $isTaken;
+ }
+
+ /**
+ * Creates a city from given request
+ *
+ * @para $requestInstance An instance of a Requestable class
+ * @return void
+ */
+ public function createCityByRequest (Requestable $requestInstance) {
+ // Make sure all required fields are there
+ assert($requestInstance->isRequestElementSet(self::DB_COLUMN_CITY_NAME));
+ assert($requestInstance->isRequestElementSet(self::DB_COLUMN_CITY_REGION_ID));
+
+ // Get city name (to save some calls)
+ $cityName = $requestInstance->getRequestElement(self::DB_COLUMN_CITY_NAME);
+
+ // Make sure the city name is not taken yet
+ assert(!$this->ifCityExists($cityName));
+
+ // Get user instance
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Get a dataset instance
+ $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_CITY_INFORMATION));
+
+ // Set the primary key
+ $dataSetInstance->setUniqueKey(self::DB_COLUMN_CITY_ID);
+
+ // Add city name and assign user id
+ $dataSetInstance->addCriteria(self::DB_COLUMN_CITY_ID , ($this->countTotalRows() + 1));
+ $dataSetInstance->addCriteria(self::DB_COLUMN_CITY_NAME , $cityName);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_CITY_USER_ID , $userInstance->getUserId());
+ $dataSetInstance->addCriteria(self::DB_COLUMN_CITY_REGION_ID, $requestInstance->getRequestElement(self::DB_COLUMN_CITY_REGION_ID));
+
+ // "Insert" this dataset instance completely into the database
+ $this->queryInsertDataSet($dataSetInstance);
+
+ // Post-check name
+ assert($this->ifCityExists($cityName));
+ }
+
+ /**
+ * Getter for all city ids as an array
+ *
+ * @return $cityIds All city ids as an array
+ */
+ public function getAllCityIds () {
+ // Init empty search instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // And run it on the database
+ $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+ // Init array
+ $cityIds = array();
+
+ // Anything found?
+ if ($resultInstance->count() == 0) {
+ // Nothing found
+ return $cityIds;
+ } // END - if
+
+ // Now get all 'city_id' columns
+ while ($resultInstance->next()) {
+ // Get current entry
+ $current = $resultInstance->current();
+
+ // 'city_id' should be there
+ assert(isset($current[self::DB_COLUMN_CITY_ID]));
+
+ // Add it to the array
+ array_push($cityIds, $current[self::DB_COLUMN_CITY_ID]);
+ } // END - while
+
+ // Return result
+ return $cityIds;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A database wrapper for city districts
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityDistrictsDatabaseWrapper extends BaseDatabaseWrapper implements CityDistrictsWrapper, Registerable {
+ // Constants for database table names
+ const DB_TABLE_CITY_DISTRICTS = 'city_districts';
+
+ // Section id, an referenced city id and district id
+ const DB_COLUMN_CITY_ID = 'city_id';
+ const DB_COLUMN_DISTRICT_ID = 'district_id';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this database wrapper by a provided user class
+ *
+ * @return $wrapperInstance An instance of the created wrapper class
+ */
+ public static final function createCityDistrictsDatabaseWrapper () {
+ // Get a new instance
+ $wrapperInstance = new CityDistrictsDatabaseWrapper();
+
+ // Set (primary!) table name
+ $wrapperInstance->setTableName(self::DB_TABLE_CITY_DISTRICTS);
+
+ // Return the instance
+ return $wrapperInstance;
+ }
+
+ /**
+ * Checks if the given city id is found in districts table
+ *
+ * @param $cityId City id to check
+ * @return $isFound Whether the city id is found
+ */
+ public function ifCityHasDistricts ($cityId) {
+ // Get search instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Search for 'city_id'
+ $searchInstance->addCriteria(self::DB_COLUMN_CITY_ID, $cityId);
+
+ /*
+ * Only one entry is enough to find, else this query could run very\
+ * long on large maps.
+ */
+ $searchInstance->setLimit(1);
+
+ // Execute it on database instance
+ $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+ // Check if there is one entry
+ $isFound = ($resultInstance->next() == 1);
+
+ // Return result
+ return $isFound;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A database wrapper for city lots
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityLotsDatabaseWrapper extends BaseDatabaseWrapper implements CityLotsWrapper, Registerable {
+ // Constants for database table names
+ const DB_TABLE_CITY_LOTS = 'city_lots';
+
+ // Section id, an referenced city id and lot id
+ const DB_COLUMN_CITY_ID = 'city_id';
+ const DB_COLUMN_LOT_ID = 'lot_id';
+ const DB_COLUMN_DISTRICT_ID = 'district_id';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this database wrapper by a provided user class
+ *
+ * @return $wrapperInstance An instance of the created wrapper class
+ */
+ public static final function createCityLotsDatabaseWrapper () {
+ // Get a new instance
+ $wrapperInstance = new CityLotsDatabaseWrapper();
+
+ // Set (primary!) table name
+ $wrapperInstance->setTableName(self::DB_TABLE_CITY_LOTS);
+
+ // Return the instance
+ return $wrapperInstance;
+ }
+
+ /**
+ * Checks if the given city id is found in lots table
+ *
+ * @param $cityId City id to check
+ * @return $isFound Whether the city id is found
+ */
+ public function ifCityHasLots ($cityId) {
+ // Get search instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Search for 'city_id'
+ $searchInstance->addCriteria(self::DB_COLUMN_CITY_ID, $cityId);
+
+ /*
+ * Only one entry is enough to find, else this query could run very\
+ * long on large maps.
+ */
+ $searchInstance->setLimit(1);
+
+ // Execute it on database instance
+ $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+ // Check if there is one entry
+ $isFound = ($resultInstance->next() == 1);
+
+ // Return result
+ return $isFound;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A database wrapper for city sections. Sections are the smalles entity of a
+ * city. They can be connected with each other and form a lot. Therefore only
+ * sections of same type (and sub type) can be linked combined, else you will
+ * something really strange, a residential building with some industry parts
+ * for example is not possible in real world.
+ *
+ * Sure you can have a small shop (commercial) on ground level and some
+ * residentials on higher levels. This city simulation does support such
+ * creations as the levels (Z axis) is different.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CitySectionsDatabaseWrapper extends BaseDatabaseWrapper implements CitySectionsWrapper, Registerable {
+ // Constants for database table names
+ const DB_TABLE_CITY_SECTIONS = 'city_sections';
+
+ // Section id, an referenced city id and lot id
+ const DB_COLUMN_SECTION_ID = 'city_section_id';
+ const DB_COLUMN_CITY_ID = 'city_id';
+
+ /*
+ * Lot id, the lot id is only set if the player has "aquired" the sections
+ * and has created a lot based on these sections.
+ */
+ const DB_COLUMN_LOT_ID = 'lot_id';
+
+ // Section and sub type (e.g. residential, hut)
+ const DB_COLUMN_SECTION_TYPE = 'section_type';
+ const DB_COLUMN_SECTION_SUB_TYPE = 'section_sub_type';
+
+ // X-Y-Z position
+ const DB_COLUMN_SECTION_POSITION_X = 'section_position_x';
+ const DB_COLUMN_SECTION_POSITION_Y = 'section_position_y';
+ const DB_COLUMN_SECTION_POSITION_Z = 'section_position_z';
+
+ // Connected neigbouring sections
+ const DB_COLUMN_SECTION_NEIGHBOUR_WEST_ID = 'section_neighbour_west_id';
+ const DB_COLUMN_SECTION_NEIGHBOUR_EAST_ID = 'section_neighbour_east_id';
+ const DB_COLUMN_SECTION_NEIGHBOUR_NORTH_ID = 'section_neighbour_north_id';
+ const DB_COLUMN_SECTION_NEIGHBOUR_SOUTH_ID = 'section_neighbour_south_id';
+ const DB_COLUMN_SECTION_NEIGHBOUR_UP_ID = 'section_neighbour_up_id';
+ const DB_COLUMN_SECTION_NEIGHBOUR_DOWN_ID = 'section_neighbour_down_id';
+
+ // Other settings:
+ // Reserved section (see documentation)
+ const DB_COLUMN_SECTION_RESERVED = 'section_reserved';
+
+ // Section types
+ // @TODO "water" is not yet supported and may end up in a very random land.
+ const SECTION_TYPE_WATER = 'water';
+ const SECTION_TYPE_EMPTY_LAND = 'land';
+
+ // Sub sections
+ // @TODO All types of water are not supported yet.
+ const SUB_SECTION_TYPE_EMPTY = 'empty';
+
+ // Reserved flag
+ const IS_NOT_RESERVED = 0;
+ const IS_RESERVED = 1;
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this database wrapper by a provided user class
+ *
+ * @return $wrapperInstance An instance of the created wrapper class
+ */
+ public static final function createCitySectionsDatabaseWrapper () {
+ // Get a new instance
+ $wrapperInstance = new CitySectionsDatabaseWrapper();
+
+ // Set (primary!) table name
+ $wrapperInstance->setTableName(self::DB_TABLE_CITY_SECTIONS);
+
+ // Return the instance
+ return $wrapperInstance;
+ }
+
+ /**
+ * Checks if the given city id is found in sections table
+ *
+ * @param $cityId City id to check
+ * @return $isFound Whether the city id is found
+ */
+ public function ifCityHasSections ($cityId) {
+ // Get search instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Search for 'city_id'
+ $searchInstance->addCriteria(self::DB_COLUMN_CITY_ID, $cityId);
+
+ /*
+ * Only one entry is enough to find, else this query could run very
+ * long on large maps.
+ */
+ $searchInstance->setLimit(1);
+
+ // Execute it on database instance
+ $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+ // Check if there is one entry
+ $isFound = ($resultInstance->next() == 1);
+
+ // Return result
+ return $isFound;
+ }
+
+ /**
+ * Expands the sections table with initial data for given city id
+ *
+ * @param $cityId City id to check
+ * @return $ids Sections ids from initial expansion
+ * @todo Add handling of water types to make a more cooler map
+ */
+ public function doInitialCityExpansion ($cityId) {
+ // Make sure this city has no sections
+ assert(!$this->ifCityHasSections($cityId));
+
+ /*
+ * "Cache" max "radius" for initial city expansion. It is not a real
+ * radius but more a max expansion area (expand +- half of "radius"
+ * from 0/0). The "zero point" is always calculated in.
+ *
+ * This gives a maxium initial area calculated as follows:
+ *
+ * totalInitialSections = (radius + 1) * (radius + 1)
+ */
+ $radius = $this->getConfigInstance()->getConfigEntry('city_max_initial_xy_expansion_radius');
+
+ // Max up and down ...
+ $maxUp = $this->getConfigInstance()->getConfigEntry('city_max_initial_up_expansion');
+ $maxDown = $this->getConfigInstance()->getConfigEntry('city_max_initial_down_expansion');
+
+ // Extremely huge debug message:
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: radius=' . $radius . ',maxUp=' . $maxUp . ',maxDown=' . $maxDown);
+
+ // Get data set instance
+ $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_CITY_SECTIONS));
+
+ // Add values for "zero point"
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_ID , 1);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_CITY_ID , $cityId);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_LOT_ID , 0);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_TYPE , self::SECTION_TYPE_EMPTY_LAND);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_SUB_TYPE , self::SUB_SECTION_TYPE_EMPTY);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_POSITION_X , 0);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_POSITION_Y , 0);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_POSITION_Z , 0);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_NEIGHBOUR_NORTH_ID, 0);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_NEIGHBOUR_SOUTH_ID, 0);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_NEIGHBOUR_WEST_ID , 0);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_NEIGHBOUR_EAST_ID , 0);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_NEIGHBOUR_UP_ID , 0);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_NEIGHBOUR_DOWN_ID , 0);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_RESERVED , self::IS_NOT_RESERVED);
+
+ // Set primary key to 'city_id'/'section_id'
+ $dataSetInstance->setPrimaryKeyCombined(array(self::DB_COLUMN_CITY_ID, self::DB_COLUMN_SECTION_ID));
+
+ // Add "zero point"
+ $this->queryInsertDataSet($dataSetInstance);
+
+ // Set section id to 2 as 1 is already initialized + init array
+ $sections = array();
+
+ // Output message to ask for user's patience ...
+ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: Writing ' . (($radius + 1) * ($radius + 1) * $maxUp * ($maxDown + 1)) . ' sections for city ' . $cityId . ' ... (this may takes some time)');
+
+ // Expand half of it to north/south (north=positive, south=negative)
+ for ($north = 1; $north < round($radius / 2); $north++) {
+ // Expand half of it to west/east (west=positive, east=negative)
+ for ($west = 1; $west < round($radius / 2); $west++) {
+ // Expand up/down (including "zero point")
+ for ($z = $maxDown; $z < ($maxUp + 1); $z++) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: north=' . $north . ',west=' . $west . ',z=' . $z);
+
+ // Fill array up with south/east/down ids
+ $sections[($north * -1)][($west * -1)][$z]['type'] = self::SECTION_TYPE_EMPTY_LAND;
+ $sections[($north * -1)][($west * -1)][$z]['sub'] = self::SUB_SECTION_TYPE_EMPTY;
+
+ // Fill up array with north/west/up ids
+ $sections[$north][$west][$z]['type'] = self::SECTION_TYPE_EMPTY_LAND;
+ $sections[$north][$west][$z]['sub'] = self::SUB_SECTION_TYPE_EMPTY;
+ } // END - for
+ } // END - for
+ } // END - for
+
+ // Init section id with 2 as 1 is the "zero point"
+ $sectionId = 2;
+
+ // Loop through whole array again for writing it to database: north/south
+ foreach ($sections as $x => $sectionX) {
+ // Loop through west/east values
+ foreach ($sectionX as $y => $sectionY) {
+ // Loop through up/down values
+ foreach ($sectionY as $z => $sectionData) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: x=' . $x . ',y=' . $y . ',z=' . $z . ',sectionId=' . $sectionId);
+
+ // Set all coordinates for positive directions
+ $dataSetInstance->setCriteria(self::DB_COLUMN_SECTION_ID , $sectionId);
+ $dataSetInstance->setCriteria(self::DB_COLUMN_SECTION_POSITION_X, $x);
+ $dataSetInstance->setCriteria(self::DB_COLUMN_SECTION_POSITION_Y, $y);
+ $dataSetInstance->setCriteria(self::DB_COLUMN_SECTION_POSITION_Z, $z);
+ $dataSetInstance->setCriteria(self::DB_COLUMN_SECTION_TYPE , $sectionData['type']);
+ $dataSetInstance->setCriteria(self::DB_COLUMN_SECTION_SUB_TYPE , $sectionData['sub']);
+
+ // Add value to database
+ $this->queryInsertDataSet($dataSetInstance);
+
+ // Count id up
+ $sectionId++;
+ } // END - foreach
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: x=' . $x . ',y=' . $y . ' has been written.');
+ } // END - foreach
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: x=' . $x . ' has been written.');
+ } // END - foreach
+
+ // Thank you for waiting! :-)
+ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: ' . (($radius + 1) * ($radius + 1) * $maxUp * ($maxDown + 1)) . ' sections has been written for city ' . $cityId . '.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A database wrapper for region informations
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 RegionInformationDatabaseWrapper extends BaseDatabaseWrapper implements RegionInformationWrapper, Registerable {
+ // Constants for database table names
+ const DB_TABLE_REGION_INFORMATION = 'region_data';
+
+ // Constants for database column names
+ const DB_COLUMN_REGION_ID = 'region_id';
+ const DB_COLUMN_REGION_NAME = 'region_name';
+ const DB_COLUMN_REGION_USER_ID = 'region_user_id';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this database wrapper by a provided user class
+ *
+ * @return $wrapperInstance An instance of the created wrapper class
+ */
+ public static final function createRegionInformationDatabaseWrapper () {
+ // Get a new instance
+ $wrapperInstance = new RegionInformationDatabaseWrapper();
+
+ // Set (primary!) table name
+ $wrapperInstance->setTableName(self::DB_TABLE_REGION_INFORMATION);
+
+ // Return the instance
+ return $wrapperInstance;
+ }
+
+ /**
+ * Removes non-public data from given array.
+ *
+ * @param $data An array with possible non-public data that needs to be removed.
+ * @return $data A cleaned up array with only public data.
+ */
+ public function removeNonPublicDataFromArray(array $data) {
+ // Currently call only inner method
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGION-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...');
+ $data = parent::removeNonPublicDataFromArray($data);
+
+ // Return cleaned data
+ return $data;
+ }
+
+ /**
+ * Checks whether the user has already founded a region
+ *
+ * @return $hasFounded Whether the user has already founded a region
+ */
+ public function ifUserHasCreatedRegion () {
+ // Get user instance
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Now get a search criteria instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Search for user's cities
+ $searchInstance->addCriteria(RegionInformationDatabaseWrapper::DB_COLUMN_REGION_USER_ID, $userInstance->getUserId());
+
+ // Get a result back
+ $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+ // Get region manager instance
+ $managerInstance = ManagerFactory::createManagerByType('region');
+
+ // Set result instance
+ $managerInstance->setResultInstance($resultInstance);
+
+ // Has it been founded?
+ $hasFounded = $resultInstance->valid();
+
+ // Return result
+ return $hasFounded;
+ }
+
+ /**
+ * Checks whether the given region name is taken
+ *
+ * @param $regionName Name of region
+ * @return $isTaken Whether the given region name is taken
+ */
+ public function ifRegionExists ($regionName) {
+ // Now get a search criteria instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Search for the region number one which is hard-coded the default
+ $searchInstance->addCriteria(RegionInformationDatabaseWrapper::DB_COLUMN_REGION_NAME, $regionName);
+ $searchInstance->setLimit(1);
+
+ // Get a result back
+ $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+ // Check it
+ $isTaken = $resultInstance->next();
+ //* NOISY-DEBUG: */ $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] isTaken[' . gettype($isTaken) . ']=' . intval($isTaken));
+
+ // Get manger instance
+ $managerInstance = ManagerFactory::createManagerByType('region');
+
+ // Set result instance
+ $managerInstance->setResultInstance($resultInstance);
+
+ // Return result
+ return $isTaken;
+ }
+
+ /**
+ * Creates a region by given name
+ *
+ * @param $regionName Name of region
+ * @return void
+ */
+ public function createRegionByName ($regionName) {
+ // Pre-check name
+ assert(!$this->ifRegionExists($regionName));
+
+ // Get user instance
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Get a dataset instance
+ $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_REGION_INFORMATION));
+
+ // Set the primary key
+ $dataSetInstance->setUniqueKey(self::DB_COLUMN_REGION_ID);
+
+ // Add region name and assign user id
+ $dataSetInstance->addCriteria(self::DB_COLUMN_REGION_ID , ($this->countTotalRows() + 1));
+ $dataSetInstance->addCriteria(self::DB_COLUMN_REGION_NAME , $regionName);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_REGION_USER_ID, $userInstance->getUserId());
+
+ // "Insert" this dataset instance completely into the database
+ $this->queryInsertDataSet($dataSetInstance);
+
+ // Post-check name
+ assert($this->ifRegionExists($regionName));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A database wrapper for region maps
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 RegionMapDatabaseWrapper extends BaseDatabaseWrapper implements RegionMapWrapper, Registerable {
+ // Constants for database table names
+ const DB_TABLE_REGION_MAP = 'region_map';
+
+ // Constants for database column names
+ const DB_COLUMN_REGION_ID = 'region_id';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this database wrapper by a provided user class
+ *
+ * @return $wrapperInstance An instance of the created wrapper class
+ */
+ public static final function createRegionMapDatabaseWrapper () {
+ // Get a new instance
+ $wrapperInstance = new RegionMapDatabaseWrapper();
+
+ // Set (primary!) table name
+ $wrapperInstance->setTableName(self::DB_TABLE_REGION_MAP);
+
+ // Return the instance
+ return $wrapperInstance;
+ }
+
+ /**
+ * Removes non-public data from given array.
+ *
+ * @param $data An array with possible non-public data that needs to be removed.
+ * @return $data A cleaned up array with only public data.
+ */
+ public function removeNonPublicDataFromArray(array $data) {
+ // Currently call only inner method
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGION-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...');
+ $data = parent::removeNonPublicDataFromArray($data);
+
+ // Return cleaned data
+ return $data;
+ }
+
+ /**
+ * Creates a region by given name
+ *
+ * @return void
+ */
+ public function createRegionByName () {
+ // Pre-check
+ die(__METHOD__ . ': Unfinshed!');
+ assert(!$this->ifRegionExists($regionName));
+
+ // Get user instance
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Get a dataset instance
+ $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_REGION_MAP));
+
+ // Set the primary key
+ $dataSetInstance->setUniqueKey(self::DB_COLUMN_REGION_ID);
+
+ // Add region name and assign user id
+ $dataSetInstance->addCriteria(self::DB_COLUMN_REGION_ID , ($this->countTotalRows() + 1));
+
+ // "Insert" this dataset instance completely into the database
+ $this->queryInsertDataSet($dataSetInstance);
+
+ // Post-check name
+ assert($this->ifRegionExists($regionName));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A factory class for cities
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 CityDaemonFactory extends ObjectFactory {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Returns a singleton (registry-based) CityHelper instance
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return $cityInstance An instance of a CityHelper class
+ * @throws FactoryRequiredParameterException If not all parameters are set and no instance 'city' is set.
+ */
+ public static final function createCityDaemonInstance (Requestable $requestInstance = NULL, Responseable $responseInstance = NULL) {
+ // Get new factory instance
+ $factoryInstance = new CityDaemonFactory();
+
+ // If there is no handler?
+ if (Registry::getRegistry()->instanceExists('city')) {
+ // Get handler from registry
+ $cityInstance = Registry::getRegistry()->getInstance('city');
+ } elseif (($requestInstance instanceof Requestable) && ($responseInstance instanceof Responseable)) {
+ // The default city-mode is from our configuration
+ $cityMode = $factoryInstance->getConfigInstance()->getConfigEntry('city_default_mode');
+
+ // Is the city 'mode' parameter set?
+ if ($requestInstance->isRequestElementSet('mode')) {
+ // Then use this which overrides the config entry temporarily
+ $cityMode = $requestInstance->getRequestElement('mode');
+ } else {
+ // Set it for easier re-usage
+ $requestInstance->setRequestElement('mode', $cityMode);
+ }
+
+ // Now convert the city-mode in a class name
+ $className = 'Simulation' . $factoryInstance->convertToClassName($cityMode) . 'CityDaemon';
+
+ // Get the city instance
+ $cityInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
+
+ // Get a registry
+ $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+ // Set the app instance
+ $cityInstance->setApplicationInstance($applicationInstance);
+
+ // Add city-specific filters
+ $cityInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
+ } else {
+ // Throw an exception here
+ throw new FactoryRequiredParameterException($factoryInstance, self::EXCEPTION_FACTORY_REQUIRE_PARAMETER);
+ }
+
+ // Return the instance
+ return $cityInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A factory class for managers
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 ManagerFactory extends ObjectFactory {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Returns a singleton (registry-based) ManageableFoo instance
+ *
+ * @param $type Type of manager to return
+ * @return $managerInstance An instance of a ManageableFoo class
+ */
+ public static final function createManagerByType ($type) {
+ // Get new factory instance
+ $factoryInstance = new ManagerFactory();
+
+ // Generate key
+ $key = $type . '_manager';
+
+ // If there is no handler?
+ if (Registry::getRegistry()->instanceExists($key)) {
+ // Get handler from registry
+ $managerInstance = Registry::getRegistry()->getInstance($key);
+ } else {
+ // Get the proper manager instance
+ $managerInstance = ObjectFactory::createObjectByConfiguredName($key . '_class');
+
+ // Add it to the registry
+ Registry::getRegistry()->addInstance($key, $managerInstance);
+ }
+
+ // Return the instance
+ return $managerInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A factory class for city states
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityStateFactory extends ObjectFactory {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of a configurable city state and sets it in the
+ * given city instance.
+ *
+ * @param $stateName Name of the state
+ * @return $stateInstance A Stateable class instance
+ */
+ public static final function createCityStateInstanceByName ($stateName) {
+ // Then construct the class' configuraton entry
+ $className = 'city_' . $stateName . '_state_class';
+
+ // Get a class from that configuration entry
+ $stateInstance = self::createObjectByConfiguredName($className);
+
+ // Get city instance
+ $cityInstance = CityDaemonFactory::createCityDaemonInstance();
+
+ // Debug message
+ self::createDebugInstance(__CLASS__)->debugOutput('CITY-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: City state has changed from ' . $cityInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
+ // Once we have that state, set it in the city instance
+ $cityInstance->setStateInstance($stateInstance);
+
+ // Update city data
+ $cityInstance->updateCityData();
+
+ // For any purposes, return the state instance
+ return $stateInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A bootstrap ??? filter for daemon
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 CityDaemonBootstrap???Filter extends BaseCityFilter 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 createCityDaemonBootstrap???Filter () {
+ // Get a new instance
+ $filterInstance = new CityDaemonBootstrap???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
+ * @throws FilterChainException If $cityInstance is null (no NullPointerException here)
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get city instance
+ $cityInstance = Registry::getRegistry()->getInstance('city');
+
+ // Now do something
+ $this->partialStub('Please implement this step.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A bootstrap InitDaemon filter for daemon
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 CityDaemonBootstrapInitDaemonFilter extends BaseCityFilter 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 createCityDaemonBootstrapInitDaemonFilter () {
+ // Get a new instance
+ $filterInstance = new CityDaemonBootstrapInitDaemonFilter();
+
+ // 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
+ * @throws FilterChainException If $cityInstance is null (no NullPointerException here)
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get city instance
+ $cityInstance = CityDaemonFactory::createCityDaemonInstance();
+
+ // Now bootstrap the daemon
+ $cityInstance->bootstrapInitCityDaemon();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? filter for citys
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 CityDaemon???Filter extends BaseCityFilter 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 createCityDaemon???Filter () {
+ // Get a new instance
+ $filterInstance = new CityDaemon???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 cities
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityDaemonInitializationFilter extends BaseCityFilter 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 static final function createCityDaemonInitializationFilter () {
+ // Get a new instance
+ $filterInstance = new CityDaemonInitializationFilter();
+
+ // 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Try to instance it by using a factory
+ try {
+ // Get an instance
+ $cityInstance = CityDaemonFactory::createCityDaemonInstance($requestInstance, $responseInstance);
+ } catch (ClassNotFoundException $e) {
+ // This exception means, the city mode is invalid.
+ // @TODO Can we rewrite this to app_exit() ?
+ $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: City daemon could not be initialized: ' . $e->getMessage());
+ }
+
+ // Debug message
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-INIT-FILTER[' . __METHOD__ . ':' . __LINE__ . ']: City daemon has been added to registry.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A PhpRequirements filter for cities
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityDaemonPhpRequirementsFilter extends BaseCityFilter 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 static final function createCityDaemonPhpRequirementsFilter () {
+ // Get a new instance
+ $filterInstance = new CityDaemonPhpRequirementsFilter();
+
+ // 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
+ * @throws FilterChainException If a required PHP function is not available
+ * @todo Add more test and try to add an extra message to the thrown exception
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // By default, the requirement check is passed and zero checks are failed
+ $checkPassed = TRUE;
+ $checksFailed = 0;
+
+ // Are all tests passed?
+ if ($checkPassed === FALSE) {
+ // Throw an exception
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ } // END - if
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A welcome-teaser filter for the console
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityDaemonWelcomeTeaserFilter extends BaseCityFilter 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 static final function createCityDaemonWelcomeTeaserFilter () {
+ // Get a new instance
+ $filterInstance = new CityDaemonWelcomeTeaserFilter();
+
+ // 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
+ * @throws FilterChainException If $cityInstance is null (no NullPointerException here)
+ * @todo Handle over the $responseInstance to outputConsoleTeaser()
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get city instance
+ $cityInstance = CityDaemonFactory::createCityDaemonInstance();
+
+ // Now output the teaser
+ $cityInstance->outputConsoleTeaser();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A ??? filter for !!!
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 City!!!???Filter extends BaseCityFilter 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 createCity!!!???Filter () {
+ // Get a new instance
+ $filterInstance = new City!!!???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
+ * @throws FilterChainException If $cityInstance is null (no NullPointerException here)
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get city instance
+ $cityInstance = Registry::getRegistry()->getInstance('city');
+
+ // Now do something
+ $this->partialStub('Please implement this step.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A generic filter for hub project
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 BaseCityFilter extends BaseFilter {
+ /**
+ * Array with all data XML nodes (which hold the actual data) and their values
+ */
+ protected $dataXmlNodes = array();
+
+ /**
+ * Protected constructor
+ *
+ * @param $className Real name of class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+ /**
+ * Processes the given raw message content. The method renderXmlContent
+ * may throw (not the method itself) several exceptions:
+ *
+ * InvalidXmlNodeException - If an invalid XML node has been found (e.g.
+ * wrong/out-dated template used)
+ * XmlNodeMismatchException - Again might be caused by invalid XML node
+ * usage
+ * XmlParserException - If the XML message is damaged or not
+ * well-formed
+ *
+ * @param $messageType Type of message
+ * @param $messageContent Raw message content
+ * @param $packageInstance An instance of a Receivable class
+ * @return void
+ * @todo Exceptions from renderXmlContent() are currently unhandled
+ */
+ protected function genericProcessMessage ($messageType, $messageContent, Receivable $packageInstance) {
+ // Get a template instance from the factory
+ $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('city_' . $messageType . '_template_class');
+
+ // And render the XML content (aka message)
+ $templateInstance->renderXmlContent($messageContent);
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Handling ' . strlen($messageContent) . ' bytes: ' . $messageContent);
+
+ /*
+ * The template system now stores all required data as 'general'
+ * variables, so simply get them. If there is an invalid XML node
+ * inside the message, the above method call will cause exceptions.
+ */
+ foreach ($this->dataXmlNodes as $key => $dummy) {
+ // Call it
+ $value = $templateInstance->readXmlData($key);
+
+ /*
+ * If value is NULL, a variable hasn't been found. This could mean
+ * that *this* node is running an out-dated software or the other
+ * peer is using an out-dated $messageType.xml template.
+ */
+ if (is_null($value)) {
+ // Output a warning
+ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Found not fully supported variable ' . $key . ' - skipping.');
+
+ // Skip this part, don't write NULLs to the array
+ continue;
+ } // END - if
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: key=' . $key . ',value=' . $value);
+
+ // Set it now
+ $this->dataXmlNodes[$key] = $value;
+ } // END - foreach
+
+ // Construct an array for pushing it on next stack
+ $messageArray = array(
+ // Message data itself
+ NetworkPackage::MESSAGE_ARRAY_DATA => $this->dataXmlNodes,
+ // Message type (which is $messageType)
+ NetworkPackage::MESSAGE_ARRAY_TYPE => $messageType
+ );
+
+ // Push the processed message back on stack
+ $packageInstance->getStackInstance()->pushNamed(NetworkPackage::STACKER_NAME_PROCESSED_MESSAGE, $messageArray);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? filter for shutting down the city.
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 CityDaemonShutdown???Filter extends BaseCityFilter 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 createCityDaemonShutdown???Filter () {
+ // Get a new instance
+ $filterInstance = new CityDaemonShutdown???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
+ * @throws FilterChainException If $cityInstance is null (no NullPointerException here)
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get city instance
+ $cityInstance = Registry::getRegistry()->getInstance('city');
+
+ // Now do something
+ $this->partialStub('Please implement this step.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A ShutdownCity filter for shutting down the city. This filter should be the
+ * last one in 'shutdown' chain so the hub is shutted down at the very end of
+ * its life... R.I.P. little hub...
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityDaemonShutdownCityFilter extends BaseCityFilter 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 static final function createCityDaemonShutdownCityFilter () {
+ // Get a new instance
+ $filterInstance = new CityDaemonShutdownCityFilter();
+
+ // 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
+ * @throws FilterChainException If $cityInstance is null (no NullPointerException please)
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get city instance
+ $cityInstance = CityDaemonFactory::createCityDaemonInstance();
+
+ // Shutdown the city. This should be the last line
+ $cityInstance->doShutdown();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A TaskHandler filter for shutting down the city.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityDaemonShutdownTaskHandlerFilter extends BaseCityFilter 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 static final function createCityDaemonShutdownTaskHandlerFilter () {
+ // Get a new instance
+ $filterInstance = new CityDaemonShutdownTaskHandlerFilter();
+
+ // 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
+ * @throws FilterChainException If $cityInstance is null (no NullPointerException here)
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get task handler instance
+ $handlerInstance = Registry::getRegistry()->getInstance('task_handler');
+
+ // Shutdown the task manager and all its registered tasks
+ $handlerInstance->doShutdown();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A TaskHandlerInitializer filter for hubs
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityDaemonTaskHandlerInitializerFilter extends BaseCityFilter 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 static final function createCityDaemonTaskHandlerInitializerFilter () {
+ // Get a new instance
+ $filterInstance = new CityDaemonTaskHandlerInitializerFilter();
+
+ // 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
+ * @throws FilterChainException If the filter chain needs to be interrupted
+ * @todo Add more tasks
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get city instance
+ $cityInstance = CityDaemonFactory::createCityDaemonInstance();
+
+ // Get a new task handler instance
+ $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class');
+
+ // Put the task handler in registry
+ Registry::getRegistry()->addInstance('task_handler', $handlerInstance);
+
+ // Prepare a city map expansion task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('city_daemon_map_expander_task_class');
+
+ // Register it
+ $handlerInstance->registerTask('map_expander', $taskInstance);
+
+ // Prepare a household growth task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('city_daemon_household_growth_task_class');
+
+ // Register it
+ $handlerInstance->registerTask('household_growth', $taskInstance);
+
+ // Prepare a building growth task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('city_daemon_building_growth_task_class');
+
+ // Register it
+ $handlerInstance->registerTask('building_growth', $taskInstance);
+
+ /*
+ * Add extra tasks depending on daemon modus.
+ */
+ $cityInstance->addExtraTasks($handlerInstance);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A concrete filter for verfying the city name. This filter may intercept the
+ * filter chain if no city name is given or if supplied city name has an invalid
+ * form. It could also intercept our filter chain if city name was not found.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityNameVerifierFilter 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 static final function createCityNameVerifierFilter () {
+ // Get a new instance
+ $filterInstance = new CityNameVerifierFilter();
+
+ // 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
+ * @throws FilterChainException If this filter fails to operate
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get city name from request
+ $cityName = $requestInstance->getRequestElement(CityInformationDatabaseWrapper::DB_COLUMN_CITY_NAME);
+
+ // Is the city name set?
+ if (is_null($cityName)) {
+ // Not found in form so stop the filtering process
+ $requestInstance->requestIsValid(FALSE);
+
+ // Add a message to the response
+ $responseInstance->addFatalMessage('city_name_unset');
+
+ // Abort here
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ } elseif (empty($cityName)) {
+ // Empty field!
+ $requestInstance->requestIsValid(FALSE);
+
+ // Add a message to the response
+ $responseInstance->addFatalMessage('city_name_empty');
+
+ // Abort here
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ } elseif ($this->ifCityNameIsTaken($cityName) === TRUE) {
+ // City name is already taken
+ $requestInstance->requestIsValid(FALSE);
+
+ // Add a message to the response
+ $responseInstance->addFatalMessage('city_name_taken');
+
+ // Abort here
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ }
+ }
+
+ /**
+ * Check whether the city name as already been taken
+ *
+ * @param $cityName Cityname to check for existence
+ * @return $alreadyTaken Whether the city name has been taken
+ */
+ private function ifCityNameIsTaken ($cityName) {
+ // Get a new instance
+ $managerInstance = ManagerFactory::createManagerByType('city');
+
+ // Does the city name exist?
+ $alreadyTaken = ($managerInstance->ifCityNameExists($cityName));
+
+ // Return the result
+ return $alreadyTaken;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A special guest login class for City
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityGuestLogin extends BaseFrameworkSystem implements LoginableUser, Registerable {
+ /**
+ * The hashed password
+ */
+ private $hashedPassword = '';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this login class
+ *
+ * @return $loginInstance An instance of this login class
+ */
+ public static final function createCityGuestLogin () {
+ // Get a new instance
+ $loginInstance = new CityGuestLogin();
+
+ // Return the instance
+ return $loginInstance;
+ }
+
+ /**
+ * Logins the user with the given request containing the credential. The
+ * result of the login can be thrown by exception or, if prefered stored
+ * in a boolean attribute which is then readable by a matching getter.
+ *
+ * @param $requestInstance An instance of a Requestable class
+ * @param $responseInstance An instance of a Responseable class
+ * @return void
+ * @throws UserPasswordMismatchException If the supplied password did not
+ * match with the stored password
+ */
+ public function doLogin (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get a user instance
+ $userInstance = UserFactory::createUserByRequest($requestInstance);
+
+ // Remember this new instance in registry
+ Registry::getRegistry()->addInstance('user', $userInstance);
+
+ // Is the password correct?
+ if ($userInstance->ifPasswordHashMatches($requestInstance) === FALSE) {
+ // Mismatching password
+ throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
+ } // END - if
+
+ // Now do the real login. This can be cookie- or session-based login
+ // which depends on the admins setting then on the user's taste.
+ // 1) Get a login helper instance
+ $helperInstance = ObjectFactory::createObjectByConfiguredName('login_helper_class', array($requestInstance));
+
+ // 2) Execute the login. This will now login...
+ $helperInstance->executeLogin($responseInstance);
+ }
+
+ /**
+ * Check if the implementation is correct. Only the request instance is
+ * needed as no redirect is done here.
+ *
+ * @param $requestInstance An instance of a Requestable class
+ * @return
+ */
+ public function testLogin (Requestable $requestInstance) {
+ // Create dummy instance
+ $dummyInstance = Guest::createGuestByRequest($requestInstance);
+ }
+
+ /**
+ * Determines wether the login was fine. This is done by checking if 'login' instance is in registry
+ *
+ * @return $loginDone Wether the login was fine or not
+ */
+ public function ifLoginWasSuccessfull () {
+ // Is the registry key there?
+ $loginDone = (Registry::getRegistry()->getInstance('login') instanceof Registerable);
+
+ // Return the result
+ return $loginDone;
+ }
+
+ /**
+ * Encrypt given request key or throw an exception if key was not found in
+ * request
+ *
+ * @param $requestKey Key in request class
+ * @return void
+ */
+ public function encryptPassword ($requestKey) {
+ // Check if password is found in request
+ if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
+ // So encrypt the password and store it for later usage in
+ // the request:
+
+ // Get the plain password
+ $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
+
+ // Get user instance
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Get a crypto helper and hash the password
+ $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword, $userInstance->getPasswordHash());
+
+ // Store the hash back in request
+ $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
+ } // END - if
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A special login class for City
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityUserLogin extends BaseFrameworkSystem implements LoginableUser, Registerable {
+ /**
+ * The hashed password
+ */
+ private $hashedPassword = '';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this login class
+ *
+ * @return $loginInstance An instance of this login class
+ */
+ public static final function createCityUserLogin () {
+ // Get a new instance
+ $loginInstance = new CityUserLogin();
+
+ // Return the instance
+ return $loginInstance;
+ }
+
+ /**
+ * Logins the user with the given request containing the credential. The
+ * result of the login can be thrown by exception or, if prefered stored
+ * in a boolean attribute which is then readable by a matching getter.
+ *
+ * @param $requestInstance An instance of a Requestable class
+ * @param $responseInstance An instance of a Responseable class
+ * @return void
+ * @throws UserPasswordMismatchException If the supplied password did not
+ * match with the stored password
+ * @todo We need to add something here which will make more than one
+ * @todo guest logins, users who are online but based on the same
+ * @todo user account.
+ */
+ public function doLogin (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get a user instance from factory
+ $userInstance = UserFactory::createUserByRequest($requestInstance);
+
+ // Remember this new instance in registry
+ Registry::getRegistry()->addInstance('user', $userInstance);
+
+ // Is the password correct?
+ if ($userInstance->ifPasswordHashMatches($requestInstance) === FALSE) {
+ // Mismatching password
+ throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
+ } // END - if
+
+ // @TODO What else?
+
+ /*
+ * Now do the real login. This can be cookie- or session-based login
+ * which depends on the admins setting then on the user's taste.
+ */
+
+ // 1) Get a login helper instance
+ $helperInstance = ObjectFactory::createObjectByConfiguredName('login_helper_class', array($requestInstance));
+
+ // 2) Execute the login. This will now login...
+ $helperInstance->executeLogin($responseInstance);
+ }
+
+ /**
+ * Check if the implementation is correct. Only the request instance is
+ * needed as no redirect is done here.
+ *
+ * @param $requestInstance An instance of a Requestable class
+ * @return
+ */
+ public function testLogin (Requestable $requestInstance) {
+ // Create a dummy instance
+ $dummyInstance = Member::createMemberByRequest($requestInstance);
+ }
+
+ /**
+ * Determines wether the login was fine. This is done by checking if 'login' instance is in registry
+ *
+ * @return $loginDone Wether the login was fine or not
+ */
+ public function ifLoginWasSuccessfull () {
+ // Is the registry key there?
+ $loginDone = (Registry::getRegistry()->getInstance('login') instanceof Registerable);
+
+ // Return the result
+ return $loginDone;
+ }
+
+ /**
+ * Encrypt given request key or throw an exception if key was not found in
+ * request
+ *
+ * @param $requestKey Key in request class
+ * @return void
+ */
+ public function encryptPassword ($requestKey) {
+ // Check if password is found in request
+ if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
+ // So encrypt the password and store it for later usage in
+ // the request:
+
+ // Get the plain password
+ $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
+
+ // Get user instance
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Get a crypto helper and hash the password
+ $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword, $userInstance->getPasswordHash());
+
+ // Store the hash back in request
+ $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
+ } // END - if
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A helper for City to login. This login helper first checks what setting
+ * (cookie or session) the admin has choosen then overwrites it with the setting
+ * from current user. The registry instance should hold an instance of this user
+ * class at key 'user' else an exception will be thrown. After this the setting
+ * from a login form will be taken as login method and be stored in database
+ * for later usage.
+ *
+ * The user shall be able to choose "Default login method" or similar to use his
+ * own login method.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityLoginHelper extends BaseLoginHelper implements HelpableLogin {
+ /**
+ * The login method we shall choose
+ */
+ private $authMethod = '';
+
+ // Exception constants
+ const EXCEPTION_INVALID_USER_INSTANCE = 0x190;
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class by given request instance
+ *
+ * @param $requestInstance An instance of a Requestable class
+ * @return $helperInstance An instance of this helper class
+ * @throws UserInstanceMissingException If the user instance in registry
+ * is missing or invalid
+ */
+ public static final function createCityLoginHelper (Requestable $requestInstance) {
+ // Get a new instance first
+ $helperInstance = new CityLoginHelper();
+
+ // Get a user instance from registry
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Is this instance valid?
+ if (!$userInstance instanceof ManageableAccount) {
+ // Thrown an exception here
+ throw new UserInstanceMissingException (array($helperInstance, 'user'), self::EXCEPTION_INVALID_USER_INSTANCE);
+ } // END - if
+
+ // Set default login method from config
+ $helperInstance->setDefaultAuthMethod();
+
+ // Set request instance
+ $helperInstance->setRequestInstance($requestInstance);
+
+ // Return the prepared instance
+ return $helperInstance;
+ }
+
+ /**
+ * Setter for default login method from config
+ *
+ * @return void
+ */
+ protected function setDefaultAuthMethod () {
+ $this->authMethod = $this->getConfigInstance()->getConfigEntry('auth_method_class');
+ }
+
+ /**
+ * Execute the login request by given response instance. This instance can
+ * be used for sending cookies or at least the session id out.
+ *
+ * @param $responseInstance An instance of a Responseable class
+ * @return void
+ */
+ public function executeLogin (Responseable $responseInstance) {
+ // Get an instance from the login method
+ $loginInstance = ObjectFactory::createObjectByName($this->authMethod, array($responseInstance));
+
+ // Set user cookie
+ $loginInstance->setUserAuth($this->getRequestInstance()->getRequestElement('username'));
+
+ // Set password cookie
+ $loginInstance->setPasswordAuth($this->getRequestInstance()->getRequestElement('pass_hash'));
+
+ // Remember this login instance for later usage
+ Registry::getRegistry()->addInstance('login', $loginInstance);
+ }
+}
+
+//
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A City manager
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 CityManager extends BaseManager implements ManageableCity {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $managerInstance An instance of a ManageableCity class
+ */
+ public final static function createCityManager () {
+ // Get new instance
+ $managerInstance = new CityManager();
+
+ // Get database wrapper
+ $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class');
+
+ // And set it here
+ $managerInstance->setWrapperInstance($wrapperInstance);
+
+ // Return the prepared instance
+ return $managerInstance;
+ }
+
+ /**
+ * Checks whether the current user has already founded a city
+ *
+ * @return $isFounded Whether the current user has already founded a city
+ */
+ public function isCityAlreadyFounded () {
+ // Check if the currently set user has already founded a city
+ $isFounded = $this->getWrapperInstance()->ifUserHasFoundedCity();
+
+ // Return result
+ return $isFounded;
+ }
+
+ /**
+ * Checks whether the given city name is already taken
+ *
+ * @para $cityName Name of city
+ * @return $isTaken Whether the given city name is already taken
+ */
+ public function ifCityNameExists ($cityName) {
+ // Check if the given city name is taken
+ $isTaken = $this->getWrapperInstance()->ifCityExists($cityName);
+
+ // Return result
+ return $isTaken;
+ }
+
+ /**
+ * Founds the first city. A dummy region will also be created
+ *
+ * @return void
+ */
+ public function foundFirstCity () {
+ // Check on request instance and 'city_name' element
+ assert($this->getRequestInstance() instanceof Requestable);
+ assert($this->getRequestInstance()->isRequestElementSet(CityInformationDatabaseWrapper::DB_COLUMN_CITY_NAME));
+
+ // Get city name
+ $cityName = $this->getRequestInstance()->getRequestElement(CityInformationDatabaseWrapper::DB_COLUMN_CITY_NAME);
+
+ // Some pre-checks
+ assert(!$this->isCityAlreadyFounded());
+ assert(!$this->ifCityNameExists($cityName));
+
+ // Get region manager
+ $managerInstance = ManagerFactory::createManagerByType('region');
+
+ // There should be no region created
+ assert(!$managerInstance->ifUserHasCreatedRegion());
+
+ // Create first region and get back whole result
+ $regionResultInstance = $managerInstance->createFirstRegion();
+
+ // Get current entry
+ $regionData = $regionResultInstance->current();
+
+ // Add region id from it
+ $this->getRequestInstance()->setRequestElement(CityInformationDatabaseWrapper::DB_COLUMN_CITY_REGION_ID, $regionData[RegionInformationDatabaseWrapper::DB_COLUMN_REGION_ID]);
+
+ // Then create the first city
+ $this->getWrapperInstance()->createCityByRequest($this->getRequestInstance());
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A city districts manager
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 CityDistrictsManager extends BaseFrameworkSystem implements ManageableCityDistricts, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $managerInstance An instance of a ManageableCityDistricts class
+ */
+ public final static function createCityDistrictsManager () {
+ // Get new instance
+ $managerInstance = new CityDistrictsManager();
+
+ // Get database wrapper
+ $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_districts_db_wrapper_class');
+
+ // And set it here
+ $managerInstance->setWrapperInstance($wrapperInstance);
+
+ // Return the prepared instance
+ return $managerInstance;
+ }
+
+ /**
+ * Checks whether at least one map requires expansion
+ *
+ * @return $requiresExpansion Whether a map requires expansion
+ * @todo 0% done
+ */
+ public function isMapPendingExpansion () {
+ // Default is no expansion is needed
+ $requireExpansion = FALSE;
+
+ // First, a simple check if the districts table contains any entries at all
+ if ($this->getWrapperInstance()->countTotalRows() == 0) {
+ // This definedly requires expansion
+ $requireExpansion = TRUE;
+ } // END - if
+
+ // Return status
+ return $requireExpansion;
+ }
+
+ /**
+ * Expands any map that requires expansion
+ *
+ * @return void
+ * @todo ~10% done
+ * @todo z-coordinate not used
+ */
+ public function expandMaps () {
+ // Get a city info wrapper instance
+ $cityWrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class');
+
+ // Get all city ids from it
+ $cityIds = $cityWrapperInstance->getAllCityIds();
+
+ // Now check all ids
+ foreach ($cityIds as $cityId) {
+ // Does this id have any districts
+ if (!$this->getWrapperInstance()->ifCityHasDistricts($cityId)) {
+ // Nothing found, so it is a brand-new city that needs first initialization
+ $districts = $this->getWrapperInstance()->doInitialCityExpansion($cityId);
+ } else {
+ // @TODO Maybe some expansion is needed
+ }
+ } // END - foreach
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A city lots manager
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 CityLotsManager extends BaseFrameworkSystem implements ManageableCityLots, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $managerInstance An instance of a ManageableCityLots class
+ */
+ public final static function createCityLotsManager () {
+ // Get new instance
+ $managerInstance = new CityLotsManager();
+
+ // Get database wrapper
+ $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_lots_db_wrapper_class');
+
+ // And set it here
+ $managerInstance->setWrapperInstance($wrapperInstance);
+
+ // Return the prepared instance
+ return $managerInstance;
+ }
+
+ /**
+ * Checks whether at least one map requires expansion
+ *
+ * @return $requiresExpansion Whether a map requires expansion
+ * @todo 0% done
+ */
+ public function isMapPendingExpansion () {
+ // Default is no expansion is needed
+ $requireExpansion = FALSE;
+
+ // First, a simple check if the lots table contains any entries at all
+ if ($this->getWrapperInstance()->countTotalRows() == 0) {
+ // This definedly requires expansion
+ $requireExpansion = TRUE;
+ } // END - if
+
+ // Return status
+ return $requireExpansion;
+ }
+
+ /**
+ * Expands any map that requires expansion
+ *
+ * @return void
+ * @todo ~10% done
+ * @todo z-coordinate not used
+ */
+ public function expandMaps () {
+ // Get a city info wrapper instance
+ $cityWrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class');
+
+ // Get all city ids from it
+ $cityIds = $cityWrapperInstance->getAllCityIds();
+
+ // Now check all ids
+ foreach ($cityIds as $cityId) {
+ // Does this id have any lots
+ if (!$this->getWrapperInstance()->ifCityHasLots($cityId)) {
+ // Nothing found, so it is a brand-new city that needs first initialization
+ $lots = $this->getWrapperInstance()->doInitialCityExpansion($cityId);
+ } else {
+ // @TODO Maybe some expansion is needed
+ }
+ } // END - foreach
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A city sections manager
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 CitySectionsManager extends BaseFrameworkSystem implements ManageableCitySections, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $managerInstance An instance of a ManageableCitySections class
+ */
+ public final static function createCitySectionsManager () {
+ // Get new instance
+ $managerInstance = new CitySectionsManager();
+
+ // Get database wrapper
+ $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_sections_db_wrapper_class');
+
+ // And set it here
+ $managerInstance->setWrapperInstance($wrapperInstance);
+
+ // Return the prepared instance
+ return $managerInstance;
+ }
+
+ /**
+ * Checks whether at least one map requires expansion
+ *
+ * @return $requiresExpansion Whether a map requires expansion
+ * @todo 0% done
+ */
+ public function isMapPendingExpansion () {
+ // Default is no expansion is needed
+ $requireExpansion = FALSE;
+
+ // First, a simple check if the sections table contains any entries at all
+ if ($this->getWrapperInstance()->countTotalRows() == 0) {
+ // This definedly requires expansion
+ $requireExpansion = TRUE;
+ } // END - if
+
+ // Return status
+ return $requireExpansion;
+ }
+
+ /**
+ * Expands any map that requires expansion
+ *
+ * @return void
+ * @todo ~10% done
+ * @todo z-coordinate not used
+ */
+ public function expandMaps () {
+ // Get a city info wrapper instance
+ $cityWrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class');
+
+ // Get all city ids from it
+ $cityIds = $cityWrapperInstance->getAllCityIds();
+
+ // Now check all ids
+ foreach ($cityIds as $cityId) {
+ // Does this id have any sections
+ if (!$this->getWrapperInstance()->ifCityHasSections($cityId)) {
+ // Nothing found, so it is a brand-new city that needs first initialization
+ $sections = $this->getWrapperInstance()->doInitialCityExpansion($cityId);
+ } else {
+ // @TODO Maybe some expansion is needed
+ }
+ } // END - foreach
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A ??? manager
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 ???Manager extends BaseFrameworkSystem implements Manageable???, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $managerInstance An instance of a Manageable??? class
+ */
+ public final static function create???Manager () {
+ // Get new instance
+ $managerInstance = new ???Manager();
+
+ // Return the prepared instance
+ return $managerInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A general Manager class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 BaseManager extends BaseCitySystem implements Manageable, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Region manager
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 Region 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 RegionManager extends BaseManager implements ManageableRegion {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $managerInstance An instance of a ManageableRegion class
+ */
+ public final static function createRegionManager () {
+ // Get new instance
+ $managerInstance = new RegionManager();
+
+ // Get database wrapper
+ $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('region_info_db_wrapper_class');
+
+ // And set it here
+ $managerInstance->setWrapperInstance($wrapperInstance);
+
+ // Return the prepared instance
+ return $managerInstance;
+ }
+
+ /**
+ * Checks whether the current user has already founded a region
+ *
+ * @return $isFounded Whether the current user has already founded a region
+ */
+ public function ifUserHasCreatedRegion () {
+ // Check if the currently set user has already founded a region
+ $isFounded = $this->getWrapperInstance()->ifUserHasCreatedRegion();
+
+ // Return result
+ return $isFounded;
+ }
+
+ /**
+ * Checks whether the given region name is already taken
+ *
+ * @para $regionName Name of region
+ * @return $isTaken Whether the given region name is already taken
+ */
+ public function ifRegionNameExists ($regionName) {
+ // Check if the given region name is taken
+ $isTaken = $this->getWrapperInstance()->ifRegionExists($regionName);
+
+ // Return result
+ return $isTaken;
+ }
+
+ /**
+ * Founds the first region. A dummy region will also be created
+ *
+ * @return $resultInstance Found result after creating it
+ */
+ public function createFirstRegion () {
+ // Dummy name
+ // @TODO Move to language system
+ $regionName = 'Region 1';
+
+ // Some pre-checks
+ assert(!$this->ifUserHasCreatedRegion());
+ assert(!$this->ifRegionNameExists($regionName));
+
+ // First region can now be created
+ $this->getWrapperInstance()->createRegionByName($regionName);
+
+ // Then try to find it
+ assert($this->ifRegionNameExists($regionName));
+
+ // Get result instance
+ $resultInstance = $this->getResultInstance();
+
+ // And return it
+ return $resultInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A region map manager
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 Region 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 RegionMapManager extends BaseManager implements ManageableRegionMap {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $managerInstance An instance of a ManageableRegion class
+ */
+ public final static function createRegionMapManager () {
+ // Get new instance
+ $managerInstance = new RegionMapManager();
+
+ // Get database wrapper
+ $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('region_map_db_wrapper_class');
+
+ // And set it here
+ $managerInstance->setWrapperInstance($wrapperInstance);
+
+ // Return the prepared instance
+ return $managerInstance;
+ }
+
+ /**
+ * Creates a map, if not found yet, for given result which should contain
+ * data about the region in question
+ *
+ * @param $resultInstance Region result instance
+ * @return void
+ */
+ public function createRegionMapByResult (SearchableResult $resultInstance) {
+ die('!ok');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? menu class for Ship-Simu
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 City???Menu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public final static function createCity???Menu () {
+ // Get a new instance
+ $menuInstance = new City???Menu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A Confirm menu class for City
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityConfirmMenu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public static final function createCityConfirmMenu () {
+ // Get a new instance
+ $menuInstance = new CityConfirmMenu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A menu class for City
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHomeMenu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public static final function createCityHomeMenu () {
+ // Get a new instance
+ $menuInstance = new CityHomeMenu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A menu class for City
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityLoginAreaMenu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public static final function createCityLoginAreaMenu () {
+ // Get a new instance
+ $menuInstance = new CityLoginAreaMenu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A LoginFailed menu class for City
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityLoginFailedMenu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public static final function createCityLoginFailedMenu () {
+ // Get a new instance
+ $menuInstance = new CityLoginFailedMenu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A menu class for City
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityLoginMenu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public static final function createCityLoginMenu () {
+ // Get a new instance
+ $menuInstance = new CityLoginMenu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A menu class for City
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityLogoutMenu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public static final function createCityLogoutMenu () {
+ // Get a new instance
+ $menuInstance = new CityLogoutMenu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A menu class for City registration
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityRegisterMenu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public static final function createCityRegisterMenu () {
+ // Get a new instance
+ $menuInstance = new CityRegisterMenu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A Status menu class for City
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityStatusMenu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public static final function createCityStatusMenu () {
+ // Get a new instance
+ $menuInstance = new CityStatusMenu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A menu class for City
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityGovernmentFailedAreaMenu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public static final function createCityGovernmentFailedAreaMenu () {
+ // Get a new instance
+ $menuInstance = new CityGovernmentFailedAreaMenu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A user registration class specially for City
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityRegistration extends BaseRegistration implements UserRegister {
+ /**
+ * Hashed password
+ */
+ private $hashedPassword = '';
+
+ /**
+ * Elements for criteria
+ */
+ private $criteriaElements = array(
+ 'username',
+ 'pass_hash',
+ 'email' => 'email1',
+ 'surname',
+ 'family',
+ 'street',
+ 'zip',
+ 'city',
+ 'icq',
+ 'jabber',
+ 'yahoo',
+ 'aol',
+ 'msn',
+ 'birth_day',
+ 'birth_month',
+ 'birth_year'
+ );
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Create a new instance
+ *
+ * @return $registrationInstance An instance of this registration class
+ */
+ public static final function createCityRegistration () {
+ // Get a new instance
+ $registrationInstance = new CityRegistration();
+
+ // Initialize the filter chains
+ $registrationInstance->initFilterChains();
+
+ // And return it
+ return $registrationInstance;
+ }
+
+ /**
+ * Encrypt given request key or throw an exception if key was not found in
+ * request
+ *
+ * @param $requestKey Key in request class
+ * @return void
+ */
+ public function encryptPassword ($requestKey) {
+ // Check if password is found in request
+ if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
+ // So encrypt the password and store it for later usage in
+ // the request:
+
+ // 1.: Get the plain password
+ $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
+
+ // 2. Get a crypto helper and hash the password
+ $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword);
+
+ // 3. Store the hash back in request
+ $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
+ }
+ }
+
+ /**
+ * Perform things like informing assigned affilates about new registration
+ * before registration
+ *
+ * @return void
+ * @todo Maybe add more things to perform
+ */
+ public function doPreRegistration () {
+ // First run all pre filters
+ $this->executePreFilters();
+ }
+
+ /**
+ * Registers the new user account by insterting the request data into the
+ * database and paying some start credits or throw exceptions if this fails
+ *
+ * @return void
+ * @todo Maybe add more things to perform
+ */
+ public function registerNewUser () {
+ // Get a user database wrapper
+ $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('user_db_wrapper_class');
+
+ // Use this instance to insert the whole registration instance
+ $wrapperInstance->insertRegistrationObject($this);
+ }
+
+ /**
+ * Perform things like notifying partner websites after registration is done
+ *
+ * @return void
+ * @todo Maybe add more things to perform
+ */
+ public function doPostRegistration () {
+ // First run all post filters
+ $this->executePostFilters();
+ }
+
+ /**
+ * Do the action which is required after all registration steps are done.
+ * This can be a simple redirect to another webpage or displaying a message
+ * to the user. Or this can be a login step into the newly created account.
+ *
+ * @return void
+ */
+ public function doPostAction () {
+ // Get an action instance from our factory
+ $actionInstance = ObjectFactory::createObjectByConfiguredName('post_registration_class');
+
+ // Execute the action
+ $actionInstance->execute($this->getRequestInstance(), $this->getResponseInstance());
+ }
+
+ /**
+ * Adds registration elements to a given dataset instance
+ *
+ * @param $criteriaInstance An instance of a StoreableCriteria class
+ * @param $requestInstance An instance of a Requestable class
+ * @return void
+ */
+ public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) {
+ // Default is unconfirmed!
+ $configEntry = 'user_status_unconfirmed';
+
+ // Is the confirmation process entirely disabled?
+ if ($this->getConfigInstance()->getConfigEntry('confirm_email_enabled') === 'N') {
+ // No confirmation of email needed
+ $configEntry = 'user_status_confirmed';
+ } // END - if
+
+ // Add a lot elements to the dataset criteria
+ foreach ($this->criteriaElements as $alias => $element) {
+ // Do we have an alias?
+ if (is_string($alias)) {
+ // Yes, so use it
+ $criteriaInstance->addCriteria($alias, $this->getRequestInstance()->getRequestElement($element));
+
+ // Debug message
+ //* DEBUG: */ $this->debugOutput('ALIAS: alias='.$alias.',element='.$element.'='.$this->getRequestInstance()->getRequestElement($element));
+ } else {
+ // No, default entry
+ $criteriaInstance->addCriteria($element, $this->getRequestInstance()->getRequestElement($element));
+
+ // Debug message
+ //* DEBUG: */ $this->debugOutput('DEFAULT: element='.$element.'='.$this->getRequestInstance()->getRequestElement($element));
+ }
+
+ // Is this a guest account?
+ if ((($element == 'username') || ($alias == 'username')) && ($this->getRequestInstance()->getRequestElement($element) == $this->getConfigInstance()->getConfigEntry('guest_login_user'))) {
+ // Yes, then set the config entry to guest status
+ $configEntry = 'user_status_guest';
+ } // END - if
+ } // END - foreach
+
+ // Mark the username as unique key
+ $criteriaInstance->setUniqueKey(UserDatabaseWrapper::DB_COLUMN_USERNAME);
+
+ // Add account status as configured
+ $criteriaInstance->addConfiguredCriteria(UserDatabaseWrapper::DB_COLUMN_USER_STATUS, $configEntry);
+
+ // Include registration timestamp
+ $criteriaInstance->addCriteria('registered', date('Y-m-d H:i:s', time()));
+ }
+}
+
+//
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A command resolver for console commands
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityConsoleCommandResolver extends BaseCommandResolver implements CommandResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to "CityConsole"
+ $this->setClassPrefix('city_console');
+ }
+
+ /**
+ * Creates an instance of a CityConsole command resolver with a given default command
+ *
+ * @param $commandName The default command we shall execute
+ * @param $applicationInstance 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 static final function createCityConsoleCommandResolver ($commandName, ManageableApplication $applicationInstance) {
+ // Create the new instance
+ $resolverInstance = new CityConsoleCommandResolver();
+
+ // 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($applicationInstance);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A command resolver for HTML commands
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlCommandResolver extends BaseCommandResolver implements CommandResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to "CityHtml"
+ $this->setClassPrefix('city_html');
+ }
+
+ /**
+ * Creates an instance of a CityHtml command resolver with a given default command
+ *
+ * @param $commandName The default command we shall execute
+ * @param $applicationInstance 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 static final function createCityHtmlCommandResolver ($commandName, ManageableApplication $applicationInstance) {
+ // Create the new instance
+ $resolverInstance = new CityHtmlCommandResolver();
+
+ // 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($applicationInstance);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A resolver for resolving controllers locally
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to 'city_console'
+ $this->setClassPrefix('city_console');
+ }
+
+ /**
+ * Creates an instance of a resolver class with a given controller
+ *
+ * @param $controllerName The controller we shall resolve
+ * @param $applicationInstance An instance of a manageable application helper class
+ * @return $resolverInstance The prepared controller resolver instance
+ * @throws EmptyVariableException Thrown if default controller is not set
+ * @throws InvalidControllerException Thrown if default controller is invalid
+ */
+ public static final function createCityConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
+ // Create the new instance
+ $resolverInstance = new CityConsoleControllerResolver();
+
+ // Is the variable $controllerName set and the controller is valid?
+ if (empty($controllerName)) {
+ // Then thrown an exception here
+ throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
+ // Invalid controller found
+ throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
+ }
+
+ // Set the application instance
+ $resolverInstance->setApplicationInstance($applicationInstance);
+
+ // Set controller name
+ $resolverInstance->setControllerName($controllerName);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A resolver for resolving controllers locally
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlControllerResolver extends BaseControllerResolver implements ControllerResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to 'city_html'
+ $this->setClassPrefix('city_html');
+ }
+
+ /**
+ * Creates an instance of a resolver class with a given controller
+ *
+ * @param $controllerName The controller we shall resolve
+ * @param $applicationInstance An instance of a manageable application helper class
+ * @return $resolverInstance The prepared controller resolver instance
+ * @throws EmptyVariableException Thrown if default controller is not set
+ * @throws InvalidControllerException Thrown if default controller is invalid
+ */
+ public static final function createCityHtmlControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
+ // Create the new instance
+ $resolverInstance = new CityHtmlControllerResolver();
+
+ // Is the variable $controllerName set and the controller is valid?
+ if (empty($controllerName)) {
+ // Then thrown an exception here
+ throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
+ // Invalid controller found
+ throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
+ }
+
+ // Set the application instance
+ $resolverInstance->setApplicationInstance($applicationInstance);
+
+ // Set controller name
+ $resolverInstance->setControllerName($controllerName);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A resolver for resolving controllers locally
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityImageControllerResolver extends BaseControllerResolver implements ControllerResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to 'image'
+ $this->setClassPrefix('image');
+ }
+
+ /**
+ * Creates an instance of a resolver class with a given controller
+ *
+ * @param $controllerName The controller we shall resolve
+ * @param $applicationInstance An instance of a manageable application helper class
+ * @return $resolverInstance The prepared controller resolver instance
+ * @throws EmptyVariableException Thrown if default controller is not set
+ * @throws InvalidControllerException Thrown if default controller is invalid
+ */
+ public static final function createCityImageControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
+ // Create the new instance
+ $resolverInstance = new CityImageControllerResolver();
+
+ // Is the variable $controllerName set and the controller is valid?
+ if (empty($controllerName)) {
+ // Then thrown an exception here
+ throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
+ // Invalid controller found
+ throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
+ }
+
+ // Set the application instance
+ $resolverInstance->setApplicationInstance($applicationInstance);
+
+ // Set controller name
+ $resolverInstance->setControllerName($controllerName);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A active city state class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityActiveState extends BaseCityState implements Stateable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructo
+ parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('active');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $stateInstance An instance of a Stateable class
+ */
+ public static final function createCityActiveState () {
+ // Get new instance
+ $stateInstance = new CityActiveState();
+
+ // Get city instance and set 'active' flag
+ CityDaemonFactory::createCityDaemonInstance()->enableIsActive();
+
+ // Return the prepared instance
+ return $stateInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A ??? city state class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 City???State extends BaseCityState implements Stateable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('!!!');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $stateInstance An instance of a Stateable class
+ */
+ public final static function createCity???State () {
+ // Get new instance
+ $stateInstance = new City???State();
+
+ // Return the prepared instance
+ return $stateInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A general city state class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 BaseCityState extends BaseState {
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+ /**
+ * Validates whether the state is 'active' or throws an exception if
+ * it is every other state.
+ *
+ * @return void
+ * @throws UnexpectedStateException If the state is not 'active'
+ */
+ public function validateCityStateIsActive () {
+ // Just compare it...
+ if (!$this instanceof CityActiveState) {
+ // Throw the exception
+ throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
+ } // END - if
+ }
+
+ /**
+ * Validates whether the state is 'init' or throws an exception if
+ * it is every other state.
+ *
+ * @return void
+ * @throws UnexpectedStateException If the state is not 'virgin'
+ */
+ public function validateCityStateIsInit () {
+ // Just compare it...
+ if (!$this instanceof CityInitState) {
+ // Throw the exception
+ throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
+ } // END - if
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A init city state class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityInitState extends BaseCityState implements Stateable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructo
+ parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('init');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $stateInstance An instance of a Stateable class
+ */
+ public static final function createCityInitState () {
+ // Get new instance
+ $stateInstance = new CityInitState();
+
+ // Return the prepared instance
+ return $stateInstance;
+ }
+
+ /**
+ * Executes the state with given Executor instance
+ *
+ * @param $executorInstance An instance of a Executor class
+ * @return void
+ */
+ public function executeState (Executor $executorInstance) {
+ // Initialize the daemon
+ $executorInstance->initializeDaemon($this);
+ }
+
+ /**
+ * Change the state to 'active' when the city daemon has initialized all
+ * tasks, queues, etc.
+ *
+ * @return void
+ */
+ public function citySimulationIsActivated () {
+ // Create the new state instance
+ CityStateFactory::createCityStateInstanceByName('active');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A general CityTask class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 BaseCityTask extends BaseTask {
+ /**
+ * An instance of a city
+ */
+ private $cityInstance = NULL;
+
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+ /**
+ * Getter for city instance
+ *
+ * @return $cityInstance An instance of a city city
+ */
+ public final function getCityInstance () {
+ return $this->cityInstance;
+ }
+
+ /**
+ * Setter for city instance
+ *
+ * @param $cityInstance An instance of a city city
+ * @return void
+ */
+ protected final function setCityInstance (CityHelper $cityInstance) {
+ $this->cityInstance = $cityInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A BuildingGrowth city daemon-task
+ *
+ * @author Roland Haeder <webmaster@ship-simu.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.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 CityDaemonBuildingGrowthTask extends BaseCityTask implements Taskable, Visitable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $taskInstance An instance of a Visitable class
+ */
+ public final static function createCityDaemonBuildingGrowthTask () {
+ // Get new instance
+ $taskInstance = new CityDaemonBuildingGrowthTask();
+
+ // Return the prepared instance
+ return $taskInstance;
+ }
+
+ /**
+ * Accepts the visitor to process the visitor
+ *
+ * @param $visitorInstance An instance of a Visitor class
+ * @return void
+ * @todo Maybe visit some sub-objects
+ */
+ public function accept (Visitor $visitorInstance) {
+ // Visit this task
+ $visitorInstance->visitTask($this);
+ }
+
+ /**
+ * Executes the task
+ *
+ * @return void
+ * @todo 0% done
+ */
+ public function executeTask () {
+ $this->partialStub('Unimplemented task.');
+ }
+
+ /**
+ * Shuts down the task
+ *
+ * @return void
+ * @todo 0% done
+ */
+ public function doShutdown () {
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A ??? city daemon-task
+ *
+ * @author Roland Haeder <webmaster@ship-simu.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.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 CityDaemon???Task extends BaseTask implements Taskable, Visitable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $taskInstance An instance of a Visitable class
+ */
+ public final static function createCityDaemon???Task () {
+ // Get new instance
+ $taskInstance = new CityDaemon???Task();
+
+ // Return the prepared instance
+ return $taskInstance;
+ }
+
+ /**
+ * Accepts the visitor to process the visitor
+ *
+ * @param $visitorInstance An instance of a Visitor class
+ * @return void
+ * @todo Maybe visit some sub-objects
+ */
+ public function accept (Visitor $visitorInstance) {
+ // Visit this task
+ $visitorInstance->visitTask($this);
+ }
+
+ /**
+ * Executes the task
+ *
+ * @return void
+ * @todo 0% done
+ */
+ public function executeTask () {
+ $this->partialStub('Unimplemented task.');
+ }
+
+ /**
+ * Shuts down the task
+ *
+ * @return void
+ * @todo 0% done
+ */
+ public function doShutdown () {
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A HouseholdGrowth city daemon-task
+ *
+ * @author Roland Haeder <webmaster@ship-simu.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.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 CityDaemonHouseholdGrowthTask extends BaseCityTask implements Taskable, Visitable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $taskInstance An instance of a Visitable class
+ */
+ public final static function createCityDaemonHouseholdGrowthTask () {
+ // Get new instance
+ $taskInstance = new CityDaemonHouseholdGrowthTask();
+
+ // Return the prepared instance
+ return $taskInstance;
+ }
+
+ /**
+ * Accepts the visitor to process the visitor
+ *
+ * @param $visitorInstance An instance of a Visitor class
+ * @return void
+ * @todo Maybe visit some sub-objects
+ */
+ public function accept (Visitor $visitorInstance) {
+ // Visit this task
+ $visitorInstance->visitTask($this);
+ }
+
+ /**
+ * Executes the task
+ *
+ * @return void
+ * @todo 0% done
+ */
+ public function executeTask () {
+ $this->partialStub('Unimplemented task.');
+ }
+
+ /**
+ * Shuts down the task
+ *
+ * @return void
+ * @todo 0% done
+ */
+ public function doShutdown () {
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A map expander task for the daemon
+ *
+ * @author Roland Haeder <webmaster@ship-simu.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.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 CityDaemonMapExpanderTask extends BaseCityTask implements Taskable, Visitable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $taskInstance An instance of a Visitable class
+ */
+ public final static function createCityDaemonMapExpanderTask () {
+ // Get new instance
+ $taskInstance = new CityDaemonMapExpanderTask();
+
+ // Get city daemon instance
+ $cityInstance = CityDaemonFactory::createCityDaemonInstance();
+
+ // Set it here for "caching" it
+ $taskInstance->setCityInstance($cityInstance);
+
+ // Return the prepared instance
+ return $taskInstance;
+ }
+
+ /**
+ * Accepts the visitor to process the visitor
+ *
+ * @param $visitorInstance An instance of a Visitor class
+ * @return void
+ * @todo Maybe visit some sub-objects
+ */
+ public function accept (Visitor $visitorInstance) {
+ // Visit this task
+ $visitorInstance->visitTask($this);
+ }
+
+ /**
+ * Executes the task
+ *
+ * @return void
+ * @todo ~ 10% done
+ */
+ public function executeTask () {
+ // Get daemon instance
+ $cityInstance = $this->getCityInstance();
+
+ // Is there at least one map to expand?
+ if ($cityInstance->isMapPendingExpansion()) {
+ // Expand the map
+ $cityInstance->expandMaps();
+ } // END - if
+ }
+
+ /**
+ * Shuts down the task
+ *
+ * @return void
+ * @todo 0% done
+ */
+ public function doShutdown () {
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
+ }
+}
+
+// [EOF]
+?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- *
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 ???Action extends BaseCityAction implements Commandable, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this action
- *
- * @param $resolverInstance An instance of an action resolver
- * @return $actionInstance An instance of this action class
- */
- public final static function create???Action (ActionResolver $resolverInstance) {
- // Get a new instance
- $actionInstance = new ???Action();
-
- // Return the instance
- return $actionInstance;
- }
-
- /**
- * Executes the 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) {
- // Call parent execute method
- parent::execute($requestInstance, $responseInstance);
-
- // Add your code here
- $this->partialStub("You have to implement me.");
- }
-
- /**
- * 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
- * @todo Add some filters here
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Call parent addExtraFilters method
- parent::addExtraFilters($controllerInstance, $requestInstance);
-
- // Unfinished method
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A general action class for city
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 BaseCityAction extends BaseAction {
- /**
- * Protected constructor
- *
- * @param $className Name of the class
- * @return void
- */
- protected function __construct ($className) {
- // Call parent constructor
- parent::__construct($className);
- }
-
- /**
- * Executes the 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
- */
- protected function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Add code here executed with every action
- }
-
- /**
- * 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
- * @todo Add some filters here
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Unfinished method
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * An action for the city map page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 HtmlCityLoginCityMapAction extends BaseCityAction implements Commandable, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this action
- *
- * @param $resolverInstance An instance of an action resolver
- * @return $actionInstance An instance of this action class
- */
- public static final function createHtmlCityLoginCityMapAction (ActionResolver $resolverInstance) {
- // Get a new instance
- $actionInstance = new HtmlCityLoginCityMapAction();
-
- // Set the resolver instance
- $actionInstance->setResolverInstance($resolverInstance);
-
- // Return the instance
- return $actionInstance;
- }
-
- /**
- * Executes the 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 Maybe add more here?
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Call parent execute method
- parent::execute($requestInstance, $responseInstance);
- }
-
- /**
- * 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
- * @todo Add some filters here
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Unfinished method
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * An action for the government page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 HtmlCityLoginGovernmentAction extends BaseCityAction implements Commandable, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this action
- *
- * @param $resolverInstance An instance of an action resolver
- * @return $actionInstance An instance of this action class
- */
- public static final function createHtmlCityLoginGovernmentAction (ActionResolver $resolverInstance) {
- // Get a new instance
- $actionInstance = new HtmlCityLoginGovernmentAction();
-
- // Set the resolver instance
- $actionInstance->setResolverInstance($resolverInstance);
-
- // Return the instance
- return $actionInstance;
- }
-
- /**
- * Executes the 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 Maybe add more here?
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Call parent execute method
- parent::execute($requestInstance, $responseInstance);
- }
-
- /**
- * 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
- * @todo Add some filters here
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Unfinished method
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * An action for logout
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 HtmlCityLoginLogoutAction extends BaseCityAction implements Commandable, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this action
- *
- * @param $resolverInstance An instance of an action resolver
- * @return $actionInstance An instance of this action class
- */
- public static final function createHtmlCityLoginLogoutAction (ActionResolver $resolverInstance) {
- // Get a new instance
- $actionInstance = new HtmlCityLoginLogoutAction();
-
- // Set the resolver instance
- $actionInstance->setResolverInstance($resolverInstance);
-
- // Return the instance
- return $actionInstance;
- }
-
- /**
- * Executes the 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) {
- // Call parent execute method
- parent::execute($requestInstance, $responseInstance);
-
- // Add your code here
- }
-
- /**
- * 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) {
- // Check for user status by default
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * An action for profile (editing) page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 HtmlCityLoginProfileAction extends BaseCityAction implements Commandable, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this action
- *
- * @param $resolverInstance An instance of an action resolver
- * @return $actionInstance An instance of this action class
- */
- public static final function createHtmlCityLoginProfileAction (ActionResolver $resolverInstance) {
- // Get a new instance
- $actionInstance = new HtmlCityLoginProfileAction();
-
- // Set the resolver instance
- $actionInstance->setResolverInstance($resolverInstance);
-
- // Return the instance
- return $actionInstance;
- }
-
- /**
- * Executes the 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) {
- // Call parent execute method
- parent::execute($requestInstance, $responseInstance);
-
- // Add your code here...
- }
-
- /**
- * 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
- * @todo Add some filters here
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Check for user status by default
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * An action for status problem handling
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 HtmlCityLoginStatusProblemAction extends BaseCityAction implements Commandable, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this action
- *
- * @param $resolverInstance An instance of an action resolver
- * @return $actionInstance An instance of this action class
- */
- public static final function createHtmlCityLoginStatusProblemAction (ActionResolver $resolverInstance) {
- // Get a new instance
- $actionInstance = new HtmlCityLoginStatusProblemAction();
-
- // Set the resolver instance
- $actionInstance->setResolverInstance($resolverInstance);
-
- // Return the instance
- return $actionInstance;
- }
-
- /**
- * Executes the 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) {
- // Call parent method
- parent::execute($requestInstance, $responseInstance);
-
- // Add your code
- }
-
- /**
- * 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
- * @todo Add some filters here
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Check for user status by default
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * An action for the welcome page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 HtmlCityLoginWelcomeAction extends BaseCityAction implements Commandable, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this action
- *
- * @param $resolverInstance An instance of an action resolver
- * @return $actionInstance An instance of this action class
- */
- public static final function createHtmlCityLoginWelcomeAction (ActionResolver $resolverInstance) {
- // Get a new instance
- $actionInstance = new HtmlCityLoginWelcomeAction();
-
- // Set the resolver instance
- $actionInstance->setResolverInstance($resolverInstance);
-
- // Return the instance
- return $actionInstance;
- }
-
- /**
- * Executes the 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 Maybe add more here?
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Call parent execute method
- parent::execute($requestInstance, $responseInstance);
- }
-
- /**
- * 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
- * @todo Add some filters here
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Unfinished method
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A hub-node class for the '???' mode
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 Simulation???CityDaemon extends BaseCity implements CityHelper, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this hub-node class
- *
- * @param $requestInstance An instance of a Requestable class
- * @return $nodeInstance An instance of this hub-node class
- */
- public final static function createSimulation???CityDaemon (Requestable $requestInstance) {
- // Get a new instance
- $nodeInstance = new Simulation???CityDaemon();
-
- // Set the request instance
- $nodeInstance->setRequestInstance($requestInstance);
-
- // Return the instance
- return $nodeInstance;
- }
-
- /**
- * Method to "bootstrap" the node. This step does also apply provided
- * command-line arguments stored in the request instance. The regular node
- * should communicate with the bootstrap-nodes at this point.
- *
- * @return void
- * @todo Implement this method
- */
- public function doBootstrapping () {
- // Call generic (parent) bootstrapping method first
- parent::doGenericBootstrapping();
- $this->partialStub('Please implement this method.');
- }
-
- /**
- * Initializes hub-specific queues
- *
- * @return void
- * @todo Implement this method
- */
- public function initQueues () {
- $this->partialStub('Please implement this method.');
- }
-
- /**
- * Add some node-specific filters
- *
- * @return void
- */
- public function addExtraCityFilters () {
- // Add some filters here
- }
-
- /**
- * Adds extra tasks to the given handler for this node
- *
- * @param $handlerInstance An instance of a HandleableTask class
- * @return void
- * @todo 0% done
- */
- public function addExtraTasks (HandleableTask $handlerInstance) {
- $this->partialStub('Please add some tasks or empty this method.');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A general City class
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 BaseCityDaemon extends BaseCitySystem implements Updateable, AddableCriteria {
- /**
- * City types
- */
- const CITY_TYPE_DEFAULT = 'default';
- const CITY_TYPE_TESTING = 'testing';
-
- /**
- * Whether this City is active (default: FALSE)
- */
- private $isActive = FALSE;
-
- /**
- * Protected constructor
- *
- * @param $className Name of the class
- * @return void
- */
- protected function __construct ($className) {
- // Call parent constructor
- parent::__construct($className);
-
- // Get a wrapper instance
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class');
-
- // Set it here
- $this->setWrapperInstance($wrapperInstance);
-
- // Get a crypto instance
- $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
-
- // Set it here
- $this->setCryptoInstance($cryptoInstance);
-
- // Add own instance to registry
- Registry::getRegistry()->addInstance('city', $this);
-
- // Init state which sets the state to 'init'
- $this->initState();
- }
-
- /**
- * Initializes the City's state which sets it to 'init'
- *
- * @return void
- */
- private function initState() {
- // Get the state factory and create the initial state.
- CityStateFactory::createCityStateInstanceByName('init');
- }
-
- /**
- * Outputs the console teaser. This should only be executed on startup or
- * full restarts. This method generates some space around the teaser.
- *
- * @return void
- */
- public function outputConsoleTeaser () {
- // Get the app instance (for shortening our code)
- $app = $this->getApplicationInstance();
-
- // Output all lines
- self::createDebugInstance(__CLASS__)->debugOutput(' ');
- self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - ' . $this->getRequestInstance()->getRequestElement('mode') . ' daemon starting');
- self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2015 City Developer Team');
- self::createDebugInstance(__CLASS__)->debugOutput(' ');
- self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.');
- self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain');
- self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.');
- self::createDebugInstance(__CLASS__)->debugOutput(' ');
- }
-
- /**
- * Adds City data elements to a given dataset instance
- *
- * @param $criteriaInstance An instance of a storeable criteria
- * @param $requestInstance An instance of a Requestable class
- * @return void
- */
- public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) {
- // Make sure the request instance is set as it is not optional.
- assert($requestInstance instanceof Requestable);
-
- // Add City number and type
- $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID , 1);
- $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_MODE, $requestInstance->getRequestElement('mode'));
-
- // Add the City id
- $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID, $this->getCityId());
-
- // Add the session id if acquired
- if ($this->getSessionId() != '') {
- $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_SESSION_ID, $this->getSessionId());
- } // END - if
-
- // Add the private key if acquired
- if ($this->getPrivateKey() != '') {
- $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY, base64_encode($this->getPrivateKey()));
- $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $this->getPrivateKeyHash());
- } // END - if
-
- // Add own external and internal addresses as UNLs
- $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL, CityTools::determineOwnInternalAddress());
- $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL, CityTools::determineOwnExternalAddress());
- }
-
- /**
- * Updates a given field with new value
- *
- * @param $fieldName Field to update
- * @param $fieldValue New value to store
- * @return void
- * @throws DatabaseUpdateSupportException If this class does not support database updates
- * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem
- */
- public function updateDatabaseField ($fieldName, $fieldValue) {
- // Unfinished
- $this->partialStub('Unfinished!');
- return;
-
- // Get a critieria instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
- // Add search criteria
- $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
- $searchInstance->setLimit(1);
-
- // Now get another criteria
- $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class');
-
- // Add criteria entry which we shall update
- $updateInstance->addCriteria($fieldName, $fieldValue);
-
- // Add the search criteria for searching for the right entry
- $updateInstance->setSearchInstance($searchInstance);
-
- // Set wrapper class name
- $updateInstance->setWrapperConfigEntry('user_db_wrapper_class');
-
- // Remember the update in database result
- $this->getResultInstance()->add2UpdateQueue($updateInstance);
- }
-
- /**
- * Activates the City by doing some final preparation and setting
- * $CityIsActive to TRUE.
- *
- * @param $requestInstance A Requestable class
- * @param $responseInstance A Responseable class
- * @return void
- */
- public function activateCityDaemon (Requestable $requestInstance, Responseable $responseInstance) {
- // Get the controller here
- $controllerInstance = Registry::getRegistry()->getInstance('controller');
-
- // Run all filters for the City activation
- $controllerInstance->executeActivationFilters($requestInstance, $responseInstance);
-
- // Make sure the city's state is 'init'
- $this->getStateInstance()->validateCityStateIsInit();
-
- // ----------------------- Last step from here ------------------------
- // Activate the city daemon. This is ALWAYS the last step in this method
- /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getStateInstance()->__toString() . ' - Activating ...');
- $this->getStateInstance()->citySimulationIsActivated();
- // ---------------------- Last step until here ------------------------
- }
-
- /**
- * Getter for isActive attribute
- *
- * @return $isActive Whether the City is active
- */
- public final function isCityActive () {
- return $this->isActive;
- }
-
- /**
- * Enables (default) or disables isActive flag
- *
- * @param $isActive Whether the City is active
- * @return void
- */
- public final function enableIsActive ($isActive = TRUE) {
- $this->isActive = (bool) $isActive;
- }
-
- /**
- * Updates/refreshes City data (e.g. status).
- *
- * @return void
- * @todo Find more to do here
- */
- public function updateCityData () {
- // Set some dummy configuration entries, e.g. city_status
- $this->getConfigInstance()->setConfigEntry('city_status', $this->getStateInstance()->getStateName());
- }
-
- /**
- * Adds all required elements from given array into data set instance
- *
- * @param $dataSetInstance An instance of a StoreableCriteria class
- * @param $CityData An array with valid City data
- * @return void
- */
- public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $cityData) {
- // Add all data the array provides
- foreach (CityInformationDatabaseWrapper::getAllElements() as $element) {
- // Is the element there?
- if (isset($cityData[$element])) {
- // Add it
- $dataSetInstance->addCriteria($element, $cityData[$element]);
- } else {
- // Output warning message
- /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY[' . __METHOD__ . ':' . __LINE__ . ']: addArrayToDataSet(): Element ' . $element . ' not found in CityData array.');
- }
- } // END - foreac
- }
-
- /**
- * Initializes the city daemon
- *
- * @return void
- * @todo 0% done
- */
- public function bootstrapInitCityDaemon () {
- $this->partialStub('Please add something here.');
- }
-
- /**
- * Checks whether at least one map requires expansion
- *
- * @return $requiresExpansion Whether a map requires expansion
- */
- public function isMapPendingExpansion () {
- // Get sections manager
- $sectionsInstance = ManagerFactory::createManagerByType('city_sections');
-
- // Call it's method and return value
- return $sectionsInstance->isMapPendingExpansion();
- }
-
- /**
- * Expands any found map that requires expansion
- *
- * @return void
- */
- public function expandMaps () {
- // Get sections manager
- $sectionsInstance = ManagerFactory::createManagerByType('city_sections');
-
- // Call it's method and return value
- $sectionsInstance->expandMaps();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * The default city daemon
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 SimulationDefaultCityDaemon extends BaseCityDaemon implements CityHelper, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this hub-node class
- *
- * @param $requestInstance An instance of a Requestable class
- * @return $nodeInstance An instance of this hub-node class
- */
- public static final function createSimulationDefaultCityDaemon (Requestable $requestInstance) {
- // Get a new instance
- $nodeInstance = new SimulationDefaultCityDaemon();
-
- // Set the request instance
- $nodeInstance->setRequestInstance($requestInstance);
-
- // Return the instance
- return $nodeInstance;
- }
-
- /**
- * Method to "bootstrap" the city simulation. This step does also apply
- * provided command-line arguments stored in the request instance.
- *
- * @return void
- * @todo Implement this method
- */
- public function doBootstrapping () {
- $this->partialStub();
- }
-
- /**
- * Add some node-specific filters
- *
- * @return void
- */
- public function addExtraCityFilters () {
- // Get the application instance from registry
- $applicationInstance = Registry::getRegistry()->getInstance('app');
-
- // Get the controller from the application
- $controllerInstance = $applicationInstance->getControllerInstance();
-
- // Foo task
- // @TODO $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('city_foo_task_filter'));
-
- // @TODO Add some filters here
- $this->partialStub('Add some filters here.');
- }
-
- /**
- * Adds extra tasks to the given handler for this node
- *
- * @param $handlerInstance An instance of a HandleableTask class
- * @return void
- * @todo 0% done
- */
- public function addExtraTasks (HandleableTask $handlerInstance) {
- $this->partialStub('Please add some tasks or empty this method.');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A ???
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 ??? extends BaseFrameworkSystem implements === {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $!!!Instance An instance of a === class
- */
- public final static function create??? () {
- // Get new instance
- $!!!Instance = new ???();
-
- // Return the prepared instance
- return $!!!Instance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A general ??? class
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 Base??? extends BaseCitySystem {
- /**
- * Protected constructor
- *
- * @param $className Name of the class
- * @return void
- */
- protected function __construct ($className) {
- // Call parent constructor
- parent::__construct($className);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A general city (simulation) system class
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 BaseCitySystem extends BaseFrameworkSystem {
- // Exception codes
- const EXCEPTION_UNSUPPORTED_ERROR_HANDLER = 0x900;
- const EXCEPTION_BASE64_ENCODING_NOT_MODULO_4 = 0x901;
-
- // Message status codes
- const MESSAGE_STATUS_CODE_OKAY = 'OKAY';
-
- /**
- * An instance of a city
- */
- private $cityInstance = NULL;
-
- /**
- * Protected constructor
- *
- * @param $className Name of the class
- * @return void
- */
- protected function __construct ($className) {
- // Call parent constructor
- parent::__construct($className);
- }
-
- /**
- * Getter for city instance
- *
- * @return $cityInstance An instance of a city city
- */
- public final function getCityInstance () {
- return $this->cityInstance;
- }
-
- /**
- * Setter for city instance
- *
- * @param $cityInstance An instance of a city city
- * @return void
- */
- protected final function setCityInstance (CityHelper $cityInstance) {
- $this->cityInstance = $cityInstance;
- }
-
- /**
- * "Getter" for a printable state name
- *
- * @return $stateName Name of the city's state in a printable format
- */
- public final function getPrintableState () {
- // Default is 'null'
- $stateName = 'null';
-
- // Get the state instance
- $stateInstance = $this->getStateInstance();
-
- // Is it an instance of Stateable?
- if ($stateInstance instanceof Stateable) {
- // Then use that state name
- $stateName = $stateInstance->getStateName();
- } // END - if
-
- // Return result
- return $stateName;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A command for the 'daemon' routine
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityConsoleDaemonCommand 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 static final function createCityConsoleDaemonCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new CityConsoleDaemonCommand();
-
- // 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 ~10% done?
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get a registry and the application instance from it
- $applicationInstance = Registry::getRegistry()->getInstance('app');
-
- /*
- * ----------------------- Bootstrapping phase ------------------------
- * Try to bootstrap the city and pass the request instance to it for
- * extra arguments which mostly override config entries or enable special
- * features within the hub (none is ready at this development stage)
- */
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...');
- $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance);
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.');
-
- // Get city instance
- $cityInstance = CityDaemonFactory::createCityDaemonInstance();
-
- // Add some city-specific filters, e.g. announcement
- $cityInstance->addExtraCityFilters();
-
- /*
- * -------------------------- City activation --------------------------
- * Activates the city daemon by doing some final preparation steps and
- * setting the attribute $cityIsActive to TRUE.
- */
- $cityInstance->activateCityDaemon($requestInstance, $responseInstance);
-
- // Get task handler instance
- $handlerInstance = Registry::getRegistry()->getInstance('task_handler');
-
- // Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---');
-
- /*
- * ----------------------------- Main loop ----------------------------
- * This is the main loop. Queried calls should come back here very fast
- * so the whole application runs on nice speed. This while-loop goes
- * until the application is no longer active or all tasks are killed.
- */
- while (($cityInstance->isCityActive()) && ($handlerInstance->hasTasksLeft())) {
- // Handle all tasks here
- $handlerInstance->handleTasks();
- } // END - while
-
- // Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---');
- }
-
- /**
- * 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
- * @todo ~10% done
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Add pre filters
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_php_requirements_filter'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_initializer_filter'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_welcome_teaser_filter'));
-
- // Add bootstrap filters
- $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_bootstrap_init_daemon_filter'));
-
- // Add city activation filters
- $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_activation_task_handler_initializer_filter'));
-
- // Add shutdown filters, you may want to shutdown the task handler as last one.
- $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_shutdown_task_handler_filter'));
-
- // This is the last generic shutdown filter
- $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_shutdown_city_filter'));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A command for guest logins
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlCityGuestLoginCommand extends BaseCommand implements Commandable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this command and sets the resolver instance
- *
- * @param $resolverInstance An instance of a command resolver
- * @return $commandInstance The created command instance
- */
- public static final function createCityHtmlCityGuestLoginCommand (CommandResolver $resolverInstance) {
- // Get a new instance
- $commandInstance = new CityHtmlCityGuestLoginCommand();
-
- // Set the resolver instance
- $commandInstance->setResolverInstance($resolverInstance);
-
- // Return the prepared instance
- return $commandInstance;
- }
-
- /**
- * Executes the 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // First get a GuestLogin instance
- $loginInstance = ObjectFactory::createObjectByConfiguredName('guest_login_class');
-
- // First set request and response instance
- $loginInstance->setRequestInstance($requestInstance);
-
- // Encrypt the password
- $loginInstance->encryptPassword('passwd');
-
- // Do the login here
- $loginInstance->doLogin($requestInstance, $responseInstance);
-
- // Was the login fine? Then redirect here
- if ($loginInstance->ifLoginWasSuccessfull()) {
- // Try to redirect here
- try {
- // Redirect...
- $responseInstance->redirectToConfiguredUrl('app_login');
-
- // Exit here
- exit();
- } catch (FrameworkException $e) {
- // Something went wrong here!
- $responseInstance->addFatalMessage($e->getMessage());
- }
- } else {
- // Attach error message to the response
- $responseInstance->addFatalMessage('failed_user_login');
- }
- }
-
- /**
- * 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
- * @todo Add more filters
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Add username verifier filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_guest_verifier_filter'));
-
- // Add password verifier filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('passwd_guest_verifier_filter'));
-
- // Add CAPTCHA verifier code
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_guest_verifier_filter'));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command for the city map
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlCityMapCommand extends BaseCommand implements Commandable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this command and sets the resolver instance
- *
- * @param $resolverInstance An instance of a command resolver
- * @return $commandInstance The created command instance
- */
- public static final function createCityHtmlCityMapCommand (CommandResolver $resolverInstance) {
- // Get a new instance
- $commandInstance = new CityHtmlCityMapCommand();
-
- // Set the resolver instance
- $commandInstance->setResolverInstance($resolverInstance);
-
- // Return the prepared instance
- return $commandInstance;
- }
-
- /**
- * Executes the 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // First get a UserRegistration instance
- $managerInstance = ManagerFactory::createManagerByType('city');
-
- // First set request and response instance
- $managerInstance->setRequestInstance($requestInstance);
- $managerInstance->setResponseInstance($responseInstance);
-
- // Is there already a city the user has founded?
- if ($managerInstance->isCityAlreadyFounded()) {
- // Found 2nd,3rd,... city
- $managerInstance->foundNewCity();
- } else {
- // Found first city
- $managerInstance->foundFirstCity();
- }
-
- // Redirect or login after registration
- $managerInstance->doPostAction();
- }
-
- /**
- * 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
- * @todo Add some more pre/post filters to the controller
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Add user auth filter (we don't need an update of the user here because it will be redirected)
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter'));
-
- // Validate user status ('confirmed' no guest)
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
-
- // Check if city name is already used
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_name_verifier_filter'));
-
- // Validate ...
- //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_validator_filter'));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command for registration form (POST) handling
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlCityRegisterCommand extends BaseCommand implements Commandable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this command and sets the resolver instance
- *
- * @param $resolverInstance An instance of a command resolver
- * @return $commandInstance The created command instance
- */
- public static final function createCityHtmlCityRegisterCommand (CommandResolver $resolverInstance) {
- // Get a new instance
- $commandInstance = new CityHtmlCityRegisterCommand();
-
- // Set the resolver instance
- $commandInstance->setResolverInstance($resolverInstance);
-
- // Return the prepared instance
- return $commandInstance;
- }
-
- /**
- * Executes the 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // First get a UserRegistration instance
- $registerInstance = ObjectFactory::createObjectByConfiguredName('user_registration_class');
-
- // First set request and response instance
- $registerInstance->setRequestInstance($requestInstance);
- $registerInstance->setResponseInstance($responseInstance);
-
- // Encrypt the password
- $registerInstance->encryptPassword('pass1');
-
- // Do things before registration
- $registerInstance->doPreRegistration();
-
- // Register the new user
- $registerInstance->registerNewUser();
-
- /*
- * Do things after registration like notifying partner pages or queueing
- * them for notification
- */
- $registerInstance->doPostRegistration();
-
- // Redirect or login after registration
- $registerInstance->doPostAction();
- }
-
- /**
- * 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
- * @todo Add some more pre/post filters to the controller
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Validate email address (if configured: check on double email addresses)
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_validator_filter'));
-
- // Validate username and check if it does not exist
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_validator_filter'));
-
- // Validate if username is "guest" and not taken
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_is_guest_filter'));
-
- // Validate if password is set
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_validator_filter'));
-
- // Check if rules where accepted
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('rules_accepted_filter'));
-
- // Validate CAPTCHA input
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_register_verifier_filter'));
-
- // Validate birthday
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('birthday_register_verifier_filter'));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command for user login
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlCityUserLoginCommand extends BaseCommand implements Commandable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this command and sets the resolver instance
- *
- * @param $resolverInstance An instance of a command resolver
- * @return $commandInstance The created command instance
- */
- public static final function createCityHtmlCityUserLoginCommand (CommandResolver $resolverInstance) {
- // Get a new instance
- $commandInstance = new CityHtmlCityUserLoginCommand();
-
- // Set the resolver instance
- $commandInstance->setResolverInstance($resolverInstance);
-
- // Return the prepared instance
- return $commandInstance;
- }
-
- /**
- * Executes the 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // First get a UserLogin instance
- $loginInstance = ObjectFactory::createObjectByConfiguredName('user_login_class');
-
- // First set request and response instance
- $loginInstance->setRequestInstance($requestInstance);
-
- // Encrypt the password
- $loginInstance->encryptPassword('pass');
-
- // Do the login here
- $loginInstance->doLogin($requestInstance, $responseInstance);
-
- // Was the login fine? Then redirect here
- if ($loginInstance->ifLoginWasSuccessfull()) {
- // Try to redirect here
- try {
- // Redirect...
- $responseInstance->redirectToConfiguredUrl('app_login');
-
- // Exit here
- exit();
- } catch (FrameworkException $e) {
- // Something went wrong here!
- $responseInstance->addFatalMessage($e->getMessage());
- }
- } else {
- // Attach error message to the response
- $responseInstance->addFatalMessage('failed_user_login');
- }
- }
-
- /**
- * 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
- * @todo Add more filters
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Which login type do we have?
- switch ($this->getConfigInstance()->getConfigEntry('login_type')) {
- case 'username': // Login via username
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter'));
- break;
-
- case 'email': // Login via email
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_verifier_filter'));
- break;
-
- default: // Wether username or email is set
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_email_verifier_filter'));
- break;
- }
-
- // Password verifier filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_verifier_filter'));
-
- // Add filter for CAPTCHA
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_user_verifier_filter'));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command for the confirmation link handling
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlConfirmCommand 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 static final function createCityHtmlConfirmCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new CityHtmlConfirmCommand();
-
- // 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get the application instance
- $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
-
- // Prepare a template instance
- $templateInstance = $this->prepareTemplateInstance($applicationInstance);
-
- // Assign application data with template engine
- $templateInstance->assignApplicationData($applicationInstance);
-
- // Assign base URL
- $templateInstance->assignConfigVariable('base_url');
-
- // Load the master template
- $masterTemplate = $applicationInstance->buildMasterTemplateName();
-
- // Load header template
- $templateInstance->loadCodeTemplate('header');
-
- // Compile and assign it with a variable
- $templateInstance->compileTemplate();
- $templateInstance->assignTemplateWithVariable('header', 'header');
-
- // Load footer template
- $templateInstance->loadCodeTemplate('footer');
-
- // Compile and assign it with a variable
- $templateInstance->compileTemplate();
- $templateInstance->assignTemplateWithVariable('footer', 'footer');
-
- // Load the home template
- $templateInstance->loadCodeTemplate('confirm_link');
-
- // Assign the home template with the master template as a content ... ;)
- $templateInstance->assignTemplateWithVariable('confirm_link', 'main_content');
-
- // Load the master template
- $templateInstance->loadCodeTemplate($masterTemplate);
-
- // Set title
- $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_confirm_link_title'));
-
- // Get user instance
- try {
- $userInstance = Registry::getRegistry()->getInstance('user');
- } catch (NullPointerException $e) {
- // Not found user, e.g. when the user is somehow invalid
- $responseInstance->redirectToConfiguredUrl('html_cmd_user_is_null');
- }
-
- // Set username
- $templateInstance->assignVariable('username', $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USERNAME));
-
- // Construct the menu in every command. We could do this in BaseCommand class. But this means
- // *every* command has a navigation system and that is want we don't want.
- $menuInstance = ObjectFactory::createObjectByConfiguredName('confirm_menu_class', array($applicationInstance));
-
- // Render the menu
- $menuInstance->renderMenu();
-
- // Transfer it to the template engine instance
- $menuInstance->transferContentToTemplateEngine($templateInstance);
-
- /*
- * ... and all variables. This should be merged together in a pattern
- * to make things easier. A cache mechanism should be added between
- * these two calls to cache compiled templates.
- */
- $templateInstance->compileVariables();
-
- // Get the content back from the template engine and put it in response class
- $templateInstance->transferToResponse($responseInstance);
- }
-
- /**
- * 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) {
- // Empty for now
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command for the form processor
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlDoFormCommand 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 static final function createCityHtmlDoFormCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new CityHtmlDoFormCommand();
-
- // 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Should never be reached...
- $this->debugBackTrace('This should never be reached.');
- }
-
- /**
- * 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) {
- // Empty for now
- }
-
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command for the 'main' routine
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlHomeCommand 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 static final function createCityHtmlHomeCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new CityHtmlHomeCommand();
-
- // 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // This command doesn't handle any POST requests, so only handle get request
- if ($requestInstance->isPostRequestMethod()) {
- // Don't handle this here
- $response->sendRequestMethodNotAllowed();
-
- // Bail out
- exit();
- } // END - if
-
- /*
- * This is a generic HTML request, this means that a regular page with
- * header, menu, content and footer shall be send to the client.
- */
- $this->sendGenericGetResponse($requestInstance, $responseInstance);
- }
-
- /**
- * 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
- * @todo 0% done
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Add pre filters
- //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_php_requirements_filter'));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command for the login area (member/gamer area)
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlLoginAreaCommand extends BaseCommand implements Commandable {
- /**
- * Name of the action
- */
- private $actionName = '';
-
- /**
- * 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 static final function createCityHtmlLoginAreaCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new CityHtmlLoginAreaCommand();
-
- // Set the application instance
- $commandInstance->setResolverInstance($resolverInstance);
-
- // Load general data like user status and such
- $commandInstance->prepareCommand();
-
- // Return the prepared instance
- return $commandInstance;
- }
-
- /**
- * Prepares some general data which shall be displayed on every page
- *
- * @return void
- * @todo Add some stuff here: Some personal data, app/game related data
- */
- protected function prepareCommand () {
- }
-
- /**
- * 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get the action instance from registry
- $actionInstance = Registry::getRegistry()->getInstance('action');
-
- // Do we have an action here?
- if ($actionInstance instanceof PerformableAction) {
- // Execute the action (shall not output anything, see below why)
- $actionInstance->execute($requestInstance, $responseInstance);
- } // END - if
-
- // Get the application instance
- $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
-
- // Prepare a template instance
- $templateInstance = $this->prepareTemplateInstance($applicationInstance);
-
- // Assign base URL
- $templateInstance->assignConfigVariable('base_url');
-
- // Assign all the application's data with template variables
- $templateInstance->assignApplicationData($applicationInstance);
-
- // Load the master template
- $masterTemplate = $applicationInstance->buildMasterTemplateName();
-
- // Load header template
- $templateInstance->loadCodeTemplate('header');
-
- // Compile and assign it with a variable
- $templateInstance->compileTemplate();
- $templateInstance->assignTemplateWithVariable('header', 'header');
-
- // Load footer template
- $templateInstance->loadCodeTemplate('footer');
-
- // Compile and assign it with a variable
- $templateInstance->compileTemplate();
- $templateInstance->assignTemplateWithVariable('footer', 'footer');
-
- // Load the matching template
- $templateInstance->loadCodeTemplate('action_' . $this->actionName);
-
- // Assign the template with the master template as a content ... ;)
- $templateInstance->compileTemplate();
- $templateInstance->assignTemplateWithVariable('action_' . $this->actionName, 'login_content');
-
- // Load main template
- $templateInstance->loadCodeTemplate('login_main');
-
- // Assign the main template with the master template as a content ... ;)
- $templateInstance->compileTemplate();
- $templateInstance->assignTemplateWithVariable('login_main', 'main_content');
-
- // Load the master template
- $templateInstance->loadCodeTemplate($masterTemplate);
-
- // Set title
- $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage($this->actionName . '_title'));
-
- // Construct the menu in every command. We could do this in BaseCommand class. But this means
- // *every* command has a navigation system and that is want we don't want.
- $menuInstance = ObjectFactory::createObjectByConfiguredName('login_area_menu_class', array($applicationInstance));
-
- // Render the menu
- $menuInstance->renderMenu();
-
- // Transfer it to the template engine instance
- $menuInstance->transferContentToTemplateEngine($templateInstance);
-
- /*
- * ... and all variables. This should be merged together in a pattern
- * to make things easier. A cache mechanism should be added between
- * these two calls to cache compiled templates.
- */
- $templateInstance->compileVariables();
-
- // Get the content back from the template engine and put it in response class
- $templateInstance->transferToResponse($responseInstance);
- }
-
- /**
- * Adds extra filters to the given controller instance. An corresponding action class must now exist!
- *
- * @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) {
- // Default is no action
- $actionInstance = NULL;
-
- // Get registry
- $registryInstance = Registry::getRegistry();
-
- // Get our application instance from the registry
- $applicationInstance = $registryInstance->getInstance('application');
-
- // Default action is the one from configuration
- $this->actionName = $this->convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . $this->getConfigInstance()->getConfigEntry('login_default_action');
-
- // Get "action" from request
- $actReq = $requestInstance->getRequestElement('action');
-
- // Do we have a "action" parameter set?
- if ((is_string($actReq)) && (!empty($actReq))) {
- // Then use it with prefix
- $this->actionName = $this->convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . $actReq;
- } // END - if
-
- // Get application instance
- $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
-
- // Get a resolver
- $actionResolver = HtmlActionResolver::createHtmlActionResolver($this->actionName, $applicationInstance);
-
- // Resolve the action
- $actionInstance = $actionResolver->resolveAction();
-
- // Add more action-specific filters
- $actionInstance->addExtraFilters($controllerInstance, $requestInstance);
-
- // Remember this action in registry
- Registry::getRegistry()->addInstance('action', $actionInstance);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command for the login form
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlLoginCommand extends BaseCommand implements Commandable, Registerable {
- /**
- * 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 static final function createCityHtmlLoginCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new CityHtmlLoginCommand();
-
- // 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Set request instance as extra instance
- Registry::getRegistry()->addInstance('extra', $this);
-
- // Get the application instance
- $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
-
- // Prepare a template instance
- $templateInstance = $this->prepareTemplateInstance($applicationInstance);
-
- // Assign application data with template engine
- $templateInstance->assignApplicationData($applicationInstance);
-
- // Assign base URL
- $templateInstance->assignConfigVariable('base_url');
-
- // Load the master template
- $masterTemplate = $applicationInstance->buildMasterTemplateName();
-
- // Load header template
- $templateInstance->loadCodeTemplate('header');
-
- // Compile and assign it with a variable
- $templateInstance->compileTemplate();
- $templateInstance->assignTemplateWithVariable('header', 'header');
-
- // Load footer template
- $templateInstance->loadCodeTemplate('footer');
-
- // Compile and assign it with a variable
- $templateInstance->compileTemplate();
- $templateInstance->assignTemplateWithVariable('footer', 'footer');
-
- // Load the home template
- $templateInstance->loadCodeTemplate('login_form');
-
- // Assign the home template with the master template as a content ... ;)
- $templateInstance->assignTemplateWithVariable('login_form', 'main_content');
-
- // Load the master template
- $templateInstance->loadCodeTemplate($masterTemplate);
-
- // Set title
- $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_login_title'));
-
- // Construct the menu in every command. We could do this in BaseCommand class. But this means
- // *every* command has a navigation system and that is want we don't want.
- $menuInstance = ObjectFactory::createObjectByConfiguredName('login_menu_class', array($applicationInstance));
-
- // Render the menu
- $menuInstance->renderMenu();
-
- // Transfer it to the template engine instance
- $menuInstance->transferContentToTemplateEngine($templateInstance);
-
- /*
- * ... and all variables. This should be merged together in a pattern
- * to make things easier. A cache mechanism should be added between
- * these two calls to cache compiled templates.
- */
- $templateInstance->compileVariables();
-
- // Get the content back from the template engine and put it in response class
- $templateInstance->transferToResponse($responseInstance);
- }
-
- /**
- * 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) {
- // Empty for now
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command for the login failed page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlLoginFailedCommand 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 static final function createCityHtmlLoginFailedCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new CityHtmlLoginFailedCommand();
-
- // 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get the application instance
- $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
-
- // Prepare a template instance
- $templateInstance = $this->prepareTemplateInstance($applicationInstance);
-
- // Assign application data with template engine
- $templateInstance->assignApplicationData($applicationInstance);
-
- // Load the master template
- $masterTemplate = $applicationInstance->buildMasterTemplateName();
-
- // Load header template
- $templateInstance->loadCodeTemplate('header');
-
- // Compile and assign it with a variable
- $templateInstance->compileTemplate();
- $templateInstance->assignTemplateWithVariable('header', 'header');
-
- // Load footer template
- $templateInstance->loadCodeTemplate('footer');
-
- // Compile and assign it with a variable
- $templateInstance->compileTemplate();
- $templateInstance->assignTemplateWithVariable('footer', 'footer');
-
- // Load the login_failed template
- $templateInstance->loadCodeTemplate('login_failed');
-
- // Assign the login_failed template with the master template as a content ... ;)
- $templateInstance->assignTemplateWithVariable('login_failed', 'main_content');
-
- // Load the master template
- $templateInstance->loadCodeTemplate($masterTemplate);
-
- // Set title
- $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('login_failed_title'));
-
- // Assign base URL
- $templateInstance->assignConfigVariable('base_url');
-
- // Construct the menu in every command. We could do this in BaseCommand class. But this means
- // *every* command has a navigation system and that is want we don't want.
- $menuInstance = ObjectFactory::createObjectByConfiguredName('login_failed_menu_class', array($applicationInstance));
-
- // Render the menu
- $menuInstance->renderMenu();
-
- // Transfer it to the template engine instance
- $menuInstance->transferContentToTemplateEngine($templateInstance);
-
- /*
- * ... and all variables. This should be merged together in a pattern
- * to make things easier. A cache mechanism should be added between
- * these two calls to cache compiled templates.
- */
- $templateInstance->compileVariables();
-
- // Get the content back from the template engine and put it in response class
- $templateInstance->transferToResponse($responseInstance);
- }
-
- /**
- * 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) {
- // Empty for now
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command for logout
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlLogoutCommand 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 static final function createCityHtmlLogoutCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new CityHtmlLogoutCommand();
-
- // 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get an auth instance for checking and updating the auth cookies
- $authInstance = ObjectFactory::createObjectByConfiguredName('auth_method_class', array($responseInstance));
-
- // Set request instance
- $authInstance->setRequestInstance($requestInstance);
-
- // Destroy the auth data
- $authInstance->destroyAuthData();
-
- // Redirect to "logout done" page
- $responseInstance->redirectToConfiguredUrl('logout_done');
-
- // Exit here
- exit();
- }
-
- /**
- * 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) {
- // Empty for now
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command for registration handling
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlRegisterCommand extends BaseCommand implements Commandable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this command and sets the resolver instance
- *
- * @param $resolverInstance An instance of a command resolver
- * @return $commandInstance The created command instance
- */
- public static final function createCityHtmlRegisterCommand (CommandResolver $resolverInstance) {
- // Get a new instance
- $commandInstance = new CityHtmlRegisterCommand();
-
- // Set the resolver instance
- $commandInstance->setResolverInstance($resolverInstance);
-
- // Return the prepared instance
- return $commandInstance;
- }
-
- /**
- * Executes the 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- /*
- * This is a generic HTML request, this means that a regular page with
- * header, menu, content and footer shall be send to the client.
- */
- $this->sendGenericGetResponse($requestInstance, $responseInstance, '_form');
- }
-
- /**
- * 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
- * @todo Add some more pre/post filters to the controller
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command class for resending the confirmation link
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlResendLinkCommand 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 static final function createCityHtmlResendLinkCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new CityHtmlResendLinkCommand();
-
- // 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get user instance from registry
- $userInstance = Registry::getRegistry()->getInstance('user');
-
- // Get an application instance
- $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
-
- // Get a RNG instance (Random Number Generator)
- $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
-
- // Generate a pseudo-random string
- $randomString = $rngInstance->randomString(255);
-
- // Get a crypto instance
- $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
-
- // Hash and encrypt the string
- $hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString));
-
- // Update the user class
- $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, $hashedString);
-
- // Re-set config entry to mailer engine
- $this->getConfigInstance()->setConfigEntry('html_template_class', $this->getConfigInstance()->getConfigEntry('mail_template_class'));
-
- // Prepare the template engine
- $templateInstance = $this->prepareTemplateInstance($applicationInstance);
-
- // Assign the application data with the template engine
- $templateInstance->assignApplicationData($applicationInstance);
-
- // Get a mailer class
- $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance, $applicationInstance, 'resend_link'));
-
- // Set this mailer in our template engine
- $templateInstance->setMailerInstance($mailerInstance);
-
- // Add template variables we shall get
- $mailerInstance->addConfigTemplateVariable('base_url');
- $mailerInstance->addConfigTemplateVariable('admin_email');
- $mailerInstance->addValueTemplateVariable('confirm_hash');
- $mailerInstance->addValueTemplateVariable('username');
- $mailerInstance->addValueTemplateVariable('email');
-
- // Add the value instance for the confirmation hash
- $mailerInstance->addValueInstance('confirm_hash', $userInstance);
- $mailerInstance->addValueInstance('username', $userInstance);
- $mailerInstance->addValueInstance('email', $userInstance);
-
- // Add the recipient
- $mailerInstance->addRecipientByUserInstance($userInstance);
-
- // Use subject line from template
- $mailerInstance->useSubjectFromTemplate();
-
- // Send the email out
- $mailerInstance->deliverEmail($responseInstance);
-
- // Send out notification to admin (depends on settings)
- $mailerInstance->sendAdminNotification($responseInstance);
- }
-
- /**
- * 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) {
- // Filter for checking if account is unconfirmed
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter'));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A command for the login failed page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 HtmlLogoutDoneCommand 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 static final function createHtmlLogoutDoneCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new HtmlLogoutDoneCommand();
-
- // 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get the application instance
- $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
-
- // Prepare a template instance
- $templateInstance = $this->prepareTemplateInstance($applicationInstance);
-
- // Assign application data
- $templateInstance->assignApplicationData($applicationInstance);
-
- // Load the master template
- $masterTemplate = $applicationInstance->buildMasterTemplateName();
-
- // Load header template
- $templateInstance->loadCodeTemplate('header');
-
- // Compile and assign it with a variable
- $templateInstance->compileTemplate();
- $templateInstance->assignTemplateWithVariable('header', 'header');
-
- // Load footer template
- $templateInstance->loadCodeTemplate('footer');
-
- // Compile and assign it with a variable
- $templateInstance->compileTemplate();
- $templateInstance->assignTemplateWithVariable('footer', 'footer');
-
- // Load the logout_done template
- $templateInstance->loadCodeTemplate('logout_done');
-
- // Assign the logout_done template with the master template as a content ... ;)
- $templateInstance->assignTemplateWithVariable('logout_done', 'main_content');
-
- // Load the master template
- $templateInstance->loadCodeTemplate($masterTemplate);
-
- // Set title
- $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('logout_done_title'));
-
- // Assign base URL
- $templateInstance->assignConfigVariable('base_url');
-
- // Construct the menu in every command. We could do this in BaseCommand class. But this means
- // *every* command has a navigation system and that is want we don't want.
- $menuInstance = ObjectFactory::createObjectByConfiguredName('logout_menu_class', array($applicationInstance));
-
- // Render the menu
- $menuInstance->renderMenu();
-
- // Transfer it to the template engine instance
- $menuInstance->transferContentToTemplateEngine($templateInstance);
-
- /*
- * ... and all variables. This should be merged together in a pattern
- * to make things easier. A cache mechanism should be added between
- * these two calls to cache compiled templates.
- */
- $templateInstance->compileVariables();
-
- // Get the content back from the template engine and put it in response class
- $templateInstance->transferToResponse($responseInstance);
- }
-
- /**
- * 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) {
- // Empty for now
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * The default controller with news for e.g. home or news page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityConsoleDefaultNewsController extends BaseController implements Controller {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Init additional filter chains
- foreach (array('bootstrap', 'activation','shutdown') as $filterChain) {
- $this->initFilterChain($filterChain);
- } // END - foreach
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $controllerInstance A prepared instance of this class
- */
- public static final function createCityConsoleDefaultNewsController (CommandResolver $resolverInstance) {
- // Create the instance
- $controllerInstance = new CityConsoleDefaultNewsController();
-
- // 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);
- }
-
- /**
- * Add a city activation filter
- *
- * @param $filterInstance A Filterable class
- * @return void
- */
- public function addActivationFilter (Filterable $filterInstance) {
- $this->addFilter('activation', $filterInstance);
- }
-
- /**
- * Executes all city activation filters
- *
- * @param $requestInstance A Requestable class
- * @param $responseInstance A Responseable class
- * @return void
- */
- public function executeActivationFilters (Requestable $requestInstance, Responseable $responseInstance) {
- $this->executeFilters('activation', $requestInstance, $responseInstance);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * Controller for confirmation link
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlConfirmController 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
- * @todo Add some filters to this controller
- */
- public static final function createCityHtmlConfirmController (CommandResolver $resolverInstance) {
- // Create the instance
- $controllerInstance = new CityHtmlConfirmController();
-
- // Set the command resolver
- $controllerInstance->setResolverInstance($resolverInstance);
-
- // Add filters for handling confirmation code and username
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('confirm_code_verifier_filter'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_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) {
- // Generic pre-post command execution
- $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * The default controller with news for e.g. home or news page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlDefaultNewsController extends BaseController implements Controller {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Init additional filter chains
- foreach (array('shutdown') as $filterChain) {
- $this->initFilterChain($filterChain);
- } // END - foreach
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $controllerInstance A prepared instance of this class
- */
- public static final function createCityHtmlDefaultNewsController (CommandResolver $resolverInstance) {
- // Create the instance
- $controllerInstance = new CityHtmlDefaultNewsController();
-
- // 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) {
- // Generic pre-post command execution
- $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * Controller for login form with password reminder and maybe enabled
- * "guest-login" button
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlLoginController extends BaseController implements Controller {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Init additional filter chains
- foreach (array('shutdown') as $filterChain) {
- $this->initFilterChain($filterChain);
- } // END - foreach
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $controllerInstance A prepared instance of this class
- * @todo Add some filters to this controller
- */
- public static final function createCityHtmlLoginController (CommandResolver $resolverInstance) {
- // Create the instance
- $controllerInstance = new CityHtmlLoginController();
-
- // Set the command resolver
- $controllerInstance->setResolverInstance($resolverInstance);
-
- // 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) {
- // Generic pre-post command execution
- $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A controller for login failed page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlLoginFailedController extends BaseController implements Controller {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Init additional filter chains
- foreach (array('shutdown') as $filterChain) {
- $this->initFilterChain($filterChain);
- } // END - foreach
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $controllerInstance A prepared instance of this class
- */
- public static final function createCityHtmlLoginFailedController (CommandResolver $resolverInstance) {
- // Create the instance
- $controllerInstance = new CityHtmlLoginFailedController();
-
- // Set the command resolver
- $controllerInstance->setResolverInstance($resolverInstance);
-
- // 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
- $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
- // This request was valid! :-D
- $requestInstance->requestIsValid();
-
- // Execute the command
- $commandInstance->execute($requestInstance, $responseInstance);
-
- // Flush the response out
- $responseInstance->flushBuffer();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * The default controller for logout page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- * @todo This controller shall still provide some headlines for sidebars
- *
- * 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 CityHtmlLogoutController extends BaseController implements Controller {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Init additional filter chains
- foreach (array('shutdown') as $filterChain) {
- $this->initFilterChain($filterChain);
- } // END - foreach
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $controllerInstance A prepared instance of this class
- */
- public static final function createCityHtmlLogoutController (CommandResolver $resolverInstance) {
- // Create the instance
- $controllerInstance = new CityHtmlLogoutController();
-
- // Set the command resolver
- $controllerInstance->setResolverInstance($resolverInstance);
-
- // Add user auth filter (we don't need an update of the user here because it will be redirected)
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter'));
-
- // User status filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_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
- $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
- // This request was valid! :-D
- $requestInstance->requestIsValid();
-
- // Execute the command
- $commandInstance->execute($requestInstance, $responseInstance);
-
- // Flush the response out
- $responseInstance->flushBuffer();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * Controller for logout done page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlLogoutDoneController extends BaseController implements Controller {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Init additional filter chains
- foreach (array('shutdown') as $filterChain) {
- $this->initFilterChain($filterChain);
- } // END - foreach
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $controllerInstance A prepared instance of this class
- * @todo Add some filters to this controller
- */
- public static final function createCityHtmlLogoutDoneController (CommandResolver $resolverInstance) {
- // Create the instance
- $controllerInstance = new CityHtmlLogoutDoneController();
-
- // Set the command resolver
- $controllerInstance->setResolverInstance($resolverInstance);
-
- // 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) {
- // Generic pre-post command execution
- $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * Controller for register form
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlRegisterController extends BaseController implements Controller {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Init additional filter chains
- foreach (array('shutdown') as $filterChain) {
- $this->initFilterChain($filterChain);
- } // END - foreach
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $controllerInstance A prepared instance of this class
- * @todo Add some filters to this controller
- */
- public static final function createCityHtmlRegisterController (CommandResolver $resolverInstance) {
- // Create the instance
- $controllerInstance = new CityHtmlRegisterController();
-
- // Set the command resolver
- $controllerInstance->setResolverInstance($resolverInstance);
-
- // 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) {
- // Generic pre-post command execution
- $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A controller for handling sent forms
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlDoFormController extends BaseController implements Controller {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Init additional filter chains
- foreach (array('shutdown') as $filterChain) {
- $this->initFilterChain($filterChain);
- } // END - foreach
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a resolver class
- * @return $controllerInstance A prepared instance of this class
- */
- public static final function createCityHtmlDoFormController (CommandResolver $resolverInstance) {
- // Create the instance
- $controllerInstance = new CityHtmlDoFormController();
-
- // Set resolver instance
- $controllerInstance->setResolverInstance($resolverInstance);
-
- // We need the controller instance in resolver class so set it here
- $resolverInstance->setControllerInstance($controllerInstance);
-
- // 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 "form action"
- $formAction = $requestInstance->getRequestElement('form');
-
- // Get command instance from resolver
- $commandInstance = $this->getResolverInstance()->resolveCommand($formAction);
-
- // Add more filters by the command
- $commandInstance->addExtraFilters($this, $requestInstance);
-
- // Try to run the pre filters, if auth exceptions come through redirect here
- try {
- // Run the pre filters
- $this->executePreFilters($requestInstance, $responseInstance);
- } catch (UserAuthorizationException $e) {
- // Redirect to main page
- $responseInstance->redirectToConfiguredUrl('login_failed');
-
- // Exit here
- exit();
- }
-
- /*
- * Is the request still valid? Post filters shall only be executed of
- * the request is valid
- */
- if ($requestInstance->isRequestValid()) {
- // Execute the command
- $commandInstance->execute($requestInstance, $responseInstance);
-
- // Execute *very* generic ppost filters
- $this->executePostFilters($requestInstance, $responseInstance);
- } // END - if
-
- // Flush the buffer out
- $responseInstance->flushBuffer();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * Controller for login area with news
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlLoginAreaController extends BaseController implements Controller {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Init additional filter chains
- foreach (array('shutdown') as $filterChain) {
- $this->initFilterChain($filterChain);
- } // END - foreach
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $controllerInstance A prepared instance of this class
- * @todo Add some morer filters to this controller
- */
- public static final function createCityHtmlLoginAreaController (CommandResolver $resolverInstance) {
- // Create the instance
- $controllerInstance = new CityHtmlLoginAreaController();
-
- // Set the command resolver
- $controllerInstance->setResolverInstance($resolverInstance);
-
- // User auth filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter'));
-
- // User update filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_filter'));
-
- // News fetcher filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter'));
-
- // News proccess/display-preparation
- $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) {
- /*
- * Generic execute of the command: pre and post filters with redirect
- * but request becomes valid after pre-filters run.
- */
- $this->genericHanleRequestLoginAreaFailedRedirect($requestInstance, $responseInstance);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A database wrapper for city informations
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityInformationDatabaseWrapper extends BaseDatabaseWrapper implements CityInformationWrapper, Registerable {
- // Constants for database table names
- const DB_TABLE_CITY_INFORMATION = 'city_data';
-
- // Constants for database column names
- const DB_COLUMN_CITY_ID = 'city_id';
- const DB_COLUMN_CITY_MODE = 'city_mode';
- const DB_COLUMN_CITY_NAME = 'city_name';
- const DB_COLUMN_CITY_USER_ID = 'city_user_id';
- const DB_COLUMN_CITY_REGION_ID = 'city_region_id';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this database wrapper by a provided user class
- *
- * @return $wrapperInstance An instance of the created wrapper class
- */
- public static final function createCityInformationDatabaseWrapper () {
- // Get a new instance
- $wrapperInstance = new CityInformationDatabaseWrapper();
-
- // Set (primary!) table name
- $wrapperInstance->setTableName(self::DB_TABLE_CITY_INFORMATION);
-
- // Return the instance
- return $wrapperInstance;
- }
-
- /**
- * Checks whether there is an entry for given city instance
- *
- * @param $cityInstance An instance of a CityHelper class
- * @return $isFound Whether a city id has been found for this city
- */
- public function ifCityDataIsFound (CityHelper $cityInstance) {
- // Now get a search criteria instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
- // Search for the city number one which is hard-coded the default
- $searchInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID , 1);
- $searchInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_MODE, $cityInstance->getRequestInstance()->getRequestElement('mode'));
- $searchInstance->setLimit(1);
-
- // Get a result back
- $resultInstance = $this->doSelectByCriteria($searchInstance);
-
- // Set result instance in city instance
- $cityInstance->setResultInstance($resultInstance);
-
- // Is it valid?
- $isFound = $resultInstance->next();
-
- // Return it
- return $isFound;
- }
-
- /**
- * 'Registers' a new city id along with data provided in the city instance.
- * This may sound confusing but avoids double code very nicely...
- *
- * @param $cityInstance A city instance
- * @param $requestInstance An instance of a Requestable class
- * @return void
- */
- public function registerCityId (BaseCityDaemon $cityInstance, Requestable $requestInstance) {
- // Get a dataset instance
- $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_CITY_INFORMATION));
-
- // Set the primary key
- $dataSetInstance->setUniqueKey(self::DB_COLUMN_CITY_ID);
-
- // Add registration elements to the dataset
- $cityInstance->addElementsToDataSet($dataSetInstance, $requestInstance);
-
- // "Insert" this dataset instance completely into the database
- $this->queryInsertDataSet($dataSetInstance);
- }
-
- /**
- * Removes non-public data from given array.
- *
- * @param $data An array with possible non-public data that needs to be removed.
- * @return $data A cleaned up array with only public data.
- */
- public function removeNonPublicDataFromArray(array $data) {
- // Currently call only inner method
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...');
- $data = parent::removeNonPublicDataFromArray($data);
-
- // Return cleaned data
- return $data;
- }
-
- /**
- * Checks whether the user has already founded a city
- *
- * @return $hasFounded Whether the user has already founded a city
- */
- public function ifUserHasFoundedCity () {
- // Get user instance
- $userInstance = Registry::getRegistry()->getInstance('user');
-
- // Now get a search criteria instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
- // Search for user's cities
- $searchInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_USER_ID, $userInstance->getUserId());
-
- // Get a result back
- $resultInstance = $this->doSelectByCriteria($searchInstance);
-
- // Get city manager instance
- $managerInstance = ManagerFactory::createManagerByType('city');
-
- // Set result instance
- $managerInstance->setResultInstance($resultInstance);
-
- // Has it been founded?
- $hasFounded = $resultInstance->next();
-
- // Return result
- return $hasFounded;
- }
-
- /**
- * Checks whether the given city name is taken
- *
- * @para $cityName Name of city
- * @return $isTaken Whether the given city name is taken
- */
- public function ifCityExists ($cityName) {
- // Now get a search criteria instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
- // Search for the city number one which is hard-coded the default
- $searchInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_NAME, $cityName);
- $searchInstance->setLimit(1);
-
- // Get a result back
- $resultInstance = $this->doSelectByCriteria($searchInstance);
-
- // Check it
- $isTaken = $resultInstance->valid();
-
- // Get manger instance
- $managerInstance = ManagerFactory::createManagerByType('city');
-
- // Set result instance
- $managerInstance->setResultInstance($resultInstance);
-
- // Return result
- return $isTaken;
- }
-
- /**
- * Creates a city from given request
- *
- * @para $requestInstance An instance of a Requestable class
- * @return void
- */
- public function createCityByRequest (Requestable $requestInstance) {
- // Make sure all required fields are there
- assert($requestInstance->isRequestElementSet(self::DB_COLUMN_CITY_NAME));
- assert($requestInstance->isRequestElementSet(self::DB_COLUMN_CITY_REGION_ID));
-
- // Get city name (to save some calls)
- $cityName = $requestInstance->getRequestElement(self::DB_COLUMN_CITY_NAME);
-
- // Make sure the city name is not taken yet
- assert(!$this->ifCityExists($cityName));
-
- // Get user instance
- $userInstance = Registry::getRegistry()->getInstance('user');
-
- // Get a dataset instance
- $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_CITY_INFORMATION));
-
- // Set the primary key
- $dataSetInstance->setUniqueKey(self::DB_COLUMN_CITY_ID);
-
- // Add city name and assign user id
- $dataSetInstance->addCriteria(self::DB_COLUMN_CITY_ID , ($this->countTotalRows() + 1));
- $dataSetInstance->addCriteria(self::DB_COLUMN_CITY_NAME , $cityName);
- $dataSetInstance->addCriteria(self::DB_COLUMN_CITY_USER_ID , $userInstance->getUserId());
- $dataSetInstance->addCriteria(self::DB_COLUMN_CITY_REGION_ID, $requestInstance->getRequestElement(self::DB_COLUMN_CITY_REGION_ID));
-
- // "Insert" this dataset instance completely into the database
- $this->queryInsertDataSet($dataSetInstance);
-
- // Post-check name
- assert($this->ifCityExists($cityName));
- }
-
- /**
- * Getter for all city ids as an array
- *
- * @return $cityIds All city ids as an array
- */
- public function getAllCityIds () {
- // Init empty search instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
- // And run it on the database
- $resultInstance = $this->doSelectByCriteria($searchInstance);
-
- // Init array
- $cityIds = array();
-
- // Anything found?
- if ($resultInstance->count() == 0) {
- // Nothing found
- return $cityIds;
- } // END - if
-
- // Now get all 'city_id' columns
- while ($resultInstance->next()) {
- // Get current entry
- $current = $resultInstance->current();
-
- // 'city_id' should be there
- assert(isset($current[self::DB_COLUMN_CITY_ID]));
-
- // Add it to the array
- array_push($cityIds, $current[self::DB_COLUMN_CITY_ID]);
- } // END - while
-
- // Return result
- return $cityIds;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A database wrapper for city districts
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityDistrictsDatabaseWrapper extends BaseDatabaseWrapper implements CityDistrictsWrapper, Registerable {
- // Constants for database table names
- const DB_TABLE_CITY_DISTRICTS = 'city_districts';
-
- // Section id, an referenced city id and district id
- const DB_COLUMN_CITY_ID = 'city_id';
- const DB_COLUMN_DISTRICT_ID = 'district_id';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this database wrapper by a provided user class
- *
- * @return $wrapperInstance An instance of the created wrapper class
- */
- public static final function createCityDistrictsDatabaseWrapper () {
- // Get a new instance
- $wrapperInstance = new CityDistrictsDatabaseWrapper();
-
- // Set (primary!) table name
- $wrapperInstance->setTableName(self::DB_TABLE_CITY_DISTRICTS);
-
- // Return the instance
- return $wrapperInstance;
- }
-
- /**
- * Checks if the given city id is found in districts table
- *
- * @param $cityId City id to check
- * @return $isFound Whether the city id is found
- */
- public function ifCityHasDistricts ($cityId) {
- // Get search instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
- // Search for 'city_id'
- $searchInstance->addCriteria(self::DB_COLUMN_CITY_ID, $cityId);
-
- /*
- * Only one entry is enough to find, else this query could run very\
- * long on large maps.
- */
- $searchInstance->setLimit(1);
-
- // Execute it on database instance
- $resultInstance = $this->doSelectByCriteria($searchInstance);
-
- // Check if there is one entry
- $isFound = ($resultInstance->next() == 1);
-
- // Return result
- return $isFound;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A database wrapper for city lots
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityLotsDatabaseWrapper extends BaseDatabaseWrapper implements CityLotsWrapper, Registerable {
- // Constants for database table names
- const DB_TABLE_CITY_LOTS = 'city_lots';
-
- // Section id, an referenced city id and lot id
- const DB_COLUMN_CITY_ID = 'city_id';
- const DB_COLUMN_LOT_ID = 'lot_id';
- const DB_COLUMN_DISTRICT_ID = 'district_id';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this database wrapper by a provided user class
- *
- * @return $wrapperInstance An instance of the created wrapper class
- */
- public static final function createCityLotsDatabaseWrapper () {
- // Get a new instance
- $wrapperInstance = new CityLotsDatabaseWrapper();
-
- // Set (primary!) table name
- $wrapperInstance->setTableName(self::DB_TABLE_CITY_LOTS);
-
- // Return the instance
- return $wrapperInstance;
- }
-
- /**
- * Checks if the given city id is found in lots table
- *
- * @param $cityId City id to check
- * @return $isFound Whether the city id is found
- */
- public function ifCityHasLots ($cityId) {
- // Get search instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
- // Search for 'city_id'
- $searchInstance->addCriteria(self::DB_COLUMN_CITY_ID, $cityId);
-
- /*
- * Only one entry is enough to find, else this query could run very\
- * long on large maps.
- */
- $searchInstance->setLimit(1);
-
- // Execute it on database instance
- $resultInstance = $this->doSelectByCriteria($searchInstance);
-
- // Check if there is one entry
- $isFound = ($resultInstance->next() == 1);
-
- // Return result
- return $isFound;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A database wrapper for city sections. Sections are the smalles entity of a
- * city. They can be connected with each other and form a lot. Therefore only
- * sections of same type (and sub type) can be linked combined, else you will
- * something really strange, a residential building with some industry parts
- * for example is not possible in real world.
- *
- * Sure you can have a small shop (commercial) on ground level and some
- * residentials on higher levels. This city simulation does support such
- * creations as the levels (Z axis) is different.
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CitySectionsDatabaseWrapper extends BaseDatabaseWrapper implements CitySectionsWrapper, Registerable {
- // Constants for database table names
- const DB_TABLE_CITY_SECTIONS = 'city_sections';
-
- // Section id, an referenced city id and lot id
- const DB_COLUMN_SECTION_ID = 'city_section_id';
- const DB_COLUMN_CITY_ID = 'city_id';
-
- /*
- * Lot id, the lot id is only set if the player has "aquired" the sections
- * and has created a lot based on these sections.
- */
- const DB_COLUMN_LOT_ID = 'lot_id';
-
- // Section and sub type (e.g. residential, hut)
- const DB_COLUMN_SECTION_TYPE = 'section_type';
- const DB_COLUMN_SECTION_SUB_TYPE = 'section_sub_type';
-
- // X-Y-Z position
- const DB_COLUMN_SECTION_POSITION_X = 'section_position_x';
- const DB_COLUMN_SECTION_POSITION_Y = 'section_position_y';
- const DB_COLUMN_SECTION_POSITION_Z = 'section_position_z';
-
- // Connected neigbouring sections
- const DB_COLUMN_SECTION_NEIGHBOUR_WEST_ID = 'section_neighbour_west_id';
- const DB_COLUMN_SECTION_NEIGHBOUR_EAST_ID = 'section_neighbour_east_id';
- const DB_COLUMN_SECTION_NEIGHBOUR_NORTH_ID = 'section_neighbour_north_id';
- const DB_COLUMN_SECTION_NEIGHBOUR_SOUTH_ID = 'section_neighbour_south_id';
- const DB_COLUMN_SECTION_NEIGHBOUR_UP_ID = 'section_neighbour_up_id';
- const DB_COLUMN_SECTION_NEIGHBOUR_DOWN_ID = 'section_neighbour_down_id';
-
- // Other settings:
- // Reserved section (see documentation)
- const DB_COLUMN_SECTION_RESERVED = 'section_reserved';
-
- // Section types
- // @TODO "water" is not yet supported and may end up in a very random land.
- const SECTION_TYPE_WATER = 'water';
- const SECTION_TYPE_EMPTY_LAND = 'land';
-
- // Sub sections
- // @TODO All types of water are not supported yet.
- const SUB_SECTION_TYPE_EMPTY = 'empty';
-
- // Reserved flag
- const IS_NOT_RESERVED = 0;
- const IS_RESERVED = 1;
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this database wrapper by a provided user class
- *
- * @return $wrapperInstance An instance of the created wrapper class
- */
- public static final function createCitySectionsDatabaseWrapper () {
- // Get a new instance
- $wrapperInstance = new CitySectionsDatabaseWrapper();
-
- // Set (primary!) table name
- $wrapperInstance->setTableName(self::DB_TABLE_CITY_SECTIONS);
-
- // Return the instance
- return $wrapperInstance;
- }
-
- /**
- * Checks if the given city id is found in sections table
- *
- * @param $cityId City id to check
- * @return $isFound Whether the city id is found
- */
- public function ifCityHasSections ($cityId) {
- // Get search instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
- // Search for 'city_id'
- $searchInstance->addCriteria(self::DB_COLUMN_CITY_ID, $cityId);
-
- /*
- * Only one entry is enough to find, else this query could run very
- * long on large maps.
- */
- $searchInstance->setLimit(1);
-
- // Execute it on database instance
- $resultInstance = $this->doSelectByCriteria($searchInstance);
-
- // Check if there is one entry
- $isFound = ($resultInstance->next() == 1);
-
- // Return result
- return $isFound;
- }
-
- /**
- * Expands the sections table with initial data for given city id
- *
- * @param $cityId City id to check
- * @return $ids Sections ids from initial expansion
- * @todo Add handling of water types to make a more cooler map
- */
- public function doInitialCityExpansion ($cityId) {
- // Make sure this city has no sections
- assert(!$this->ifCityHasSections($cityId));
-
- /*
- * "Cache" max "radius" for initial city expansion. It is not a real
- * radius but more a max expansion area (expand +- half of "radius"
- * from 0/0). The "zero point" is always calculated in.
- *
- * This gives a maxium initial area calculated as follows:
- *
- * totalInitialSections = (radius + 1) * (radius + 1)
- */
- $radius = $this->getConfigInstance()->getConfigEntry('city_max_initial_xy_expansion_radius');
-
- // Max up and down ...
- $maxUp = $this->getConfigInstance()->getConfigEntry('city_max_initial_up_expansion');
- $maxDown = $this->getConfigInstance()->getConfigEntry('city_max_initial_down_expansion');
-
- // Extremely huge debug message:
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: radius=' . $radius . ',maxUp=' . $maxUp . ',maxDown=' . $maxDown);
-
- // Get data set instance
- $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_CITY_SECTIONS));
-
- // Add values for "zero point"
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_ID , 1);
- $dataSetInstance->addCriteria(self::DB_COLUMN_CITY_ID , $cityId);
- $dataSetInstance->addCriteria(self::DB_COLUMN_LOT_ID , 0);
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_TYPE , self::SECTION_TYPE_EMPTY_LAND);
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_SUB_TYPE , self::SUB_SECTION_TYPE_EMPTY);
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_POSITION_X , 0);
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_POSITION_Y , 0);
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_POSITION_Z , 0);
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_NEIGHBOUR_NORTH_ID, 0);
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_NEIGHBOUR_SOUTH_ID, 0);
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_NEIGHBOUR_WEST_ID , 0);
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_NEIGHBOUR_EAST_ID , 0);
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_NEIGHBOUR_UP_ID , 0);
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_NEIGHBOUR_DOWN_ID , 0);
- $dataSetInstance->addCriteria(self::DB_COLUMN_SECTION_RESERVED , self::IS_NOT_RESERVED);
-
- // Set primary key to 'city_id'/'section_id'
- $dataSetInstance->setPrimaryKeyCombined(array(self::DB_COLUMN_CITY_ID, self::DB_COLUMN_SECTION_ID));
-
- // Add "zero point"
- $this->queryInsertDataSet($dataSetInstance);
-
- // Set section id to 2 as 1 is already initialized + init array
- $sections = array();
-
- // Output message to ask for user's patience ...
- self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: Writing ' . (($radius + 1) * ($radius + 1) * $maxUp * ($maxDown + 1)) . ' sections for city ' . $cityId . ' ... (this may takes some time)');
-
- // Expand half of it to north/south (north=positive, south=negative)
- for ($north = 1; $north < round($radius / 2); $north++) {
- // Expand half of it to west/east (west=positive, east=negative)
- for ($west = 1; $west < round($radius / 2); $west++) {
- // Expand up/down (including "zero point")
- for ($z = $maxDown; $z < ($maxUp + 1); $z++) {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: north=' . $north . ',west=' . $west . ',z=' . $z);
-
- // Fill array up with south/east/down ids
- $sections[($north * -1)][($west * -1)][$z]['type'] = self::SECTION_TYPE_EMPTY_LAND;
- $sections[($north * -1)][($west * -1)][$z]['sub'] = self::SUB_SECTION_TYPE_EMPTY;
-
- // Fill up array with north/west/up ids
- $sections[$north][$west][$z]['type'] = self::SECTION_TYPE_EMPTY_LAND;
- $sections[$north][$west][$z]['sub'] = self::SUB_SECTION_TYPE_EMPTY;
- } // END - for
- } // END - for
- } // END - for
-
- // Init section id with 2 as 1 is the "zero point"
- $sectionId = 2;
-
- // Loop through whole array again for writing it to database: north/south
- foreach ($sections as $x => $sectionX) {
- // Loop through west/east values
- foreach ($sectionX as $y => $sectionY) {
- // Loop through up/down values
- foreach ($sectionY as $z => $sectionData) {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: x=' . $x . ',y=' . $y . ',z=' . $z . ',sectionId=' . $sectionId);
-
- // Set all coordinates for positive directions
- $dataSetInstance->setCriteria(self::DB_COLUMN_SECTION_ID , $sectionId);
- $dataSetInstance->setCriteria(self::DB_COLUMN_SECTION_POSITION_X, $x);
- $dataSetInstance->setCriteria(self::DB_COLUMN_SECTION_POSITION_Y, $y);
- $dataSetInstance->setCriteria(self::DB_COLUMN_SECTION_POSITION_Z, $z);
- $dataSetInstance->setCriteria(self::DB_COLUMN_SECTION_TYPE , $sectionData['type']);
- $dataSetInstance->setCriteria(self::DB_COLUMN_SECTION_SUB_TYPE , $sectionData['sub']);
-
- // Add value to database
- $this->queryInsertDataSet($dataSetInstance);
-
- // Count id up
- $sectionId++;
- } // END - foreach
-
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: x=' . $x . ',y=' . $y . ' has been written.');
- } // END - foreach
-
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: x=' . $x . ' has been written.');
- } // END - foreach
-
- // Thank you for waiting! :-)
- self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: ' . (($radius + 1) * ($radius + 1) * $maxUp * ($maxDown + 1)) . ' sections has been written for city ' . $cityId . '.');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A database wrapper for region informations
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 RegionInformationDatabaseWrapper extends BaseDatabaseWrapper implements RegionInformationWrapper, Registerable {
- // Constants for database table names
- const DB_TABLE_REGION_INFORMATION = 'region_data';
-
- // Constants for database column names
- const DB_COLUMN_REGION_ID = 'region_id';
- const DB_COLUMN_REGION_NAME = 'region_name';
- const DB_COLUMN_REGION_USER_ID = 'region_user_id';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this database wrapper by a provided user class
- *
- * @return $wrapperInstance An instance of the created wrapper class
- */
- public static final function createRegionInformationDatabaseWrapper () {
- // Get a new instance
- $wrapperInstance = new RegionInformationDatabaseWrapper();
-
- // Set (primary!) table name
- $wrapperInstance->setTableName(self::DB_TABLE_REGION_INFORMATION);
-
- // Return the instance
- return $wrapperInstance;
- }
-
- /**
- * Removes non-public data from given array.
- *
- * @param $data An array with possible non-public data that needs to be removed.
- * @return $data A cleaned up array with only public data.
- */
- public function removeNonPublicDataFromArray(array $data) {
- // Currently call only inner method
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGION-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...');
- $data = parent::removeNonPublicDataFromArray($data);
-
- // Return cleaned data
- return $data;
- }
-
- /**
- * Checks whether the user has already founded a region
- *
- * @return $hasFounded Whether the user has already founded a region
- */
- public function ifUserHasCreatedRegion () {
- // Get user instance
- $userInstance = Registry::getRegistry()->getInstance('user');
-
- // Now get a search criteria instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
- // Search for user's cities
- $searchInstance->addCriteria(RegionInformationDatabaseWrapper::DB_COLUMN_REGION_USER_ID, $userInstance->getUserId());
-
- // Get a result back
- $resultInstance = $this->doSelectByCriteria($searchInstance);
-
- // Get region manager instance
- $managerInstance = ManagerFactory::createManagerByType('region');
-
- // Set result instance
- $managerInstance->setResultInstance($resultInstance);
-
- // Has it been founded?
- $hasFounded = $resultInstance->valid();
-
- // Return result
- return $hasFounded;
- }
-
- /**
- * Checks whether the given region name is taken
- *
- * @param $regionName Name of region
- * @return $isTaken Whether the given region name is taken
- */
- public function ifRegionExists ($regionName) {
- // Now get a search criteria instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
- // Search for the region number one which is hard-coded the default
- $searchInstance->addCriteria(RegionInformationDatabaseWrapper::DB_COLUMN_REGION_NAME, $regionName);
- $searchInstance->setLimit(1);
-
- // Get a result back
- $resultInstance = $this->doSelectByCriteria($searchInstance);
-
- // Check it
- $isTaken = $resultInstance->next();
- //* NOISY-DEBUG: */ $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] isTaken[' . gettype($isTaken) . ']=' . intval($isTaken));
-
- // Get manger instance
- $managerInstance = ManagerFactory::createManagerByType('region');
-
- // Set result instance
- $managerInstance->setResultInstance($resultInstance);
-
- // Return result
- return $isTaken;
- }
-
- /**
- * Creates a region by given name
- *
- * @param $regionName Name of region
- * @return void
- */
- public function createRegionByName ($regionName) {
- // Pre-check name
- assert(!$this->ifRegionExists($regionName));
-
- // Get user instance
- $userInstance = Registry::getRegistry()->getInstance('user');
-
- // Get a dataset instance
- $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_REGION_INFORMATION));
-
- // Set the primary key
- $dataSetInstance->setUniqueKey(self::DB_COLUMN_REGION_ID);
-
- // Add region name and assign user id
- $dataSetInstance->addCriteria(self::DB_COLUMN_REGION_ID , ($this->countTotalRows() + 1));
- $dataSetInstance->addCriteria(self::DB_COLUMN_REGION_NAME , $regionName);
- $dataSetInstance->addCriteria(self::DB_COLUMN_REGION_USER_ID, $userInstance->getUserId());
-
- // "Insert" this dataset instance completely into the database
- $this->queryInsertDataSet($dataSetInstance);
-
- // Post-check name
- assert($this->ifRegionExists($regionName));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A database wrapper for region maps
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 RegionMapDatabaseWrapper extends BaseDatabaseWrapper implements RegionMapWrapper, Registerable {
- // Constants for database table names
- const DB_TABLE_REGION_MAP = 'region_map';
-
- // Constants for database column names
- const DB_COLUMN_REGION_ID = 'region_id';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this database wrapper by a provided user class
- *
- * @return $wrapperInstance An instance of the created wrapper class
- */
- public static final function createRegionMapDatabaseWrapper () {
- // Get a new instance
- $wrapperInstance = new RegionMapDatabaseWrapper();
-
- // Set (primary!) table name
- $wrapperInstance->setTableName(self::DB_TABLE_REGION_MAP);
-
- // Return the instance
- return $wrapperInstance;
- }
-
- /**
- * Removes non-public data from given array.
- *
- * @param $data An array with possible non-public data that needs to be removed.
- * @return $data A cleaned up array with only public data.
- */
- public function removeNonPublicDataFromArray(array $data) {
- // Currently call only inner method
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGION-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...');
- $data = parent::removeNonPublicDataFromArray($data);
-
- // Return cleaned data
- return $data;
- }
-
- /**
- * Creates a region by given name
- *
- * @return void
- */
- public function createRegionByName () {
- // Pre-check
- die(__METHOD__ . ': Unfinshed!');
- assert(!$this->ifRegionExists($regionName));
-
- // Get user instance
- $userInstance = Registry::getRegistry()->getInstance('user');
-
- // Get a dataset instance
- $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_REGION_MAP));
-
- // Set the primary key
- $dataSetInstance->setUniqueKey(self::DB_COLUMN_REGION_ID);
-
- // Add region name and assign user id
- $dataSetInstance->addCriteria(self::DB_COLUMN_REGION_ID , ($this->countTotalRows() + 1));
-
- // "Insert" this dataset instance completely into the database
- $this->queryInsertDataSet($dataSetInstance);
-
- // Post-check name
- assert($this->ifRegionExists($regionName));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A factory class for cities
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 CityDaemonFactory extends ObjectFactory {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Returns a singleton (registry-based) CityHelper instance
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return $cityInstance An instance of a CityHelper class
- * @throws FactoryRequiredParameterException If not all parameters are set and no instance 'city' is set.
- */
- public static final function createCityDaemonInstance (Requestable $requestInstance = NULL, Responseable $responseInstance = NULL) {
- // Get new factory instance
- $factoryInstance = new CityDaemonFactory();
-
- // If there is no handler?
- if (Registry::getRegistry()->instanceExists('city')) {
- // Get handler from registry
- $cityInstance = Registry::getRegistry()->getInstance('city');
- } elseif (($requestInstance instanceof Requestable) && ($responseInstance instanceof Responseable)) {
- // The default city-mode is from our configuration
- $cityMode = $factoryInstance->getConfigInstance()->getConfigEntry('city_default_mode');
-
- // Is the city 'mode' parameter set?
- if ($requestInstance->isRequestElementSet('mode')) {
- // Then use this which overrides the config entry temporarily
- $cityMode = $requestInstance->getRequestElement('mode');
- } else {
- // Set it for easier re-usage
- $requestInstance->setRequestElement('mode', $cityMode);
- }
-
- // Now convert the city-mode in a class name
- $className = 'Simulation' . $factoryInstance->convertToClassName($cityMode) . 'CityDaemon';
-
- // Get the city instance
- $cityInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
-
- // Get a registry
- $applicationInstance = Registry::getRegistry()->getInstance('app');
-
- // Set the app instance
- $cityInstance->setApplicationInstance($applicationInstance);
-
- // Add city-specific filters
- $cityInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
- } else {
- // Throw an exception here
- throw new FactoryRequiredParameterException($factoryInstance, self::EXCEPTION_FACTORY_REQUIRE_PARAMETER);
- }
-
- // Return the instance
- return $cityInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A factory class for managers
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 ManagerFactory extends ObjectFactory {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Returns a singleton (registry-based) ManageableFoo instance
- *
- * @param $type Type of manager to return
- * @return $managerInstance An instance of a ManageableFoo class
- */
- public static final function createManagerByType ($type) {
- // Get new factory instance
- $factoryInstance = new ManagerFactory();
-
- // Generate key
- $key = $type . '_manager';
-
- // If there is no handler?
- if (Registry::getRegistry()->instanceExists($key)) {
- // Get handler from registry
- $managerInstance = Registry::getRegistry()->getInstance($key);
- } else {
- // Get the proper manager instance
- $managerInstance = ObjectFactory::createObjectByConfiguredName($key . '_class');
-
- // Add it to the registry
- Registry::getRegistry()->addInstance($key, $managerInstance);
- }
-
- // Return the instance
- return $managerInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A factory class for city states
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityStateFactory extends ObjectFactory {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of a configurable city state and sets it in the
- * given city instance.
- *
- * @param $stateName Name of the state
- * @return $stateInstance A Stateable class instance
- */
- public static final function createCityStateInstanceByName ($stateName) {
- // Then construct the class' configuraton entry
- $className = 'city_' . $stateName . '_state_class';
-
- // Get a class from that configuration entry
- $stateInstance = self::createObjectByConfiguredName($className);
-
- // Get city instance
- $cityInstance = CityDaemonFactory::createCityDaemonInstance();
-
- // Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('CITY-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: City state has changed from ' . $cityInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
-
- // Once we have that state, set it in the city instance
- $cityInstance->setStateInstance($stateInstance);
-
- // Update city data
- $cityInstance->updateCityData();
-
- // For any purposes, return the state instance
- return $stateInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A bootstrap ??? filter for daemon
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 CityDaemonBootstrap???Filter extends BaseCityFilter 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 createCityDaemonBootstrap???Filter () {
- // Get a new instance
- $filterInstance = new CityDaemonBootstrap???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
- * @throws FilterChainException If $cityInstance is null (no NullPointerException here)
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get city instance
- $cityInstance = Registry::getRegistry()->getInstance('city');
-
- // Now do something
- $this->partialStub('Please implement this step.');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A bootstrap InitDaemon filter for daemon
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 CityDaemonBootstrapInitDaemonFilter extends BaseCityFilter 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 createCityDaemonBootstrapInitDaemonFilter () {
- // Get a new instance
- $filterInstance = new CityDaemonBootstrapInitDaemonFilter();
-
- // 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
- * @throws FilterChainException If $cityInstance is null (no NullPointerException here)
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get city instance
- $cityInstance = CityDaemonFactory::createCityDaemonInstance();
-
- // Now bootstrap the daemon
- $cityInstance->bootstrapInitCityDaemon();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A ??? filter for citys
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 CityDaemon???Filter extends BaseCityFilter 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 createCityDaemon???Filter () {
- // Get a new instance
- $filterInstance = new CityDaemon???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 cities
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityDaemonInitializationFilter extends BaseCityFilter 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 static final function createCityDaemonInitializationFilter () {
- // Get a new instance
- $filterInstance = new CityDaemonInitializationFilter();
-
- // 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Try to instance it by using a factory
- try {
- // Get an instance
- $cityInstance = CityDaemonFactory::createCityDaemonInstance($requestInstance, $responseInstance);
- } catch (ClassNotFoundException $e) {
- // This exception means, the city mode is invalid.
- // @TODO Can we rewrite this to app_exit() ?
- $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: City daemon could not be initialized: ' . $e->getMessage());
- }
-
- // Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-INIT-FILTER[' . __METHOD__ . ':' . __LINE__ . ']: City daemon has been added to registry.');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A PhpRequirements filter for cities
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityDaemonPhpRequirementsFilter extends BaseCityFilter 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 static final function createCityDaemonPhpRequirementsFilter () {
- // Get a new instance
- $filterInstance = new CityDaemonPhpRequirementsFilter();
-
- // 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
- * @throws FilterChainException If a required PHP function is not available
- * @todo Add more test and try to add an extra message to the thrown exception
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // By default, the requirement check is passed and zero checks are failed
- $checkPassed = TRUE;
- $checksFailed = 0;
-
- // Are all tests passed?
- if ($checkPassed === FALSE) {
- // Throw an exception
- throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
- } // END - if
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A welcome-teaser filter for the console
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityDaemonWelcomeTeaserFilter extends BaseCityFilter 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 static final function createCityDaemonWelcomeTeaserFilter () {
- // Get a new instance
- $filterInstance = new CityDaemonWelcomeTeaserFilter();
-
- // 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
- * @throws FilterChainException If $cityInstance is null (no NullPointerException here)
- * @todo Handle over the $responseInstance to outputConsoleTeaser()
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get city instance
- $cityInstance = CityDaemonFactory::createCityDaemonInstance();
-
- // Now output the teaser
- $cityInstance->outputConsoleTeaser();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A ??? filter for !!!
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 City!!!???Filter extends BaseCityFilter 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 createCity!!!???Filter () {
- // Get a new instance
- $filterInstance = new City!!!???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
- * @throws FilterChainException If $cityInstance is null (no NullPointerException here)
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get city instance
- $cityInstance = Registry::getRegistry()->getInstance('city');
-
- // Now do something
- $this->partialStub('Please implement this step.');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A generic filter for hub project
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 BaseCityFilter extends BaseFilter {
- /**
- * Array with all data XML nodes (which hold the actual data) and their values
- */
- protected $dataXmlNodes = array();
-
- /**
- * Protected constructor
- *
- * @param $className Real name of class
- * @return void
- */
- protected function __construct ($className) {
- // Call parent constructor
- parent::__construct($className);
- }
-
- /**
- * Processes the given raw message content. The method renderXmlContent
- * may throw (not the method itself) several exceptions:
- *
- * InvalidXmlNodeException - If an invalid XML node has been found (e.g.
- * wrong/out-dated template used)
- * XmlNodeMismatchException - Again might be caused by invalid XML node
- * usage
- * XmlParserException - If the XML message is damaged or not
- * well-formed
- *
- * @param $messageType Type of message
- * @param $messageContent Raw message content
- * @param $packageInstance An instance of a Receivable class
- * @return void
- * @todo Exceptions from renderXmlContent() are currently unhandled
- */
- protected function genericProcessMessage ($messageType, $messageContent, Receivable $packageInstance) {
- // Get a template instance from the factory
- $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('city_' . $messageType . '_template_class');
-
- // And render the XML content (aka message)
- $templateInstance->renderXmlContent($messageContent);
-
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Handling ' . strlen($messageContent) . ' bytes: ' . $messageContent);
-
- /*
- * The template system now stores all required data as 'general'
- * variables, so simply get them. If there is an invalid XML node
- * inside the message, the above method call will cause exceptions.
- */
- foreach ($this->dataXmlNodes as $key => $dummy) {
- // Call it
- $value = $templateInstance->readXmlData($key);
-
- /*
- * If value is NULL, a variable hasn't been found. This could mean
- * that *this* node is running an out-dated software or the other
- * peer is using an out-dated $messageType.xml template.
- */
- if (is_null($value)) {
- // Output a warning
- self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Found not fully supported variable ' . $key . ' - skipping.');
-
- // Skip this part, don't write NULLs to the array
- continue;
- } // END - if
-
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: key=' . $key . ',value=' . $value);
-
- // Set it now
- $this->dataXmlNodes[$key] = $value;
- } // END - foreach
-
- // Construct an array for pushing it on next stack
- $messageArray = array(
- // Message data itself
- NetworkPackage::MESSAGE_ARRAY_DATA => $this->dataXmlNodes,
- // Message type (which is $messageType)
- NetworkPackage::MESSAGE_ARRAY_TYPE => $messageType
- );
-
- // Push the processed message back on stack
- $packageInstance->getStackInstance()->pushNamed(NetworkPackage::STACKER_NAME_PROCESSED_MESSAGE, $messageArray);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A ??? filter for shutting down the city.
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 CityDaemonShutdown???Filter extends BaseCityFilter 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 createCityDaemonShutdown???Filter () {
- // Get a new instance
- $filterInstance = new CityDaemonShutdown???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
- * @throws FilterChainException If $cityInstance is null (no NullPointerException here)
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get city instance
- $cityInstance = Registry::getRegistry()->getInstance('city');
-
- // Now do something
- $this->partialStub('Please implement this step.');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A ShutdownCity filter for shutting down the city. This filter should be the
- * last one in 'shutdown' chain so the hub is shutted down at the very end of
- * its life... R.I.P. little hub...
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityDaemonShutdownCityFilter extends BaseCityFilter 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 static final function createCityDaemonShutdownCityFilter () {
- // Get a new instance
- $filterInstance = new CityDaemonShutdownCityFilter();
-
- // 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
- * @throws FilterChainException If $cityInstance is null (no NullPointerException please)
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get city instance
- $cityInstance = CityDaemonFactory::createCityDaemonInstance();
-
- // Shutdown the city. This should be the last line
- $cityInstance->doShutdown();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A TaskHandler filter for shutting down the city.
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityDaemonShutdownTaskHandlerFilter extends BaseCityFilter 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 static final function createCityDaemonShutdownTaskHandlerFilter () {
- // Get a new instance
- $filterInstance = new CityDaemonShutdownTaskHandlerFilter();
-
- // 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
- * @throws FilterChainException If $cityInstance is null (no NullPointerException here)
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get task handler instance
- $handlerInstance = Registry::getRegistry()->getInstance('task_handler');
-
- // Shutdown the task manager and all its registered tasks
- $handlerInstance->doShutdown();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A TaskHandlerInitializer filter for hubs
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityDaemonTaskHandlerInitializerFilter extends BaseCityFilter 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 static final function createCityDaemonTaskHandlerInitializerFilter () {
- // Get a new instance
- $filterInstance = new CityDaemonTaskHandlerInitializerFilter();
-
- // 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
- * @throws FilterChainException If the filter chain needs to be interrupted
- * @todo Add more tasks
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get city instance
- $cityInstance = CityDaemonFactory::createCityDaemonInstance();
-
- // Get a new task handler instance
- $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class');
-
- // Put the task handler in registry
- Registry::getRegistry()->addInstance('task_handler', $handlerInstance);
-
- // Prepare a city map expansion task
- $taskInstance = ObjectFactory::createObjectByConfiguredName('city_daemon_map_expander_task_class');
-
- // Register it
- $handlerInstance->registerTask('map_expander', $taskInstance);
-
- // Prepare a household growth task
- $taskInstance = ObjectFactory::createObjectByConfiguredName('city_daemon_household_growth_task_class');
-
- // Register it
- $handlerInstance->registerTask('household_growth', $taskInstance);
-
- // Prepare a building growth task
- $taskInstance = ObjectFactory::createObjectByConfiguredName('city_daemon_building_growth_task_class');
-
- // Register it
- $handlerInstance->registerTask('building_growth', $taskInstance);
-
- /*
- * Add extra tasks depending on daemon modus.
- */
- $cityInstance->addExtraTasks($handlerInstance);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A concrete filter for verfying the city name. This filter may intercept the
- * filter chain if no city name is given or if supplied city name has an invalid
- * form. It could also intercept our filter chain if city name was not found.
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityNameVerifierFilter 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 static final function createCityNameVerifierFilter () {
- // Get a new instance
- $filterInstance = new CityNameVerifierFilter();
-
- // 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
- * @throws FilterChainException If this filter fails to operate
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get city name from request
- $cityName = $requestInstance->getRequestElement(CityInformationDatabaseWrapper::DB_COLUMN_CITY_NAME);
-
- // Is the city name set?
- if (is_null($cityName)) {
- // Not found in form so stop the filtering process
- $requestInstance->requestIsValid(FALSE);
-
- // Add a message to the response
- $responseInstance->addFatalMessage('city_name_unset');
-
- // Abort here
- throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
- } elseif (empty($cityName)) {
- // Empty field!
- $requestInstance->requestIsValid(FALSE);
-
- // Add a message to the response
- $responseInstance->addFatalMessage('city_name_empty');
-
- // Abort here
- throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
- } elseif ($this->ifCityNameIsTaken($cityName) === TRUE) {
- // City name is already taken
- $requestInstance->requestIsValid(FALSE);
-
- // Add a message to the response
- $responseInstance->addFatalMessage('city_name_taken');
-
- // Abort here
- throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
- }
- }
-
- /**
- * Check whether the city name as already been taken
- *
- * @param $cityName Cityname to check for existence
- * @return $alreadyTaken Whether the city name has been taken
- */
- private function ifCityNameIsTaken ($cityName) {
- // Get a new instance
- $managerInstance = ManagerFactory::createManagerByType('city');
-
- // Does the city name exist?
- $alreadyTaken = ($managerInstance->ifCityNameExists($cityName));
-
- // Return the result
- return $alreadyTaken;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A special guest login class for City
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityGuestLogin extends BaseFrameworkSystem implements LoginableUser, Registerable {
- /**
- * The hashed password
- */
- private $hashedPassword = '';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this login class
- *
- * @return $loginInstance An instance of this login class
- */
- public static final function createCityGuestLogin () {
- // Get a new instance
- $loginInstance = new CityGuestLogin();
-
- // Return the instance
- return $loginInstance;
- }
-
- /**
- * Logins the user with the given request containing the credential. The
- * result of the login can be thrown by exception or, if prefered stored
- * in a boolean attribute which is then readable by a matching getter.
- *
- * @param $requestInstance An instance of a Requestable class
- * @param $responseInstance An instance of a Responseable class
- * @return void
- * @throws UserPasswordMismatchException If the supplied password did not
- * match with the stored password
- */
- public function doLogin (Requestable $requestInstance, Responseable $responseInstance) {
- // Get a user instance
- $userInstance = UserFactory::createUserByRequest($requestInstance);
-
- // Remember this new instance in registry
- Registry::getRegistry()->addInstance('user', $userInstance);
-
- // Is the password correct?
- if ($userInstance->ifPasswordHashMatches($requestInstance) === FALSE) {
- // Mismatching password
- throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
- } // END - if
-
- // Now do the real login. This can be cookie- or session-based login
- // which depends on the admins setting then on the user's taste.
- // 1) Get a login helper instance
- $helperInstance = ObjectFactory::createObjectByConfiguredName('login_helper_class', array($requestInstance));
-
- // 2) Execute the login. This will now login...
- $helperInstance->executeLogin($responseInstance);
- }
-
- /**
- * Check if the implementation is correct. Only the request instance is
- * needed as no redirect is done here.
- *
- * @param $requestInstance An instance of a Requestable class
- * @return
- */
- public function testLogin (Requestable $requestInstance) {
- // Create dummy instance
- $dummyInstance = Guest::createGuestByRequest($requestInstance);
- }
-
- /**
- * Determines wether the login was fine. This is done by checking if 'login' instance is in registry
- *
- * @return $loginDone Wether the login was fine or not
- */
- public function ifLoginWasSuccessfull () {
- // Is the registry key there?
- $loginDone = (Registry::getRegistry()->getInstance('login') instanceof Registerable);
-
- // Return the result
- return $loginDone;
- }
-
- /**
- * Encrypt given request key or throw an exception if key was not found in
- * request
- *
- * @param $requestKey Key in request class
- * @return void
- */
- public function encryptPassword ($requestKey) {
- // Check if password is found in request
- if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
- // So encrypt the password and store it for later usage in
- // the request:
-
- // Get the plain password
- $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
-
- // Get user instance
- $userInstance = Registry::getRegistry()->getInstance('user');
-
- // Get a crypto helper and hash the password
- $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword, $userInstance->getPasswordHash());
-
- // Store the hash back in request
- $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
- } // END - if
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A special login class for City
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityUserLogin extends BaseFrameworkSystem implements LoginableUser, Registerable {
- /**
- * The hashed password
- */
- private $hashedPassword = '';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this login class
- *
- * @return $loginInstance An instance of this login class
- */
- public static final function createCityUserLogin () {
- // Get a new instance
- $loginInstance = new CityUserLogin();
-
- // Return the instance
- return $loginInstance;
- }
-
- /**
- * Logins the user with the given request containing the credential. The
- * result of the login can be thrown by exception or, if prefered stored
- * in a boolean attribute which is then readable by a matching getter.
- *
- * @param $requestInstance An instance of a Requestable class
- * @param $responseInstance An instance of a Responseable class
- * @return void
- * @throws UserPasswordMismatchException If the supplied password did not
- * match with the stored password
- * @todo We need to add something here which will make more than one
- * @todo guest logins, users who are online but based on the same
- * @todo user account.
- */
- public function doLogin (Requestable $requestInstance, Responseable $responseInstance) {
- // Get a user instance from factory
- $userInstance = UserFactory::createUserByRequest($requestInstance);
-
- // Remember this new instance in registry
- Registry::getRegistry()->addInstance('user', $userInstance);
-
- // Is the password correct?
- if ($userInstance->ifPasswordHashMatches($requestInstance) === FALSE) {
- // Mismatching password
- throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
- } // END - if
-
- // @TODO What else?
-
- /*
- * Now do the real login. This can be cookie- or session-based login
- * which depends on the admins setting then on the user's taste.
- */
-
- // 1) Get a login helper instance
- $helperInstance = ObjectFactory::createObjectByConfiguredName('login_helper_class', array($requestInstance));
-
- // 2) Execute the login. This will now login...
- $helperInstance->executeLogin($responseInstance);
- }
-
- /**
- * Check if the implementation is correct. Only the request instance is
- * needed as no redirect is done here.
- *
- * @param $requestInstance An instance of a Requestable class
- * @return
- */
- public function testLogin (Requestable $requestInstance) {
- // Create a dummy instance
- $dummyInstance = Member::createMemberByRequest($requestInstance);
- }
-
- /**
- * Determines wether the login was fine. This is done by checking if 'login' instance is in registry
- *
- * @return $loginDone Wether the login was fine or not
- */
- public function ifLoginWasSuccessfull () {
- // Is the registry key there?
- $loginDone = (Registry::getRegistry()->getInstance('login') instanceof Registerable);
-
- // Return the result
- return $loginDone;
- }
-
- /**
- * Encrypt given request key or throw an exception if key was not found in
- * request
- *
- * @param $requestKey Key in request class
- * @return void
- */
- public function encryptPassword ($requestKey) {
- // Check if password is found in request
- if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
- // So encrypt the password and store it for later usage in
- // the request:
-
- // Get the plain password
- $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
-
- // Get user instance
- $userInstance = Registry::getRegistry()->getInstance('user');
-
- // Get a crypto helper and hash the password
- $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword, $userInstance->getPasswordHash());
-
- // Store the hash back in request
- $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
- } // END - if
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A helper for City to login. This login helper first checks what setting
- * (cookie or session) the admin has choosen then overwrites it with the setting
- * from current user. The registry instance should hold an instance of this user
- * class at key 'user' else an exception will be thrown. After this the setting
- * from a login form will be taken as login method and be stored in database
- * for later usage.
- *
- * The user shall be able to choose "Default login method" or similar to use his
- * own login method.
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityLoginHelper extends BaseLoginHelper implements HelpableLogin {
- /**
- * The login method we shall choose
- */
- private $authMethod = '';
-
- // Exception constants
- const EXCEPTION_INVALID_USER_INSTANCE = 0x190;
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class by given request instance
- *
- * @param $requestInstance An instance of a Requestable class
- * @return $helperInstance An instance of this helper class
- * @throws UserInstanceMissingException If the user instance in registry
- * is missing or invalid
- */
- public static final function createCityLoginHelper (Requestable $requestInstance) {
- // Get a new instance first
- $helperInstance = new CityLoginHelper();
-
- // Get a user instance from registry
- $userInstance = Registry::getRegistry()->getInstance('user');
-
- // Is this instance valid?
- if (!$userInstance instanceof ManageableAccount) {
- // Thrown an exception here
- throw new UserInstanceMissingException (array($helperInstance, 'user'), self::EXCEPTION_INVALID_USER_INSTANCE);
- } // END - if
-
- // Set default login method from config
- $helperInstance->setDefaultAuthMethod();
-
- // Set request instance
- $helperInstance->setRequestInstance($requestInstance);
-
- // Return the prepared instance
- return $helperInstance;
- }
-
- /**
- * Setter for default login method from config
- *
- * @return void
- */
- protected function setDefaultAuthMethod () {
- $this->authMethod = $this->getConfigInstance()->getConfigEntry('auth_method_class');
- }
-
- /**
- * Execute the login request by given response instance. This instance can
- * be used for sending cookies or at least the session id out.
- *
- * @param $responseInstance An instance of a Responseable class
- * @return void
- */
- public function executeLogin (Responseable $responseInstance) {
- // Get an instance from the login method
- $loginInstance = ObjectFactory::createObjectByName($this->authMethod, array($responseInstance));
-
- // Set user cookie
- $loginInstance->setUserAuth($this->getRequestInstance()->getRequestElement('username'));
-
- // Set password cookie
- $loginInstance->setPasswordAuth($this->getRequestInstance()->getRequestElement('pass_hash'));
-
- // Remember this login instance for later usage
- Registry::getRegistry()->addInstance('login', $loginInstance);
- }
-}
-
-//
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A City manager
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 CityManager extends BaseManager implements ManageableCity {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $managerInstance An instance of a ManageableCity class
- */
- public final static function createCityManager () {
- // Get new instance
- $managerInstance = new CityManager();
-
- // Get database wrapper
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class');
-
- // And set it here
- $managerInstance->setWrapperInstance($wrapperInstance);
-
- // Return the prepared instance
- return $managerInstance;
- }
-
- /**
- * Checks whether the current user has already founded a city
- *
- * @return $isFounded Whether the current user has already founded a city
- */
- public function isCityAlreadyFounded () {
- // Check if the currently set user has already founded a city
- $isFounded = $this->getWrapperInstance()->ifUserHasFoundedCity();
-
- // Return result
- return $isFounded;
- }
-
- /**
- * Checks whether the given city name is already taken
- *
- * @para $cityName Name of city
- * @return $isTaken Whether the given city name is already taken
- */
- public function ifCityNameExists ($cityName) {
- // Check if the given city name is taken
- $isTaken = $this->getWrapperInstance()->ifCityExists($cityName);
-
- // Return result
- return $isTaken;
- }
-
- /**
- * Founds the first city. A dummy region will also be created
- *
- * @return void
- */
- public function foundFirstCity () {
- // Check on request instance and 'city_name' element
- assert($this->getRequestInstance() instanceof Requestable);
- assert($this->getRequestInstance()->isRequestElementSet(CityInformationDatabaseWrapper::DB_COLUMN_CITY_NAME));
-
- // Get city name
- $cityName = $this->getRequestInstance()->getRequestElement(CityInformationDatabaseWrapper::DB_COLUMN_CITY_NAME);
-
- // Some pre-checks
- assert(!$this->isCityAlreadyFounded());
- assert(!$this->ifCityNameExists($cityName));
-
- // Get region manager
- $managerInstance = ManagerFactory::createManagerByType('region');
-
- // There should be no region created
- assert(!$managerInstance->ifUserHasCreatedRegion());
-
- // Create first region and get back whole result
- $regionResultInstance = $managerInstance->createFirstRegion();
-
- // Get current entry
- $regionData = $regionResultInstance->current();
-
- // Add region id from it
- $this->getRequestInstance()->setRequestElement(CityInformationDatabaseWrapper::DB_COLUMN_CITY_REGION_ID, $regionData[RegionInformationDatabaseWrapper::DB_COLUMN_REGION_ID]);
-
- // Then create the first city
- $this->getWrapperInstance()->createCityByRequest($this->getRequestInstance());
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A city districts manager
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 CityDistrictsManager extends BaseFrameworkSystem implements ManageableCityDistricts, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $managerInstance An instance of a ManageableCityDistricts class
- */
- public final static function createCityDistrictsManager () {
- // Get new instance
- $managerInstance = new CityDistrictsManager();
-
- // Get database wrapper
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_districts_db_wrapper_class');
-
- // And set it here
- $managerInstance->setWrapperInstance($wrapperInstance);
-
- // Return the prepared instance
- return $managerInstance;
- }
-
- /**
- * Checks whether at least one map requires expansion
- *
- * @return $requiresExpansion Whether a map requires expansion
- * @todo 0% done
- */
- public function isMapPendingExpansion () {
- // Default is no expansion is needed
- $requireExpansion = FALSE;
-
- // First, a simple check if the districts table contains any entries at all
- if ($this->getWrapperInstance()->countTotalRows() == 0) {
- // This definedly requires expansion
- $requireExpansion = TRUE;
- } // END - if
-
- // Return status
- return $requireExpansion;
- }
-
- /**
- * Expands any map that requires expansion
- *
- * @return void
- * @todo ~10% done
- * @todo z-coordinate not used
- */
- public function expandMaps () {
- // Get a city info wrapper instance
- $cityWrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class');
-
- // Get all city ids from it
- $cityIds = $cityWrapperInstance->getAllCityIds();
-
- // Now check all ids
- foreach ($cityIds as $cityId) {
- // Does this id have any districts
- if (!$this->getWrapperInstance()->ifCityHasDistricts($cityId)) {
- // Nothing found, so it is a brand-new city that needs first initialization
- $districts = $this->getWrapperInstance()->doInitialCityExpansion($cityId);
- } else {
- // @TODO Maybe some expansion is needed
- }
- } // END - foreach
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A city lots manager
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 CityLotsManager extends BaseFrameworkSystem implements ManageableCityLots, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $managerInstance An instance of a ManageableCityLots class
- */
- public final static function createCityLotsManager () {
- // Get new instance
- $managerInstance = new CityLotsManager();
-
- // Get database wrapper
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_lots_db_wrapper_class');
-
- // And set it here
- $managerInstance->setWrapperInstance($wrapperInstance);
-
- // Return the prepared instance
- return $managerInstance;
- }
-
- /**
- * Checks whether at least one map requires expansion
- *
- * @return $requiresExpansion Whether a map requires expansion
- * @todo 0% done
- */
- public function isMapPendingExpansion () {
- // Default is no expansion is needed
- $requireExpansion = FALSE;
-
- // First, a simple check if the lots table contains any entries at all
- if ($this->getWrapperInstance()->countTotalRows() == 0) {
- // This definedly requires expansion
- $requireExpansion = TRUE;
- } // END - if
-
- // Return status
- return $requireExpansion;
- }
-
- /**
- * Expands any map that requires expansion
- *
- * @return void
- * @todo ~10% done
- * @todo z-coordinate not used
- */
- public function expandMaps () {
- // Get a city info wrapper instance
- $cityWrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class');
-
- // Get all city ids from it
- $cityIds = $cityWrapperInstance->getAllCityIds();
-
- // Now check all ids
- foreach ($cityIds as $cityId) {
- // Does this id have any lots
- if (!$this->getWrapperInstance()->ifCityHasLots($cityId)) {
- // Nothing found, so it is a brand-new city that needs first initialization
- $lots = $this->getWrapperInstance()->doInitialCityExpansion($cityId);
- } else {
- // @TODO Maybe some expansion is needed
- }
- } // END - foreach
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A city sections manager
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 CitySectionsManager extends BaseFrameworkSystem implements ManageableCitySections, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $managerInstance An instance of a ManageableCitySections class
- */
- public final static function createCitySectionsManager () {
- // Get new instance
- $managerInstance = new CitySectionsManager();
-
- // Get database wrapper
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_sections_db_wrapper_class');
-
- // And set it here
- $managerInstance->setWrapperInstance($wrapperInstance);
-
- // Return the prepared instance
- return $managerInstance;
- }
-
- /**
- * Checks whether at least one map requires expansion
- *
- * @return $requiresExpansion Whether a map requires expansion
- * @todo 0% done
- */
- public function isMapPendingExpansion () {
- // Default is no expansion is needed
- $requireExpansion = FALSE;
-
- // First, a simple check if the sections table contains any entries at all
- if ($this->getWrapperInstance()->countTotalRows() == 0) {
- // This definedly requires expansion
- $requireExpansion = TRUE;
- } // END - if
-
- // Return status
- return $requireExpansion;
- }
-
- /**
- * Expands any map that requires expansion
- *
- * @return void
- * @todo ~10% done
- * @todo z-coordinate not used
- */
- public function expandMaps () {
- // Get a city info wrapper instance
- $cityWrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class');
-
- // Get all city ids from it
- $cityIds = $cityWrapperInstance->getAllCityIds();
-
- // Now check all ids
- foreach ($cityIds as $cityId) {
- // Does this id have any sections
- if (!$this->getWrapperInstance()->ifCityHasSections($cityId)) {
- // Nothing found, so it is a brand-new city that needs first initialization
- $sections = $this->getWrapperInstance()->doInitialCityExpansion($cityId);
- } else {
- // @TODO Maybe some expansion is needed
- }
- } // END - foreach
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A ??? manager
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 ???Manager extends BaseFrameworkSystem implements Manageable???, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $managerInstance An instance of a Manageable??? class
- */
- public final static function create???Manager () {
- // Get new instance
- $managerInstance = new ???Manager();
-
- // Return the prepared instance
- return $managerInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A general Manager class
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 BaseManager extends BaseCitySystem implements Manageable, Registerable {
- /**
- * Protected constructor
- *
- * @param $className Name of the class
- * @return void
- */
- protected function __construct ($className) {
- // Call parent constructor
- parent::__construct($className);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A Region manager
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 Region 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 RegionManager extends BaseManager implements ManageableRegion {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $managerInstance An instance of a ManageableRegion class
- */
- public final static function createRegionManager () {
- // Get new instance
- $managerInstance = new RegionManager();
-
- // Get database wrapper
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('region_info_db_wrapper_class');
-
- // And set it here
- $managerInstance->setWrapperInstance($wrapperInstance);
-
- // Return the prepared instance
- return $managerInstance;
- }
-
- /**
- * Checks whether the current user has already founded a region
- *
- * @return $isFounded Whether the current user has already founded a region
- */
- public function ifUserHasCreatedRegion () {
- // Check if the currently set user has already founded a region
- $isFounded = $this->getWrapperInstance()->ifUserHasCreatedRegion();
-
- // Return result
- return $isFounded;
- }
-
- /**
- * Checks whether the given region name is already taken
- *
- * @para $regionName Name of region
- * @return $isTaken Whether the given region name is already taken
- */
- public function ifRegionNameExists ($regionName) {
- // Check if the given region name is taken
- $isTaken = $this->getWrapperInstance()->ifRegionExists($regionName);
-
- // Return result
- return $isTaken;
- }
-
- /**
- * Founds the first region. A dummy region will also be created
- *
- * @return $resultInstance Found result after creating it
- */
- public function createFirstRegion () {
- // Dummy name
- // @TODO Move to language system
- $regionName = 'Region 1';
-
- // Some pre-checks
- assert(!$this->ifUserHasCreatedRegion());
- assert(!$this->ifRegionNameExists($regionName));
-
- // First region can now be created
- $this->getWrapperInstance()->createRegionByName($regionName);
-
- // Then try to find it
- assert($this->ifRegionNameExists($regionName));
-
- // Get result instance
- $resultInstance = $this->getResultInstance();
-
- // And return it
- return $resultInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A region map manager
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 Region 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 RegionMapManager extends BaseManager implements ManageableRegionMap {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $managerInstance An instance of a ManageableRegion class
- */
- public final static function createRegionMapManager () {
- // Get new instance
- $managerInstance = new RegionMapManager();
-
- // Get database wrapper
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('region_map_db_wrapper_class');
-
- // And set it here
- $managerInstance->setWrapperInstance($wrapperInstance);
-
- // Return the prepared instance
- return $managerInstance;
- }
-
- /**
- * Creates a map, if not found yet, for given result which should contain
- * data about the region in question
- *
- * @param $resultInstance Region result instance
- * @return void
- */
- public function createRegionMapByResult (SearchableResult $resultInstance) {
- die('!ok');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A ??? menu class for Ship-Simu
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 City???Menu extends BaseMenu implements RenderableMenu {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $menuInstance An instance of this class
- */
- public final static function createCity???Menu () {
- // Get a new instance
- $menuInstance = new City???Menu();
-
- // Return the prepared instance
- return $menuInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A Confirm menu class for City
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityConfirmMenu extends BaseMenu implements RenderableMenu {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $menuInstance An instance of this class
- */
- public static final function createCityConfirmMenu () {
- // Get a new instance
- $menuInstance = new CityConfirmMenu();
-
- // Return the prepared instance
- return $menuInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A menu class for City
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHomeMenu extends BaseMenu implements RenderableMenu {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $menuInstance An instance of this class
- */
- public static final function createCityHomeMenu () {
- // Get a new instance
- $menuInstance = new CityHomeMenu();
-
- // Return the prepared instance
- return $menuInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A menu class for City
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityLoginAreaMenu extends BaseMenu implements RenderableMenu {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $menuInstance An instance of this class
- */
- public static final function createCityLoginAreaMenu () {
- // Get a new instance
- $menuInstance = new CityLoginAreaMenu();
-
- // Return the prepared instance
- return $menuInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A LoginFailed menu class for City
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityLoginFailedMenu extends BaseMenu implements RenderableMenu {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $menuInstance An instance of this class
- */
- public static final function createCityLoginFailedMenu () {
- // Get a new instance
- $menuInstance = new CityLoginFailedMenu();
-
- // Return the prepared instance
- return $menuInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A menu class for City
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityLoginMenu extends BaseMenu implements RenderableMenu {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $menuInstance An instance of this class
- */
- public static final function createCityLoginMenu () {
- // Get a new instance
- $menuInstance = new CityLoginMenu();
-
- // Return the prepared instance
- return $menuInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A menu class for City
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityLogoutMenu extends BaseMenu implements RenderableMenu {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $menuInstance An instance of this class
- */
- public static final function createCityLogoutMenu () {
- // Get a new instance
- $menuInstance = new CityLogoutMenu();
-
- // Return the prepared instance
- return $menuInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A menu class for City registration
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityRegisterMenu extends BaseMenu implements RenderableMenu {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $menuInstance An instance of this class
- */
- public static final function createCityRegisterMenu () {
- // Get a new instance
- $menuInstance = new CityRegisterMenu();
-
- // Return the prepared instance
- return $menuInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A Status menu class for City
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityStatusMenu extends BaseMenu implements RenderableMenu {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $menuInstance An instance of this class
- */
- public static final function createCityStatusMenu () {
- // Get a new instance
- $menuInstance = new CityStatusMenu();
-
- // Return the prepared instance
- return $menuInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A menu class for City
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityGovernmentFailedAreaMenu extends BaseMenu implements RenderableMenu {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $menuInstance An instance of this class
- */
- public static final function createCityGovernmentFailedAreaMenu () {
- // Get a new instance
- $menuInstance = new CityGovernmentFailedAreaMenu();
-
- // Return the prepared instance
- return $menuInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A user registration class specially for City
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityRegistration extends BaseRegistration implements UserRegister {
- /**
- * Hashed password
- */
- private $hashedPassword = '';
-
- /**
- * Elements for criteria
- */
- private $criteriaElements = array(
- 'username',
- 'pass_hash',
- 'email' => 'email1',
- 'surname',
- 'family',
- 'street',
- 'zip',
- 'city',
- 'icq',
- 'jabber',
- 'yahoo',
- 'aol',
- 'msn',
- 'birth_day',
- 'birth_month',
- 'birth_year'
- );
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Create a new instance
- *
- * @return $registrationInstance An instance of this registration class
- */
- public static final function createCityRegistration () {
- // Get a new instance
- $registrationInstance = new CityRegistration();
-
- // Initialize the filter chains
- $registrationInstance->initFilterChains();
-
- // And return it
- return $registrationInstance;
- }
-
- /**
- * Encrypt given request key or throw an exception if key was not found in
- * request
- *
- * @param $requestKey Key in request class
- * @return void
- */
- public function encryptPassword ($requestKey) {
- // Check if password is found in request
- if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
- // So encrypt the password and store it for later usage in
- // the request:
-
- // 1.: Get the plain password
- $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
-
- // 2. Get a crypto helper and hash the password
- $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword);
-
- // 3. Store the hash back in request
- $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
- }
- }
-
- /**
- * Perform things like informing assigned affilates about new registration
- * before registration
- *
- * @return void
- * @todo Maybe add more things to perform
- */
- public function doPreRegistration () {
- // First run all pre filters
- $this->executePreFilters();
- }
-
- /**
- * Registers the new user account by insterting the request data into the
- * database and paying some start credits or throw exceptions if this fails
- *
- * @return void
- * @todo Maybe add more things to perform
- */
- public function registerNewUser () {
- // Get a user database wrapper
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('user_db_wrapper_class');
-
- // Use this instance to insert the whole registration instance
- $wrapperInstance->insertRegistrationObject($this);
- }
-
- /**
- * Perform things like notifying partner websites after registration is done
- *
- * @return void
- * @todo Maybe add more things to perform
- */
- public function doPostRegistration () {
- // First run all post filters
- $this->executePostFilters();
- }
-
- /**
- * Do the action which is required after all registration steps are done.
- * This can be a simple redirect to another webpage or displaying a message
- * to the user. Or this can be a login step into the newly created account.
- *
- * @return void
- */
- public function doPostAction () {
- // Get an action instance from our factory
- $actionInstance = ObjectFactory::createObjectByConfiguredName('post_registration_class');
-
- // Execute the action
- $actionInstance->execute($this->getRequestInstance(), $this->getResponseInstance());
- }
-
- /**
- * Adds registration elements to a given dataset instance
- *
- * @param $criteriaInstance An instance of a StoreableCriteria class
- * @param $requestInstance An instance of a Requestable class
- * @return void
- */
- public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) {
- // Default is unconfirmed!
- $configEntry = 'user_status_unconfirmed';
-
- // Is the confirmation process entirely disabled?
- if ($this->getConfigInstance()->getConfigEntry('confirm_email_enabled') === 'N') {
- // No confirmation of email needed
- $configEntry = 'user_status_confirmed';
- } // END - if
-
- // Add a lot elements to the dataset criteria
- foreach ($this->criteriaElements as $alias => $element) {
- // Do we have an alias?
- if (is_string($alias)) {
- // Yes, so use it
- $criteriaInstance->addCriteria($alias, $this->getRequestInstance()->getRequestElement($element));
-
- // Debug message
- //* DEBUG: */ $this->debugOutput('ALIAS: alias='.$alias.',element='.$element.'='.$this->getRequestInstance()->getRequestElement($element));
- } else {
- // No, default entry
- $criteriaInstance->addCriteria($element, $this->getRequestInstance()->getRequestElement($element));
-
- // Debug message
- //* DEBUG: */ $this->debugOutput('DEFAULT: element='.$element.'='.$this->getRequestInstance()->getRequestElement($element));
- }
-
- // Is this a guest account?
- if ((($element == 'username') || ($alias == 'username')) && ($this->getRequestInstance()->getRequestElement($element) == $this->getConfigInstance()->getConfigEntry('guest_login_user'))) {
- // Yes, then set the config entry to guest status
- $configEntry = 'user_status_guest';
- } // END - if
- } // END - foreach
-
- // Mark the username as unique key
- $criteriaInstance->setUniqueKey(UserDatabaseWrapper::DB_COLUMN_USERNAME);
-
- // Add account status as configured
- $criteriaInstance->addConfiguredCriteria(UserDatabaseWrapper::DB_COLUMN_USER_STATUS, $configEntry);
-
- // Include registration timestamp
- $criteriaInstance->addCriteria('registered', date('Y-m-d H:i:s', time()));
- }
-}
-
-//
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A command resolver for console commands
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityConsoleCommandResolver extends BaseCommandResolver implements CommandResolver {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set prefix to "CityConsole"
- $this->setClassPrefix('city_console');
- }
-
- /**
- * Creates an instance of a CityConsole command resolver with a given default command
- *
- * @param $commandName The default command we shall execute
- * @param $applicationInstance 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 static final function createCityConsoleCommandResolver ($commandName, ManageableApplication $applicationInstance) {
- // Create the new instance
- $resolverInstance = new CityConsoleCommandResolver();
-
- // 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($applicationInstance);
-
- // Return the prepared instance
- return $resolverInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A command resolver for HTML commands
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlCommandResolver extends BaseCommandResolver implements CommandResolver {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set prefix to "CityHtml"
- $this->setClassPrefix('city_html');
- }
-
- /**
- * Creates an instance of a CityHtml command resolver with a given default command
- *
- * @param $commandName The default command we shall execute
- * @param $applicationInstance 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 static final function createCityHtmlCommandResolver ($commandName, ManageableApplication $applicationInstance) {
- // Create the new instance
- $resolverInstance = new CityHtmlCommandResolver();
-
- // 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($applicationInstance);
-
- // Return the prepared instance
- return $resolverInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A resolver for resolving controllers locally
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set prefix to 'city_console'
- $this->setClassPrefix('city_console');
- }
-
- /**
- * Creates an instance of a resolver class with a given controller
- *
- * @param $controllerName The controller we shall resolve
- * @param $applicationInstance An instance of a manageable application helper class
- * @return $resolverInstance The prepared controller resolver instance
- * @throws EmptyVariableException Thrown if default controller is not set
- * @throws InvalidControllerException Thrown if default controller is invalid
- */
- public static final function createCityConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
- // Create the new instance
- $resolverInstance = new CityConsoleControllerResolver();
-
- // Is the variable $controllerName set and the controller is valid?
- if (empty($controllerName)) {
- // Then thrown an exception here
- throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
- // Invalid controller found
- throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
- }
-
- // Set the application instance
- $resolverInstance->setApplicationInstance($applicationInstance);
-
- // Set controller name
- $resolverInstance->setControllerName($controllerName);
-
- // Return the prepared instance
- return $resolverInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A resolver for resolving controllers locally
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlControllerResolver extends BaseControllerResolver implements ControllerResolver {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set prefix to 'city_html'
- $this->setClassPrefix('city_html');
- }
-
- /**
- * Creates an instance of a resolver class with a given controller
- *
- * @param $controllerName The controller we shall resolve
- * @param $applicationInstance An instance of a manageable application helper class
- * @return $resolverInstance The prepared controller resolver instance
- * @throws EmptyVariableException Thrown if default controller is not set
- * @throws InvalidControllerException Thrown if default controller is invalid
- */
- public static final function createCityHtmlControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
- // Create the new instance
- $resolverInstance = new CityHtmlControllerResolver();
-
- // Is the variable $controllerName set and the controller is valid?
- if (empty($controllerName)) {
- // Then thrown an exception here
- throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
- // Invalid controller found
- throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
- }
-
- // Set the application instance
- $resolverInstance->setApplicationInstance($applicationInstance);
-
- // Set controller name
- $resolverInstance->setControllerName($controllerName);
-
- // Return the prepared instance
- return $resolverInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A resolver for resolving controllers locally
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityImageControllerResolver extends BaseControllerResolver implements ControllerResolver {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set prefix to 'image'
- $this->setClassPrefix('image');
- }
-
- /**
- * Creates an instance of a resolver class with a given controller
- *
- * @param $controllerName The controller we shall resolve
- * @param $applicationInstance An instance of a manageable application helper class
- * @return $resolverInstance The prepared controller resolver instance
- * @throws EmptyVariableException Thrown if default controller is not set
- * @throws InvalidControllerException Thrown if default controller is invalid
- */
- public static final function createCityImageControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
- // Create the new instance
- $resolverInstance = new CityImageControllerResolver();
-
- // Is the variable $controllerName set and the controller is valid?
- if (empty($controllerName)) {
- // Then thrown an exception here
- throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
- // Invalid controller found
- throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
- }
-
- // Set the application instance
- $resolverInstance->setApplicationInstance($applicationInstance);
-
- // Set controller name
- $resolverInstance->setControllerName($controllerName);
-
- // Return the prepared instance
- return $resolverInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A active city state class
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityActiveState extends BaseCityState implements Stateable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructo
- parent::__construct(__CLASS__);
-
- // Set state name
- $this->setStateName('active');
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $stateInstance An instance of a Stateable class
- */
- public static final function createCityActiveState () {
- // Get new instance
- $stateInstance = new CityActiveState();
-
- // Get city instance and set 'active' flag
- CityDaemonFactory::createCityDaemonInstance()->enableIsActive();
-
- // Return the prepared instance
- return $stateInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A ??? city state class
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 City???State extends BaseCityState implements Stateable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set state name
- $this->setStateName('!!!');
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $stateInstance An instance of a Stateable class
- */
- public final static function createCity???State () {
- // Get new instance
- $stateInstance = new City???State();
-
- // Return the prepared instance
- return $stateInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A general city state class
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 BaseCityState extends BaseState {
- /**
- * Protected constructor
- *
- * @param $className Name of the class
- * @return void
- */
- protected function __construct ($className) {
- // Call parent constructor
- parent::__construct($className);
- }
-
- /**
- * Validates whether the state is 'active' or throws an exception if
- * it is every other state.
- *
- * @return void
- * @throws UnexpectedStateException If the state is not 'active'
- */
- public function validateCityStateIsActive () {
- // Just compare it...
- if (!$this instanceof CityActiveState) {
- // Throw the exception
- throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
- }
-
- /**
- * Validates whether the state is 'init' or throws an exception if
- * it is every other state.
- *
- * @return void
- * @throws UnexpectedStateException If the state is not 'virgin'
- */
- public function validateCityStateIsInit () {
- // Just compare it...
- if (!$this instanceof CityInitState) {
- // Throw the exception
- throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A init city state class
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityInitState extends BaseCityState implements Stateable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructo
- parent::__construct(__CLASS__);
-
- // Set state name
- $this->setStateName('init');
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $stateInstance An instance of a Stateable class
- */
- public static final function createCityInitState () {
- // Get new instance
- $stateInstance = new CityInitState();
-
- // Return the prepared instance
- return $stateInstance;
- }
-
- /**
- * Executes the state with given Executor instance
- *
- * @param $executorInstance An instance of a Executor class
- * @return void
- */
- public function executeState (Executor $executorInstance) {
- // Initialize the daemon
- $executorInstance->initializeDaemon($this);
- }
-
- /**
- * Change the state to 'active' when the city daemon has initialized all
- * tasks, queues, etc.
- *
- * @return void
- */
- public function citySimulationIsActivated () {
- // Create the new state instance
- CityStateFactory::createCityStateInstanceByName('active');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A general CityTask class
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City 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 BaseCityTask extends BaseTask {
- /**
- * An instance of a city
- */
- private $cityInstance = NULL;
-
- /**
- * Protected constructor
- *
- * @param $className Name of the class
- * @return void
- */
- protected function __construct ($className) {
- // Call parent constructor
- parent::__construct($className);
- }
-
- /**
- * Getter for city instance
- *
- * @return $cityInstance An instance of a city city
- */
- public final function getCityInstance () {
- return $this->cityInstance;
- }
-
- /**
- * Setter for city instance
- *
- * @param $cityInstance An instance of a city city
- * @return void
- */
- protected final function setCityInstance (CityHelper $cityInstance) {
- $this->cityInstance = $cityInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A BuildingGrowth city daemon-task
- *
- * @author Roland Haeder <webmaster@ship-simu.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.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 CityDaemonBuildingGrowthTask extends BaseCityTask implements Taskable, Visitable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $taskInstance An instance of a Visitable class
- */
- public final static function createCityDaemonBuildingGrowthTask () {
- // Get new instance
- $taskInstance = new CityDaemonBuildingGrowthTask();
-
- // Return the prepared instance
- return $taskInstance;
- }
-
- /**
- * Accepts the visitor to process the visitor
- *
- * @param $visitorInstance An instance of a Visitor class
- * @return void
- * @todo Maybe visit some sub-objects
- */
- public function accept (Visitor $visitorInstance) {
- // Visit this task
- $visitorInstance->visitTask($this);
- }
-
- /**
- * Executes the task
- *
- * @return void
- * @todo 0% done
- */
- public function executeTask () {
- $this->partialStub('Unimplemented task.');
- }
-
- /**
- * Shuts down the task
- *
- * @return void
- * @todo 0% done
- */
- public function doShutdown () {
- self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A ??? city daemon-task
- *
- * @author Roland Haeder <webmaster@ship-simu.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.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 CityDaemon???Task extends BaseTask implements Taskable, Visitable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $taskInstance An instance of a Visitable class
- */
- public final static function createCityDaemon???Task () {
- // Get new instance
- $taskInstance = new CityDaemon???Task();
-
- // Return the prepared instance
- return $taskInstance;
- }
-
- /**
- * Accepts the visitor to process the visitor
- *
- * @param $visitorInstance An instance of a Visitor class
- * @return void
- * @todo Maybe visit some sub-objects
- */
- public function accept (Visitor $visitorInstance) {
- // Visit this task
- $visitorInstance->visitTask($this);
- }
-
- /**
- * Executes the task
- *
- * @return void
- * @todo 0% done
- */
- public function executeTask () {
- $this->partialStub('Unimplemented task.');
- }
-
- /**
- * Shuts down the task
- *
- * @return void
- * @todo 0% done
- */
- public function doShutdown () {
- self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A HouseholdGrowth city daemon-task
- *
- * @author Roland Haeder <webmaster@ship-simu.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.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 CityDaemonHouseholdGrowthTask extends BaseCityTask implements Taskable, Visitable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $taskInstance An instance of a Visitable class
- */
- public final static function createCityDaemonHouseholdGrowthTask () {
- // Get new instance
- $taskInstance = new CityDaemonHouseholdGrowthTask();
-
- // Return the prepared instance
- return $taskInstance;
- }
-
- /**
- * Accepts the visitor to process the visitor
- *
- * @param $visitorInstance An instance of a Visitor class
- * @return void
- * @todo Maybe visit some sub-objects
- */
- public function accept (Visitor $visitorInstance) {
- // Visit this task
- $visitorInstance->visitTask($this);
- }
-
- /**
- * Executes the task
- *
- * @return void
- * @todo 0% done
- */
- public function executeTask () {
- $this->partialStub('Unimplemented task.');
- }
-
- /**
- * Shuts down the task
- *
- * @return void
- * @todo 0% done
- */
- public function doShutdown () {
- self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A map expander task for the daemon
- *
- * @author Roland Haeder <webmaster@ship-simu.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.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 CityDaemonMapExpanderTask extends BaseCityTask implements Taskable, Visitable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $taskInstance An instance of a Visitable class
- */
- public final static function createCityDaemonMapExpanderTask () {
- // Get new instance
- $taskInstance = new CityDaemonMapExpanderTask();
-
- // Get city daemon instance
- $cityInstance = CityDaemonFactory::createCityDaemonInstance();
-
- // Set it here for "caching" it
- $taskInstance->setCityInstance($cityInstance);
-
- // Return the prepared instance
- return $taskInstance;
- }
-
- /**
- * Accepts the visitor to process the visitor
- *
- * @param $visitorInstance An instance of a Visitor class
- * @return void
- * @todo Maybe visit some sub-objects
- */
- public function accept (Visitor $visitorInstance) {
- // Visit this task
- $visitorInstance->visitTask($this);
- }
-
- /**
- * Executes the task
- *
- * @return void
- * @todo ~ 10% done
- */
- public function executeTask () {
- // Get daemon instance
- $cityInstance = $this->getCityInstance();
-
- // Is there at least one map to expand?
- if ($cityInstance->isMapPendingExpansion()) {
- // Expand the map
- $cityInstance->expandMaps();
- } // END - if
- }
-
- /**
- * Shuts down the task
- *
- * @return void
- * @todo 0% done
- */
- public function doShutdown () {
- self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
- }
-}
-
-// [EOF]
-?>
-Subproject commit 17f36438ae9e5d239cbfc019890ea81ba5f00bb1
+Subproject commit 7bc4014657a70dedfc38b9b28d134aa7c3a6158c