From 434ac4c43f3b450e25001111584298ee42b8e12a Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 18 Apr 2015 03:07:08 +0200 Subject: [PATCH] Now only use 'main_content' + added missing command classes (for possible customization?). Signed-off-by: Roland Haeder --- application/city/config.php | 15 +- ...> class_CityHtmlCityGuestLoginCommand.php} | 6 +- ...d.php => class_CityHtmlCityMapCommand.php} | 8 +- ... => class_CityHtmlCityRegisterCommand.php} | 6 +- ...=> class_CityHtmlCityUserLoginCommand.php} | 6 +- .../html/class_CityHtmlDoFormCommand.php | 78 +++++++ .../html/class_CityHtmlLoginAreaCommand.php | 203 ++++++++++++++++++ .../html/class_CityHtmlLoginCommand.php | 138 ++++++++++++ .../html/class_CityHtmlLoginFailedCommand.php | 135 ++++++++++++ .../class_CityHtmlLoginFailedController.php | 75 +++++++ .../class_CityInformationDatabaseWrapper.php | 1 + .../city/templates/de/code/city_main.ctp | 1 - .../city/templates/de/code/login_failed.ctp | 46 ++++ 13 files changed, 698 insertions(+), 20 deletions(-) rename application/city/main/commands/html/{class_HtmlCityGuestLoginCommand.php => class_CityHtmlCityGuestLoginCommand.php} (93%) rename application/city/main/commands/html/{class_HtmlCityMapCommand.php => class_CityHtmlCityMapCommand.php} (93%) rename application/city/main/commands/html/{class_HtmlCityRegisterCommand.php => class_CityHtmlCityRegisterCommand.php} (94%) rename application/city/main/commands/html/{class_HtmlCityUserLoginCommand.php => class_CityHtmlCityUserLoginCommand.php} (94%) create mode 100644 application/city/main/commands/html/class_CityHtmlDoFormCommand.php create mode 100644 application/city/main/commands/html/class_CityHtmlLoginAreaCommand.php create mode 100644 application/city/main/commands/html/class_CityHtmlLoginCommand.php create mode 100644 application/city/main/commands/html/class_CityHtmlLoginFailedCommand.php create mode 100644 application/city/main/controller/html/class_CityHtmlLoginFailedController.php create mode 100644 application/city/templates/de/code/login_failed.ctp diff --git a/application/city/config.php b/application/city/config.php index 8c46d53..c1fd59a 100644 --- a/application/city/config.php +++ b/application/city/config.php @@ -72,7 +72,10 @@ $cfg->setConfigEntry('city_html_cmd_home_resolver_class', 'CityHtmlCommandResolv $cfg->setConfigEntry('city_html_cmd_register_resolver_class', 'CityHtmlCommandResolver'); // CFG: CITY-HTML-CMD-LOGIN-RESOLVER-CLASS -$cfg->setConfigEntry('city_html_cmd_login_resolver_class', 'HtmlCommandResolver'); +$cfg->setConfigEntry('city_html_cmd_login_resolver_class', 'CityHtmlCommandResolver'); + +// CFG: CITY-HTML-CMD-LOGIN-FAILED-RESOLVER-CLASS +$cfg->setConfigEntry('city_html_cmd_login_failed_resolver_class', 'CityHtmlCommandResolver'); // CFG: NEWS-READER-HOME-CLASS $cfg->setConfigEntry('news_reader_home_class', 'DefaultNewsReader'); @@ -294,19 +297,19 @@ $cfg->setConfigEntry('city_name_verifier_filter', 'CityNameVerifierFilter'); $cfg->setConfigEntry('user_status_filter', 'UserStatusVerifierFilter'); // CFG: CITY-HTML-CMD-DO-FORM-RESOLVER-CLASS -$cfg->setConfigEntry('city_html_cmd_do_form_resolver_class', 'HtmlCommandResolver'); +$cfg->setConfigEntry('city_html_cmd_do_form_resolver_class', 'CityHtmlCommandResolver'); // CFG: CITY-HTML-CMD-LOGIN-AREA-RESOLVER-CLASS -$cfg->setConfigEntry('city_html_cmd_login_area_resolver_class', 'HtmlCommandResolver'); +$cfg->setConfigEntry('city_html_cmd_login_area_resolver_class', 'CityHtmlCommandResolver'); // CFG: CITY-HTML-CMD-CONFIRM-RESOLVER-CLASS -$cfg->setConfigEntry('city_html_cmd_confirm_resolver_class', 'HtmlCommandResolver'); +$cfg->setConfigEntry('city_html_cmd_confirm_resolver_class', 'CityHtmlCommandResolver'); // CFG: CITY-HTML-CMD-PROBLEM-RESOLVER-CLASS -$cfg->setConfigEntry('city_html_cmd_problem_resolver_class', 'HtmlCommandResolver'); +$cfg->setConfigEntry('city_html_cmd_problem_resolver_class', 'CityHtmlCommandResolver'); // CFG: CITY-HTML-CMD-LOGOUT-RESOLVER-CLASS -$cfg->setConfigEntry('city_html_cmd_logout_resolver_class', 'HtmlCommandResolver'); +$cfg->setConfigEntry('city_html_cmd_logout_resolver_class', 'CityHtmlCommandResolver'); // CFG: EMAIL-CHANGE-ALLOWED $cfg->setConfigEntry('email_change_allowed', 'Y'); diff --git a/application/city/main/commands/html/class_HtmlCityGuestLoginCommand.php b/application/city/main/commands/html/class_CityHtmlCityGuestLoginCommand.php similarity index 93% rename from application/city/main/commands/html/class_HtmlCityGuestLoginCommand.php rename to application/city/main/commands/html/class_CityHtmlCityGuestLoginCommand.php index cc71d92..98d42da 100644 --- a/application/city/main/commands/html/class_HtmlCityGuestLoginCommand.php +++ b/application/city/main/commands/html/class_CityHtmlCityGuestLoginCommand.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class HtmlCityGuestLoginCommand extends BaseCommand implements Commandable { +class CityHtmlCityGuestLoginCommand extends BaseCommand implements Commandable { /** * Protected constructor * @@ -38,9 +38,9 @@ class HtmlCityGuestLoginCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver * @return $commandInstance The created command instance */ - public static final function createHtmlCityGuestLoginCommand (CommandResolver $resolverInstance) { + public static final function createCityHtmlCityGuestLoginCommand (CommandResolver $resolverInstance) { // Get a new instance - $commandInstance = new HtmlCityGuestLoginCommand(); + $commandInstance = new CityHtmlCityGuestLoginCommand(); // Set the resolver instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/application/city/main/commands/html/class_HtmlCityMapCommand.php b/application/city/main/commands/html/class_CityHtmlCityMapCommand.php similarity index 93% rename from application/city/main/commands/html/class_HtmlCityMapCommand.php rename to application/city/main/commands/html/class_CityHtmlCityMapCommand.php index 965accd..53f66c8 100644 --- a/application/city/main/commands/html/class_HtmlCityMapCommand.php +++ b/application/city/main/commands/html/class_CityHtmlCityMapCommand.php @@ -1,6 +1,6 @@ * @version 0.0.0 @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class HtmlCityMapCommand extends BaseCommand implements Commandable { +class CityHtmlCityMapCommand extends BaseCommand implements Commandable { /** * Protected constructor * @@ -38,9 +38,9 @@ class HtmlCityMapCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver * @return $commandInstance The created command instance */ - public static final function createHtmlCityMapCommand (CommandResolver $resolverInstance) { + public static final function createCityHtmlCityMapCommand (CommandResolver $resolverInstance) { // Get a new instance - $commandInstance = new HtmlCityMapCommand(); + $commandInstance = new CityHtmlCityMapCommand(); // Set the resolver instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/application/city/main/commands/html/class_HtmlCityRegisterCommand.php b/application/city/main/commands/html/class_CityHtmlCityRegisterCommand.php similarity index 94% rename from application/city/main/commands/html/class_HtmlCityRegisterCommand.php rename to application/city/main/commands/html/class_CityHtmlCityRegisterCommand.php index a683c42..1473ffc 100644 --- a/application/city/main/commands/html/class_HtmlCityRegisterCommand.php +++ b/application/city/main/commands/html/class_CityHtmlCityRegisterCommand.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class HtmlCityRegisterCommand extends BaseCommand implements Commandable { +class CityHtmlCityRegisterCommand extends BaseCommand implements Commandable { /** * Protected constructor * @@ -38,9 +38,9 @@ class HtmlCityRegisterCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver * @return $commandInstance The created command instance */ - public static final function createHtmlCityRegisterCommand (CommandResolver $resolverInstance) { + public static final function createCityHtmlCityRegisterCommand (CommandResolver $resolverInstance) { // Get a new instance - $commandInstance = new HtmlCityRegisterCommand(); + $commandInstance = new CityHtmlCityRegisterCommand(); // Set the resolver instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/application/city/main/commands/html/class_HtmlCityUserLoginCommand.php b/application/city/main/commands/html/class_CityHtmlCityUserLoginCommand.php similarity index 94% rename from application/city/main/commands/html/class_HtmlCityUserLoginCommand.php rename to application/city/main/commands/html/class_CityHtmlCityUserLoginCommand.php index 37c3d2d..d02eef0 100644 --- a/application/city/main/commands/html/class_HtmlCityUserLoginCommand.php +++ b/application/city/main/commands/html/class_CityHtmlCityUserLoginCommand.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class HtmlCityUserLoginCommand extends BaseCommand implements Commandable { +class CityHtmlCityUserLoginCommand extends BaseCommand implements Commandable { /** * Protected constructor * @@ -38,9 +38,9 @@ class HtmlCityUserLoginCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver * @return $commandInstance The created command instance */ - public static final function createHtmlCityUserLoginCommand (CommandResolver $resolverInstance) { + public static final function createCityHtmlCityUserLoginCommand (CommandResolver $resolverInstance) { // Get a new instance - $commandInstance = new HtmlCityUserLoginCommand(); + $commandInstance = new CityHtmlCityUserLoginCommand(); // Set the resolver instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/application/city/main/commands/html/class_CityHtmlDoFormCommand.php b/application/city/main/commands/html/class_CityHtmlDoFormCommand.php new file mode 100644 index 0000000..36b9a11 --- /dev/null +++ b/application/city/main/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/main/commands/html/class_CityHtmlLoginAreaCommand.php b/application/city/main/commands/html/class_CityHtmlLoginAreaCommand.php new file mode 100644 index 0000000..8888a09 --- /dev/null +++ b/application/city/main/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/main/commands/html/class_CityHtmlLoginCommand.php b/application/city/main/commands/html/class_CityHtmlLoginCommand.php new file mode 100644 index 0000000..7d6f472 --- /dev/null +++ b/application/city/main/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/main/commands/html/class_CityHtmlLoginFailedCommand.php b/application/city/main/commands/html/class_CityHtmlLoginFailedCommand.php new file mode 100644 index 0000000..558091d --- /dev/null +++ b/application/city/main/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/main/controller/html/class_CityHtmlLoginFailedController.php b/application/city/main/controller/html/class_CityHtmlLoginFailedController.php new file mode 100644 index 0000000..fd12355 --- /dev/null +++ b/application/city/main/controller/html/class_CityHtmlLoginFailedController.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 CityHtmlLoginFailedController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public 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/database/frontend/city/class_CityInformationDatabaseWrapper.php b/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php index 2884e1e..8de393d 100644 --- a/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php +++ b/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php @@ -185,6 +185,7 @@ class CityInformationDatabaseWrapper extends BaseDatabaseWrapper implements City // Return result return $isTaken; + } /** * Creates a city from given request diff --git a/application/city/templates/de/code/city_main.ctp b/application/city/templates/de/code/city_main.ctp index e053198..a83364f 100644 --- a/application/city/templates/de/code/city_main.ctp +++ b/application/city/templates/de/code/city_main.ctp @@ -19,7 +19,6 @@
{?main_content?} - {?content?}