From: Roland Häder Date: Sat, 1 Aug 2009 09:59:02 +0000 (+0000) Subject: Failed attempts for governments added X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=50d2890511eb23971eb4ee1e392748a42b066def;p=shipsimu.git Failed attempts for governments added --- diff --git a/.gitattributes b/.gitattributes index bf54969..7bbc70b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/application/selector/class_ApplicationHelper.php b/application/selector/class_ApplicationHelper.php index 1617173..87f0590 100644 --- a/application/selector/class_ApplicationHelper.php +++ b/application/selector/class_ApplicationHelper.php @@ -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."
\n"); + print("MSG:" . $message . "
\n"); } // END - if } diff --git a/application/ship-simu/config.php b/application/ship-simu/config.php index 802e984..23178ce 100644 --- a/application/ship-simu/config.php +++ b/application/ship-simu/config.php @@ -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] ?> diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php index 4c9d0e8..6d2450e 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php @@ -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'); } diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php index 831e118..add9a42 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php @@ -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; diff --git a/application/ship-simu/main/commands/web/government/class_WebGovernmentFailedStartupCommand.php b/application/ship-simu/main/commands/web/government/class_WebGovernmentFailedStartupCommand.php index d91a36b..31d56b3 100644 --- a/application/ship-simu/main/commands/web/government/class_WebGovernmentFailedStartupCommand.php +++ b/application/ship-simu/main/commands/web/government/class_WebGovernmentFailedStartupCommand.php @@ -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); } /** diff --git a/application/ship-simu/main/commands/web/government/class_WebGovernmentFailedTrainingCommand.php b/application/ship-simu/main/commands/web/government/class_WebGovernmentFailedTrainingCommand.php index c792635..8942067 100644 --- a/application/ship-simu/main/commands/web/government/class_WebGovernmentFailedTrainingCommand.php +++ b/application/ship-simu/main/commands/web/government/class_WebGovernmentFailedTrainingCommand.php @@ -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); } /** diff --git a/application/ship-simu/main/commands/web/government/class_WebShipsimuGovernmentStartupCommand.php b/application/ship-simu/main/commands/web/government/class_WebShipsimuGovernmentStartupCommand.php index d9ffd33..4464074 100644 --- a/application/ship-simu/main/commands/web/government/class_WebShipsimuGovernmentStartupCommand.php +++ b/application/ship-simu/main/commands/web/government/class_WebShipsimuGovernmentStartupCommand.php @@ -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 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/main/menu/government/.htaccess @@ -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 index 0000000..d70b5e2 --- /dev/null +++ b/application/ship-simu/main/menu/government/class_ShipSimuGovernmentFailedAreaMenu.php @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/ship-simu/main/user/extended/class_ShipSimuMember.php b/application/ship-simu/main/user/extended/class_ShipSimuMember.php index b805f50..fa2c0d9 100644 --- a/application/ship-simu/main/user/extended/class_ShipSimuMember.php +++ b/application/ship-simu/main/user/extended/class_ShipSimuMember.php @@ -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 index 0000000..9b8ec22 --- /dev/null +++ b/application/ship-simu/templates/de/code/government_failed_main.ctp @@ -0,0 +1,106 @@ +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] +?> +
+ Willkommen zum Staat in {?app_full_name?}! +
+ +
+ {?government_failed_content?} +
+ +
+
+ Account-Infos: +
+ +
+ {?persona_data?} +
+ +
+ {?logout?} +
+
+ +
+
+ Reederei-Infos: +
+ +
+ {?company_data?} +
+
diff --git a/application/ship-simu/templates/de/code/login_main.ctp b/application/ship-simu/templates/de/code/login_main.ctp index eb13861..4345df7 100644 --- a/application/ship-simu/templates/de/code/login_main.ctp +++ b/application/ship-simu/templates/de/code/login_main.ctp @@ -74,7 +74,7 @@ $linkInstance->flushContent(); // [EOC] ?>
- Willkommen im Loginbereich von {?app_full_name?}! + Willkommen im Loginbereich von {?app_full_name?}!