Failed attempts for governments added
authorRoland Häder <roland@mxchange.org>
Sat, 1 Aug 2009 09:59:02 +0000 (09:59 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 1 Aug 2009 09:59:02 +0000 (09:59 +0000)
13 files changed:
.gitattributes
application/selector/class_ApplicationHelper.php
application/ship-simu/config.php
application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php
application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php
application/ship-simu/main/commands/web/government/class_WebGovernmentFailedStartupCommand.php
application/ship-simu/main/commands/web/government/class_WebGovernmentFailedTrainingCommand.php
application/ship-simu/main/commands/web/government/class_WebShipsimuGovernmentStartupCommand.php
application/ship-simu/main/menu/government/.htaccess [new file with mode: 0644]
application/ship-simu/main/menu/government/class_ShipSimuGovernmentFailedAreaMenu.php [new file with mode: 0644]
application/ship-simu/main/user/extended/class_ShipSimuMember.php
application/ship-simu/templates/de/code/government_failed_main.ctp [new file with mode: 0644]
application/ship-simu/templates/de/code/login_main.ctp

index bf5496918bb62a9a55ba2d822f164a1eaecc0227..7bbc70b1ddfbe946a929152a22029d403510fb0b 100644 (file)
@@ -153,6 +153,8 @@ application/ship-simu/main/menu/class_ShipSimuLoginAreaMenu.php -text
 application/ship-simu/main/menu/class_ShipSimuLoginMenu.php -text
 application/ship-simu/main/menu/class_ShipSimuLogoutMenu.php -text
 application/ship-simu/main/menu/class_ShipSimuRegisterMenu.php -text
+application/ship-simu/main/menu/government/.htaccess -text
+application/ship-simu/main/menu/government/class_ShipSimuGovernmentFailedAreaMenu.php -text
 application/ship-simu/main/parts/.htaccess -text
 application/ship-simu/main/parts/class_BaseShipPart.php -text
 application/ship-simu/main/parts/maschineroom/.htaccess -text
@@ -220,6 +222,7 @@ application/ship-simu/templates/de/code/confirm_link.ctp -text
 application/ship-simu/templates/de/code/emergency_exit.ctp -text
 application/ship-simu/templates/de/code/footer.ctp -text
 application/ship-simu/templates/de/code/footer_msg.ctp -text
+application/ship-simu/templates/de/code/government_failed_main.ctp -text
 application/ship-simu/templates/de/code/header.ctp -text
 application/ship-simu/templates/de/code/header_extras_hook.ctp -text
 application/ship-simu/templates/de/code/home.ctp -text
index 1617173e0457e1b90a8dd83ec8008a28add5851c..87f0590f175a4a7ddd6479f02c4163307e9e6a4a 100644 (file)
@@ -160,7 +160,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication
         */
        public function buildMasterTemplateName () {
                // Get short name and add suffix
-               $masterTemplateName = str_replace("-", "", $this->getAppShortName()) . "_main";
+               $masterTemplateName = str_replace('-', '', $this->getAppShortName()) . '_main';
 
                // Return it
                return $masterTemplateName;
@@ -175,9 +175,9 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication
                // Create a new request object
                $requestInstance = ObjectFactory::createObjectByName('HttpRequest');
 
-               // Default response is HTTP (HTML page) and type is "Web"
-               $response = "http";
-               $responseType = "web";
+               // Default response is HTTP (HTML page) and type is 'Web'
+               $response = 'http';
+               $responseType = 'web';
 
                // Do we have another response?
                if ($requestInstance->isRequestElementSet('request')) {
@@ -227,7 +227,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication
        public function handleFatalMessages (array $messageList) {
                // Walk through all messages
                foreach ($messageList as $message) {
-                       print("MSG:".$message."<br />\n");
+                       print("MSG:" . $message . "<br />\n");
                } // END - if
        }
 
index 802e984669f82847ecfa5f2063e95a9d49ad1061..23178cef9e4f4e1d5b326ebe47416f048ee8a270 100644 (file)
@@ -142,12 +142,21 @@ $cfg->setConfigEntry('login_default_action', "welcome");
 // CFG: LOGIN-AREA-LOGOUT-ACTION
 $cfg->setConfigEntry('login_area_logout_action', "index.php?app={?app_short_name?}&page=login_area&action=logout");
 
+// CFG: GOVERNMENT-FAILED-LOGOUT-ACTION
+$cfg->setConfigEntry('government_failed_logout_action', "index.php?app={?app_short_name?}&page=login_area&action=logout");
+
 // CFG: LOGIN-AREA-PROFILE-ACTION
 $cfg->setConfigEntry('login_area_profile_action', "index.php?app={?app_short_name?}&page=login_area&action=profile");
 
+// CFG: GOVERNMENT-FAILED-PROFILE-ACTION
+$cfg->setConfigEntry('government_failed_profile_action', "index.php?app={?app_short_name?}&page=login_area&action=profile");
+
 // CFG: LOGIN-AREA-COMPANY-ACTION
 $cfg->setConfigEntry('login_area_company_action', "index.php?app={?app_short_name?}&page=login_area");
 
+// CFG: GOVERNMENT-FAILED-COMPANY-ACTION
+$cfg->setConfigEntry('government_failed_company_action', "index.php?app={?app_short_name?}&page=login_area");
+
 // CFG: LOGIN-AREA-LIST-COMPANIES-ACTION
 $cfg->setConfigEntry('login_area_list_companies_action', "index.php?app={?app_short_name?}&page=login_area");
 
@@ -454,5 +463,8 @@ $cfg->setConfigEntry('register_menu_class', "ShipSimuRegisterMenu");
 // CFG: LOGIN-AREA-MENU-CLASS
 $cfg->setConfigEntry('login_area_menu_class', "ShipSimuLoginAreaMenu");
 
+// CFG: GOVERNMENT-FAILED-AREA-MENU-CLASS
+$cfg->setConfigEntry('government_failed_area_menu_class', "ShipSimuGovernmentFailedAreaMenu");
+
 // [EOF]
 ?>
index 4c9d0e881182ccb7fee681c83c987bb2431c3c72..6d2450e4437f7c9391e733c78018c48e9985e711 100644 (file)
@@ -68,7 +68,7 @@ class WebShipsimuRefillCommand extends BaseCommand implements Commandable {
                $templateInstance->assignVariable('refill_done', $requestInstance->getRequestElement('type'));
                $templateInstance->assignVariable('amount'     , $requestInstance->getRequestElement('amount'));
 
-               // This method does currently redirect if all goes right
+               // This method does currently redirect if all goes right. Booking is done in filters
                $responseInstance->redirectToConfiguredUrl('refill_page_done');
        }
 
index 831e1181265d41ac9ca3f88f9a5d8496b38613ac..add9a42eb8c60778c69b819b207048a275d36df8 100644 (file)
@@ -103,11 +103,11 @@ class WebShipsimuUserLoginCommand extends BaseCommand implements Commandable {
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
                // Which login type do we have?
                switch ($this->getConfigInstance()->getConfigEntry('login_type')) {
-                       case "username": // Login via username
+                       case 'username': // Login via username
                                $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter'));
                                break;
 
-                       case "email": // Login via email
+                       case 'email': // Login via email
                                $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_verifier_filter'));
                                break;
 
index d91a36bc178172e1e4b3b47fae7e9bc2758bd906..31d56b3d8d16842b8d0ff3a846daaebf3652b15f 100644 (file)
@@ -59,7 +59,68 @@ class WebGovernmentFailedStartupCommand extends BaseCommand implements Commandab
         * @todo        0% done
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
-               $this->partialStub("Unfinished method.");
+               // 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
+               $appInstance = $this->getResolverInstance()->getApplicationInstance();
+
+               // Prepare a template instance
+               $templateInstance = $this->prepareTemplateInstance($appInstance);
+
+               // Assign base URL
+               $templateInstance->assignConfigVariable('base_url');
+
+               // Assign all the application's data with template variables
+               $templateInstance->assignApplicationData($appInstance);
+
+               // Load the master template
+               $masterTemplate = $appInstance->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 main template
+               $templateInstance->loadCodeTemplate('government_failed_main');
+
+               // Assign the main template with the master template as a content ... ;)
+               $templateInstance->compileTemplate();
+               $templateInstance->assignTemplateWithVariable('government_failed_main', 'content');
+
+               // Load the master template
+               $templateInstance->loadCodeTemplate($masterTemplate);
+
+               // Set title
+               $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage($requestInstance->getRequestElement('page') . '_' . $requestInstance->getRequestElement('failed') . '_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('government_failed_area_menu_class', array($appInstance));
+
+               // ... 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);
        }
 
        /**
index c792635afaaa38769d73bd16323629041e6064bb..89420676fee120d928e4b3368eeb41429f4869b7 100644 (file)
@@ -59,7 +59,68 @@ class WebGovernmentFailedTrainingCommand extends BaseCommand implements Commanda
         * @todo        0% done
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
-               $this->partialStub("Unfinished method.");
+               // 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
+               $appInstance = $this->getResolverInstance()->getApplicationInstance();
+
+               // Prepare a template instance
+               $templateInstance = $this->prepareTemplateInstance($appInstance);
+
+               // Assign base URL
+               $templateInstance->assignConfigVariable('base_url');
+
+               // Assign all the application's data with template variables
+               $templateInstance->assignApplicationData($appInstance);
+
+               // Load the master template
+               $masterTemplate = $appInstance->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 main template
+               $templateInstance->loadCodeTemplate('government_failed_main');
+
+               // Assign the main template with the master template as a content ... ;)
+               $templateInstance->compileTemplate();
+               $templateInstance->assignTemplateWithVariable('government_failed_main', 'content');
+
+               // Load the master template
+               $templateInstance->loadCodeTemplate($masterTemplate);
+
+               // Set title
+               $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage($requestInstance->getRequestElement('page') . '_' . $requestInstance->getRequestElement('failed') . '_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('government_failed_area_menu_class', array($appInstance));
+
+               // ... 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);
        }
 
        /**
index d9ffd339040083f787ca72d15a3a4424f663b948..4464074923eff1de1bac4f497790a94378ccf0e8 100644 (file)
@@ -59,7 +59,7 @@ class WebShipsimuGovernmentStartupCommand extends BaseCommand implements Command
         * @todo        0% done
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
-               $this->partialStub("Unfinished method.");
+               $this->partialStub('Unfinished method.');
        }
 
        /**
diff --git a/application/ship-simu/main/menu/government/.htaccess b/application/ship-simu/main/menu/government/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/ship-simu/main/menu/government/class_ShipSimuGovernmentFailedAreaMenu.php b/application/ship-simu/main/menu/government/class_ShipSimuGovernmentFailedAreaMenu.php
new file mode 100644 (file)
index 0000000..d70b5e2
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A menu class for Ship-Simu
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu Developer Team
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class ShipSimuGovernmentFailedAreaMenu extends BaseMenu implements RenderableMenu {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $menuInstance   An instance of this class
+        */
+       public final static function createShipSimuGovernmentFailedAreaMenu () {
+               // Get a new instance
+               $menuInstance = new ShipSimuGovernmentFailedAreaMenu();
+
+               // Return the prepared instance
+               return $menuInstance;
+       }
+}
+
+// [EOF]
+?>
index b805f50340ec57aa62a722d3600520f50958ab5d..fa2c0d9ae3694f3b6c69c6c7521a129626ec2f84 100644 (file)
@@ -145,8 +145,8 @@ class ShipSimuMember extends ShipSimuBaseUser implements ManageableMember, Booka
                $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class');
 
                // And add our both entries
-               $updateInstance->addCriteria("last_activity", date("Y-m-d H:i:s", time()));
-               $updateInstance->addCriteria("last_action", $lastAction);
+               $updateInstance->addCriteria('last_activity', date('Y-m-d H:i:s', time()));
+               $updateInstance->addCriteria('last_action', $lastAction);
 
                // Add the search criteria for searching for the right entry
                $updateInstance->setSearchInstance($searchInstance);
@@ -159,8 +159,8 @@ class ShipSimuMember extends ShipSimuBaseUser implements ManageableMember, Booka
        }
 
        /**
-        * Books the given 'amount' in the request instance on the users "points
-        * account"
+        * Books the given 'amount' in the request instance on the users 'points
+        * account'
         *
         * @param       $requestInstance        An instance of a Requestable class
         * @return      void
diff --git a/application/ship-simu/templates/de/code/government_failed_main.ctp b/application/ship-simu/templates/de/code/government_failed_main.ctp
new file mode 100644 (file)
index 0000000..9b8ec22
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+///////////////////////////////
+// Assign personal user data //
+///////////////////////////////
+
+// Get a new instance for personal data
+$blockInstance = ObjectFactory::createObjectByConfiguredName('web_block_helper', array($this, 'persona_data'));
+
+// Set the data source instance which must exist in registry
+$blockInstance->prefetchValueInstance('user');
+
+// Assign fields with template variables
+$blockInstance->assignField('username');
+$blockInstance->assignFieldWithFilter('user_status', "user_status_translator");
+
+// Shall we include registration date?
+if ($blockInstance->ifIncludeRegistrationStamp()) {
+       // Then assign it as well!
+       $blockInstance->assignFieldWithFilter('registered', 'formatTimestamp');
+} // END - if
+
+// Flush the content out to a template variable
+$blockInstance->flushContent();
+
+//////////////////////////////////////
+// Assign the shipping company data //
+//////////////////////////////////////
+
+// Get a new instance for personal data
+$blockInstance = ObjectFactory::createObjectByConfiguredName('web_block_helper', array($this, 'company_data'));
+
+// Set the data source instance
+$blockInstance->prefetchValueInstance('company', 'user');
+
+// Assign the company name
+if ($blockInstance->getValueInstance()->ifUserIsFounder()) {
+       // User is the founder of the company
+       $blockInstance->assignMessageField('company_status', "user_is_company_founder");
+       $blockInstance->assignLinkFieldWithAction('company' , "company_overview");
+       $blockInstance->assignMessageField('company', "link_text_company_overview");
+       $blockInstance->assignMessageField('company_title', "link_title_company_overview");
+} elseif ($blockInstance->getValueInstance()->ifUserIsOwner()) {
+       // User owns the company
+       $blockInstance->assignMessageField('company_status', "user_is_company_owner");
+       $blockInstance->assignLinkFieldWithAction('company' , "company_overview");
+       $blockInstance->assignMessageField('company', "link_text_company_overview");
+       $blockInstance->assignMessageField('company_title', "link_title_company_overview");
+} elseif ($blockInstance->getValueInstance()->ifUserIsEmployee()) {
+       // User is employed in company
+       $blockInstance->assignMessageField('company_status', "user_is_employed_in_company");
+       $blockInstance->assignLinkFieldWithAction('company' , "employee_overview");
+       $blockInstance->assignMessageField('company', "link_text_employee_overview");
+       $blockInstance->assignMessageField('company_title', "link_title_employee_overview");
+} else {
+       // No company participation!
+       $blockInstance->assignMessageField('company_status', "user_not_assigned_company");
+       $blockInstance->assignLinkFieldWithAction('company' , "company");
+       $blockInstance->assignMessageField('company', "link_text_company");
+       $blockInstance->assignMessageField('company_title', "link_title_company");
+}
+
+// Flush the content out to a template variable
+$blockInstance->flushContent();
+
+// Get helper instance
+$linkInstance = ObjectFactory::createObjectByConfiguredName('web_link_helper', array($this, 'logout'));
+
+// Add action
+$linkInstance->addActionLinkById('logout', 'logout');
+
+// Flush the content
+$linkInstance->flushContent();
+
+// [EOC]
+?>
+<div id="content_header">
+       Willkommen zum Staat in <span class=\"app_name\">{?app_full_name?}</span>!
+</div>
+
+<div id="content_body">
+       {?government_failed_content?}
+</div>
+
+<div id="persona_data" title="Informationen zu Deinem Spieleaccount">
+       <div id="persona_header">
+               Account-Infos:
+       </div>
+
+       <div id="persona_body">
+               {?persona_data?}
+       </div>
+
+       <div id="logout">
+               {?logout?}
+       </div>
+</div>
+
+<div id="company_data" title="Informationen zu der aktuell ausgew&auml;hlten Reederei">
+       <div id="company_header">
+               Reederei-Infos:
+       </div>
+
+       <div id="company_body">
+               {?company_data?}
+       </div>
+</div>
index eb1386187e77da5ff945c4aaa9205b50296b789e..4345df761e7ec5c8d7b718183ae43843a61cc729 100644 (file)
@@ -74,7 +74,7 @@ $linkInstance->flushContent();
 // [EOC]
 ?>
 <div id="content_header">
-       Willkommen im Loginbereich  von <span class=\"app_name\">{?app_full_name?}</span>!
+       Willkommen im Loginbereich von <span class=\"app_name\">{?app_full_name?}</span>!
 </div>
 
 <div id="content_body">