From: Roland Haeder Date: Tue, 25 Aug 2015 16:46:34 +0000 (+0200) Subject: Updated 'core' + renamed main->classes X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e846ee2bfd5833a9df8da8c5445ef7b445dcfdee;p=city.git Updated 'core' + renamed main->classes Signed-off-by: Roland Haeder --- diff --git a/application/city/classes/.htaccess b/application/city/classes/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/actions/.htaccess b/application/city/classes/actions/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/actions/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/actions/class_ b/application/city/classes/actions/class_ new file mode 100644 index 0000000..1f7aa89 --- /dev/null +++ b/application/city/classes/actions/class_ @@ -0,0 +1,82 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/actions/class_BaseCityAction.php b/application/city/classes/actions/class_BaseCityAction.php new file mode 100644 index 0000000..a21caf5 --- /dev/null +++ b/application/city/classes/actions/class_BaseCityAction.php @@ -0,0 +1,62 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/actions/html/.htaccess b/application/city/classes/actions/html/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/actions/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/actions/html/city/.htaccess b/application/city/classes/actions/html/city/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/actions/html/city/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/actions/html/city/class_HtmlCityLoginCityMapAction.php b/application/city/classes/actions/html/city/class_HtmlCityLoginCityMapAction.php new file mode 100644 index 0000000..db5fe94 --- /dev/null +++ b/application/city/classes/actions/html/city/class_HtmlCityLoginCityMapAction.php @@ -0,0 +1,79 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/actions/html/class_HtmlCityLoginGovernmentAction.php b/application/city/classes/actions/html/class_HtmlCityLoginGovernmentAction.php new file mode 100644 index 0000000..4dfbc09 --- /dev/null +++ b/application/city/classes/actions/html/class_HtmlCityLoginGovernmentAction.php @@ -0,0 +1,79 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/actions/html/class_HtmlCityLoginLogoutAction.php b/application/city/classes/actions/html/class_HtmlCityLoginLogoutAction.php new file mode 100644 index 0000000..e56aa1c --- /dev/null +++ b/application/city/classes/actions/html/class_HtmlCityLoginLogoutAction.php @@ -0,0 +1,81 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/actions/html/class_HtmlCityLoginProfileAction.php b/application/city/classes/actions/html/class_HtmlCityLoginProfileAction.php new file mode 100644 index 0000000..d9d704f --- /dev/null +++ b/application/city/classes/actions/html/class_HtmlCityLoginProfileAction.php @@ -0,0 +1,82 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/actions/html/class_HtmlCityLoginStatusProblemAction.php b/application/city/classes/actions/html/class_HtmlCityLoginStatusProblemAction.php new file mode 100644 index 0000000..7d278f2 --- /dev/null +++ b/application/city/classes/actions/html/class_HtmlCityLoginStatusProblemAction.php @@ -0,0 +1,82 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/actions/html/class_HtmlCityLoginWelcomeAction.php b/application/city/classes/actions/html/class_HtmlCityLoginWelcomeAction.php new file mode 100644 index 0000000..27d576c --- /dev/null +++ b/application/city/classes/actions/html/class_HtmlCityLoginWelcomeAction.php @@ -0,0 +1,79 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/city_daemon/.htaccess b/application/city/classes/city_daemon/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/city_daemon/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/city_daemon/class_ b/application/city/classes/city_daemon/class_ new file mode 100644 index 0000000..94302a2 --- /dev/null +++ b/application/city/classes/city_daemon/class_ @@ -0,0 +1,98 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/city_daemon/class_BaseCityDaemon.php b/application/city/classes/city_daemon/class_BaseCityDaemon.php new file mode 100644 index 0000000..8584beb --- /dev/null +++ b/application/city/classes/city_daemon/class_BaseCityDaemon.php @@ -0,0 +1,281 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/city_daemon/default/.htaccess b/application/city/classes/city_daemon/default/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/city_daemon/default/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/city_daemon/default/class_SimulationDefaultCityDaemon.php b/application/city/classes/city_daemon/default/class_SimulationDefaultCityDaemon.php new file mode 100644 index 0000000..3cde128 --- /dev/null +++ b/application/city/classes/city_daemon/default/class_SimulationDefaultCityDaemon.php @@ -0,0 +1,95 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/class_ b/application/city/classes/class_ new file mode 100644 index 0000000..2ebd875 --- /dev/null +++ b/application/city/classes/class_ @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/class_Base b/application/city/classes/class_Base new file mode 100644 index 0000000..da87388 --- /dev/null +++ b/application/city/classes/class_Base @@ -0,0 +1,38 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/class_BaseCitySystem.php b/application/city/classes/class_BaseCitySystem.php new file mode 100644 index 0000000..f52a55a --- /dev/null +++ b/application/city/classes/class_BaseCitySystem.php @@ -0,0 +1,91 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/.htaccess b/application/city/classes/commands/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/commands/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/commands/console/.htaccess b/application/city/classes/commands/console/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/commands/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/commands/console/class_CityConsoleDaemonCommand.php b/application/city/classes/commands/console/class_CityConsoleDaemonCommand.php new file mode 100644 index 0000000..08f564e --- /dev/null +++ b/application/city/classes/commands/console/class_CityConsoleDaemonCommand.php @@ -0,0 +1,137 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/.htaccess b/application/city/classes/commands/html/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/commands/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/commands/html/class_CityHtmlCityGuestLoginCommand.php b/application/city/classes/commands/html/class_CityHtmlCityGuestLoginCommand.php new file mode 100644 index 0000000..98d42da --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlCityGuestLoginCommand.php @@ -0,0 +1,112 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_CityHtmlCityMapCommand.php b/application/city/classes/commands/html/class_CityHtmlCityMapCommand.php new file mode 100644 index 0000000..53f66c8 --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlCityMapCommand.php @@ -0,0 +1,104 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_CityHtmlCityRegisterCommand.php b/application/city/classes/commands/html/class_CityHtmlCityRegisterCommand.php new file mode 100644 index 0000000..1473ffc --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlCityRegisterCommand.php @@ -0,0 +1,119 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_CityHtmlCityUserLoginCommand.php b/application/city/classes/commands/html/class_CityHtmlCityUserLoginCommand.php new file mode 100644 index 0000000..d02eef0 --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlCityUserLoginCommand.php @@ -0,0 +1,124 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_CityHtmlConfirmCommand.php b/application/city/classes/commands/html/class_CityHtmlConfirmCommand.php new file mode 100644 index 0000000..1796cff --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlConfirmCommand.php @@ -0,0 +1,146 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_CityHtmlDoFormCommand.php b/application/city/classes/commands/html/class_CityHtmlDoFormCommand.php new file mode 100644 index 0000000..36b9a11 --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlDoFormCommand.php @@ -0,0 +1,78 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_CityHtmlHomeCommand.php b/application/city/classes/commands/html/class_CityHtmlHomeCommand.php new file mode 100644 index 0000000..8a7ef60 --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlHomeCommand.php @@ -0,0 +1,91 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_CityHtmlLoginAreaCommand.php b/application/city/classes/commands/html/class_CityHtmlLoginAreaCommand.php new file mode 100644 index 0000000..8888a09 --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlLoginAreaCommand.php @@ -0,0 +1,203 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_CityHtmlLoginCommand.php b/application/city/classes/commands/html/class_CityHtmlLoginCommand.php new file mode 100644 index 0000000..7d6f472 --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlLoginCommand.php @@ -0,0 +1,138 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_CityHtmlLoginFailedCommand.php b/application/city/classes/commands/html/class_CityHtmlLoginFailedCommand.php new file mode 100644 index 0000000..558091d --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlLoginFailedCommand.php @@ -0,0 +1,135 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_CityHtmlLogoutCommand.php b/application/city/classes/commands/html/class_CityHtmlLogoutCommand.php new file mode 100644 index 0000000..38986dd --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlLogoutCommand.php @@ -0,0 +1,89 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_CityHtmlRegisterCommand.php b/application/city/classes/commands/html/class_CityHtmlRegisterCommand.php new file mode 100644 index 0000000..012bbbc --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlRegisterCommand.php @@ -0,0 +1,80 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_CityHtmlResendLinkCommand.php b/application/city/classes/commands/html/class_CityHtmlResendLinkCommand.php new file mode 100644 index 0000000..1744594 --- /dev/null +++ b/application/city/classes/commands/html/class_CityHtmlResendLinkCommand.php @@ -0,0 +1,135 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/commands/html/class_HtmlLogoutDoneCommand.php b/application/city/classes/commands/html/class_HtmlLogoutDoneCommand.php new file mode 100644 index 0000000..42bf403 --- /dev/null +++ b/application/city/classes/commands/html/class_HtmlLogoutDoneCommand.php @@ -0,0 +1,135 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/controller/.htaccess b/application/city/classes/controller/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/controller/console/.htaccess b/application/city/classes/controller/console/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/controller/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/controller/console/class_CityConsoleDefaultNewsController.php b/application/city/classes/controller/console/class_CityConsoleDefaultNewsController.php new file mode 100644 index 0000000..ea1f057 --- /dev/null +++ b/application/city/classes/controller/console/class_CityConsoleDefaultNewsController.php @@ -0,0 +1,135 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/controller/html/.htaccess b/application/city/classes/controller/html/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/controller/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/controller/html/class_CityHtmlConfirmController.php b/application/city/classes/controller/html/class_CityHtmlConfirmController.php new file mode 100644 index 0000000..3d90c4a --- /dev/null +++ b/application/city/classes/controller/html/class_CityHtmlConfirmController.php @@ -0,0 +1,73 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/controller/html/class_CityHtmlDefaultNewsController.php b/application/city/classes/controller/html/class_CityHtmlDefaultNewsController.php new file mode 100644 index 0000000..9ec4914 --- /dev/null +++ b/application/city/classes/controller/html/class_CityHtmlDefaultNewsController.php @@ -0,0 +1,75 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/controller/html/class_CityHtmlLoginController.php b/application/city/classes/controller/html/class_CityHtmlLoginController.php new file mode 100644 index 0000000..b0d0d6a --- /dev/null +++ b/application/city/classes/controller/html/class_CityHtmlLoginController.php @@ -0,0 +1,73 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/controller/html/class_CityHtmlLoginFailedController.php b/application/city/classes/controller/html/class_CityHtmlLoginFailedController.php new file mode 100644 index 0000000..c7a010a --- /dev/null +++ b/application/city/classes/controller/html/class_CityHtmlLoginFailedController.php @@ -0,0 +1,80 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/controller/html/class_CityHtmlLogoutController.php b/application/city/classes/controller/html/class_CityHtmlLogoutController.php new file mode 100644 index 0000000..4bed8dc --- /dev/null +++ b/application/city/classes/controller/html/class_CityHtmlLogoutController.php @@ -0,0 +1,87 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/controller/html/class_CityHtmlLogoutDoneController.php b/application/city/classes/controller/html/class_CityHtmlLogoutDoneController.php new file mode 100644 index 0000000..dc311c5 --- /dev/null +++ b/application/city/classes/controller/html/class_CityHtmlLogoutDoneController.php @@ -0,0 +1,72 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/controller/html/class_CityHtmlRegisterController.php b/application/city/classes/controller/html/class_CityHtmlRegisterController.php new file mode 100644 index 0000000..fd4f4b8 --- /dev/null +++ b/application/city/classes/controller/html/class_CityHtmlRegisterController.php @@ -0,0 +1,72 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/controller/html/form/.htaccess b/application/city/classes/controller/html/form/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/controller/html/form/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/controller/html/form/class_CityHtmlDoFormController.php b/application/city/classes/controller/html/form/class_CityHtmlDoFormController.php new file mode 100644 index 0000000..aef6eb5 --- /dev/null +++ b/application/city/classes/controller/html/form/class_CityHtmlDoFormController.php @@ -0,0 +1,107 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/controller/html/login/.htaccess b/application/city/classes/controller/html/login/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/controller/html/login/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/controller/html/login/class_CityHtmlLoginAreaController.php b/application/city/classes/controller/html/login/class_CityHtmlLoginAreaController.php new file mode 100644 index 0000000..5169a87 --- /dev/null +++ b/application/city/classes/controller/html/login/class_CityHtmlLoginAreaController.php @@ -0,0 +1,87 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/database/.htaccess b/application/city/classes/database/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/database/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/database/frontend/.htaccess b/application/city/classes/database/frontend/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/database/frontend/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/database/frontend/city/.htaccess b/application/city/classes/database/frontend/city/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/database/frontend/city/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/database/frontend/city/class_CityInformationDatabaseWrapper.php b/application/city/classes/database/frontend/city/class_CityInformationDatabaseWrapper.php new file mode 100644 index 0000000..6624b56 --- /dev/null +++ b/application/city/classes/database/frontend/city/class_CityInformationDatabaseWrapper.php @@ -0,0 +1,265 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/database/frontend/city_entities/.htaccess b/application/city/classes/database/frontend/city_entities/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/database/frontend/city_entities/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/database/frontend/city_entities/districts/.htaccess b/application/city/classes/database/frontend/city_entities/districts/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/database/frontend/city_entities/districts/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/database/frontend/city_entities/districts/class_CityDistrictsDatabaseWrapper.php b/application/city/classes/database/frontend/city_entities/districts/class_CityDistrictsDatabaseWrapper.php new file mode 100644 index 0000000..67ea7c4 --- /dev/null +++ b/application/city/classes/database/frontend/city_entities/districts/class_CityDistrictsDatabaseWrapper.php @@ -0,0 +1,89 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/database/frontend/city_entities/lots/.htaccess b/application/city/classes/database/frontend/city_entities/lots/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/database/frontend/city_entities/lots/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php b/application/city/classes/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php new file mode 100644 index 0000000..7e4bfd5 --- /dev/null +++ b/application/city/classes/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php @@ -0,0 +1,90 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/database/frontend/city_entities/sections/.htaccess b/application/city/classes/database/frontend/city_entities/sections/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/database/frontend/city_entities/sections/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php b/application/city/classes/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php new file mode 100644 index 0000000..28826ad --- /dev/null +++ b/application/city/classes/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php @@ -0,0 +1,257 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/database/frontend/region/.htaccess b/application/city/classes/database/frontend/region/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/database/frontend/region/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/database/frontend/region/class_RegionInformationDatabaseWrapper.php b/application/city/classes/database/frontend/region/class_RegionInformationDatabaseWrapper.php new file mode 100644 index 0000000..5dd0765 --- /dev/null +++ b/application/city/classes/database/frontend/region/class_RegionInformationDatabaseWrapper.php @@ -0,0 +1,169 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/database/frontend/region_map/.htaccess b/application/city/classes/database/frontend/region_map/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/database/frontend/region_map/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/database/frontend/region_map/class_RegionMapDatabaseWrapper.php b/application/city/classes/database/frontend/region_map/class_RegionMapDatabaseWrapper.php new file mode 100644 index 0000000..a2d215b --- /dev/null +++ b/application/city/classes/database/frontend/region_map/class_RegionMapDatabaseWrapper.php @@ -0,0 +1,103 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/factories/.htaccess b/application/city/classes/factories/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/factories/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/factories/city_daemon/.htaccess b/application/city/classes/factories/city_daemon/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/factories/city_daemon/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/factories/city_daemon/class_CityDaemonFactory.php b/application/city/classes/factories/city_daemon/class_CityDaemonFactory.php new file mode 100644 index 0000000..ac34e8f --- /dev/null +++ b/application/city/classes/factories/city_daemon/class_CityDaemonFactory.php @@ -0,0 +1,89 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/factories/manager/.htaccess b/application/city/classes/factories/manager/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/factories/manager/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/factories/manager/class_ManagerFactory.php b/application/city/classes/factories/manager/class_ManagerFactory.php new file mode 100644 index 0000000..c0a93bd --- /dev/null +++ b/application/city/classes/factories/manager/class_ManagerFactory.php @@ -0,0 +1,66 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/factories/states/.htaccess b/application/city/classes/factories/states/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/factories/states/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/factories/states/city/.htaccess b/application/city/classes/factories/states/city/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/factories/states/city/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/factories/states/city/class_CityStateFactory.php b/application/city/classes/factories/states/city/class_CityStateFactory.php new file mode 100644 index 0000000..8332257 --- /dev/null +++ b/application/city/classes/factories/states/city/class_CityStateFactory.php @@ -0,0 +1,67 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/.htaccess b/application/city/classes/filter/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/filter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/filter/bootstrap/.htaccess b/application/city/classes/filter/bootstrap/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/filter/bootstrap/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/filter/bootstrap/class_CityDaemonBootstrap b/application/city/classes/filter/bootstrap/class_CityDaemonBootstrap new file mode 100644 index 0000000..9ac5ede --- /dev/null +++ b/application/city/classes/filter/bootstrap/class_CityDaemonBootstrap @@ -0,0 +1,67 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/bootstrap/init/.htaccess b/application/city/classes/filter/bootstrap/init/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/filter/bootstrap/init/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php b/application/city/classes/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php new file mode 100644 index 0000000..5bc30aa --- /dev/null +++ b/application/city/classes/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php @@ -0,0 +1,67 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/city_daemon/.htaccess b/application/city/classes/filter/city_daemon/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/filter/city_daemon/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/filter/city_daemon/class_CityDaemon b/application/city/classes/filter/city_daemon/class_CityDaemon new file mode 100644 index 0000000..e5e2f4d --- /dev/null +++ b/application/city/classes/filter/city_daemon/class_CityDaemon @@ -0,0 +1,63 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/city_daemon/class_CityDaemonInitializationFilter.php b/application/city/classes/filter/city_daemon/class_CityDaemonInitializationFilter.php new file mode 100644 index 0000000..74a905e --- /dev/null +++ b/application/city/classes/filter/city_daemon/class_CityDaemonInitializationFilter.php @@ -0,0 +1,72 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/city_daemon/class_CityDaemonPhpRequirementsFilter.php b/application/city/classes/filter/city_daemon/class_CityDaemonPhpRequirementsFilter.php new file mode 100644 index 0000000..8ee57a4 --- /dev/null +++ b/application/city/classes/filter/city_daemon/class_CityDaemonPhpRequirementsFilter.php @@ -0,0 +1,71 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/city_daemon/class_CityDaemonWelcomeTeaserFilter.php b/application/city/classes/filter/city_daemon/class_CityDaemonWelcomeTeaserFilter.php new file mode 100644 index 0000000..d2b1533 --- /dev/null +++ b/application/city/classes/filter/city_daemon/class_CityDaemonWelcomeTeaserFilter.php @@ -0,0 +1,67 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/class_ b/application/city/classes/filter/class_ new file mode 100644 index 0000000..68dd7c7 --- /dev/null +++ b/application/city/classes/filter/class_ @@ -0,0 +1,67 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/class_BaseCityFilter.php b/application/city/classes/filter/class_BaseCityFilter.php new file mode 100644 index 0000000..e9017c9 --- /dev/null +++ b/application/city/classes/filter/class_BaseCityFilter.php @@ -0,0 +1,111 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/shutdown/.htaccess b/application/city/classes/filter/shutdown/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/filter/shutdown/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/filter/shutdown/city/.htaccess b/application/city/classes/filter/shutdown/city/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/filter/shutdown/city/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/filter/shutdown/city/class_CityDaemonShutdown b/application/city/classes/filter/shutdown/city/class_CityDaemonShutdown new file mode 100644 index 0000000..9ad60d4 --- /dev/null +++ b/application/city/classes/filter/shutdown/city/class_CityDaemonShutdown @@ -0,0 +1,67 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/shutdown/city/class_CityDaemonShutdownCityFilter.php b/application/city/classes/filter/shutdown/city/class_CityDaemonShutdownCityFilter.php new file mode 100644 index 0000000..e92c27a --- /dev/null +++ b/application/city/classes/filter/shutdown/city/class_CityDaemonShutdownCityFilter.php @@ -0,0 +1,68 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/shutdown/city/class_CityDaemonShutdownTaskHandlerFilter.php b/application/city/classes/filter/shutdown/city/class_CityDaemonShutdownTaskHandlerFilter.php new file mode 100644 index 0000000..a80fdae --- /dev/null +++ b/application/city/classes/filter/shutdown/city/class_CityDaemonShutdownTaskHandlerFilter.php @@ -0,0 +1,67 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/task/.htaccess b/application/city/classes/filter/task/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/filter/task/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/filter/task/city_daemon/.htaccess b/application/city/classes/filter/task/city_daemon/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/filter/task/city_daemon/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php b/application/city/classes/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php new file mode 100644 index 0000000..1a0eeef --- /dev/null +++ b/application/city/classes/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php @@ -0,0 +1,93 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/filter/verifier/.htaccess b/application/city/classes/filter/verifier/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/filter/verifier/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/filter/verifier/class_CityNameVerifierFilter.php b/application/city/classes/filter/verifier/class_CityNameVerifierFilter.php new file mode 100644 index 0000000..af90201 --- /dev/null +++ b/application/city/classes/filter/verifier/class_CityNameVerifierFilter.php @@ -0,0 +1,112 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/login/.htaccess b/application/city/classes/login/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/login/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/login/class_CityGuestLogin.php b/application/city/classes/login/class_CityGuestLogin.php new file mode 100644 index 0000000..61f00b4 --- /dev/null +++ b/application/city/classes/login/class_CityGuestLogin.php @@ -0,0 +1,140 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/login/class_CityUserLogin.php b/application/city/classes/login/class_CityUserLogin.php new file mode 100644 index 0000000..9901ee4 --- /dev/null +++ b/application/city/classes/login/class_CityUserLogin.php @@ -0,0 +1,148 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/login/helper/.htaccess b/application/city/classes/login/helper/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/login/helper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/login/helper/class_CityLoginHelper.php b/application/city/classes/login/helper/class_CityLoginHelper.php new file mode 100644 index 0000000..0abe805 --- /dev/null +++ b/application/city/classes/login/helper/class_CityLoginHelper.php @@ -0,0 +1,114 @@ + + * @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 . + */ +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); + } +} + +// +?> diff --git a/application/city/classes/manager/.htaccess b/application/city/classes/manager/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/manager/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/manager/city/.htaccess b/application/city/classes/manager/city/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/manager/city/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/manager/city/class_CityManager.php b/application/city/classes/manager/city/class_CityManager.php new file mode 100644 index 0000000..64f7983 --- /dev/null +++ b/application/city/classes/manager/city/class_CityManager.php @@ -0,0 +1,119 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/manager/city_entities/.htaccess b/application/city/classes/manager/city_entities/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/manager/city_entities/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/manager/city_entities/districts/.htaccess b/application/city/classes/manager/city_entities/districts/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/manager/city_entities/districts/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/manager/city_entities/districts/class_CityDistrictsManager.php b/application/city/classes/manager/city_entities/districts/class_CityDistrictsManager.php new file mode 100644 index 0000000..a029214 --- /dev/null +++ b/application/city/classes/manager/city_entities/districts/class_CityDistrictsManager.php @@ -0,0 +1,102 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/manager/city_entities/lots/.htaccess b/application/city/classes/manager/city_entities/lots/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/manager/city_entities/lots/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/manager/city_entities/lots/class_CityLotsManager.php b/application/city/classes/manager/city_entities/lots/class_CityLotsManager.php new file mode 100644 index 0000000..f4a7e98 --- /dev/null +++ b/application/city/classes/manager/city_entities/lots/class_CityLotsManager.php @@ -0,0 +1,102 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/manager/city_entities/sections/.htaccess b/application/city/classes/manager/city_entities/sections/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/manager/city_entities/sections/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/manager/city_entities/sections/class_CitySectionsManager.php b/application/city/classes/manager/city_entities/sections/class_CitySectionsManager.php new file mode 100644 index 0000000..b082111 --- /dev/null +++ b/application/city/classes/manager/city_entities/sections/class_CitySectionsManager.php @@ -0,0 +1,102 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/manager/class_ b/application/city/classes/manager/class_ new file mode 100644 index 0000000..be19c93 --- /dev/null +++ b/application/city/classes/manager/class_ @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/manager/class_BaseManager.php b/application/city/classes/manager/class_BaseManager.php new file mode 100644 index 0000000..ec3e690 --- /dev/null +++ b/application/city/classes/manager/class_BaseManager.php @@ -0,0 +1,38 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/manager/region/.htaccess b/application/city/classes/manager/region/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/manager/region/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/manager/region/class_RegionManager.php b/application/city/classes/manager/region/class_RegionManager.php new file mode 100644 index 0000000..2f56b28 --- /dev/null +++ b/application/city/classes/manager/region/class_RegionManager.php @@ -0,0 +1,110 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/manager/region/class_RegionMapManager.php b/application/city/classes/manager/region/class_RegionMapManager.php new file mode 100644 index 0000000..fe06506 --- /dev/null +++ b/application/city/classes/manager/region/class_RegionMapManager.php @@ -0,0 +1,67 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/menu/.htaccess b/application/city/classes/menu/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/menu/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/menu/class_City b/application/city/classes/menu/class_City new file mode 100644 index 0000000..979c2e0 --- /dev/null +++ b/application/city/classes/menu/class_City @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/menu/class_CityConfirmMenu.php b/application/city/classes/menu/class_CityConfirmMenu.php new file mode 100644 index 0000000..8ed5299 --- /dev/null +++ b/application/city/classes/menu/class_CityConfirmMenu.php @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/menu/class_CityHomeMenu.php b/application/city/classes/menu/class_CityHomeMenu.php new file mode 100644 index 0000000..b80e67f --- /dev/null +++ b/application/city/classes/menu/class_CityHomeMenu.php @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/menu/class_CityLoginAreaMenu.php b/application/city/classes/menu/class_CityLoginAreaMenu.php new file mode 100644 index 0000000..99f5519 --- /dev/null +++ b/application/city/classes/menu/class_CityLoginAreaMenu.php @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/menu/class_CityLoginFailedMenu.php b/application/city/classes/menu/class_CityLoginFailedMenu.php new file mode 100644 index 0000000..1d772db --- /dev/null +++ b/application/city/classes/menu/class_CityLoginFailedMenu.php @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/menu/class_CityLoginMenu.php b/application/city/classes/menu/class_CityLoginMenu.php new file mode 100644 index 0000000..f4b07aa --- /dev/null +++ b/application/city/classes/menu/class_CityLoginMenu.php @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/menu/class_CityLogoutMenu.php b/application/city/classes/menu/class_CityLogoutMenu.php new file mode 100644 index 0000000..6709d80 --- /dev/null +++ b/application/city/classes/menu/class_CityLogoutMenu.php @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/menu/class_CityRegisterMenu.php b/application/city/classes/menu/class_CityRegisterMenu.php new file mode 100644 index 0000000..5205c00 --- /dev/null +++ b/application/city/classes/menu/class_CityRegisterMenu.php @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/menu/class_CityStatusMenu.php b/application/city/classes/menu/class_CityStatusMenu.php new file mode 100644 index 0000000..cb26d46 --- /dev/null +++ b/application/city/classes/menu/class_CityStatusMenu.php @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/menu/government/.htaccess b/application/city/classes/menu/government/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/menu/government/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/menu/government/class_CityGovernmentFailedAreaMenu.php b/application/city/classes/menu/government/class_CityGovernmentFailedAreaMenu.php new file mode 100644 index 0000000..79ec895 --- /dev/null +++ b/application/city/classes/menu/government/class_CityGovernmentFailedAreaMenu.php @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/registration/.htaccess b/application/city/classes/registration/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/registration/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/registration/class_CityRegistration.php b/application/city/classes/registration/class_CityRegistration.php new file mode 100644 index 0000000..8169bb7 --- /dev/null +++ b/application/city/classes/registration/class_CityRegistration.php @@ -0,0 +1,208 @@ + + * @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 . + */ +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())); + } +} + +// +?> diff --git a/application/city/classes/resolver/.htaccess b/application/city/classes/resolver/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/resolver/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/resolver/command/.htaccess b/application/city/classes/resolver/command/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/resolver/command/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/resolver/command/console/.htaccess b/application/city/classes/resolver/command/console/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/resolver/command/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/resolver/command/console/class_CityConsoleCommandResolver.php b/application/city/classes/resolver/command/console/class_CityConsoleCommandResolver.php new file mode 100644 index 0000000..1eb5af2 --- /dev/null +++ b/application/city/classes/resolver/command/console/class_CityConsoleCommandResolver.php @@ -0,0 +1,69 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/resolver/command/html/.htaccess b/application/city/classes/resolver/command/html/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/resolver/command/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/resolver/command/html/class_CityHtmlCommandResolver.php b/application/city/classes/resolver/command/html/class_CityHtmlCommandResolver.php new file mode 100644 index 0000000..af3d122 --- /dev/null +++ b/application/city/classes/resolver/command/html/class_CityHtmlCommandResolver.php @@ -0,0 +1,69 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/resolver/controller/.htaccess b/application/city/classes/resolver/controller/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/resolver/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/resolver/controller/console/.htaccess b/application/city/classes/resolver/controller/console/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/resolver/controller/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/resolver/controller/console/class_CityConsoleControllerResolver.php b/application/city/classes/resolver/controller/console/class_CityConsoleControllerResolver.php new file mode 100644 index 0000000..8bc4aed --- /dev/null +++ b/application/city/classes/resolver/controller/console/class_CityConsoleControllerResolver.php @@ -0,0 +1,72 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/resolver/controller/html/.htaccess b/application/city/classes/resolver/controller/html/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/resolver/controller/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/resolver/controller/html/class_CityHtmlControllerResolver.php b/application/city/classes/resolver/controller/html/class_CityHtmlControllerResolver.php new file mode 100644 index 0000000..ea84e32 --- /dev/null +++ b/application/city/classes/resolver/controller/html/class_CityHtmlControllerResolver.php @@ -0,0 +1,72 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/resolver/controller/image/.htaccess b/application/city/classes/resolver/controller/image/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/resolver/controller/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/resolver/controller/image/class_CityImageControllerResolver.php b/application/city/classes/resolver/controller/image/class_CityImageControllerResolver.php new file mode 100644 index 0000000..c6d302b --- /dev/null +++ b/application/city/classes/resolver/controller/image/class_CityImageControllerResolver.php @@ -0,0 +1,72 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/states/.htaccess b/application/city/classes/states/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/states/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/states/city/.htaccess b/application/city/classes/states/city/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/states/city/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/states/city/active/.htaccess b/application/city/classes/states/city/active/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/states/city/active/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/states/city/active/class_CityActiveState.php b/application/city/classes/states/city/active/class_CityActiveState.php new file mode 100644 index 0000000..cbf3b67 --- /dev/null +++ b/application/city/classes/states/city/active/class_CityActiveState.php @@ -0,0 +1,56 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/states/city/class_ b/application/city/classes/states/city/class_ new file mode 100644 index 0000000..a1f38ca --- /dev/null +++ b/application/city/classes/states/city/class_ @@ -0,0 +1,53 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/states/city/class_BaseCityState.php b/application/city/classes/states/city/class_BaseCityState.php new file mode 100644 index 0000000..ad6f1e8 --- /dev/null +++ b/application/city/classes/states/city/class_BaseCityState.php @@ -0,0 +1,68 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/states/city/init/.htaccess b/application/city/classes/states/city/init/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/states/city/init/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/states/city/init/class_CityInitState.php b/application/city/classes/states/city/init/class_CityInitState.php new file mode 100644 index 0000000..954e24a --- /dev/null +++ b/application/city/classes/states/city/init/class_CityInitState.php @@ -0,0 +1,75 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/tasks/.htaccess b/application/city/classes/tasks/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/tasks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/tasks/class_BaseCityTask.php b/application/city/classes/tasks/class_BaseCityTask.php new file mode 100644 index 0000000..1be4e51 --- /dev/null +++ b/application/city/classes/tasks/class_BaseCityTask.php @@ -0,0 +1,62 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/tasks/daemon/.htaccess b/application/city/classes/tasks/daemon/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/tasks/daemon/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/tasks/daemon/building/.htaccess b/application/city/classes/tasks/daemon/building/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/tasks/daemon/building/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/tasks/daemon/building/class_CityDaemonBuildingGrowthTask.php b/application/city/classes/tasks/daemon/building/class_CityDaemonBuildingGrowthTask.php new file mode 100644 index 0000000..54d6903 --- /dev/null +++ b/application/city/classes/tasks/daemon/building/class_CityDaemonBuildingGrowthTask.php @@ -0,0 +1,82 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/tasks/daemon/class_CityDaemon b/application/city/classes/tasks/daemon/class_CityDaemon new file mode 100644 index 0000000..48e0724 --- /dev/null +++ b/application/city/classes/tasks/daemon/class_CityDaemon @@ -0,0 +1,82 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/tasks/daemon/household/.htaccess b/application/city/classes/tasks/daemon/household/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/tasks/daemon/household/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/tasks/daemon/household/class_CityDaemonHouseholdGrowthTask.php b/application/city/classes/tasks/daemon/household/class_CityDaemonHouseholdGrowthTask.php new file mode 100644 index 0000000..179a927 --- /dev/null +++ b/application/city/classes/tasks/daemon/household/class_CityDaemonHouseholdGrowthTask.php @@ -0,0 +1,82 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/classes/tasks/daemon/map_expander/.htaccess b/application/city/classes/tasks/daemon/map_expander/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/classes/tasks/daemon/map_expander/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/classes/tasks/daemon/map_expander/class_CityDaemonMapExpanderTask.php b/application/city/classes/tasks/daemon/map_expander/class_CityDaemonMapExpanderTask.php new file mode 100644 index 0000000..a3ba21d --- /dev/null +++ b/application/city/classes/tasks/daemon/map_expander/class_CityDaemonMapExpanderTask.php @@ -0,0 +1,95 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/main/.htaccess b/application/city/main/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/actions/.htaccess b/application/city/main/actions/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/actions/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/actions/class_ b/application/city/main/actions/class_ deleted file mode 100644 index 1f7aa89..0000000 --- a/application/city/main/actions/class_ +++ /dev/null @@ -1,82 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/actions/class_BaseCityAction.php b/application/city/main/actions/class_BaseCityAction.php deleted file mode 100644 index a21caf5..0000000 --- a/application/city/main/actions/class_BaseCityAction.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/actions/html/.htaccess b/application/city/main/actions/html/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/actions/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/actions/html/city/.htaccess b/application/city/main/actions/html/city/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/actions/html/city/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/actions/html/city/class_HtmlCityLoginCityMapAction.php b/application/city/main/actions/html/city/class_HtmlCityLoginCityMapAction.php deleted file mode 100644 index db5fe94..0000000 --- a/application/city/main/actions/html/city/class_HtmlCityLoginCityMapAction.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/actions/html/class_HtmlCityLoginGovernmentAction.php b/application/city/main/actions/html/class_HtmlCityLoginGovernmentAction.php deleted file mode 100644 index 4dfbc09..0000000 --- a/application/city/main/actions/html/class_HtmlCityLoginGovernmentAction.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/actions/html/class_HtmlCityLoginLogoutAction.php b/application/city/main/actions/html/class_HtmlCityLoginLogoutAction.php deleted file mode 100644 index e56aa1c..0000000 --- a/application/city/main/actions/html/class_HtmlCityLoginLogoutAction.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/actions/html/class_HtmlCityLoginProfileAction.php b/application/city/main/actions/html/class_HtmlCityLoginProfileAction.php deleted file mode 100644 index d9d704f..0000000 --- a/application/city/main/actions/html/class_HtmlCityLoginProfileAction.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/actions/html/class_HtmlCityLoginStatusProblemAction.php b/application/city/main/actions/html/class_HtmlCityLoginStatusProblemAction.php deleted file mode 100644 index 7d278f2..0000000 --- a/application/city/main/actions/html/class_HtmlCityLoginStatusProblemAction.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/actions/html/class_HtmlCityLoginWelcomeAction.php b/application/city/main/actions/html/class_HtmlCityLoginWelcomeAction.php deleted file mode 100644 index 27d576c..0000000 --- a/application/city/main/actions/html/class_HtmlCityLoginWelcomeAction.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/city_daemon/.htaccess b/application/city/main/city_daemon/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/city_daemon/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/city_daemon/class_ b/application/city/main/city_daemon/class_ deleted file mode 100644 index 94302a2..0000000 --- a/application/city/main/city_daemon/class_ +++ /dev/null @@ -1,98 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/city_daemon/class_BaseCityDaemon.php b/application/city/main/city_daemon/class_BaseCityDaemon.php deleted file mode 100644 index 8584beb..0000000 --- a/application/city/main/city_daemon/class_BaseCityDaemon.php +++ /dev/null @@ -1,281 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/city_daemon/default/.htaccess b/application/city/main/city_daemon/default/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/city_daemon/default/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/city_daemon/default/class_SimulationDefaultCityDaemon.php b/application/city/main/city_daemon/default/class_SimulationDefaultCityDaemon.php deleted file mode 100644 index 3cde128..0000000 --- a/application/city/main/city_daemon/default/class_SimulationDefaultCityDaemon.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/class_ b/application/city/main/class_ deleted file mode 100644 index 2ebd875..0000000 --- a/application/city/main/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/class_Base b/application/city/main/class_Base deleted file mode 100644 index da87388..0000000 --- a/application/city/main/class_Base +++ /dev/null @@ -1,38 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/class_BaseCitySystem.php b/application/city/main/class_BaseCitySystem.php deleted file mode 100644 index f52a55a..0000000 --- a/application/city/main/class_BaseCitySystem.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/.htaccess b/application/city/main/commands/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/commands/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/commands/console/.htaccess b/application/city/main/commands/console/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/commands/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/commands/console/class_CityConsoleDaemonCommand.php b/application/city/main/commands/console/class_CityConsoleDaemonCommand.php deleted file mode 100644 index 08f564e..0000000 --- a/application/city/main/commands/console/class_CityConsoleDaemonCommand.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/.htaccess b/application/city/main/commands/html/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/commands/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/commands/html/class_CityHtmlCityGuestLoginCommand.php b/application/city/main/commands/html/class_CityHtmlCityGuestLoginCommand.php deleted file mode 100644 index 98d42da..0000000 --- a/application/city/main/commands/html/class_CityHtmlCityGuestLoginCommand.php +++ /dev/null @@ -1,112 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_CityHtmlCityMapCommand.php b/application/city/main/commands/html/class_CityHtmlCityMapCommand.php deleted file mode 100644 index 53f66c8..0000000 --- a/application/city/main/commands/html/class_CityHtmlCityMapCommand.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_CityHtmlCityRegisterCommand.php b/application/city/main/commands/html/class_CityHtmlCityRegisterCommand.php deleted file mode 100644 index 1473ffc..0000000 --- a/application/city/main/commands/html/class_CityHtmlCityRegisterCommand.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_CityHtmlCityUserLoginCommand.php b/application/city/main/commands/html/class_CityHtmlCityUserLoginCommand.php deleted file mode 100644 index d02eef0..0000000 --- a/application/city/main/commands/html/class_CityHtmlCityUserLoginCommand.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_CityHtmlConfirmCommand.php b/application/city/main/commands/html/class_CityHtmlConfirmCommand.php deleted file mode 100644 index 1796cff..0000000 --- a/application/city/main/commands/html/class_CityHtmlConfirmCommand.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_CityHtmlDoFormCommand.php b/application/city/main/commands/html/class_CityHtmlDoFormCommand.php deleted file mode 100644 index 36b9a11..0000000 --- a/application/city/main/commands/html/class_CityHtmlDoFormCommand.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_CityHtmlHomeCommand.php b/application/city/main/commands/html/class_CityHtmlHomeCommand.php deleted file mode 100644 index 8a7ef60..0000000 --- a/application/city/main/commands/html/class_CityHtmlHomeCommand.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_CityHtmlLoginAreaCommand.php b/application/city/main/commands/html/class_CityHtmlLoginAreaCommand.php deleted file mode 100644 index 8888a09..0000000 --- a/application/city/main/commands/html/class_CityHtmlLoginAreaCommand.php +++ /dev/null @@ -1,203 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_CityHtmlLoginCommand.php b/application/city/main/commands/html/class_CityHtmlLoginCommand.php deleted file mode 100644 index 7d6f472..0000000 --- a/application/city/main/commands/html/class_CityHtmlLoginCommand.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_CityHtmlLoginFailedCommand.php b/application/city/main/commands/html/class_CityHtmlLoginFailedCommand.php deleted file mode 100644 index 558091d..0000000 --- a/application/city/main/commands/html/class_CityHtmlLoginFailedCommand.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_CityHtmlLogoutCommand.php b/application/city/main/commands/html/class_CityHtmlLogoutCommand.php deleted file mode 100644 index 38986dd..0000000 --- a/application/city/main/commands/html/class_CityHtmlLogoutCommand.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_CityHtmlRegisterCommand.php b/application/city/main/commands/html/class_CityHtmlRegisterCommand.php deleted file mode 100644 index 012bbbc..0000000 --- a/application/city/main/commands/html/class_CityHtmlRegisterCommand.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_CityHtmlResendLinkCommand.php b/application/city/main/commands/html/class_CityHtmlResendLinkCommand.php deleted file mode 100644 index 1744594..0000000 --- a/application/city/main/commands/html/class_CityHtmlResendLinkCommand.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/commands/html/class_HtmlLogoutDoneCommand.php b/application/city/main/commands/html/class_HtmlLogoutDoneCommand.php deleted file mode 100644 index 42bf403..0000000 --- a/application/city/main/commands/html/class_HtmlLogoutDoneCommand.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/controller/.htaccess b/application/city/main/controller/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/controller/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/controller/console/.htaccess b/application/city/main/controller/console/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/controller/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/controller/console/class_CityConsoleDefaultNewsController.php b/application/city/main/controller/console/class_CityConsoleDefaultNewsController.php deleted file mode 100644 index ea1f057..0000000 --- a/application/city/main/controller/console/class_CityConsoleDefaultNewsController.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/controller/html/.htaccess b/application/city/main/controller/html/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/controller/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/controller/html/class_CityHtmlConfirmController.php b/application/city/main/controller/html/class_CityHtmlConfirmController.php deleted file mode 100644 index 3d90c4a..0000000 --- a/application/city/main/controller/html/class_CityHtmlConfirmController.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/controller/html/class_CityHtmlDefaultNewsController.php b/application/city/main/controller/html/class_CityHtmlDefaultNewsController.php deleted file mode 100644 index 9ec4914..0000000 --- a/application/city/main/controller/html/class_CityHtmlDefaultNewsController.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/controller/html/class_CityHtmlLoginController.php b/application/city/main/controller/html/class_CityHtmlLoginController.php deleted file mode 100644 index b0d0d6a..0000000 --- a/application/city/main/controller/html/class_CityHtmlLoginController.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/controller/html/class_CityHtmlLoginFailedController.php b/application/city/main/controller/html/class_CityHtmlLoginFailedController.php deleted file mode 100644 index c7a010a..0000000 --- a/application/city/main/controller/html/class_CityHtmlLoginFailedController.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/controller/html/class_CityHtmlLogoutController.php b/application/city/main/controller/html/class_CityHtmlLogoutController.php deleted file mode 100644 index 4bed8dc..0000000 --- a/application/city/main/controller/html/class_CityHtmlLogoutController.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/controller/html/class_CityHtmlLogoutDoneController.php b/application/city/main/controller/html/class_CityHtmlLogoutDoneController.php deleted file mode 100644 index dc311c5..0000000 --- a/application/city/main/controller/html/class_CityHtmlLogoutDoneController.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/controller/html/class_CityHtmlRegisterController.php b/application/city/main/controller/html/class_CityHtmlRegisterController.php deleted file mode 100644 index fd4f4b8..0000000 --- a/application/city/main/controller/html/class_CityHtmlRegisterController.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/controller/html/form/.htaccess b/application/city/main/controller/html/form/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/controller/html/form/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/controller/html/form/class_CityHtmlDoFormController.php b/application/city/main/controller/html/form/class_CityHtmlDoFormController.php deleted file mode 100644 index aef6eb5..0000000 --- a/application/city/main/controller/html/form/class_CityHtmlDoFormController.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/controller/html/login/.htaccess b/application/city/main/controller/html/login/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/controller/html/login/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/controller/html/login/class_CityHtmlLoginAreaController.php b/application/city/main/controller/html/login/class_CityHtmlLoginAreaController.php deleted file mode 100644 index 5169a87..0000000 --- a/application/city/main/controller/html/login/class_CityHtmlLoginAreaController.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/database/.htaccess b/application/city/main/database/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/database/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/database/frontend/.htaccess b/application/city/main/database/frontend/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/database/frontend/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/database/frontend/city/.htaccess b/application/city/main/database/frontend/city/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/database/frontend/city/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php b/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php deleted file mode 100644 index 6624b56..0000000 --- a/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php +++ /dev/null @@ -1,265 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/database/frontend/city_entities/.htaccess b/application/city/main/database/frontend/city_entities/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/database/frontend/city_entities/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/database/frontend/city_entities/districts/.htaccess b/application/city/main/database/frontend/city_entities/districts/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/database/frontend/city_entities/districts/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/database/frontend/city_entities/districts/class_CityDistrictsDatabaseWrapper.php b/application/city/main/database/frontend/city_entities/districts/class_CityDistrictsDatabaseWrapper.php deleted file mode 100644 index 67ea7c4..0000000 --- a/application/city/main/database/frontend/city_entities/districts/class_CityDistrictsDatabaseWrapper.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/database/frontend/city_entities/lots/.htaccess b/application/city/main/database/frontend/city_entities/lots/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/database/frontend/city_entities/lots/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php b/application/city/main/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php deleted file mode 100644 index 7e4bfd5..0000000 --- a/application/city/main/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/database/frontend/city_entities/sections/.htaccess b/application/city/main/database/frontend/city_entities/sections/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/database/frontend/city_entities/sections/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php b/application/city/main/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php deleted file mode 100644 index 28826ad..0000000 --- a/application/city/main/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php +++ /dev/null @@ -1,257 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/database/frontend/region/.htaccess b/application/city/main/database/frontend/region/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/database/frontend/region/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/database/frontend/region/class_RegionInformationDatabaseWrapper.php b/application/city/main/database/frontend/region/class_RegionInformationDatabaseWrapper.php deleted file mode 100644 index 5dd0765..0000000 --- a/application/city/main/database/frontend/region/class_RegionInformationDatabaseWrapper.php +++ /dev/null @@ -1,169 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/database/frontend/region_map/.htaccess b/application/city/main/database/frontend/region_map/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/database/frontend/region_map/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/database/frontend/region_map/class_RegionMapDatabaseWrapper.php b/application/city/main/database/frontend/region_map/class_RegionMapDatabaseWrapper.php deleted file mode 100644 index a2d215b..0000000 --- a/application/city/main/database/frontend/region_map/class_RegionMapDatabaseWrapper.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/factories/.htaccess b/application/city/main/factories/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/factories/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/factories/city_daemon/.htaccess b/application/city/main/factories/city_daemon/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/factories/city_daemon/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/factories/city_daemon/class_CityDaemonFactory.php b/application/city/main/factories/city_daemon/class_CityDaemonFactory.php deleted file mode 100644 index ac34e8f..0000000 --- a/application/city/main/factories/city_daemon/class_CityDaemonFactory.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/factories/manager/.htaccess b/application/city/main/factories/manager/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/factories/manager/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/factories/manager/class_ManagerFactory.php b/application/city/main/factories/manager/class_ManagerFactory.php deleted file mode 100644 index c0a93bd..0000000 --- a/application/city/main/factories/manager/class_ManagerFactory.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/factories/states/.htaccess b/application/city/main/factories/states/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/factories/states/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/factories/states/city/.htaccess b/application/city/main/factories/states/city/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/factories/states/city/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/factories/states/city/class_CityStateFactory.php b/application/city/main/factories/states/city/class_CityStateFactory.php deleted file mode 100644 index 8332257..0000000 --- a/application/city/main/factories/states/city/class_CityStateFactory.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/.htaccess b/application/city/main/filter/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/filter/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/filter/bootstrap/.htaccess b/application/city/main/filter/bootstrap/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/filter/bootstrap/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/filter/bootstrap/class_CityDaemonBootstrap b/application/city/main/filter/bootstrap/class_CityDaemonBootstrap deleted file mode 100644 index 9ac5ede..0000000 --- a/application/city/main/filter/bootstrap/class_CityDaemonBootstrap +++ /dev/null @@ -1,67 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/bootstrap/init/.htaccess b/application/city/main/filter/bootstrap/init/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/filter/bootstrap/init/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php b/application/city/main/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php deleted file mode 100644 index 5bc30aa..0000000 --- a/application/city/main/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/city_daemon/.htaccess b/application/city/main/filter/city_daemon/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/filter/city_daemon/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/filter/city_daemon/class_CityDaemon b/application/city/main/filter/city_daemon/class_CityDaemon deleted file mode 100644 index e5e2f4d..0000000 --- a/application/city/main/filter/city_daemon/class_CityDaemon +++ /dev/null @@ -1,63 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/city_daemon/class_CityDaemonInitializationFilter.php b/application/city/main/filter/city_daemon/class_CityDaemonInitializationFilter.php deleted file mode 100644 index 74a905e..0000000 --- a/application/city/main/filter/city_daemon/class_CityDaemonInitializationFilter.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/city_daemon/class_CityDaemonPhpRequirementsFilter.php b/application/city/main/filter/city_daemon/class_CityDaemonPhpRequirementsFilter.php deleted file mode 100644 index 8ee57a4..0000000 --- a/application/city/main/filter/city_daemon/class_CityDaemonPhpRequirementsFilter.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/city_daemon/class_CityDaemonWelcomeTeaserFilter.php b/application/city/main/filter/city_daemon/class_CityDaemonWelcomeTeaserFilter.php deleted file mode 100644 index d2b1533..0000000 --- a/application/city/main/filter/city_daemon/class_CityDaemonWelcomeTeaserFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/class_ b/application/city/main/filter/class_ deleted file mode 100644 index 68dd7c7..0000000 --- a/application/city/main/filter/class_ +++ /dev/null @@ -1,67 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/class_BaseCityFilter.php b/application/city/main/filter/class_BaseCityFilter.php deleted file mode 100644 index e9017c9..0000000 --- a/application/city/main/filter/class_BaseCityFilter.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/shutdown/.htaccess b/application/city/main/filter/shutdown/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/filter/shutdown/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/filter/shutdown/city/.htaccess b/application/city/main/filter/shutdown/city/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/filter/shutdown/city/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/filter/shutdown/city/class_CityDaemonShutdown b/application/city/main/filter/shutdown/city/class_CityDaemonShutdown deleted file mode 100644 index 9ad60d4..0000000 --- a/application/city/main/filter/shutdown/city/class_CityDaemonShutdown +++ /dev/null @@ -1,67 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/shutdown/city/class_CityDaemonShutdownCityFilter.php b/application/city/main/filter/shutdown/city/class_CityDaemonShutdownCityFilter.php deleted file mode 100644 index e92c27a..0000000 --- a/application/city/main/filter/shutdown/city/class_CityDaemonShutdownCityFilter.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/shutdown/city/class_CityDaemonShutdownTaskHandlerFilter.php b/application/city/main/filter/shutdown/city/class_CityDaemonShutdownTaskHandlerFilter.php deleted file mode 100644 index a80fdae..0000000 --- a/application/city/main/filter/shutdown/city/class_CityDaemonShutdownTaskHandlerFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/task/.htaccess b/application/city/main/filter/task/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/filter/task/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/filter/task/city_daemon/.htaccess b/application/city/main/filter/task/city_daemon/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/filter/task/city_daemon/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php b/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php deleted file mode 100644 index 1a0eeef..0000000 --- a/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/filter/verifier/.htaccess b/application/city/main/filter/verifier/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/filter/verifier/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/filter/verifier/class_CityNameVerifierFilter.php b/application/city/main/filter/verifier/class_CityNameVerifierFilter.php deleted file mode 100644 index af90201..0000000 --- a/application/city/main/filter/verifier/class_CityNameVerifierFilter.php +++ /dev/null @@ -1,112 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/login/.htaccess b/application/city/main/login/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/login/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/login/class_CityGuestLogin.php b/application/city/main/login/class_CityGuestLogin.php deleted file mode 100644 index 61f00b4..0000000 --- a/application/city/main/login/class_CityGuestLogin.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/login/class_CityUserLogin.php b/application/city/main/login/class_CityUserLogin.php deleted file mode 100644 index 9901ee4..0000000 --- a/application/city/main/login/class_CityUserLogin.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/login/helper/.htaccess b/application/city/main/login/helper/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/login/helper/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/login/helper/class_CityLoginHelper.php b/application/city/main/login/helper/class_CityLoginHelper.php deleted file mode 100644 index 0abe805..0000000 --- a/application/city/main/login/helper/class_CityLoginHelper.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @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 . - */ -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); - } -} - -// -?> diff --git a/application/city/main/manager/.htaccess b/application/city/main/manager/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/manager/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/manager/city/.htaccess b/application/city/main/manager/city/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/manager/city/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/manager/city/class_CityManager.php b/application/city/main/manager/city/class_CityManager.php deleted file mode 100644 index 64f7983..0000000 --- a/application/city/main/manager/city/class_CityManager.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/manager/city_entities/.htaccess b/application/city/main/manager/city_entities/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/manager/city_entities/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/manager/city_entities/districts/.htaccess b/application/city/main/manager/city_entities/districts/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/manager/city_entities/districts/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/manager/city_entities/districts/class_CityDistrictsManager.php b/application/city/main/manager/city_entities/districts/class_CityDistrictsManager.php deleted file mode 100644 index a029214..0000000 --- a/application/city/main/manager/city_entities/districts/class_CityDistrictsManager.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/manager/city_entities/lots/.htaccess b/application/city/main/manager/city_entities/lots/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/manager/city_entities/lots/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/manager/city_entities/lots/class_CityLotsManager.php b/application/city/main/manager/city_entities/lots/class_CityLotsManager.php deleted file mode 100644 index f4a7e98..0000000 --- a/application/city/main/manager/city_entities/lots/class_CityLotsManager.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/manager/city_entities/sections/.htaccess b/application/city/main/manager/city_entities/sections/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/manager/city_entities/sections/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/manager/city_entities/sections/class_CitySectionsManager.php b/application/city/main/manager/city_entities/sections/class_CitySectionsManager.php deleted file mode 100644 index b082111..0000000 --- a/application/city/main/manager/city_entities/sections/class_CitySectionsManager.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/manager/class_ b/application/city/main/manager/class_ deleted file mode 100644 index be19c93..0000000 --- a/application/city/main/manager/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/manager/class_BaseManager.php b/application/city/main/manager/class_BaseManager.php deleted file mode 100644 index ec3e690..0000000 --- a/application/city/main/manager/class_BaseManager.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/manager/region/.htaccess b/application/city/main/manager/region/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/manager/region/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/manager/region/class_RegionManager.php b/application/city/main/manager/region/class_RegionManager.php deleted file mode 100644 index 2f56b28..0000000 --- a/application/city/main/manager/region/class_RegionManager.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/manager/region/class_RegionMapManager.php b/application/city/main/manager/region/class_RegionMapManager.php deleted file mode 100644 index fe06506..0000000 --- a/application/city/main/manager/region/class_RegionMapManager.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/menu/.htaccess b/application/city/main/menu/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/menu/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/menu/class_City b/application/city/main/menu/class_City deleted file mode 100644 index 979c2e0..0000000 --- a/application/city/main/menu/class_City +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/menu/class_CityConfirmMenu.php b/application/city/main/menu/class_CityConfirmMenu.php deleted file mode 100644 index 8ed5299..0000000 --- a/application/city/main/menu/class_CityConfirmMenu.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/menu/class_CityHomeMenu.php b/application/city/main/menu/class_CityHomeMenu.php deleted file mode 100644 index b80e67f..0000000 --- a/application/city/main/menu/class_CityHomeMenu.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/menu/class_CityLoginAreaMenu.php b/application/city/main/menu/class_CityLoginAreaMenu.php deleted file mode 100644 index 99f5519..0000000 --- a/application/city/main/menu/class_CityLoginAreaMenu.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/menu/class_CityLoginFailedMenu.php b/application/city/main/menu/class_CityLoginFailedMenu.php deleted file mode 100644 index 1d772db..0000000 --- a/application/city/main/menu/class_CityLoginFailedMenu.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/menu/class_CityLoginMenu.php b/application/city/main/menu/class_CityLoginMenu.php deleted file mode 100644 index f4b07aa..0000000 --- a/application/city/main/menu/class_CityLoginMenu.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/menu/class_CityLogoutMenu.php b/application/city/main/menu/class_CityLogoutMenu.php deleted file mode 100644 index 6709d80..0000000 --- a/application/city/main/menu/class_CityLogoutMenu.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/menu/class_CityRegisterMenu.php b/application/city/main/menu/class_CityRegisterMenu.php deleted file mode 100644 index 5205c00..0000000 --- a/application/city/main/menu/class_CityRegisterMenu.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/menu/class_CityStatusMenu.php b/application/city/main/menu/class_CityStatusMenu.php deleted file mode 100644 index cb26d46..0000000 --- a/application/city/main/menu/class_CityStatusMenu.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/menu/government/.htaccess b/application/city/main/menu/government/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/menu/government/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/menu/government/class_CityGovernmentFailedAreaMenu.php b/application/city/main/menu/government/class_CityGovernmentFailedAreaMenu.php deleted file mode 100644 index 79ec895..0000000 --- a/application/city/main/menu/government/class_CityGovernmentFailedAreaMenu.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/registration/.htaccess b/application/city/main/registration/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/registration/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/registration/class_CityRegistration.php b/application/city/main/registration/class_CityRegistration.php deleted file mode 100644 index 8169bb7..0000000 --- a/application/city/main/registration/class_CityRegistration.php +++ /dev/null @@ -1,208 +0,0 @@ - - * @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 . - */ -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())); - } -} - -// -?> diff --git a/application/city/main/resolver/.htaccess b/application/city/main/resolver/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/resolver/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/resolver/command/.htaccess b/application/city/main/resolver/command/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/resolver/command/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/resolver/command/console/.htaccess b/application/city/main/resolver/command/console/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/resolver/command/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/resolver/command/console/class_CityConsoleCommandResolver.php b/application/city/main/resolver/command/console/class_CityConsoleCommandResolver.php deleted file mode 100644 index 1eb5af2..0000000 --- a/application/city/main/resolver/command/console/class_CityConsoleCommandResolver.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/resolver/command/html/.htaccess b/application/city/main/resolver/command/html/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/resolver/command/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/resolver/command/html/class_CityHtmlCommandResolver.php b/application/city/main/resolver/command/html/class_CityHtmlCommandResolver.php deleted file mode 100644 index af3d122..0000000 --- a/application/city/main/resolver/command/html/class_CityHtmlCommandResolver.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/resolver/controller/.htaccess b/application/city/main/resolver/controller/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/resolver/controller/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/resolver/controller/console/.htaccess b/application/city/main/resolver/controller/console/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/resolver/controller/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/resolver/controller/console/class_CityConsoleControllerResolver.php b/application/city/main/resolver/controller/console/class_CityConsoleControllerResolver.php deleted file mode 100644 index 8bc4aed..0000000 --- a/application/city/main/resolver/controller/console/class_CityConsoleControllerResolver.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/resolver/controller/html/.htaccess b/application/city/main/resolver/controller/html/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/resolver/controller/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/resolver/controller/html/class_CityHtmlControllerResolver.php b/application/city/main/resolver/controller/html/class_CityHtmlControllerResolver.php deleted file mode 100644 index ea84e32..0000000 --- a/application/city/main/resolver/controller/html/class_CityHtmlControllerResolver.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/resolver/controller/image/.htaccess b/application/city/main/resolver/controller/image/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/resolver/controller/image/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/resolver/controller/image/class_CityImageControllerResolver.php b/application/city/main/resolver/controller/image/class_CityImageControllerResolver.php deleted file mode 100644 index c6d302b..0000000 --- a/application/city/main/resolver/controller/image/class_CityImageControllerResolver.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/states/.htaccess b/application/city/main/states/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/states/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/states/city/.htaccess b/application/city/main/states/city/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/states/city/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/states/city/active/.htaccess b/application/city/main/states/city/active/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/states/city/active/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/states/city/active/class_CityActiveState.php b/application/city/main/states/city/active/class_CityActiveState.php deleted file mode 100644 index cbf3b67..0000000 --- a/application/city/main/states/city/active/class_CityActiveState.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/states/city/class_ b/application/city/main/states/city/class_ deleted file mode 100644 index a1f38ca..0000000 --- a/application/city/main/states/city/class_ +++ /dev/null @@ -1,53 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/states/city/class_BaseCityState.php b/application/city/main/states/city/class_BaseCityState.php deleted file mode 100644 index ad6f1e8..0000000 --- a/application/city/main/states/city/class_BaseCityState.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/states/city/init/.htaccess b/application/city/main/states/city/init/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/states/city/init/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/states/city/init/class_CityInitState.php b/application/city/main/states/city/init/class_CityInitState.php deleted file mode 100644 index 954e24a..0000000 --- a/application/city/main/states/city/init/class_CityInitState.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/tasks/.htaccess b/application/city/main/tasks/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/tasks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/tasks/class_BaseCityTask.php b/application/city/main/tasks/class_BaseCityTask.php deleted file mode 100644 index 1be4e51..0000000 --- a/application/city/main/tasks/class_BaseCityTask.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/tasks/daemon/.htaccess b/application/city/main/tasks/daemon/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/tasks/daemon/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/tasks/daemon/building/.htaccess b/application/city/main/tasks/daemon/building/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/tasks/daemon/building/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/tasks/daemon/building/class_CityDaemonBuildingGrowthTask.php b/application/city/main/tasks/daemon/building/class_CityDaemonBuildingGrowthTask.php deleted file mode 100644 index 54d6903..0000000 --- a/application/city/main/tasks/daemon/building/class_CityDaemonBuildingGrowthTask.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/tasks/daemon/class_CityDaemon b/application/city/main/tasks/daemon/class_CityDaemon deleted file mode 100644 index 48e0724..0000000 --- a/application/city/main/tasks/daemon/class_CityDaemon +++ /dev/null @@ -1,82 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/tasks/daemon/household/.htaccess b/application/city/main/tasks/daemon/household/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/tasks/daemon/household/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/tasks/daemon/household/class_CityDaemonHouseholdGrowthTask.php b/application/city/main/tasks/daemon/household/class_CityDaemonHouseholdGrowthTask.php deleted file mode 100644 index 179a927..0000000 --- a/application/city/main/tasks/daemon/household/class_CityDaemonHouseholdGrowthTask.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/tasks/daemon/map_expander/.htaccess b/application/city/main/tasks/daemon/map_expander/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/tasks/daemon/map_expander/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/tasks/daemon/map_expander/class_CityDaemonMapExpanderTask.php b/application/city/main/tasks/daemon/map_expander/class_CityDaemonMapExpanderTask.php deleted file mode 100644 index a3ba21d..0000000 --- a/application/city/main/tasks/daemon/map_expander/class_CityDaemonMapExpanderTask.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/core b/core index 17f3643..7bc4014 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 17f36438ae9e5d239cbfc019890ea81ba5f00bb1 +Subproject commit 7bc4014657a70dedfc38b9b28d134aa7c3a6158c