]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/commands/web/class_WebLoginAreaCommand.php
TODO tag rewritten, first login action (empty for now) added
[shipsimu.git] / inc / classes / main / commands / web / class_WebLoginAreaCommand.php
index 8b73b2ba1367bcc14cd744d528110c331d8e2fff..9908233fe20c68c4bd98d57e47c4bb98c18a6916 100644 (file)
@@ -54,10 +54,22 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable {
                // Set the application instance
                $commandInstance->setResolverInstance($resolverInstance);
 
                // Set the application instance
                $commandInstance->setResolverInstance($resolverInstance);
 
+               // Load general data like user status and such
+               $commandInstance->prepareCommand();
+
                // Return the prepared instance
                return $commandInstance;
        }
 
                // 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
         *
        /**
         * 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
         */
        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'));
 
                $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);
 
                // 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();
 
                // Load the master template
                $masterTemplate = $appInstance->getMasterTemplate();
 
@@ -92,17 +124,6 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable {
                $templateInstance->compileTemplate();
                $templateInstance->assignTemplateWithVariable("footer", "footer");
 
                $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);
 
                // Load the matching template
                $templateInstance->loadCodeTemplate($action);
 
@@ -113,7 +134,7 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable {
                $templateInstance->loadCodeTemplate($masterTemplate);
 
                // Set title
                $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
 
                // ... and all variables. This should be merged together in a pattern
                // to make things easier. A cache mechanism should be added between