X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcommands%2Fweb%2Fclass_WebLoginAreaCommand.php;h=9908233fe20c68c4bd98d57e47c4bb98c18a6916;hp=8b73b2ba1367bcc14cd744d528110c331d8e2fff;hb=1cfec479b8c4a745b5b97683d22c8a431f9a3ee7;hpb=ccf0a6ac2e9ce6d660cbdf66c4c9c4a10f7a1345 diff --git a/inc/classes/main/commands/web/class_WebLoginAreaCommand.php b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php index 8b73b2b..9908233 100644 --- a/inc/classes/main/commands/web/class_WebLoginAreaCommand.php +++ b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php @@ -54,10 +54,22 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { // 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 + */ + protected function prepareCommand () { + /* @TODO Add some stuff here: Some personal data, app/game related data */ + } + /** * Executes the given command with given request and response objects * @@ -67,14 +79,34 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Default action is the one from configuration + $actionClass = sprintf("login_%s_action_class", $this->getConfigInstance()->readConfig('login_default_action')); $action = sprintf("login_%s", $this->getConfigInstance()->readConfig('login_default_action')); + // Get "action" from request + $actReq = $requestInstance->getRequestElement('action'); + + // Do we have a "action" parameter set? + if (is_string($actReq)) { + // Then use it with prefix + $actionClass = sprintf("login_%s_action_class", $actReq); + $action = sprintf("login_%s", $actReq); + } // END - if + + // Get an action instance + $actionInstance = ObjectFactory::createObjectByConfiguredName($actionClass); + + // Execute the action (shall not output anything, see below why) + $actionInstance->execute($requestInstance, $responseInstance); + // Get the application instance $appInstance = $this->getResolverInstance()->getApplicationInstance(); // Prepare a template instance $templateInstance = $this->prepareTemplateEngine($appInstance); + // Assign all the application's data with template variables + $templateInstance->assignApplicationData($appInstance); + // Load the master template $masterTemplate = $appInstance->getMasterTemplate(); @@ -92,17 +124,6 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { $templateInstance->compileTemplate(); $templateInstance->assignTemplateWithVariable("footer", "footer"); - // Get "action" from request - $actReq = $requestInstance->getRequestElement("action"); - - // Do we have a "action" parameter set? - if (is_string($actReq)) { - // Then use it with prefix - $action = sprintf("login_%s", $actReq); - } // END - if - - // @TODO Do the action somewhere here - // Load the matching template $templateInstance->loadCodeTemplate($action); @@ -113,7 +134,7 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { $templateInstance->loadCodeTemplate($masterTemplate); // Set title - $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('login_{$action}_title')); + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage("login_{$action}_title")); // ... and all variables. This should be merged together in a pattern // to make things easier. A cache mechanism should be added between