From: Roland Häder Date: Wed, 18 Jun 2008 19:53:09 +0000 (+0000) Subject: TODO tag rewritten, first login action (empty for now) added X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=commitdiff_plain;h=1cfec479b8c4a745b5b97683d22c8a431f9a3ee7 TODO tag rewritten, first login action (empty for now) added --- diff --git a/.gitattributes b/.gitattributes index eb798cc..05dd822 100644 --- a/.gitattributes +++ b/.gitattributes @@ -54,6 +54,8 @@ application/ship-simu/interfaces/class_SignableContract.php -text application/ship-simu/interfaces/class_TradeableItem.php -text application/ship-simu/loader.php -text application/ship-simu/main/.htaccess -text +application/ship-simu/main/actions/.htaccess -text +application/ship-simu/main/actions/class_ShipSimuLoginAction.php -text application/ship-simu/main/class_ -text application/ship-simu/main/class_BasePersonell.php -text application/ship-simu/main/class_BaseSimulator.php -text @@ -132,12 +134,14 @@ application/ship-simu/templates/de/code/header.ctp -text application/ship-simu/templates/de/code/home.ctp -text application/ship-simu/templates/de/code/login_failed.ctp -text application/ship-simu/templates/de/code/login_form.ctp -text +application/ship-simu/templates/de/code/login_welcome.ctp -text application/ship-simu/templates/de/code/register_form.ctp -text application/ship-simu/templates/de/code/shipsimu_main.ctp -text application/ship-simu/templates/de/html/.htaccess -text application/ship-simu/templates/de/html/nav_advert.tpl -text application/ship-simu/templates/de/html/selector_ship-simu.tpl -text db/.htaccess -text +db/news/.htaccess -text db/user/.htaccess -text devel/.htaccess -text devel/class_Debug.php -text diff --git a/application/ship-simu/class_ApplicationHelper.php b/application/ship-simu/class_ApplicationHelper.php index f499c48..ab372a5 100644 --- a/application/ship-simu/class_ApplicationHelper.php +++ b/application/ship-simu/class_ApplicationHelper.php @@ -69,6 +69,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica * An instance of this class */ private static $thisInstance = null; + /** * Protected constructor * diff --git a/application/ship-simu/config.php b/application/ship-simu/config.php index 1abafff..0217b61 100644 --- a/application/ship-simu/config.php +++ b/application/ship-simu/config.php @@ -127,5 +127,8 @@ $cfg->setConfigEntry('guest_login_username', "guest"); // CFG: GUEST-LOGIN-PASSWORD $cfg->setConfigEntry('guest_login_password', "guest"); +// CFG: LOGIN-WELCOME-ACTION-CLASS +$cfg->setConfigEntry('login_welcome_action_class', "ShipSimuLoginAction"); + // [EOF] ?> diff --git a/application/ship-simu/main/actions/.htaccess b/application/ship-simu/main/actions/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/main/actions/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/ship-simu/main/actions/class_ShipSimuLoginAction.php b/application/ship-simu/main/actions/class_ShipSimuLoginAction.php new file mode 100644 index 0000000..baf56a0 --- /dev/null +++ b/application/ship-simu/main/actions/class_ShipSimuLoginAction.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @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 ShipSimuLoginAction extends BaseAction implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set description + $this->setObjectDescription("Login welcome action"); + + // Generate unique key + $this->generateUniqueId(); + } + + /** + * Creates an instance of this action + * + * @return $actionInstance An instance of this action class + */ + public final static function createShipSimuLoginAction () { + // Get a new instance + $actionInstance = new ShipSimuLoginAction(); + + // Return the instance + return $actionInstance; + } + + /** + * Executes the command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + /* @TODO Maybe we need to do something later here */ + } +} + +// [EOF] +?> diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php index cc9b0b7..f7e50f7 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php @@ -58,7 +58,7 @@ class WebShipsimuRegisterCommand extends BaseCommand implements Commandable { // Get the controller instance from the resolver (breaks MVC pattern again) $controllerInstance = $resolverInstance->getControllerInstance(); - // @TODO Add some more pre/post filters to the controller + /* @TODO Add some more pre/post filters to the controller */ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_validator_class')); $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_validator_class')); $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_validator_class')); diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php index afab446..6a2ab50 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php @@ -71,7 +71,8 @@ class WebShipsimuUserLoginCommand extends BaseCommand implements Commandable { $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_email_verifier_class')); break; } - // @TODO Add more filters + + /* @TODO Add more filters */ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_verifier_class')); // Return the prepared instance diff --git a/application/ship-simu/main/ships/passenger/class_PassengerShip.php b/application/ship-simu/main/ships/passenger/class_PassengerShip.php index b78f7dd..cbe0a22 100644 --- a/application/ship-simu/main/ships/passenger/class_PassengerShip.php +++ b/application/ship-simu/main/ships/passenger/class_PassengerShip.php @@ -49,7 +49,7 @@ class PassengerShip extends BaseShip implements ConstructableShip, LimitableObje __CLASS__, __LINE__ )); - } + } // END - if // Set ship's name $passInstance->setShipName($shipName); @@ -66,7 +66,7 @@ class PassengerShip extends BaseShip implements ConstructableShip, LimitableObje if (is_null($struct)) { // Empty structures list! throw new EmptyStructuresListException($this, self::EXCEPTION_EMPTY_STRUCTURES_ARRAY); - } + } // END - if // Anzahl Betten auf 0 setzen $numBeds = 0; @@ -108,7 +108,7 @@ class PassengerShip extends BaseShip implements ConstructableShip, LimitableObje $el->getObjectDescription() )); } - } + } // END - for if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das %s mit dem Namen %s hat %d Betten.
\n", __CLASS__, @@ -125,10 +125,10 @@ class PassengerShip extends BaseShip implements ConstructableShip, LimitableObje /** * Reduces the volume of a processed object. * - * @param $limitInstance An instance to ObjectLimits which holds - * attribute names that we want to include in the processing - * phase. Other attributes except $uniqueID and $realClass will - * be ignored and keept out. + * @param $limitInstance An instance to ObjectLimits which holds + * attribute names that we want to include in the processing phase. + * Other attributes except $uniqueID and $realClass will be ignored + * and keept out. * @return void */ function limitObject (ObjectLimits $limitInstance) { diff --git a/application/ship-simu/templates/de/code/login_welcome.ctp b/application/ship-simu/templates/de/code/login_welcome.ctp new file mode 100644 index 0000000..7d3df54 --- /dev/null +++ b/application/ship-simu/templates/de/code/login_welcome.ctp @@ -0,0 +1,7 @@ +
+ Willkommen im Loginbereich von {?app_full_name?} +
+ +
+ {?ship_simu_login_news?} +
diff --git a/db/news/.htaccess b/db/news/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/db/news/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/response/class_Responseable.php b/inc/classes/interfaces/response/class_Responseable.php index a1fabde..1904b14 100644 --- a/inc/classes/interfaces/response/class_Responseable.php +++ b/inc/classes/interfaces/response/class_Responseable.php @@ -50,7 +50,7 @@ interface Responseable extends FrameworkInterface { /** * Flushs the cached HTTP response to the outer world * - * @param $foce Wether we shall force the output or abort if headers are + * @param $force Wether we shall force the output or abort if headers are * already sent with an exception * @return void * @throws ResponseHeadersAlreadySentException Thrown if headers are 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 diff --git a/inc/classes/main/controller/default/class_WebLoginController.php b/inc/classes/main/controller/default/class_WebLoginController.php index 1758c8a..5c8f9f4 100644 --- a/inc/classes/main/controller/default/class_WebLoginController.php +++ b/inc/classes/main/controller/default/class_WebLoginController.php @@ -52,7 +52,7 @@ class WebLoginController extends BaseController implements Controller { // Set the command resolver $controllerInstance->setResolverInstance($resolverInstance); - // @TODO Add some filters to this controller + /* @TODO Add some filters to this controller */ // Return the prepared instance return $controllerInstance; diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php index 220ad14..610843a 100644 --- a/inc/classes/main/database/databases/class_LocalFileDatabase.php +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -479,7 +479,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend * @return void */ public function connectToDatabase () { - // @TODO Do some checks on the database directory and files here + /* @TODO Do some checks on the database directory and files here */ } /** diff --git a/inc/classes/main/filter/news/class_NewsProcessFilter.php b/inc/classes/main/filter/news/class_NewsProcessFilter.php index 8df6a0f..b6be041 100644 --- a/inc/classes/main/filter/news/class_NewsProcessFilter.php +++ b/inc/classes/main/filter/news/class_NewsProcessFilter.php @@ -60,7 +60,7 @@ class NewsProcessFilter extends BaseFilter implements Filterable { * @return void */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { - $this->partialStub("Unfinished work."); + /* @TODO Unfinished stub, add functionality here */ } } diff --git a/inc/classes/main/helper/web/class_WebFormHelper.php b/inc/classes/main/helper/web/class_WebFormHelper.php index 6dbffb5..293a6fc 100644 --- a/inc/classes/main/helper/web/class_WebFormHelper.php +++ b/inc/classes/main/helper/web/class_WebFormHelper.php @@ -151,7 +151,7 @@ class WebFormHelper extends BaseHelper { $this->addFormGroup("", ""); } - // @TODO Add some unique PIN here to bypass problems with some browser and/or extensions + /* @TODO Add some unique PIN here to bypass problems with some browser and/or extensions */ // Simply close it $this->formOpened = false; } diff --git a/inc/classes/main/response/class_HttpResponse.php b/inc/classes/main/response/class_HttpResponse.php index b3cbd0b..57e4eb7 100644 --- a/inc/classes/main/response/class_HttpResponse.php +++ b/inc/classes/main/response/class_HttpResponse.php @@ -148,7 +148,7 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { /** * Flushs the cached HTTP response to the outer world * - * @param $foce Wether we shall force the output or abort if headers are + * @param $force Wether we shall force the output or abort if headers are * already sent with an exception * @return void * @throws ResponseHeadersAlreadySentException Thrown if headers are @@ -256,7 +256,7 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { // Shall we encrypt the cookie? if ($encrypted === true) { - // @TODO Encryption of cookie data not yet supported + /* @TODO Encryption of cookie data not yet supported */ } // END - if // For slow browsers set the cookie array element first @@ -271,15 +271,15 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { $domain = $this->getConfigInstance()->readConfig('cookie_domain'); setcookie($cookieName, $cookieValue, $expires); - // @TODO Why are these parameters conflicting? + /* @TODO Why are these parameters conflicting? */ //, $path, $domain, (isset($_SERVER['HTTPS'])) return; - // @TODO This will send only one cookie out, the first one. + /* @TODO This will send only one cookie out, the first one. */ // Now construct the full header $cookieString = $cookieName . "=" . $cookieValue . "; "; $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT"; - // @TODO Why are these parameters conflicting? + /* @TODO Why are these parameters conflicting? */ // $cookieString .= "; path=".$path."; domain=".$domain; // Set the cookie as a header diff --git a/inc/classes/main/rng/class_RandomNumberGenerator.php b/inc/classes/main/rng/class_RandomNumberGenerator.php index a72e13a..12e1c01 100644 --- a/inc/classes/main/rng/class_RandomNumberGenerator.php +++ b/inc/classes/main/rng/class_RandomNumberGenerator.php @@ -105,7 +105,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem { } // One-way data we need for "extra-salting" the random number - // @TODO Add site key for stronger salt! + /* @TODO Add site key for stronger salt! */ $this->extraSalt = sha1($serverIp . ":" . getenv('SERVER_SOFTWARE') . ":" . $this->getConfigInstance()->readConfig('date_key') . ":" . serialize($this->getDatabaseInstance()->getConnectionData())); // Get config entry for max salt length @@ -143,7 +143,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem { * @return $num Pseudo-random number */ public function randomNumnber ($min, $max) { - // @TODO I had a better random number generator here + /* @TODO I had a better random number generator here */ return mt_rand($min, $max); } diff --git a/inc/classes/main/template/class_TemplateEngine.php b/inc/classes/main/template/class_TemplateEngine.php index 7fada10..7378a40 100644 --- a/inc/classes/main/template/class_TemplateEngine.php +++ b/inc/classes/main/template/class_TemplateEngine.php @@ -793,7 +793,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate $this->assignVariable($var, $varMatches[3][$key]); } elseif (!empty($varMatches[2][$key])) { // Non-string found so we need some deeper analysis... - // @TODO Unfinished work or don't die here. + /* @TODO Unfinished work or don't die here. */ die("Deeper analysis not yet implemented!"); } @@ -986,7 +986,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate ); // This loop does remove the backslashes (\) in PHP parameters - // @TODO Make this some nicer... + /* @TODO Make this some nicer... */ while (strpos($eval, "