]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/class_ApplicationHelper.php
More class descriptions translated, generic user class added
[shipsimu.git] / application / ship-simu / class_ApplicationHelper.php
index ff8fe5e76d9e71f489330f634aa1bfa50b849a7f..b925ebdff6c92f83ce317baef7a3880d9f0f68d9 100644 (file)
@@ -55,11 +55,20 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
         */
        private $shortName = "";
 
+       /**
+        * The name of the master template
+        */
+       private $masterTemplate = "shipsimu_main";
+
+       /**
+        * An instance of a controller
+        */
+       private $controllerInstance = null;
+
        /**
         * An instance of this class
         */
        private static $thisInstance = null;
-
        /**
         * Protected constructor
         *
@@ -97,7 +106,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
        /**
         * Getter for the version number
         *
-        * @return      $appVersion     The application's version number
+        * @return      $appVersion             The application's version number
         */
        public final function getAppVersion () {
                return $this->appVersion;
@@ -106,7 +115,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
        /**
         * Setter for the version number
         *
-        * @param       $appVersion     The application's version number
+        * @param       $appVersion             The application's version number
         * @return      void
         */
        public final function setAppVersion ($appVersion) {
@@ -157,23 +166,60 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
                $this->shortName = $shortName;
        }
 
+       /**
+        * Getter for master template name
+        *
+        * @return      $masterTemplate         Name of the master template
+        */
+       public final function getMasterTemplate () {
+               return $this->masterTemplate;
+       }
+
        /**
         * Launches the ship-simulator game
         *
         * @return      void
         */
        public final function entryPoint () {
-               // Handle the request
-               $this->handleRequest();
+               // Create a new request object
+               $requestInstance = HttpRequest::createHttpRequest();
 
-               // Prepare the template engine
-               $tplEngine = $this->prepareTemplateEngine($this);
+               // ... and a new response object
+               $responseInstance = HttpResponse::createHttpResponse($this);
 
-               // Load the main template
-               $tplEngine->loadCodeTemplate("shipsimu_main");
+               // Get command parameter
+               $commandPara = $this->getConfigInstance()->readConfig('command_parameter');
 
-               // Raise an error here
-               trigger_error(__METHOD__.": Unfinished work!");
+               // Get the parameter from the request
+               $commandName = $requestInstance->getRequestElement($commandPara);
+
+               // If it is null then get default command
+               if (is_null($commandName)) {
+                       $commandName = $this->getConfigInstance()->readConfig('default_command');
+               }
+
+               // Get a resolver
+               $resolverInstance = WebControllerResolver::createWebControllerResolver($commandName, $this);
+
+               // Get a controller instance as well
+               $this->controllerInstance = $resolverInstance->resolveCommandController();
+
+               // Handle the request
+               $this->controllerInstance->handleRequest($requestInstance, $responseInstance);
+       }
+
+       /**
+        * Handle the indexed array of fatal messages and puts them out in an
+        * acceptable fasion
+        *
+        * @param       $messageList    An array of fatal messages
+        * @return      void
+        */
+       public function handleFatalMessages (array $messageList) {
+               // Walk through all messages
+               foreach ($messageList as $message) {
+                       die("MSG:".$message);
+               }
        }
 }