From 5c3d5d84f8f862d0d51f095f9858860f86788ae8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 28 Jun 2008 17:33:19 +0000 Subject: [PATCH] Login area extended and misc things changed: - Ship-Simu's action classes moved to sub directory "ship-simu" - Action for listing shipping companies added which redirects if you have not confirmed your email address. - Template for above action created - In responses, variable $templateEngine rewritten to $templateInstance and removed due to we already have such getter/setter in BaseFrameworkSystem - Several smaller improvements --- .gitattributes | 8 +- .../selector/class_ApplicationSelector.php | 35 ++++---- .../main/actions/ship-simu/.htaccess | 1 + .../class_ShipSimuLoginAction.php | 0 .../class_ShipSimuProfileAction.php | 0 .../ship-simu/main/actions/web/.htaccess | 1 + .../web/class_WebLoginCompanyAction.php | 83 +++++++++++++++++++ .../de/code/action_login_company.ctp | 13 +++ .../main/class_BaseFrameworkSystem.php | 10 +-- .../image/class_ImageCodeCaptchaCommand.php | 2 +- .../commands/web/class_WebHomeCommand.php | 2 +- .../web/class_WebLoginAreaCommand.php | 2 +- .../commands/web/class_WebLoginCommand.php | 2 +- .../web/class_WebLoginFailedCommand.php | 2 +- .../web/class_WebLogoutDoneCommand.php | 2 +- .../commands/web/class_WebRegisterCommand.php | 2 +- .../web/class_WebResendLinkCommand.php | 11 ++- .../main/mailer/debug/class_DebugMailer.php | 9 +- .../main/response/class_HttpResponse.php | 13 +-- .../main/response/class_ImageResponse.php | 16 +--- 20 files changed, 151 insertions(+), 63 deletions(-) create mode 100644 application/ship-simu/main/actions/ship-simu/.htaccess rename application/ship-simu/main/actions/{ => ship-simu}/class_ShipSimuLoginAction.php (100%) rename application/ship-simu/main/actions/{ => ship-simu}/class_ShipSimuProfileAction.php (100%) create mode 100644 application/ship-simu/main/actions/web/.htaccess create mode 100644 application/ship-simu/main/actions/web/class_WebLoginCompanyAction.php create mode 100644 application/ship-simu/templates/de/code/action_login_company.ctp diff --git a/.gitattributes b/.gitattributes index 06875a8..38eab89 100644 --- a/.gitattributes +++ b/.gitattributes @@ -56,8 +56,11 @@ application/ship-simu/interfaces/class_TradeableItem.php -text application/ship-simu/loader.php -text application/ship-simu/main/.htaccess -text application/ship-simu/main/actions/.htaccess -text -application/ship-simu/main/actions/class_ShipSimuLoginAction.php -text -application/ship-simu/main/actions/class_ShipSimuProfileAction.php -text +application/ship-simu/main/actions/ship-simu/.htaccess -text +application/ship-simu/main/actions/ship-simu/class_ShipSimuLoginAction.php -text +application/ship-simu/main/actions/ship-simu/class_ShipSimuProfileAction.php -text +application/ship-simu/main/actions/web/.htaccess -text +application/ship-simu/main/actions/web/class_WebLoginCompanyAction.php -text application/ship-simu/main/class_ -text application/ship-simu/main/class_BasePersonell.php -text application/ship-simu/main/class_BaseSimulator.php -text @@ -136,6 +139,7 @@ application/ship-simu/main/wrapper/class_CompanyDatabaseWrapper.php -text application/ship-simu/starter.php -text application/ship-simu/templates/.htaccess -text application/ship-simu/templates/de/.htaccess -text +application/ship-simu/templates/de/code/action_login_company.ctp -text application/ship-simu/templates/de/code/action_login_logout.ctp -text application/ship-simu/templates/de/code/action_login_profile.ctp -text application/ship-simu/templates/de/code/action_login_status_problem.ctp -text diff --git a/application/selector/class_ApplicationSelector.php b/application/selector/class_ApplicationSelector.php index 0e9070a..007550f 100644 --- a/application/selector/class_ApplicationSelector.php +++ b/application/selector/class_ApplicationSelector.php @@ -77,9 +77,9 @@ class ApplicationSelector extends BaseFrameworkSystem { /** * Create a prepared instance of ApplicationSelector * - * @param $langInstance The language sub-system: LanguageSystem - * @param $fileIOInstance The file I/O instance - * @return $selInstance An instance of ApplicationSelector + * @param $langInstance The language sub-system: LanguageSystem + * @param $fileIOInstance The file I/O instance + * @return $selInstance An instance of ApplicationSelector */ public final static function createApplicationSelector (ManageableLanguage $langInstance, FileIoHandler $fileIOInstance) { // Get a new instance @@ -118,8 +118,8 @@ class ApplicationSelector extends BaseFrameworkSystem { * Load the init.php script of an application and append the application * instance to $foundApps * - * @param $initScript The FQFN of init.php - * @param $appName The application's Uni* name + * @param $initScript The FQFN of init.php + * @param $appName The application's Uni* name * @return void */ private function loadInitScript ($initScript, $appName) { @@ -137,10 +137,11 @@ class ApplicationSelector extends BaseFrameworkSystem { /** * Setter for the selector's template engine instance * - * @param $tplEngine An instance of TemplateEngine + * @param $templateInstance An instance of TemplateEngine + * @return void */ - private final function setSelectorTemplateEngine (CompileableTemplate $tplEngine) { - $this->selectorTplEngine = $tplEngine; + private final function setSelectorTemplateEngine (CompileableTemplate $templateInstance) { + $this->selectorTplEngine = $templateInstance; } /** @@ -163,7 +164,7 @@ class ApplicationSelector extends BaseFrameworkSystem { } /** - * Method for compatiblity with prepareTemplateEngine() + * Method for compatiblity with prepareTemplateInstance() * * @return $shortName This selector's short name */ @@ -244,17 +245,17 @@ class ApplicationSelector extends BaseFrameworkSystem { $appInstance = $idx->current(); // Prepare the template engine for the current template - $tplEngine = $this->prepareTemplateEngine($appInstance); + $templateInstance = $this->prepareTemplateInstance($appInstance); // Try to load the web template - $tplEngine->loadWebTemplate(sprintf("%s_%s", + $templateInstance->loadWebTemplate(sprintf("%s_%s", $this->getConfigInstance()->readConfig('tpl_selector_prefix'), strtolower($appInstance->getAppShortName()) )); // Remember this template and the application for later usage $this->loadedTemplates->append(array( - 'template_class' => $tplEngine, + 'template_class' => $templateInstance, 'app_instance' => $appInstance )); } @@ -280,13 +281,13 @@ class ApplicationSelector extends BaseFrameworkSystem { */ public function loadSelectorTemplate () { // Prepare the template engine - $tplEngine = $this->prepareTemplateEngine($this); + $templateInstance = $this->prepareTemplateInstance($this); // Load the selector's template - $tplEngine->loadCodeTemplate($this->getConfigInstance()->readConfig('selector_main_tpl')); + $templateInstance->loadCodeTemplate($this->getConfigInstance()->readConfig('selector_main_tpl')); // Now store it in the class - $this->setSelectorTemplateEngine($tplEngine); + $this->setSelectorTemplateEngine($templateInstance); } /** @@ -302,10 +303,10 @@ class ApplicationSelector extends BaseFrameworkSystem { */ public function insertApplicationTemplates () { // First prepare the instance - $tplEngine = $this->prepareTemplateEngine($this); + $templateInstance = $this->prepareTemplateInstance($this); // Load template which shall later hold all application templates - $tplEngine->loadCodeTemplate($this->getConfigInstance()->readConfig('selector_apps_tpl')); + $templateInstance->loadCodeTemplate($this->getConfigInstance()->readConfig('selector_apps_tpl')); // Add all loaded application templates together $dummy = ""; diff --git a/application/ship-simu/main/actions/ship-simu/.htaccess b/application/ship-simu/main/actions/ship-simu/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/main/actions/ship-simu/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/ship-simu/main/actions/class_ShipSimuLoginAction.php b/application/ship-simu/main/actions/ship-simu/class_ShipSimuLoginAction.php similarity index 100% rename from application/ship-simu/main/actions/class_ShipSimuLoginAction.php rename to application/ship-simu/main/actions/ship-simu/class_ShipSimuLoginAction.php diff --git a/application/ship-simu/main/actions/class_ShipSimuProfileAction.php b/application/ship-simu/main/actions/ship-simu/class_ShipSimuProfileAction.php similarity index 100% rename from application/ship-simu/main/actions/class_ShipSimuProfileAction.php rename to application/ship-simu/main/actions/ship-simu/class_ShipSimuProfileAction.php diff --git a/application/ship-simu/main/actions/web/.htaccess b/application/ship-simu/main/actions/web/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/main/actions/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/ship-simu/main/actions/web/class_WebLoginCompanyAction.php b/application/ship-simu/main/actions/web/class_WebLoginCompanyAction.php new file mode 100644 index 0000000..283280d --- /dev/null +++ b/application/ship-simu/main/actions/web/class_WebLoginCompanyAction.php @@ -0,0 +1,83 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @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 WebLoginCompanyAction extends BaseAction implements Commandable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set description + $this->setObjectDescription("Shipping comany action"); + + // Generate unique key + $this->generateUniqueId(); + } + + /** + * 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 createWebLoginCompanyAction (ActionResolver $resolverInstance) { + // Get a new instance + $actionInstance = new WebLoginCompanyAction(); + + // 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 + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + $this->partialStub("Maybe add fetching company list 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) { + // Add user status filter here + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_class')); + } +} + +// [EOF] +?> diff --git a/application/ship-simu/templates/de/code/action_login_company.ctp b/application/ship-simu/templates/de/code/action_login_company.ctp new file mode 100644 index 0000000..a00b8cc --- /dev/null +++ b/application/ship-simu/templates/de/code/action_login_company.ctp @@ -0,0 +1,13 @@ +
+ Auflistung der Reedereien, an denenen du dich beteiligst: +
+ +
+ {?company_list?} +
+ + diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 08abd1f..0707487 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -935,17 +935,17 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * * @param $appInstance An application helper instance or * null if we shall use the default - * @return $tplEngine The template engine instance + * @return $templateInstance The template engine instance * @throws NullPointerException If the template engine could not * be initialized - * @throws UnsupportedTemplateEngineException If $tplEngine is an + * @throws UnsupportedTemplateEngineException If $templateInstance is an * unsupported template engine * @throws MissingLanguageHandlerException If the language sub-system * is not yet initialized * @throws NullPointerException If the discovered application * instance is still null */ - protected function prepareTemplateEngine (BaseFrameworkSystem $appInstance=null) { + protected function prepareTemplateInstance (BaseFrameworkSystem $appInstance=null) { // Is the application instance set? if (is_null($appInstance)) { // Get the current instance @@ -976,10 +976,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // Initialize the template engine - $tplEngine = ObjectFactory::createObjectByConfiguredName('template_class', array($fqfn, $appInstance->getLanguageInstance(), $appInstance->getFileIoInstance())); + $templateInstance = ObjectFactory::createObjectByConfiguredName('template_class', array($fqfn, $appInstance->getLanguageInstance(), $appInstance->getFileIoInstance())); // Return the prepared instance - return $tplEngine; + return $templateInstance; } /** diff --git a/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php b/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php index 7a735af..1ece666 100644 --- a/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php +++ b/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php @@ -73,7 +73,7 @@ class ImageCodeCaptchaCommand extends BaseCommand implements Commandable { $appInstance = $this->getResolverInstance()->getApplicationInstance(); // Prepare a template instance - $templateInstance = $this->prepareTemplateEngine($appInstance); + $templateInstance = $this->prepareTemplateInstance($appInstance); // Assign variable $templateInstance->assignVariable('decrypted_code', $decryptedCode); diff --git a/inc/classes/main/commands/web/class_WebHomeCommand.php b/inc/classes/main/commands/web/class_WebHomeCommand.php index eae9dd9..572d71d 100644 --- a/inc/classes/main/commands/web/class_WebHomeCommand.php +++ b/inc/classes/main/commands/web/class_WebHomeCommand.php @@ -70,7 +70,7 @@ class WebHomeCommand extends BaseCommand implements Commandable { $appInstance = $this->getResolverInstance()->getApplicationInstance(); // Prepare a template instance - $templateInstance = $this->prepareTemplateEngine($appInstance); + $templateInstance = $this->prepareTemplateInstance($appInstance); // Load the master template $masterTemplate = $appInstance->getMasterTemplate(); diff --git a/inc/classes/main/commands/web/class_WebLoginAreaCommand.php b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php index a841273..eae3413 100644 --- a/inc/classes/main/commands/web/class_WebLoginAreaCommand.php +++ b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php @@ -96,7 +96,7 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { $appInstance = $this->getResolverInstance()->getApplicationInstance(); // Prepare a template instance - $templateInstance = $this->prepareTemplateEngine($appInstance); + $templateInstance = $this->prepareTemplateInstance($appInstance); // Assign base URL $templateInstance->assignConfigVariable('base_url'); diff --git a/inc/classes/main/commands/web/class_WebLoginCommand.php b/inc/classes/main/commands/web/class_WebLoginCommand.php index a87b7d8..6dbb59e 100644 --- a/inc/classes/main/commands/web/class_WebLoginCommand.php +++ b/inc/classes/main/commands/web/class_WebLoginCommand.php @@ -70,7 +70,7 @@ class WebLoginCommand extends BaseCommand implements Commandable { $appInstance = $this->getResolverInstance()->getApplicationInstance(); // Prepare a template instance - $templateInstance = $this->prepareTemplateEngine($appInstance); + $templateInstance = $this->prepareTemplateInstance($appInstance); // Assign application data with template engine $templateInstance->assignApplicationData($appInstance); diff --git a/inc/classes/main/commands/web/class_WebLoginFailedCommand.php b/inc/classes/main/commands/web/class_WebLoginFailedCommand.php index 47eae80..a60bb8e 100644 --- a/inc/classes/main/commands/web/class_WebLoginFailedCommand.php +++ b/inc/classes/main/commands/web/class_WebLoginFailedCommand.php @@ -70,7 +70,7 @@ class WebLoginFailedCommand extends BaseCommand implements Commandable { $appInstance = $this->getResolverInstance()->getApplicationInstance(); // Prepare a template instance - $templateInstance = $this->prepareTemplateEngine($appInstance); + $templateInstance = $this->prepareTemplateInstance($appInstance); // Load the master template $masterTemplate = $appInstance->getMasterTemplate(); diff --git a/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php b/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php index fe07ce5..73dd4d6 100644 --- a/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php +++ b/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php @@ -70,7 +70,7 @@ class WebLogoutDoneCommand extends BaseCommand implements Commandable { $appInstance = $this->getResolverInstance()->getApplicationInstance(); // Prepare a template instance - $templateInstance = $this->prepareTemplateEngine($appInstance); + $templateInstance = $this->prepareTemplateInstance($appInstance); // Load the master template $masterTemplate = $appInstance->getMasterTemplate(); diff --git a/inc/classes/main/commands/web/class_WebRegisterCommand.php b/inc/classes/main/commands/web/class_WebRegisterCommand.php index a8b8110..5b4d0b1 100644 --- a/inc/classes/main/commands/web/class_WebRegisterCommand.php +++ b/inc/classes/main/commands/web/class_WebRegisterCommand.php @@ -73,7 +73,7 @@ class WebRegisterCommand extends BaseCommand implements Commandable, Registerabl $appInstance = $this->getResolverInstance()->getApplicationInstance(); // Prepare a template instance - $templateInstance = $this->prepareTemplateEngine($appInstance); + $templateInstance = $this->prepareTemplateInstance($appInstance); // Assign all the application's data with template variables $templateInstance->assignApplicationData($appInstance); diff --git a/inc/classes/main/commands/web/class_WebResendLinkCommand.php b/inc/classes/main/commands/web/class_WebResendLinkCommand.php index 5decea5..c08066a 100644 --- a/inc/classes/main/commands/web/class_WebResendLinkCommand.php +++ b/inc/classes/main/commands/web/class_WebResendLinkCommand.php @@ -66,17 +66,20 @@ class WebResendLinkCommand extends BaseCommand implements Commandable { * @return void */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a user instance from registry - $userInstance = Registry::getRegistry()->getInstance('user'); + // Get template instance + $templateInstance = $responseInstance->getTemplateInstance(); // Get a mailer class - $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class'); + $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance)); // Load the mail template $mailerInstance->loadTemplate('resend_link'); + // Get a user instance from registry + $userInstance = Registry::getRegistry()->getInstance('user'); + // Add the recipient - $mailerInstance->addRecipientByUser($userInstance); + $mailerInstance->addRecipientByUserInstance($userInstance); // Set subject line from template $mailerInstance->setSubjectFromTemplate(); diff --git a/inc/classes/main/mailer/debug/class_DebugMailer.php b/inc/classes/main/mailer/debug/class_DebugMailer.php index 6437823..62c5920 100644 --- a/inc/classes/main/mailer/debug/class_DebugMailer.php +++ b/inc/classes/main/mailer/debug/class_DebugMailer.php @@ -1,6 +1,7 @@ * @version 0.0.0 @@ -41,12 +42,16 @@ class DebugMailer extends BaseMailer implements DeliverableMail { /** * Creates an instance of this mailer class * + * @param $templateInstance A template instance * @return $mailerInstance An instance of this mailer class */ - public final static function createDebugMailer () { + public final static function createDebugMailer (CompileableTemplate $templateInstance) { // Get a new instance $mailerInstance = new DebugMailer(); + // Set template instance + $mailerInstance->setTemplateInstance($templateInstance); + // Return the instance return $mailerInstance; } diff --git a/inc/classes/main/response/class_HttpResponse.php b/inc/classes/main/response/class_HttpResponse.php index cc3910c..6882981 100644 --- a/inc/classes/main/response/class_HttpResponse.php +++ b/inc/classes/main/response/class_HttpResponse.php @@ -48,7 +48,7 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { /** * Instance of the template engine */ - private $templateEngine = null; + private $templateInstance = null; /** * Fatal resolved messages from filters and so on @@ -213,16 +213,7 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { * @return void */ public final function initTemplateEngine (ManageableApplication $appInstance) { - $this->templateEngine = $this->prepareTemplateEngine($appInstance); - } - - /** - * Getter for the template engine instance - * - * @return $templateEngine An instance of the used template engine - */ - public final function getTemplateEngine () { - return $this->templateEngine; + $this->setTemplateInstance($this->prepareTemplateInstance($appInstance)); } /** diff --git a/inc/classes/main/response/class_ImageResponse.php b/inc/classes/main/response/class_ImageResponse.php index 3d81da9..abf3491 100644 --- a/inc/classes/main/response/class_ImageResponse.php +++ b/inc/classes/main/response/class_ImageResponse.php @@ -45,11 +45,6 @@ class ImageResponse extends BaseFrameworkSystem implements Responseable { */ private $responseBody = ""; - /** - * Instance of the template engine - */ - private $templateEngine = null; - /** * Fatal resolved messages from filters and so on */ @@ -228,16 +223,7 @@ class ImageResponse extends BaseFrameworkSystem implements Responseable { $cfg->setConfigEntry('code_template_type' , "image"); // Get a prepared instance - $this->templateEngine = $this->prepareTemplateEngine($appInstance); - } - - /** - * Getter for the template engine instance - * - * @return $templateEngine An instance of the used template engine - */ - public final function getTemplateEngine () { - return $this->templateEngine; + $this->setTemplateInstance($this->prepareTemplateInstance($appInstance)); } /** -- 2.39.5