From: Roland Häder Date: Sun, 16 Nov 2008 01:13:24 +0000 (+0000) Subject: Typos fixed and special command resolver are now possible X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=commitdiff_plain;h=5bf79580029c4f6ee71e6c9e7890169e4b344def Typos fixed and special command resolver are now possible - Two typos fixed: In terms like "if the" and "in the" >the< has been removed - If a special "page" depending web command resolver is found it will be used - Otherwise the default command resolver WebCommandResolver will be used as fall-back - Some minor fixes - TODO extended with a good "naming convention idea" --- diff --git a/.gitattributes b/.gitattributes index 01097e3..6ae7adf 100644 --- a/.gitattributes +++ b/.gitattributes @@ -165,6 +165,7 @@ application/ship-simu/main/actions/ship-simu/class_ShipSimuProfileAction.php -te application/ship-simu/main/actions/web/.htaccess -text application/ship-simu/main/actions/web/class_WebShipSimuLogin -text application/ship-simu/main/actions/web/class_WebShipSimuLoginCompanyAction.php -text +application/ship-simu/main/actions/web/class_WebShipSimuLoginGovermentStartupHelpAction.php -text application/ship-simu/main/actions/web/class_WebShipSimuLoginGovermentTrainingAction.php -text application/ship-simu/main/actions/web/class_WebShipSimuLoginLogoutAction.php -text application/ship-simu/main/actions/web/class_WebShipSimuLoginProfileAction.php -text @@ -198,6 +199,9 @@ application/ship-simu/main/constructions/terminals/.htaccess -text application/ship-simu/main/constructions/terminals/class_Terminal.php -text application/ship-simu/main/constructions/yards/.htaccess -text application/ship-simu/main/constructions/yards/class_Shipyard.php -text +application/ship-simu/main/controller/.htaccess -text +application/ship-simu/main/controller/web/.htaccess -text +application/ship-simu/main/controller/web/class_WebGovermentFailedController.php -text application/ship-simu/main/drives/.htaccess -text application/ship-simu/main/drives/class_BaseDrive.php -text application/ship-simu/main/drives/motor/.htaccess -text @@ -206,6 +210,7 @@ application/ship-simu/main/factories/.htaccess -text application/ship-simu/main/factories/class_ShipSimuWebNewsFactory.php -text application/ship-simu/main/filter/.htaccess -text application/ship-simu/main/filter/goverment/.htaccess -text +application/ship-simu/main/filter/goverment/class_ShipSimuGovermentPaysStartupHelpFilter.php -text application/ship-simu/main/filter/goverment/class_ShipSimuGovermentPaysTrainingFilter.php -text application/ship-simu/main/filter/page/.htaccess -text application/ship-simu/main/filter/page/class_RefillPageFilter.php -text @@ -228,6 +233,9 @@ application/ship-simu/main/personell/company/.htaccess -text application/ship-simu/main/personell/company/class_CompanyEmployee.php -text application/ship-simu/main/registration/.htaccess -text application/ship-simu/main/registration/class_ShipSimuRegistration.php -text +application/ship-simu/main/resolver/.htaccess -text +application/ship-simu/main/resolver/web/.htaccess -text +application/ship-simu/main/resolver/web/class_WebGovermentFailedCommandResolver.php -text application/ship-simu/main/ships/.htaccess -text application/ship-simu/main/ships/class_BaseShip.php -text application/ship-simu/main/ships/passenger/.htaccess -text @@ -627,6 +635,7 @@ inc/classes/main/commands/class_BaseCommand.php -text inc/classes/main/commands/image/.htaccess -text inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php -text inc/classes/main/commands/web/.htaccess -text +inc/classes/main/commands/web/class_ -text inc/classes/main/commands/web/class_WebConfirmCommand.php -text inc/classes/main/commands/web/class_WebDoFormCommand.php -text inc/classes/main/commands/web/class_WebHomeCommand.php -text @@ -656,6 +665,7 @@ inc/classes/main/controller/image/class_ImageDefaultController.php -text inc/classes/main/controller/login/.htaccess -text inc/classes/main/controller/login/class_WebLoginAreaController.php -text inc/classes/main/controller/web/.htaccess -text +inc/classes/main/controller/web/class_ -text inc/classes/main/controller/web/class_WebConfirmController.php -text inc/classes/main/controller/web/class_WebDefaultController.php -text inc/classes/main/controller/web/class_WebDefaultNewsController.php -text @@ -803,6 +813,7 @@ inc/classes/main/resolver/command/class_BaseCommandResolver.php -text inc/classes/main/resolver/command/image/.htaccess -text inc/classes/main/resolver/command/image/class_ImageCommandResolver.php -text inc/classes/main/resolver/command/web/.htaccess -text +inc/classes/main/resolver/command/web/class_ -text inc/classes/main/resolver/command/web/class_WebCommandResolver.php -text inc/classes/main/resolver/controller/.htaccess -text inc/classes/main/resolver/controller/class_BaseControllerResolver.php -text diff --git a/application/admin/main/login/class_AdminUserLogin.php b/application/admin/main/login/class_AdminUserLogin.php index 3cf2678..a4187a5 100644 --- a/application/admin/main/login/class_AdminUserLogin.php +++ b/application/admin/main/login/class_AdminUserLogin.php @@ -106,7 +106,7 @@ class AdminUserLogin extends BaseFrameworkSystem implements LoginableUser { } /** - * Determines wether the login was fine. This is done by checking if the 'login' instance is in registry + * Determines wether the login was fine. This is done by checking if 'login' instance is in registry * * @return $loginDone Wether the login was fine or not */ @@ -119,14 +119,14 @@ class AdminUserLogin extends BaseFrameworkSystem implements LoginableUser { } /** - * Encrypt the given request key or throw an exception if the key was not - * found in the request + * Encrypt given request key or throw an exception if key was not found in + * request * * @param $requestKey Key in request class * @return void */ public function encryptPassword ($requestKey) { - // Check if the password is found in the request + // Check if password is found in request if ($this->getRequestInstance()->isRequestElementSet($requestKey)) { // So encrypt the password and store it for later usage in // the request: @@ -140,7 +140,7 @@ class AdminUserLogin extends BaseFrameworkSystem implements LoginableUser { // Get a crypto helper and hash the password $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword, $userInstance->getPasswordHash()); - // Store the hash back in the request + // Store the hash back in request $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword); } // END - if } diff --git a/application/ship-simu/config.php b/application/ship-simu/config.php index 24f8cd7..72c01ec 100644 --- a/application/ship-simu/config.php +++ b/application/ship-simu/config.php @@ -121,6 +121,12 @@ $cfg->setConfigEntry('confirm_code_invalid_url', "index.php?app={?app_short_name // CFG: USER-NOT-FOUND-URL $cfg->setConfigEntry('user_not_found_url', "index.php?app={?app_short_name?}&page=status&status=user_not_found"); +// CFG: LOGIN-GOVERMENT-STARTUP-FAILED-URL +$cfg->setConfigEntry('login_goverment_startup_failed_url', "index.php?app={?app_short_name?}&page=goverment_failed&failed=startup"); + +// CFG: LOGIN-GOVERMENT-TRAINING-FAILED-URL +$cfg->setConfigEntry('login_goverment_training_failed_url', "index.php?app={?app_short_name?}&page=goverment_failed&failed=training"); + // CFG: LOGIN-DEFAULT-ACTION $cfg->setConfigEntry('login_default_action', "welcome"); @@ -178,6 +184,9 @@ $cfg->setConfigEntry('payment_discovery_filter', "PaymentDiscoveryFilter"); // CFG: GOVERMENT-PAYS-TRAINING-FILTER $cfg->setConfigEntry('goverment_pays_training_filter', "ShipSimuGovermentPaysTrainingFilter"); +// CFG: GOVERMENT-PAYS-STARTUP-HELP-FILTER +$cfg->setConfigEntry('goverment_pays_startup_help_filter', "ShipSimuGovermentPaysStartupHelpFilter"); + // CFG: NEWS-HOME-LIMIT $cfg->setConfigEntry('news_home_limit', 10); @@ -334,5 +343,8 @@ $cfg->setConfigEntry('web_form_helper', "WebFormHelper"); // CFG: WEB-LINK-HELPER $cfg->setConfigEntry('web_link_helper', "WebLinkHelper"); +// CFG: WEB-CMD-GOVERMENT-FAILED-RESOLVER-CLASS +$cfg->setConfigEntry('web_cmd_goverment_failed_resolver_class', "WebGovermentFailedCommandResolver"); + // [EOF] ?> diff --git a/application/ship-simu/exceptions/class_ItemNotInPriceListException.php b/application/ship-simu/exceptions/class_ItemNotInPriceListException.php index 03268ee..8daaa24 100644 --- a/application/ship-simu/exceptions/class_ItemNotInPriceListException.php +++ b/application/ship-simu/exceptions/class_ItemNotInPriceListException.php @@ -1,6 +1,6 @@ * @version 0.0.0 diff --git a/application/ship-simu/main/actions/web/class_WebShipSimuLoginGovermentStartupHelpAction.php b/application/ship-simu/main/actions/web/class_WebShipSimuLoginGovermentStartupHelpAction.php new file mode 100644 index 0000000..5ecc924 --- /dev/null +++ b/application/ship-simu/main/actions/web/class_WebShipSimuLoginGovermentStartupHelpAction.php @@ -0,0 +1,82 @@ + + * @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 WebShipSimuLoginGovermentStartupHelpAction extends BaseAction implements Commandable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this action + * + * @param $resolverInstance An instance of an action resolver + * @return $actionInstance An instance of this action class + */ + public final static function createWebShipSimuLoginGovermentStartupHelpAction (ActionResolver $resolverInstance) { + // Get a new instance + $actionInstance = new WebShipSimuLoginGovermentStartupHelpAction(); + + // Set the resolver instance + $actionInstance->setResolverInstance($resolverInstance); + + // 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 + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Unfinished method + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Add some filters here + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Check for user status by default + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter')); + + // Check if goverment can pay startup help + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('goverment_pays_startup_help_filter')); + } +} + +// [EOF] +?> diff --git a/application/ship-simu/main/companies/class_ShippingCompany.php b/application/ship-simu/main/companies/class_ShippingCompany.php index 1d6877b..24603fd 100644 --- a/application/ship-simu/main/companies/class_ShippingCompany.php +++ b/application/ship-simu/main/companies/class_ShippingCompany.php @@ -519,7 +519,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Get it's real class name $shipType = $shipInstance->__toString(); - // Now check if the ship type is in any list and return the result + // Now check if ship type is in any list and return the result return ($this->isShipTypeConstructable($shipType)); } @@ -556,7 +556,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner throw new ClassMismatchException(array($shipyard->__toString(), "Shipyard"), self::EXCEPTION_CLASSES_NOT_MATCHING); } - // Validate if the first found shipyard can construct the requested type + // Validate if first found shipyard can construct the requested type $result = $shipyard->isShipTypeConstructable($shipType); // Does this shipyard construct the requested ship type? diff --git a/application/ship-simu/main/controller/.htaccess b/application/ship-simu/main/controller/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/main/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/ship-simu/main/controller/web/.htaccess b/application/ship-simu/main/controller/web/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/main/controller/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/ship-simu/main/controller/web/class_WebGovermentFailedController.php b/application/ship-simu/main/controller/web/class_WebGovermentFailedController.php new file mode 100644 index 0000000..79fe215 --- /dev/null +++ b/application/ship-simu/main/controller/web/class_WebGovermentFailedController.php @@ -0,0 +1,103 @@ + + * @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 WebGovermentFailedController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public final static function createWebGovermentFailedController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebGovermentFailedController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // User auth filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter')); + + // User update filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_filter')); + + // News fetcher filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); + + // News proccess/display-preparation + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Try to run the pre filters, if auth exceptions come through redirect here + try { + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + } catch (UserAuthorizationException $e) { + // Redirect to main page + $responseInstance->redirectToConfiguredUrl('login_failed_url'); + } + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/application/ship-simu/main/filter/goverment/class_ShipSimuGovermentPaysStartupHelpFilter.php b/application/ship-simu/main/filter/goverment/class_ShipSimuGovermentPaysStartupHelpFilter.php new file mode 100644 index 0000000..3d02ad9 --- /dev/null +++ b/application/ship-simu/main/filter/goverment/class_ShipSimuGovermentPaysStartupHelpFilter.php @@ -0,0 +1,79 @@ + + * @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 ShipSimuGovermentPaysStartupHelpFilter extends BaseFrameworkSystem implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createShipSimuGovermentPaysStartupHelpFilter () { + // Get a new instance + $filterInstance = new ShipSimuGovermentPaysStartupHelpFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter 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 + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the user instance from registry + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Now simply check for it + if (($userInstance instanceof ManageableMember) || ($userInstance->ifGovermentPaysStartupHelp() === false)) { + // Request is invalid + $requestInstance->requestIsValid(false); + + // Redirect to configured URL + $responseInstance->redirectToConfiguredUrl('login_goverment_startup_failed_url'); + + // Stop processing here + exit(); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/ship-simu/main/filter/goverment/class_ShipSimuGovermentPaysTrainingFilter.php b/application/ship-simu/main/filter/goverment/class_ShipSimuGovermentPaysTrainingFilter.php index febd4bd..466059c 100644 --- a/application/ship-simu/main/filter/goverment/class_ShipSimuGovermentPaysTrainingFilter.php +++ b/application/ship-simu/main/filter/goverment/class_ShipSimuGovermentPaysTrainingFilter.php @@ -66,11 +66,11 @@ class ShipSimuGovermentPaysTrainingFilter extends BaseFrameworkSystem implements // Request is invalid $requestInstance->requestIsValid(false); - // Add a message to the response - $responseInstance->addFatalMessage('goverment_pays_no_training'); + // Redirect to configured URL + $responseInstance->redirectToConfiguredUrl('login_goverment_training_failed_url'); - // Abort here - return false; + // Stop processing here + exit(); } // END - if } } diff --git a/application/ship-simu/main/login/class_ShipSimuGuestLogin.php b/application/ship-simu/main/login/class_ShipSimuGuestLogin.php index 7336865..d4b0365 100644 --- a/application/ship-simu/main/login/class_ShipSimuGuestLogin.php +++ b/application/ship-simu/main/login/class_ShipSimuGuestLogin.php @@ -118,7 +118,7 @@ class ShipSimuGuestLogin extends BaseFrameworkSystem implements LoginableUser { } /** - * Determines wether the login was fine. This is done by checking if the 'login' instance is in registry + * Determines wether the login was fine. This is done by checking if 'login' instance is in registry * * @return $loginDone Wether the login was fine or not */ @@ -131,14 +131,14 @@ class ShipSimuGuestLogin extends BaseFrameworkSystem implements LoginableUser { } /** - * Encrypt the given request key or throw an exception if the key was not - * found in the request + * Encrypt given request key or throw an exception if key was not found in + * request * * @param $requestKey Key in request class * @return void */ public function encryptPassword ($requestKey) { - // Check if the password is found in the request + // Check if password is found in request if ($this->getRequestInstance()->isRequestElementSet($requestKey)) { // So encrypt the password and store it for later usage in // the request: @@ -152,7 +152,7 @@ class ShipSimuGuestLogin extends BaseFrameworkSystem implements LoginableUser { // Get a crypto helper and hash the password $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword, $userInstance->getPasswordHash()); - // Store the hash back in the request + // Store the hash back in request $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword); } // END - if } diff --git a/application/ship-simu/main/login/class_ShipSimuUserLogin.php b/application/ship-simu/main/login/class_ShipSimuUserLogin.php index 541e188..178c408 100644 --- a/application/ship-simu/main/login/class_ShipSimuUserLogin.php +++ b/application/ship-simu/main/login/class_ShipSimuUserLogin.php @@ -106,7 +106,7 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser { } /** - * Determines wether the login was fine. This is done by checking if the 'login' instance is in registry + * Determines wether the login was fine. This is done by checking if 'login' instance is in registry * * @return $loginDone Wether the login was fine or not */ @@ -119,14 +119,14 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser { } /** - * Encrypt the given request key or throw an exception if the key was not - * found in the request + * Encrypt given request key or throw an exception if key was not found in + * request * * @param $requestKey Key in request class * @return void */ public function encryptPassword ($requestKey) { - // Check if the password is found in the request + // Check if password is found in request if ($this->getRequestInstance()->isRequestElementSet($requestKey)) { // So encrypt the password and store it for later usage in // the request: @@ -140,7 +140,7 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser { // Get a crypto helper and hash the password $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword, $userInstance->getPasswordHash()); - // Store the hash back in the request + // Store the hash back in request $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword); } // END - if } diff --git a/application/ship-simu/main/registration/class_ShipSimuRegistration.php b/application/ship-simu/main/registration/class_ShipSimuRegistration.php index 1ad9731..5778665 100644 --- a/application/ship-simu/main/registration/class_ShipSimuRegistration.php +++ b/application/ship-simu/main/registration/class_ShipSimuRegistration.php @@ -1,6 +1,6 @@ * @version 0.0.0 @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ShipSimuRegistration extends BaseRegistration { +class ShipSimuRegistration extends BaseRegistration implements UserRegister { /** * Hashed password */ @@ -73,14 +73,14 @@ class ShipSimuRegistration extends BaseRegistration { } /** - * Encrypt the given request key or throw an exception if the key was not - * found in the request + * Encrypt given request key or throw an exception if key was not found in + * request * * @param $requestKey Key in request class * @return void */ public function encryptPassword ($requestKey) { - // Check if the password is found in the request + // Check if password is found in request if ($this->getRequestInstance()->isRequestElementSet($requestKey)) { // So encrypt the password and store it for later usage in // the request: @@ -91,7 +91,7 @@ class ShipSimuRegistration extends BaseRegistration { // 2. Get a crypto helper and hash the password $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword); - // 3. Store the hash back in the request + // 3. Store the hash back in request $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword); } } @@ -101,6 +101,7 @@ class ShipSimuRegistration extends BaseRegistration { * before registration * * @return void + * @todo Maybe add more things to perform */ public function doPreRegistration () { // First run all pre filters @@ -112,6 +113,7 @@ class ShipSimuRegistration extends BaseRegistration { * database and paying some start credits or throw exceptions if this fails * * @return void + * @todo Maybe add more things to perform */ public function registerNewUser () { // Get a user database wrapper @@ -125,6 +127,7 @@ class ShipSimuRegistration extends BaseRegistration { * Perform things like notifying partner websites after registration is done * * @return void + * @todo Maybe add more things to perform */ public function doPostRegistration () { // First run all post filters diff --git a/application/ship-simu/main/resolver/.htaccess b/application/ship-simu/main/resolver/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/main/resolver/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/ship-simu/main/resolver/web/.htaccess b/application/ship-simu/main/resolver/web/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/main/resolver/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/ship-simu/main/resolver/web/class_WebGovermentFailedCommandResolver.php b/application/ship-simu/main/resolver/web/class_WebGovermentFailedCommandResolver.php new file mode 100644 index 0000000..a7e5b38 --- /dev/null +++ b/application/ship-simu/main/resolver/web/class_WebGovermentFailedCommandResolver.php @@ -0,0 +1,186 @@ + + * @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 WebGovermentFailedCommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Last successfull resolved command + */ + private $lastCommandInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "Web" + $this->setCommandPrefix("Web"); + } + + /** + * Creates an instance of a Web command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidInterfaceException Thrown if command does not implement interface Commandable + */ + public final static function createWebGovermentFailedCommandResolver ($commandName, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new WebGovermentFailedCommandResolver(); + + // Get request instance + $requestInstance = $appInstance->getRequestInstance(); + + // Is the variable $commandName set and the command is valid? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!$resolverInstance->resolveCommandByRequest($requestInstance) instanceof Commandable) { + // Invalid command found (missing interface?) + throw new InvalidInterfaceException(array($userInstance, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an command instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $commandInstance An instance of the resolved command + * @throws InvalidCommandException Thrown if $commandName is + * invalid + * @throws InvalidCommandInstanceException Thrown if $commandInstance + * is an invalid instance + */ + public function resolveCommandByRequest (Requestable $requestInstance) { + // Init instance + $commandInstance = null; + + // This goes fine so let's resolv the command + $commandName = $requestInstance->getRequestElement('page'); + + // Is there a "failed" request? + if ($requestInstance->isRequestElementSet('failed')) { + // Then include with within the command name + $commandName = sprintf("%s_%s", $commandName, $requestInstance->getRequestElement('failed')); + } // END - if + + // Is the command empty? Then fall back to default command + if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command'); + + // Check if command is valid + if ($this->isCommandValid($commandName) === false) { + // This command is invalid! + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Get the command + $commandInstance = $this->loadCommand($commandName); + + // And validate it + if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) { + // This command has an invalid instance! + throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Set last command + $this->lastCommandInstance = $commandInstance; + + // Return the resolved command instance + return $commandInstance; + } + + /** + * Resolves the command by its direct name and returns an instance of its class + * + * @param $commandName The direct command name we shall resolve + * @return $commandInstance An instance of the command class + * @throws InvalidCommandException Thrown if $commandName is invalid + */ + public function resolveCommand ($commandName) { + // Initiate the instance variable + $commandInstance = null; + + // Is the command empty? Then fall back to default command + if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command'); + + // Check if command is valid + if ($this->isCommandValid($commandName) === false) { + // This command is invalid! + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Get the command + $commandInstance = $this->loadCommand($commandName); + + // Return the instance + return $commandInstance; + } + + /** + * "Loads" a given command and instances it if not yet cached + * + * @param $commandName A command name we shall look for + * @return $commandInstance A loaded command instance + * @throws InvalidCommandException Thrown if even the default + * command class is missing (bad!) + */ + private function loadCommand ($commandName) { + // Cache default command + $defaultCommand = $this->getConfigInstance()->readConfig('default_web_command'); + + // Init command instance + $commandInstance = null; + + // Create command class name + $this->setClassName(sprintf("Web%sCommand", + $this->convertToClassName($commandName) + )); + + // Is this class loaded? + if (!class_exists($this->getClassName())) { + // Class not found, so throw an exception + throw new InvalidCommandException(array($this, $defaultCommand), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Initiate the command + $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this)); + + // Return the result + return $commandInstance; + } +} + +// [EOF] +?> diff --git a/application/ship-simu/main/user/class_ShipSimuBaseUser.php b/application/ship-simu/main/user/class_ShipSimuBaseUser.php index 61feb28..63c9b8d 100644 --- a/application/ship-simu/main/user/class_ShipSimuBaseUser.php +++ b/application/ship-simu/main/user/class_ShipSimuBaseUser.php @@ -90,9 +90,9 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { } /** - * Determines if the goverment can still pay a "virtual training course" in general + * Determines if goverment can still pay a "virtual training course" in general * - * @return $ifGovHelps Wether if the goverment helps the user with a virtual training course + * @return $ifGovHelps Wether if goverment helps the user with a virtual training course */ public function ifGovermentPaysTraining () { // By default they want to help. @@ -121,9 +121,9 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { } /** - * Determines if the goverment can still pay a "startup help" to the user + * Determines if goverment can still pay a "startup help" to the user * - * @return $ifGovHelps Wether if the goverment helps the user with some startup money + * @return $ifGovHelps Wether if goverment helps the user with some startup money */ public function ifGovermentPaysStartupHelp () { // By default they want to help. diff --git a/application/ship-simu/main/user/extended/class_ShipSimuGuest.php b/application/ship-simu/main/user/extended/class_ShipSimuGuest.php index 1f7ec55..7009d3a 100644 --- a/application/ship-simu/main/user/extended/class_ShipSimuGuest.php +++ b/application/ship-simu/main/user/extended/class_ShipSimuGuest.php @@ -40,7 +40,7 @@ class ShipSimuGuest extends ShipSimuBaseUser implements ManageableGuest { /** * Creates an instance of this user class by a provided username. This - * factory method will check if the username is already taken and if not + * factory method will check if username is already taken and if not * so it will throw an exception. * * @param $userName Username we need a class instance for @@ -54,7 +54,7 @@ class ShipSimuGuest extends ShipSimuBaseUser implements ManageableGuest { // Set the username $userInstance->setUserName($userName); - // Check if the username exists + // Check if username exists if ($userInstance->ifUsernameExists() === false) { // Throw an exception here throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); @@ -66,7 +66,7 @@ class ShipSimuGuest extends ShipSimuBaseUser implements ManageableGuest { /** * Creates an instance of this user class by a provided email address. This - * factory method will not check if the email address is there. + * factory method will not check if email address is there. * * @param $email Email address of the user * @return $userInstance An instance of this user class diff --git a/application/ship-simu/main/user/extended/class_ShipSimuMember.php b/application/ship-simu/main/user/extended/class_ShipSimuMember.php index 46fb2ed..98e7a2a 100644 --- a/application/ship-simu/main/user/extended/class_ShipSimuMember.php +++ b/application/ship-simu/main/user/extended/class_ShipSimuMember.php @@ -48,7 +48,7 @@ class ShipSimuMember extends ShipSimuBaseUser implements ManageableMember { /** * Creates an instance of this user class by a provided username. This - * factory method will check if the username is already taken and if not + * factory method will check if username is already taken and if not * so it will throw an exception. * * @param $userName Username we need a class instance for @@ -62,7 +62,7 @@ class ShipSimuMember extends ShipSimuBaseUser implements ManageableMember { // Set the username $userInstance->setUserName($userName); - // Check if the username exists + // Check if username exists if ($userInstance->ifUsernameExists() === false) { // Throw an exception here throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); @@ -74,7 +74,7 @@ class ShipSimuMember extends ShipSimuBaseUser implements ManageableMember { /** * Creates an instance of this user class by a provided email address. This - * factory method will not check if the email address is there. + * factory method will not check if email address is there. * * @param $email Email address of the user * @return $userInstance An instance of this user class diff --git a/docs/TODO b/docs/TODO index 77521c0..70e41b1 100644 --- a/docs/TODO +++ b/docs/TODO @@ -1,6 +1,8 @@ TODO: ===== +- Rename all FooNotFoundException to NoBarException + - Hub and MXChange 0.3.0 must be ported to new framework changes: + ClassLoader::includeAllClasses() removed + FrameworkArrayObject::__construct($className) requires class name diff --git a/inc/classes/exceptions/main/class_InvalidInterfaceException.php b/inc/classes/exceptions/main/class_InvalidInterfaceException.php index c628542..93958ed 100644 --- a/inc/classes/exceptions/main/class_InvalidInterfaceException.php +++ b/inc/classes/exceptions/main/class_InvalidInterfaceException.php @@ -31,7 +31,7 @@ class InvalidInterfaceException extends FrameworkException { */ public function __construct (array $classArray, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] Object does not implement expected interface .", + $message = sprintf("[%s:%d] Object does not implement expected interface %s.", $classArray[0]->__toString(), $this->getLine(), $classArray[1] diff --git a/inc/classes/exceptions/result/class_ResultUpdateException.php b/inc/classes/exceptions/result/class_ResultUpdateException.php index da2ec8f..e58ab04 100644 --- a/inc/classes/exceptions/result/class_ResultUpdateException.php +++ b/inc/classes/exceptions/result/class_ResultUpdateException.php @@ -1,6 +1,6 @@ * @version 0.0.0 diff --git a/inc/classes/interfaces/crypto/class_Cryptable.php b/inc/classes/interfaces/crypto/class_Cryptable.php index 3d6f600..9bb6075 100644 --- a/inc/classes/interfaces/crypto/class_Cryptable.php +++ b/inc/classes/interfaces/crypto/class_Cryptable.php @@ -25,8 +25,8 @@ interface Cryptable extends FrameworkInterface { /** * Hashes a string with salt and returns the hash. If an old previous hash * is supplied the method will use the first X chars of that hash for hashing - * the password. This is useful if you want to check if the password is - * identical for authorization purposes. + * the password. This is useful if you want to check if password is identical + * for authorization purposes. * * @param $str Unhashed string * @param $oldHash A hash from previous hashed string diff --git a/inc/classes/interfaces/registration/class_UserRegister.php b/inc/classes/interfaces/registration/class_UserRegister.php index aa29b1a..cc15f8e 100644 --- a/inc/classes/interfaces/registration/class_UserRegister.php +++ b/inc/classes/interfaces/registration/class_UserRegister.php @@ -23,8 +23,8 @@ */ interface UserRegister extends FrameworkInterface { /** - * Encrypt the given request key or throws an exception if the key was not - * found in the request + * Encrypt given request key or throws an exception if key was not found in + * request. * * @param $requestKey Key in request class * @return void diff --git a/inc/classes/interfaces/registry/class_Register.php b/inc/classes/interfaces/registry/class_Register.php index 37da876..d59051f 100644 --- a/inc/classes/interfaces/registry/class_Register.php +++ b/inc/classes/interfaces/registry/class_Register.php @@ -25,8 +25,8 @@ interface Register extends FrameworkInterface { /** * Checks wether an instance key was found * - * @param $instanceKey The key holding an instance in the registry - * @return $exists Wether the key exists in the registry + * @param $instanceKey The key holding an instance in registry + * @return $exists Wether the key exists in registry */ function instanceExists ($instanceKey); diff --git a/inc/classes/interfaces/request/class_Requestable.php b/inc/classes/interfaces/request/class_Requestable.php index 5be733c..e5f9fa6 100644 --- a/inc/classes/interfaces/request/class_Requestable.php +++ b/inc/classes/interfaces/request/class_Requestable.php @@ -40,7 +40,7 @@ interface Requestable extends FrameworkInterface { function isRequestElementSet ($element); /** - * Getter for request element or 'null' if the element was not found + * Getter for request element or 'null' if element was not found * * @param $element Name of the request element we want to check * @return $value Value of the found request element or 'null' if the @@ -56,7 +56,7 @@ interface Requestable extends FrameworkInterface { function getParameterNames (); /** - * Getter for a header element or 'null' if the header was not found + * Getter for a header element or 'null' if header was not found * * @param $headerName Name of the header * @return $headerValue Value of the header or 'null' if not found diff --git a/inc/classes/interfaces/resolver/actions/class_ActionResolver.php b/inc/classes/interfaces/resolver/actions/class_ActionResolver.php index 956d2b8..7a12f3d 100644 --- a/inc/classes/interfaces/resolver/actions/class_ActionResolver.php +++ b/inc/classes/interfaces/resolver/actions/class_ActionResolver.php @@ -42,7 +42,7 @@ interface ActionResolver extends Resolver { * * @param $actionName The default action we shall execute * @return $isValid Wether the given action is valid - * @throws EmptyVariableException Thrown if the given action is not set + * @throws EmptyVariableException Thrown if given action is not set */ function isActionValid ($actionName); } diff --git a/inc/classes/interfaces/resolver/commands/class_CommandResolver.php b/inc/classes/interfaces/resolver/commands/class_CommandResolver.php index dd2ff06..d7f3976 100644 --- a/inc/classes/interfaces/resolver/commands/class_CommandResolver.php +++ b/inc/classes/interfaces/resolver/commands/class_CommandResolver.php @@ -35,7 +35,7 @@ interface CommandResolver extends Resolver { * * @param $commandName The default command we shall execute * @return $isValid Wether the given command is valid - * @throws EmptyVariableException Thrown if the given command is not set + * @throws EmptyVariableException Thrown if given command is not set */ function isCommandValid ($commandName); } diff --git a/inc/classes/interfaces/user/class_ManageableAccount.php b/inc/classes/interfaces/user/class_ManageableAccount.php index 3e88853..2dd0706 100644 --- a/inc/classes/interfaces/user/class_ManageableAccount.php +++ b/inc/classes/interfaces/user/class_ManageableAccount.php @@ -37,8 +37,8 @@ interface ManageableAccount extends FrameworkInterface { function ifEmailAddressExists (); /** - * Checks if the supplied password hash in request matches with the stored - * in database. + * Checks if supplied password hash in request matches with stored in + * database. * * @param $requestInstance A requestable class instance * @return $matches Wether the supplied password hash matches diff --git a/inc/classes/main/actions/class_BaseAction.php b/inc/classes/main/actions/class_BaseAction.php index 0b2cd81..a2b1665 100644 --- a/inc/classes/main/actions/class_BaseAction.php +++ b/inc/classes/main/actions/class_BaseAction.php @@ -1,6 +1,8 @@ * @version 0.0.0 diff --git a/inc/classes/main/cache/class_MemoryCache.php b/inc/classes/main/cache/class_MemoryCache.php index 840519d..7e0dfd0 100644 --- a/inc/classes/main/cache/class_MemoryCache.php +++ b/inc/classes/main/cache/class_MemoryCache.php @@ -82,7 +82,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable { * Setter for cache offset * * @param $offset The offset we shall set - * @param $data Data to store in the cache + * @param $data Data to store in cache * @return void */ public final function offsetSet ($offset, $data) { @@ -93,7 +93,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable { * Getter for cache offset or "null" if not found * * @param $offset The offset we shall set - * @return $data Data to store in the cache + * @return $data Data to store in cache */ public final function offsetGet ($offset) { // Default is offset not found diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index ee34a87..0c490f1 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -192,7 +192,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Set real class $this->setRealClass($className); - // Initialize the class if the class Registry is there + // Initialize the class if class Registry is there if ((class_exists('Registry')) && (Registry::isInitialized() === false)) { // Initialize the registry automatically $this->initInstance(); diff --git a/inc/classes/main/class_FrameworkArrayObject.php b/inc/classes/main/class_FrameworkArrayObject.php index e7becae..167423c 100644 --- a/inc/classes/main/class_FrameworkArrayObject.php +++ b/inc/classes/main/class_FrameworkArrayObject.php @@ -1,7 +1,7 @@ diff --git a/inc/classes/main/commands/web/class_ b/inc/classes/main/commands/web/class_ new file mode 100644 index 0000000..d5c0bc0 --- /dev/null +++ b/inc/classes/main/commands/web/class_ @@ -0,0 +1,77 @@ + + * @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 Web???Command extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWeb???Command (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new Web???Command(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given 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 + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + $this->partialStub("Unfinished method."); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/web/class_WebConfirmCommand.php b/inc/classes/main/commands/web/class_WebConfirmCommand.php index db15067..ca44f8b 100644 --- a/inc/classes/main/commands/web/class_WebConfirmCommand.php +++ b/inc/classes/main/commands/web/class_WebConfirmCommand.php @@ -109,7 +109,7 @@ class WebConfirmCommand extends BaseCommand implements Commandable { // these two calls to cache compiled templates. $templateInstance->compileVariables(); - // Get the content back from the template engine and put it in the response class + // Get the content back from the template engine and put it in response class $templateInstance->transferToResponse($responseInstance); } diff --git a/inc/classes/main/commands/web/class_WebHomeCommand.php b/inc/classes/main/commands/web/class_WebHomeCommand.php index 14a7a9c..6aad8cf 100644 --- a/inc/classes/main/commands/web/class_WebHomeCommand.php +++ b/inc/classes/main/commands/web/class_WebHomeCommand.php @@ -100,7 +100,7 @@ class WebHomeCommand extends BaseCommand implements Commandable { // these two calls to cache compiled templates. $templateInstance->compileVariables(); - // Get the content back from the template engine and put it in the response class + // Get the content back from the template engine and put it in response class $templateInstance->transferToResponse($responseInstance); } diff --git a/inc/classes/main/commands/web/class_WebLoginAreaCommand.php b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php index 98f76cd..749de17 100644 --- a/inc/classes/main/commands/web/class_WebLoginAreaCommand.php +++ b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php @@ -137,7 +137,7 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { // these two calls to cache compiled templates. $templateInstance->compileVariables(); - // Get the content back from the template engine and put it in the response class + // Get the content back from the template engine and put it in response class $templateInstance->transferToResponse($responseInstance); } diff --git a/inc/classes/main/commands/web/class_WebLoginCommand.php b/inc/classes/main/commands/web/class_WebLoginCommand.php index e02e2b5..9726e84 100644 --- a/inc/classes/main/commands/web/class_WebLoginCommand.php +++ b/inc/classes/main/commands/web/class_WebLoginCommand.php @@ -103,7 +103,7 @@ class WebLoginCommand extends BaseCommand implements Commandable { // these two calls to cache compiled templates. $templateInstance->compileVariables(); - // Get the content back from the template engine and put it in the response class + // Get the content back from the template engine and put it in response class $templateInstance->transferToResponse($responseInstance); } diff --git a/inc/classes/main/commands/web/class_WebLoginFailedCommand.php b/inc/classes/main/commands/web/class_WebLoginFailedCommand.php index 7c74d7b..f2b6b81 100644 --- a/inc/classes/main/commands/web/class_WebLoginFailedCommand.php +++ b/inc/classes/main/commands/web/class_WebLoginFailedCommand.php @@ -103,7 +103,7 @@ class WebLoginFailedCommand extends BaseCommand implements Commandable { // these two calls to cache compiled templates. $templateInstance->compileVariables(); - // Get the content back from the template engine and put it in the response class + // Get the content back from the template engine and put it in response class $templateInstance->transferToResponse($responseInstance); } diff --git a/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php b/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php index bbb7f2f..8dfdee3 100644 --- a/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php +++ b/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php @@ -103,7 +103,7 @@ class WebLogoutDoneCommand extends BaseCommand implements Commandable { // these two calls to cache compiled templates. $templateInstance->compileVariables(); - // Get the content back from the template engine and put it in the response class + // Get the content back from the template engine and put it in response class $templateInstance->transferToResponse($responseInstance); } diff --git a/inc/classes/main/commands/web/class_WebRegisterCommand.php b/inc/classes/main/commands/web/class_WebRegisterCommand.php index 42f9379..c23b647 100644 --- a/inc/classes/main/commands/web/class_WebRegisterCommand.php +++ b/inc/classes/main/commands/web/class_WebRegisterCommand.php @@ -107,7 +107,7 @@ class WebRegisterCommand extends BaseCommand implements Commandable, Registerabl // these two calls to cache compiled templates. $templateInstance->compileVariables(); - // Get the content back from the template engine and put it in the response class + // Get the content back from the template engine and put it in response class $templateInstance->transferToResponse($responseInstance); } diff --git a/inc/classes/main/controller/form/class_WebDoFormController.php b/inc/classes/main/controller/form/class_WebDoFormController.php index e760492..021057b 100644 --- a/inc/classes/main/controller/form/class_WebDoFormController.php +++ b/inc/classes/main/controller/form/class_WebDoFormController.php @@ -45,7 +45,7 @@ class WebDoFormController extends BaseController implements Controller { // Set resolver instance $controllerInstance->setResolverInstance($resolverInstance); - // We need the controller instance in the resolver class so set it here + // We need the controller instance in resolver class so set it here $resolverInstance->setControllerInstance($controllerInstance); // Return the prepared instance diff --git a/inc/classes/main/controller/web/class_ b/inc/classes/main/controller/web/class_ new file mode 100644 index 0000000..4e5bdee --- /dev/null +++ b/inc/classes/main/controller/web/class_ @@ -0,0 +1,85 @@ + + * @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 Web???Controller extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public final static function createWeb???Controller (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new Web???Controller(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add filters + //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_filter')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/criteria/class_SearchCriteria.php b/inc/classes/main/criteria/class_SearchCriteria.php index 0e76ede..faeb8be 100644 --- a/inc/classes/main/criteria/class_SearchCriteria.php +++ b/inc/classes/main/criteria/class_SearchCriteria.php @@ -201,7 +201,7 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria } // END - foreach } // END - foreach - // Now check if the criteria matches + // Now check if expected criteria counts match $matches = ($counted == count($this->searchCriteria)); // Return the result diff --git a/inc/classes/main/crypto/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php index 1ccdaae..0456e10 100644 --- a/inc/classes/main/crypto/class_CryptoHelper.php +++ b/inc/classes/main/crypto/class_CryptoHelper.php @@ -119,8 +119,8 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { /** * Hashes a string with salt and returns the hash. If an old previous hash * is supplied the method will use the first X chars of that hash for hashing - * the password. This is useful if you want to check if the password is - * identical for authorization purposes. + * the password. This is useful if you want to check if password is identical + * for authorization purposes. * * @param $str Unhashed string * @param $oldHash A hash from previous hashed string diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php index 29e2e5e..dc4371e 100644 --- a/inc/classes/main/database/databases/class_LocalFileDatabase.php +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -273,7 +273,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend } /** - * Getter for table information file contents or an empty if the info file was not created + * Getter for table information file contents or an empty if info file was not created * * @param $dataSetInstance An instance of a database set class * @return $infoArray An array with all table informations diff --git a/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php b/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php index b399a89..01774b7 100644 --- a/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php +++ b/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php @@ -1,6 +1,6 @@ * @version 0.0.0 diff --git a/inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php b/inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php index fc11b73..e40f1e3 100644 --- a/inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php +++ b/inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php @@ -1,7 +1,7 @@ * @version 0.0.0 diff --git a/inc/classes/main/filter/validator/class_EmailValidatorFilter.php b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php index 264c4e1..819ec89 100644 --- a/inc/classes/main/filter/validator/class_EmailValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php @@ -1,9 +1,9 @@ * @version 0.0.0 diff --git a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php index 39bfee2..534823b 100644 --- a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php @@ -1,9 +1,8 @@ * @version 0.0.0 diff --git a/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php b/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php index 98fc1e6..eb6ca97 100644 --- a/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php @@ -1,6 +1,6 @@ * @version 0.0.0 diff --git a/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php index cf44e53..4506a28 100644 --- a/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php @@ -1,9 +1,8 @@ * @version 0.0.0 diff --git a/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php index cab4380..b61db66 100644 --- a/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php @@ -1,9 +1,8 @@ * @version 0.0.0 diff --git a/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php index 79e0ace..d2d53d8 100644 --- a/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php @@ -1,6 +1,6 @@ * @version 0.0.0 diff --git a/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php index c87942b..fd5bb60 100644 --- a/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php @@ -1,6 +1,6 @@ * @version 0.0.0 diff --git a/inc/classes/main/helper/captcha/images/class_ImageHelper.php b/inc/classes/main/helper/captcha/images/class_ImageHelper.php index 0b5a76f..fa8bd85 100644 --- a/inc/classes/main/helper/captcha/images/class_ImageHelper.php +++ b/inc/classes/main/helper/captcha/images/class_ImageHelper.php @@ -270,7 +270,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { /** * Setter for image message string * - * @param $imageString A message to display in the image + * @param $imageString A message to display in image * @return void */ public final function setImageString ($imageString) { @@ -280,7 +280,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { /** * Getter for image message string * - * @return $imageString A message to display in the image + * @return $imageString A message to display in image */ public final function getImageString () { return $this->imageStrings[$this->currString]['string']; diff --git a/inc/classes/main/helper/web/forms/class_WebFormHelper.php b/inc/classes/main/helper/web/forms/class_WebFormHelper.php index 539f025..1fffb7a 100644 --- a/inc/classes/main/helper/web/forms/class_WebFormHelper.php +++ b/inc/classes/main/helper/web/forms/class_WebFormHelper.php @@ -426,7 +426,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { // Switch the state $this->closePreviousGroupByContent($content); - // All call it again if the group name is not empty + // All call it again if group name is not empty if ((!empty($groupId)) && ($groupId != $prevGroupId)) { //* DEBUG: */ echo $groupId."/".$prevGroupId."
\n"; $this->addFormGroup($groupId, $groupText); @@ -436,8 +436,8 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { /** * Add a form sub group or close an already opened and open a new one or - * throws an exception if no group has been opened before or if the sub - * group name is empty. + * throws an exception if no group has been opened before or if sub group + * name is empty. * * @param $subGroupId Name of the group or last opened if empty * @param $subGroupText Text including HTML to show above this group diff --git a/inc/classes/main/io/class_FrameworkDirectoryPointer.php b/inc/classes/main/io/class_FrameworkDirectoryPointer.php index e19b067..ccbb545 100644 --- a/inc/classes/main/io/class_FrameworkDirectoryPointer.php +++ b/inc/classes/main/io/class_FrameworkDirectoryPointer.php @@ -195,7 +195,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem { * @return void */ public final function setPointer ($dirPointer) { - // Sanity-check if the pointer is a valid directory resource + // Sanity-check if pointer is a valid directory resource if (is_resource($dirPointer) || is_null($dirPointer)) { // Is a valid resource $this->dirPointer = $dirPointer; diff --git a/inc/classes/main/io/class_FrameworkFileInputPointer.php b/inc/classes/main/io/class_FrameworkFileInputPointer.php index 172c02f..35376e9 100644 --- a/inc/classes/main/io/class_FrameworkFileInputPointer.php +++ b/inc/classes/main/io/class_FrameworkFileInputPointer.php @@ -178,7 +178,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { * @return void */ public final function setPointer ($filePointer) { - // Sanity-check if the pointer is a valid file resource + // Sanity-check if pointer is a valid file resource if (is_resource($filePointer) || is_null($filePointer)) { // Is a valid resource $this->filePointer = $filePointer; diff --git a/inc/classes/main/io/class_FrameworkFileOutputPointer.php b/inc/classes/main/io/class_FrameworkFileOutputPointer.php index 37c2285..84c8ed4 100644 --- a/inc/classes/main/io/class_FrameworkFileOutputPointer.php +++ b/inc/classes/main/io/class_FrameworkFileOutputPointer.php @@ -148,7 +148,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem { * @return void */ public final function setPointer ($filePointer) { - // Sanity-check if the pointer is a valid file resource + // Sanity-check if pointer is a valid file resource if (is_resource($filePointer) || is_null($filePointer)) { // Is a valid resource $this->filePointer = $filePointer; diff --git a/inc/classes/main/mailer/debug/class_DebugMailer.php b/inc/classes/main/mailer/debug/class_DebugMailer.php index 042ee69..14bdd41 100644 --- a/inc/classes/main/mailer/debug/class_DebugMailer.php +++ b/inc/classes/main/mailer/debug/class_DebugMailer.php @@ -101,7 +101,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { // Get the field from the value instance $fieldValue = $recipientList['values'][$variable]->getField($variable); - // Set it in the template engine + // Set it in template engine $templateInstance->assignVariable($variable, $fieldValue); } diff --git a/inc/classes/main/registration/class_BaseRegistration.php b/inc/classes/main/registration/class_BaseRegistration.php index 0cc0040..1ebf7e5 100644 --- a/inc/classes/main/registration/class_BaseRegistration.php +++ b/inc/classes/main/registration/class_BaseRegistration.php @@ -1,6 +1,6 @@ * @version 0.0.0 @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -abstract class BaseRegistration extends BaseFrameworkSystem implements UserRegister { +class BaseRegistration extends BaseFrameworkSystem { /** * Pre-registration filter chain */ diff --git a/inc/classes/main/registry/class_Registry.php b/inc/classes/main/registry/class_Registry.php index 2ca0382..9a8b648 100644 --- a/inc/classes/main/registry/class_Registry.php +++ b/inc/classes/main/registry/class_Registry.php @@ -86,8 +86,8 @@ class Registry extends BaseFrameworkSystem implements Register { /** * Checks wether an instance key was found * - * @param $instanceKey The key holding an instance in the registry - * @return $exists Wether the key exists in the registry + * @param $instanceKey The key holding an instance in registry + * @return $exists Wether the key exists in registry */ public function instanceExists ($instanceKey) { // Does this key exists? @@ -115,7 +115,7 @@ class Registry extends BaseFrameworkSystem implements Register { * @return $objectInstance An instance we shall store */ public function getInstance ($instanceKey) { - // By default the instance is not in the registry + // By default the instance is not in registry $objectInstance = null; // Is the instance there? diff --git a/inc/classes/main/request/class_HttpRequest.php b/inc/classes/main/request/class_HttpRequest.php index bd31476..0538512 100644 --- a/inc/classes/main/request/class_HttpRequest.php +++ b/inc/classes/main/request/class_HttpRequest.php @@ -83,17 +83,14 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable { */ public function isRequestElementSet ($element) { // Is this element found? - if (!isset($this->requestData[$element])) { - // Then return false - return false; - } // END - if + $isSet = isset($this->requestData[$element]); - // All clear - return true; + // Return result + return $isSet; } /** - * Getter for request element or 'null' if the element was not found + * Getter for request element or 'null' if element was not found * * @param $element Name of the request element we want to check * @return $value Value of the found request element or 'null' if the @@ -137,7 +134,7 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable { } /** - * Getter for a header element or 'null' if the header was not found + * Getter for a header element or 'null' if header was not found * * @param $headerName Name of the header * @return $headerValue Value of the header or 'null' if not found diff --git a/inc/classes/main/resolver/action/class_BaseActionResolver.php b/inc/classes/main/resolver/action/class_BaseActionResolver.php index 250fa01..7e462cc 100644 --- a/inc/classes/main/resolver/action/class_BaseActionResolver.php +++ b/inc/classes/main/resolver/action/class_BaseActionResolver.php @@ -77,7 +77,7 @@ class BaseActionResolver extends BaseResolver { * * @param $actionName The default action we shall execute * @return $isValid Wether the given action is valid - * @throws EmptyVariableException Thrown if the given action is not set + * @throws EmptyVariableException Thrown if given action is not set */ public function isActionValid ($actionName) { // By default nothing shall be valid diff --git a/inc/classes/main/resolver/action/web/class_WebActionResolver.php b/inc/classes/main/resolver/action/web/class_WebActionResolver.php index 4d86ee0..6276b11 100644 --- a/inc/classes/main/resolver/action/web/class_WebActionResolver.php +++ b/inc/classes/main/resolver/action/web/class_WebActionResolver.php @@ -46,8 +46,8 @@ class WebActionResolver extends BaseActionResolver implements ActionResolver { * @param $actionName The default action we shall execute * @param $appInstance An instance of a manageable application helper class * @return $resolverInstance The prepared action resolver instance - * @throws EmptyVariableException Thrown if the default action is not set - * @throws InvalidActionException Thrown if the default action is invalid + * @throws EmptyVariableException Thrown if default action is not set + * @throws InvalidActionException Thrown if default action is invalid */ public final static function createWebActionResolver ($actionName, ManageableApplication $appInstance) { // Create the new instance @@ -91,7 +91,7 @@ class WebActionResolver extends BaseActionResolver implements ActionResolver { // Is the action empty? Then fall back to default action if (empty($actionName)) $actionName = $this->getConfigInstance()->readConfig('default_action'); - // Check if the action is valid + // Check if action is valid if ($this->isActionValid($actionName) === false) { // This action is invalid! throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); @@ -129,7 +129,7 @@ class WebActionResolver extends BaseActionResolver implements ActionResolver { // Is the action empty? Then fall back to default action if (empty($actionName)) $actionName = $this->getConfigInstance()->readConfig('default_action'); - // Check if the action is valid + // Check if action is valid if ($this->isActionValid($actionName) === false) { // This action is invalid! throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); diff --git a/inc/classes/main/resolver/command/class_BaseCommandResolver.php b/inc/classes/main/resolver/command/class_BaseCommandResolver.php index d1fa003..465ee5c 100644 --- a/inc/classes/main/resolver/command/class_BaseCommandResolver.php +++ b/inc/classes/main/resolver/command/class_BaseCommandResolver.php @@ -101,7 +101,7 @@ class BaseCommandResolver extends BaseResolver { * * @param $commandName The default command we shall execute * @return $isValid Wether the given command is valid - * @throws EmptyVariableException Thrown if the given command is not set + * @throws EmptyVariableException Thrown if given command is not set */ public function isCommandValid ($commandName) { // By default nothing shall be valid diff --git a/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php b/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php index 4a74091..dc104e6 100644 --- a/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php +++ b/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php @@ -46,8 +46,8 @@ class ImageCommandResolver extends BaseCommandResolver implements CommandResolve * @param $commandName The default command we shall execute * @param $appInstance An instance of a manageable application helper class * @return $resolverInstance The prepared command resolver instance - * @throws EmptyVariableException Thrown if the default command is not set - * @throws InvalidCommandException Thrown if the default command is invalid + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidCommandException Thrown if default command is invalid */ public final static function createImageCommandResolver ($commandName, ManageableApplication $appInstance) { // Create the new instance @@ -91,7 +91,7 @@ class ImageCommandResolver extends BaseCommandResolver implements CommandResolve // Is the command empty? Then fall back to default command if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_image_command'); - // Check if the command is valid + // Check if command is valid if ($this->isCommandValid($commandName) === false) { // This command is invalid! throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); @@ -127,7 +127,7 @@ class ImageCommandResolver extends BaseCommandResolver implements CommandResolve // Is the command empty? Then fall back to default command if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_image_command'); - // Check if the command is valid + // Check if command is valid if ($this->isCommandValid($commandName) === false) { // This command is invalid! throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); diff --git a/inc/classes/main/resolver/command/web/class_ b/inc/classes/main/resolver/command/web/class_ new file mode 100644 index 0000000..4808086 --- /dev/null +++ b/inc/classes/main/resolver/command/web/class_ @@ -0,0 +1,178 @@ + + * @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 Web???CommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Last successfull resolved command + */ + private $lastCommandInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "Web" + $this->setCommandPrefix("Web"); + } + + /** + * Creates an instance of a Web command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if the default command is not set + * @throws InvalidCommandException Thrown if the default command is invalid + */ + public final static function createWeb???CommandResolver ($commandName, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new Web???CommandResolver(); + + // Is the variable $commandName set and the command is valid? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isCommandValid($commandName) === false) { + // Invalid command found + throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an command instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $commandInstance An instance of the resolved command + * @throws InvalidCommandException Thrown if $commandName is + * invalid + * @throws InvalidCommandInstanceException Thrown if $commandInstance + * is an invalid instance + */ + public function resolveCommandByRequest (Requestable $requestInstance) { + // Init variables + $commandName = ""; + $commandInstance = null; + + // This goes fine so let's resolv the command + $commandName = $requestInstance->getRequestElement('page'); + + // Is the command empty? Then fall back to default command + if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command'); + + // Check if the command is valid + if ($this->isCommandValid($commandName) === false) { + // This command is invalid! + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Get the command + $commandInstance = $this->loadCommand($commandName); + + // And validate it + if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) { + // This command has an invalid instance! + throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Set last command + $this->lastCommandInstance = $commandInstance; + + // Return the resolved command instance + return $commandInstance; + } + + /** + * Resolves the command by its direct name and returns an instance of its class + * + * @param $commandName The direct command name we shall resolve + * @return $commandInstance An instance of the command class + * @throws InvalidCommandException Thrown if $commandName is invalid + */ + public function resolveCommand ($commandName) { + // Initiate the instance variable + $commandInstance = null; + + // Is the command empty? Then fall back to default command + if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command'); + + // Check if the command is valid + if ($this->isCommandValid($commandName) === false) { + // This command is invalid! + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Get the command + $commandInstance = $this->loadCommand($commandName); + + // Return the instance + return $commandInstance; + } + + /** + * "Loads" a given command and instances it if not yet cached + * + * @param $commandName A command name we shall look for + * @return $commandInstance A loaded command instance + * @throws InvalidCommandException Thrown if even the default + * command class is missing (bad!) + */ + private function loadCommand ($commandName) { + // Cache default command + $defaultCommand = $this->getConfigInstance()->readConfig('default_web_command'); + + // Init command instance + $commandInstance = null; + + // Create command class name + $this->setClassName(sprintf("Web%sCommand", + $this->convertToClassName($commandName) + )); + + // Is this class loaded? + if (!class_exists($this->getClassName())) { + // Class not found, so throw an exception + throw new InvalidCommandException(array($this, $defaultCommand), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Initiate the command + $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this)); + + // Return the result + return $commandInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/resolver/command/web/class_WebCommandResolver.php b/inc/classes/main/resolver/command/web/class_WebCommandResolver.php index ba80974..42ae37a 100644 --- a/inc/classes/main/resolver/command/web/class_WebCommandResolver.php +++ b/inc/classes/main/resolver/command/web/class_WebCommandResolver.php @@ -46,8 +46,8 @@ class WebCommandResolver extends BaseCommandResolver implements CommandResolver * @param $commandName The default command we shall execute * @param $appInstance An instance of a manageable application helper class * @return $resolverInstance The prepared command resolver instance - * @throws EmptyVariableException Thrown if the default command is not set - * @throws InvalidCommandException Thrown if the default command is invalid + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidCommandException Thrown if default command is invalid */ public final static function createWebCommandResolver ($commandName, ManageableApplication $appInstance) { // Create the new instance @@ -91,7 +91,7 @@ class WebCommandResolver extends BaseCommandResolver implements CommandResolver // Is the command empty? Then fall back to default command if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command'); - // Check if the command is valid + // Check if command is valid if ($this->isCommandValid($commandName) === false) { // This command is invalid! throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); @@ -127,7 +127,7 @@ class WebCommandResolver extends BaseCommandResolver implements CommandResolver // Is the command empty? Then fall back to default command if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command'); - // Check if the command is valid + // Check if command is valid if ($this->isCommandValid($commandName) === false) { // This command is invalid! throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); diff --git a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php index 21694a8..a667fe6 100644 --- a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php +++ b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php @@ -77,8 +77,8 @@ class BaseControllerResolver extends BaseResolver { * * @param $controllerName The default controller we shall execute * @return $isValid Wether the given controller is valid - * @throws EmptyVariableException Thrown if the given controller is not set - * @throws DefaultControllerException If the default controller was not found + * @throws EmptyVariableException Thrown if given controller is not set + * @throws DefaultControllerException Thrown if default controller was not found */ public function isControllerValid ($controllerName) { // By default nothing shall be valid diff --git a/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php b/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php index 1000543..39d88d1 100644 --- a/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php +++ b/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php @@ -51,8 +51,8 @@ class ImageControllerResolver extends BaseControllerResolver implements Controll * @param $controllerName The controller we shall resolve * @param $appInstance An instance of a manageable application helper class * @return $resolverInstance The prepared controller resolver instance - * @throws EmptyVariableException Thrown if the default command is not set - * @throws InvalidControllerException Thrown if the default controller is invalid + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidControllerException Thrown if default controller is invalid */ public final static function createImageControllerResolver ($controllerName, ManageableApplication $appInstance) { // Create the new instance diff --git a/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php index 2293393..5378006 100644 --- a/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php +++ b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php @@ -51,8 +51,8 @@ class WebControllerResolver extends BaseControllerResolver implements Controller * @param $controllerName The controller we shall resolve * @param $appInstance An instance of a manageable application helper class * @return $resolverInstance The prepared controller resolver instance - * @throws EmptyVariableException Thrown if the default command is not set - * @throws InvalidControllerException Thrown if the default controller is invalid + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidControllerException Thrown if default controller is invalid */ public final static function createWebControllerResolver ($controllerName, ManageableApplication $appInstance) { // Create the new instance @@ -151,11 +151,26 @@ class WebControllerResolver extends BaseControllerResolver implements Controller throw new InvalidControllerException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); } // END - if + // Set default resolver config name + $resolverConfigEntry = ""; + + // Try to read a config entry for our resolver including controller name... ;-) + try { + // Create the resolver name + $resolverConfigEntry = sprintf("web_cmd_%s_resolver_class", strtolower($controllerName)); + + // Get the config, this will throw an exception if there is no special command resolver + $resolverClass = $this->getConfigInstance()->readConfig($resolverConfigEntry); + } catch (ConfigEntryNotFoundException $e) { + // Use default resolver entry + $resolverConfigEntry = "web_cmd_resolver_class"; + } + // Initiate the resolver and controller - $resolverInstance = ObjectFactory::createObjectByConfiguredName('web_cmd_resolver_class', array($controllerName, $this->getApplicationInstance())); + $resolverInstance = ObjectFactory::createObjectByConfiguredName($resolverConfigEntry, array($controllerName, $this->getApplicationInstance())); $controllerInstance = ObjectFactory::createObjectByName($this->getClassName(), array($resolverInstance)); - // Remove resolver + // Remove resolver (we don't need it anymore) unset($resolverInstance); // Return the result diff --git a/inc/classes/main/result/class_DatabaseResult.php b/inc/classes/main/result/class_DatabaseResult.php index 603f8cb..94fe3b5 100644 --- a/inc/classes/main/result/class_DatabaseResult.php +++ b/inc/classes/main/result/class_DatabaseResult.php @@ -119,7 +119,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up /** * "Iterator" method next() to advance to the next valid entry. This method - * does also check if the result is invalid + * does also check if result is invalid * * @return $nextValid Wether the next entry is valid */ @@ -223,7 +223,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up } /** - * Searches for an entry in the data result and returns it + * Searches for an entry in data result and returns it * * @param $criteriaInstance The criteria to look inside the data set * @return $result Found result entry diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php index 2bbec44..8690db6 100644 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -1172,7 +1172,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return void */ public function transferToResponse (Responseable $responseInstance) { - // Get the content and set it in the response class + // Get the content and set it in response class $responseInstance->writeToBody($this->getCompiledData()); } diff --git a/inc/classes/main/user/class_BaseUser.php b/inc/classes/main/user/class_BaseUser.php index 0e3dba9..b00a073 100644 --- a/inc/classes/main/user/class_BaseUser.php +++ b/inc/classes/main/user/class_BaseUser.php @@ -213,8 +213,8 @@ class BaseUser extends BaseFrameworkSystem { } /** - * Checks if the supplied password hash in request matches with the stored - * in database. + * Checks if supplied password hash in request matches with the stored in + * database. * * @param $requestInstance A requestable class instance * @return $matches Wether the supplied password hash matches diff --git a/inc/classes/main/user/guest/class_Guest.php b/inc/classes/main/user/guest/class_Guest.php index 3f45a4f..2362921 100644 --- a/inc/classes/main/user/guest/class_Guest.php +++ b/inc/classes/main/user/guest/class_Guest.php @@ -39,8 +39,8 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { /** * Creates an instance of this user class by a provided username. This - * factory method will check if the username is already taken and if not - * so it will throw an exception. + * factory method will check if username is already taken and if not so it + * will throw an exception. * * @param $userName Username we need a class instance for * @return $userInstance An instance of this user class @@ -53,7 +53,7 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { // Set the username $userInstance->setUserName($userName); - // Check if the username exists + // Check if username exists if ($userInstance->ifUsernameExists() === false) { // Throw an exception here throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); @@ -65,7 +65,7 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { /** * Creates an instance of this user class by a provided email address. This - * factory method will not check if the email address is there. + * factory method will not check if email address is there. * * @param $email Email address of the user * @return $userInstance An instance of this user class diff --git a/inc/classes/main/user/member/class_Member.php b/inc/classes/main/user/member/class_Member.php index 6c84ec9..b67ad88 100644 --- a/inc/classes/main/user/member/class_Member.php +++ b/inc/classes/main/user/member/class_Member.php @@ -47,8 +47,8 @@ class Member extends BaseUser implements ManageableMember, Registerable, Updatea /** * Creates an instance of this user class by a provided username. This - * factory method will check if the username is already taken and if not - * so it will throw an exception. + * factory method will check if username is already taken and if not so it + * will throw an exception. * * @param $userName Username we need a class instance for * @return $userInstance An instance of this user class @@ -61,7 +61,7 @@ class Member extends BaseUser implements ManageableMember, Registerable, Updatea // Set the username $userInstance->setUserName($userName); - // Check if the username exists + // Check if username exists if ($userInstance->ifUsernameExists() === false) { // Throw an exception here throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); @@ -73,7 +73,7 @@ class Member extends BaseUser implements ManageableMember, Registerable, Updatea /** * Creates an instance of this user class by a provided email address. This - * factory method will not check if the email address is there. + * factory method will not check if email address is there. * * @param $email Email address of the user * @return $userInstance An instance of this user class diff --git a/inc/config/class_FrameworkConfiguration.php b/inc/config/class_FrameworkConfiguration.php index 2261c0f..e320260 100644 --- a/inc/config/class_FrameworkConfiguration.php +++ b/inc/config/class_FrameworkConfiguration.php @@ -2,8 +2,8 @@ /** * A class for the configuration stuff implemented in a singleton design paddern * - * NOTE: We cannot put this in inc/classes/ because it would be loaded (again) - * in the class loader. See inc/loader/class_ClassLoader.php for instance + * NOTE: We cannot put this in inc/classes/ because it would be loaded (again) in + * class loader. See inc/loader/class_ClassLoader.php for instance * * @see ClassLoader * @author Roland Haeder