From 838cbd34450e0b29c5b749d86a526871dac461ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 30 May 2008 21:29:07 +0000 Subject: [PATCH] More class descriptions translated, generic user class added --- .gitattributes | 8 +- .../ship-simu/class_ApplicationHelper.php | 7 +- inc/classes/exceptions/user/.htaccess | 1 + .../user/class_UsernameMissingException.php | 46 ++++++++ inc/classes/interfaces/user/.htaccess | 1 + .../interfaces/user/class_ManageableUser.php | 28 +++++ .../commands/web/class_WebDoFormCommand.php | 2 +- .../commands/web/class_WebHomeCommand.php | 2 +- .../commands/web/class_WebRegisterCommand.php | 2 +- .../main/compressor/class_Bzip2Compressor.php | 2 +- .../main/compressor/class_GzipCompressor.php | 2 +- .../main/compressor/class_NullCompressor.php | 2 +- .../main/console/class_ConsoleTools.php | 2 +- .../default/class_WebDefaultController.php | 2 +- .../class_WebDefaultNewsController.php | 4 +- .../classes/class_LocalFileDatabase.php | 2 +- .../main/debug/class_DebugConsoleOutput.php | 2 +- .../main/debug/class_DebugErrorLogOutput.php | 2 +- .../main/debug/class_DebugWebOutput.php | 2 +- .../main/extended/class_ObjectLimits.php | 2 +- .../extended/class_SerializationContainer.php | 2 +- .../factories/objects/class_ObjectFactory.php | 2 +- ...wsFactory.php => class_WebNewsFactory.php} | 0 inc/classes/main/filter/class_FilterChain.php | 2 +- .../class_UserNameValidatorFilter.php | 37 +++++-- inc/classes/main/helper/class_BaseHelper.php | 3 - .../main/helper/web/class_WebFormHelper.php | 5 +- inc/classes/main/io/class_FileIoStream.php | 10 +- .../io/class_FrameworkDirectoryPointer.php | 2 +- .../io/class_FrameworkFileInputPointer.php | 2 +- .../io/class_FrameworkFileOutputPointer.php | 2 +- .../main/language/class_LanguageSystem.php | 4 +- .../main/output/class_ConsoleOutput.php | 2 +- inc/classes/main/output/class_WebOutput.php | 2 +- .../main/request/class_HttpRequest.php | 2 +- .../resolver/web/class_WebCommandResolver.php | 2 +- .../web/class_WebControllerResolver.php | 2 +- .../main/response/class_HttpResponse.php | 2 +- .../main/template/class_TemplateEngine.php | 2 +- inc/classes/main/user/.htaccess | 1 + inc/classes/main/user/class_User.php | 103 ++++++++++++++++++ inc/config.php | 13 ++- inc/database/lib-local.php | 12 +- 43 files changed, 272 insertions(+), 63 deletions(-) create mode 100644 inc/classes/exceptions/user/.htaccess create mode 100644 inc/classes/exceptions/user/class_UsernameMissingException.php create mode 100644 inc/classes/interfaces/user/.htaccess create mode 100644 inc/classes/interfaces/user/class_ManageableUser.php rename inc/classes/main/factories/web/{class_NewsFactory.php => class_WebNewsFactory.php} (100%) create mode 100644 inc/classes/main/user/.htaccess create mode 100644 inc/classes/main/user/class_User.php diff --git a/.gitattributes b/.gitattributes index 62c4a88..4078b21 100644 --- a/.gitattributes +++ b/.gitattributes @@ -210,6 +210,8 @@ inc/classes/exceptions/template/class_InvalidTemplateVariableNameException.php - inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php -text inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php -text inc/classes/exceptions/template/class_ViewHelperNotFoundException.php -text +inc/classes/exceptions/user/.htaccess -text +inc/classes/exceptions/user/class_UsernameMissingException.php -text inc/classes/interfaces/.htaccess -text inc/classes/interfaces/application/.htaccess -text inc/classes/interfaces/application/class_ManageableApplication.php -text @@ -252,6 +254,8 @@ inc/classes/interfaces/response/class_Responseable.php -text inc/classes/interfaces/template/.htaccess -text inc/classes/interfaces/template/class_CompileableTemplate.php -text inc/classes/interfaces/template/view/class_ViewHelper.php -text +inc/classes/interfaces/user/.htaccess -text +inc/classes/interfaces/user/class_ManageableUser.php -text inc/classes/main/.htaccess -text inc/classes/main/class_ -text inc/classes/main/class_BaseFrameworkSystem.php -text @@ -293,7 +297,7 @@ inc/classes/main/factories/class_BaseFactory.php -text inc/classes/main/factories/objects/.htaccess -text inc/classes/main/factories/objects/class_ObjectFactory.php -text inc/classes/main/factories/web/.htaccess -text -inc/classes/main/factories/web/class_NewsFactory.php -text +inc/classes/main/factories/web/class_WebNewsFactory.php -text inc/classes/main/filter/.htaccess -text inc/classes/main/filter/class_ -text inc/classes/main/filter/class_AbstractFilterDecorator.php -text @@ -326,6 +330,8 @@ inc/classes/main/response/.htaccess -text inc/classes/main/response/class_HttpResponse.php -text inc/classes/main/template/.htaccess -text inc/classes/main/template/class_TemplateEngine.php -text +inc/classes/main/user/.htaccess -text +inc/classes/main/user/class_User.php -text inc/classes/middleware/.htaccess -text inc/classes/middleware/class_BaseMiddleware.php -text inc/classes/middleware/compressor/.htaccess -text diff --git a/application/ship-simu/class_ApplicationHelper.php b/application/ship-simu/class_ApplicationHelper.php index 407b588..b925ebd 100644 --- a/application/ship-simu/class_ApplicationHelper.php +++ b/application/ship-simu/class_ApplicationHelper.php @@ -201,7 +201,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica // Get a resolver $resolverInstance = WebControllerResolver::createWebControllerResolver($commandName, $this); - // Get a new controller instance as well + // Get a controller instance as well $this->controllerInstance = $resolverInstance->resolveCommandController(); // Handle the request @@ -216,7 +216,10 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica * @return void */ public function handleFatalMessages (array $messageList) { - die("
".print_r($messageList, true)."
"); + // Walk through all messages + foreach ($messageList as $message) { + die("MSG:".$message); + } } } diff --git a/inc/classes/exceptions/user/.htaccess b/inc/classes/exceptions/user/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/exceptions/user/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/user/class_UsernameMissingException.php b/inc/classes/exceptions/user/class_UsernameMissingException.php new file mode 100644 index 0000000..8016cf3 --- /dev/null +++ b/inc/classes/exceptions/user/class_UsernameMissingException.php @@ -0,0 +1,46 @@ + + * @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 UsernameMissingException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray The non-optional message for the exception + * @param $code An optional code for better debugging + * @return void + */ + public function __construct(array $msgArray, $code = 0) { + // Create the message + $message = sprintf("[%s:%d] Username %s was not found.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Make sure everything is assigned properly + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/user/.htaccess b/inc/classes/interfaces/user/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/interfaces/user/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/user/class_ManageableUser.php b/inc/classes/interfaces/user/class_ManageableUser.php new file mode 100644 index 0000000..eef4ef8 --- /dev/null +++ b/inc/classes/interfaces/user/class_ManageableUser.php @@ -0,0 +1,28 @@ + + * @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 . + */ +interface ManageableUser extends FrameworkInterface { +} + +// +?> diff --git a/inc/classes/main/commands/web/class_WebDoFormCommand.php b/inc/classes/main/commands/web/class_WebDoFormCommand.php index 559c4bc..e4c2300 100644 --- a/inc/classes/main/commands/web/class_WebDoFormCommand.php +++ b/inc/classes/main/commands/web/class_WebDoFormCommand.php @@ -32,7 +32,7 @@ class WebDoFormCommand extends BaseCommand implements Commandable { parent::__construct(__CLASS__); // Set special description - $this->setObjectDescription("DoForm-Command"); + $this->setObjectDescription("Command for handling forms on a centralized place"); // Create unique ID number $this->createUniqueID(); diff --git a/inc/classes/main/commands/web/class_WebHomeCommand.php b/inc/classes/main/commands/web/class_WebHomeCommand.php index a0f9560..0b7e9c4 100644 --- a/inc/classes/main/commands/web/class_WebHomeCommand.php +++ b/inc/classes/main/commands/web/class_WebHomeCommand.php @@ -32,7 +32,7 @@ class WebHomeCommand extends BaseCommand implements Commandable { parent::__construct(__CLASS__); // Set special description - $this->setObjectDescription("Home-Command"); + $this->setObjectDescription("Command for the "home" page"); // Create unique ID number $this->createUniqueID(); diff --git a/inc/classes/main/commands/web/class_WebRegisterCommand.php b/inc/classes/main/commands/web/class_WebRegisterCommand.php index 8ed4a44..af1d748 100644 --- a/inc/classes/main/commands/web/class_WebRegisterCommand.php +++ b/inc/classes/main/commands/web/class_WebRegisterCommand.php @@ -32,7 +32,7 @@ class WebRegisterCommand extends BaseCommand implements Commandable { parent::__construct(__CLASS__); // Set special description - $this->setObjectDescription("Anmeldeformular-Command"); + $this->setObjectDescription("Command for the registration form"); // Create unique ID number $this->createUniqueID(); diff --git a/inc/classes/main/compressor/class_Bzip2Compressor.php b/inc/classes/main/compressor/class_Bzip2Compressor.php index 88322b6..24566b9 100644 --- a/inc/classes/main/compressor/class_Bzip2Compressor.php +++ b/inc/classes/main/compressor/class_Bzip2Compressor.php @@ -32,7 +32,7 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { parent::__construct(__CLASS__); // Set description - $this->setObjectDescription("BZIP2-Kompressor"); + $this->setObjectDescription("BZIP2 compressor"); // Create an unique ID $this->createUniqueID(); diff --git a/inc/classes/main/compressor/class_GzipCompressor.php b/inc/classes/main/compressor/class_GzipCompressor.php index 4e95f80..08b1a6d 100644 --- a/inc/classes/main/compressor/class_GzipCompressor.php +++ b/inc/classes/main/compressor/class_GzipCompressor.php @@ -32,7 +32,7 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { parent::__construct(__CLASS__); // Set description - $this->setObjectDescription("GZIP-Kompressor"); + $this->setObjectDescription("GZIP compressor"); // Create an unique ID $this->createUniqueID(); diff --git a/inc/classes/main/compressor/class_NullCompressor.php b/inc/classes/main/compressor/class_NullCompressor.php index a8a570c..157dc1a 100644 --- a/inc/classes/main/compressor/class_NullCompressor.php +++ b/inc/classes/main/compressor/class_NullCompressor.php @@ -32,7 +32,7 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor { parent::__construct(__CLASS__); // Set description - $this->setObjectDescription("Null-Kompressor"); + $this->setObjectDescription("Null compressor"); // Create an unique ID $this->createUniqueID(); diff --git a/inc/classes/main/console/class_ConsoleTools.php b/inc/classes/main/console/class_ConsoleTools.php index 78dc94c..054c8c7 100644 --- a/inc/classes/main/console/class_ConsoleTools.php +++ b/inc/classes/main/console/class_ConsoleTools.php @@ -32,7 +32,7 @@ class ConsoleTools extends BaseFrameworkSystem { parent::__construct(__CLASS__); // Set description - $this->setObjectDescription("Console-Tools"); + $this->setObjectDescription("General console tools"); // Create an unique ID $this->createUniqueID(); diff --git a/inc/classes/main/controller/default/class_WebDefaultController.php b/inc/classes/main/controller/default/class_WebDefaultController.php index 6b2b89d..9d60e61 100644 --- a/inc/classes/main/controller/default/class_WebDefaultController.php +++ b/inc/classes/main/controller/default/class_WebDefaultController.php @@ -32,7 +32,7 @@ class WebWebDefaultController extends BaseController implements Controller { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("Standart-Controller für alle übrigen Anfragen"); + $this->setObjectDescription("Default controller for all other requests"); // Create unique ID number $this->createUniqueID(); diff --git a/inc/classes/main/controller/default/class_WebDefaultNewsController.php b/inc/classes/main/controller/default/class_WebDefaultNewsController.php index 8781206..b8bbc05 100644 --- a/inc/classes/main/controller/default/class_WebDefaultNewsController.php +++ b/inc/classes/main/controller/default/class_WebDefaultNewsController.php @@ -32,7 +32,7 @@ class WebDefaultNewsController extends BaseController implements Controller { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("Standart-Controller mit News-Auflistung"); + $this->setObjectDescription("Default controller with news"); // Create unique ID number $this->createUniqueID(); @@ -87,7 +87,7 @@ class WebDefaultNewsController extends BaseController implements Controller { */ private function loadNewsByRequest (Requestable $requestInstance) { // Generate a new news object but not carring about which concrete we have - $newsInstance = NewsFactory::createFactoryByRequest($requestInstance)->createNewsObject(); + $newsInstance = WebNewsFactory::createFactoryByRequest($requestInstance)->createNewsObject(); } } diff --git a/inc/classes/main/database/classes/class_LocalFileDatabase.php b/inc/classes/main/database/classes/class_LocalFileDatabase.php index b23dbc5..dbe55ac 100644 --- a/inc/classes/main/database/classes/class_LocalFileDatabase.php +++ b/inc/classes/main/database/classes/class_LocalFileDatabase.php @@ -55,7 +55,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend parent::__construct(__CLASS__); // Set description - $this->setObjectDescription("Dateidatenbankschicht"); + $this->setObjectDescription("Class for local file databases"); // Create unique ID $this->createUniqueID(); diff --git a/inc/classes/main/debug/class_DebugConsoleOutput.php b/inc/classes/main/debug/class_DebugConsoleOutput.php index dfcfd36..e9be4a5 100644 --- a/inc/classes/main/debug/class_DebugConsoleOutput.php +++ b/inc/classes/main/debug/class_DebugConsoleOutput.php @@ -32,7 +32,7 @@ class DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, Output parent::__construct(__CLASS__); // Set description - $this->setObjectDescription("Debug-Ausgabe auf Konsole"); + $this->setObjectDescription("Debug output for the console"); // Create an unique ID $this->createUniqueID(); diff --git a/inc/classes/main/debug/class_DebugErrorLogOutput.php b/inc/classes/main/debug/class_DebugErrorLogOutput.php index 26b099d..1a1723f 100644 --- a/inc/classes/main/debug/class_DebugErrorLogOutput.php +++ b/inc/classes/main/debug/class_DebugErrorLogOutput.php @@ -32,7 +32,7 @@ class DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, Outpu parent::__construct(__CLASS__); // Set description - $this->setObjectDescription("Debug-Ausgabe in error_log()"); + $this->setObjectDescription("Debug output to error_log()"); // Create an unique ID $this->createUniqueID(); diff --git a/inc/classes/main/debug/class_DebugWebOutput.php b/inc/classes/main/debug/class_DebugWebOutput.php index 17faa19..0c763e0 100644 --- a/inc/classes/main/debug/class_DebugWebOutput.php +++ b/inc/classes/main/debug/class_DebugWebOutput.php @@ -32,7 +32,7 @@ class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStre parent::__construct(__CLASS__); // Set description - $this->setObjectDescription("Debug-Ausgabe auf Konsole"); + $this->setObjectDescription("Debug output for webpages"); // Create an unique ID $this->createUniqueID(); diff --git a/inc/classes/main/extended/class_ObjectLimits.php b/inc/classes/main/extended/class_ObjectLimits.php index 75925c6..3c23f80 100644 --- a/inc/classes/main/extended/class_ObjectLimits.php +++ b/inc/classes/main/extended/class_ObjectLimits.php @@ -39,7 +39,7 @@ class ObjectLimits extends BaseFrameworkSystem { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("Limitierungsobjekt"); + $this->setObjectDescription("Class for "limiting" other classes. See description for details."); // Create unique ID number $this->createUniqueID(); diff --git a/inc/classes/main/extended/class_SerializationContainer.php b/inc/classes/main/extended/class_SerializationContainer.php index a0980e3..7924d4c 100644 --- a/inc/classes/main/extended/class_SerializationContainer.php +++ b/inc/classes/main/extended/class_SerializationContainer.php @@ -44,7 +44,7 @@ class SerializationContainer extends FrameworkArrayObject { * @return $containerInstance An instance of SerializationContainer * @throws GetterNotFoundException If a getter was not found */ - public final static function createSerializationContainer (ObjectLimits $limitInstance, $object) { + public final static function createSerializationContainer (ObjectLimits $limitInstance, FrameworkInterface $object) { // Get an instance $containerInstance = new SerializationContainer(); diff --git a/inc/classes/main/factories/objects/class_ObjectFactory.php b/inc/classes/main/factories/objects/class_ObjectFactory.php index fd983ca..5dda5fb 100644 --- a/inc/classes/main/factories/objects/class_ObjectFactory.php +++ b/inc/classes/main/factories/objects/class_ObjectFactory.php @@ -33,7 +33,7 @@ class ObjectFactory extends BaseFactory { parent::__construct(__CLASS__); // Set object description - $this->setObjectDescription("Objekte-Fabrik"); + $this->setObjectDescription("Simple generic object factory"); } /** diff --git a/inc/classes/main/factories/web/class_NewsFactory.php b/inc/classes/main/factories/web/class_WebNewsFactory.php similarity index 100% rename from inc/classes/main/factories/web/class_NewsFactory.php rename to inc/classes/main/factories/web/class_WebNewsFactory.php diff --git a/inc/classes/main/filter/class_FilterChain.php b/inc/classes/main/filter/class_FilterChain.php index 95450e7..cf2ff3b 100644 --- a/inc/classes/main/filter/class_FilterChain.php +++ b/inc/classes/main/filter/class_FilterChain.php @@ -37,7 +37,7 @@ class FilterChain extends BaseFrameworkSystem { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription(""); + $this->setObjectDescription("A filter chain class"); // Create unique ID number $this->createUniqueID(); diff --git a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php index 6f18e6b..1c7c54a 100644 --- a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php @@ -88,16 +88,7 @@ class UserNameValidatorFilter extends BaseFrameworkSystem implements Filterable // Abort here return false; - } elseif (!$this->ifUserNameIsValid($userName)) { - // Regular expression check failed! - $requestInstance->requestIsValid(false); - - // Set a message for the response - $responseInstance->addFatalMessage('username_invalid'); - - // Abort here - return false; - } elseif (!$this->ifUserNameIsTaken($userName)) { + } elseif ($this->ifUserNameIsTaken($userName)) { // Username is already taken $requestInstance->requestIsValid(false); @@ -108,6 +99,32 @@ class UserNameValidatorFilter extends BaseFrameworkSystem implements Filterable return false; } } + + /** + * Check wether the username as already been taken + * + * @param $userName Username to check for existence + * @return $alreadyTaken Wether the username has been taken + */ + private function ifUserNameIsTaken ($userName) { + // Default is already taken + $alreadyTaken = true; + + // Try to create a user instance + try { + // If this instance is created then the username *does* exist + $userInstance = User::createUserByUsername($userName); + } catch (UsernameMissingException $e) { + // Okay, this user is missing! + $alreadyTaken = false; + } catch (FrameworkException $e) { + // Something bad happend + ApplicationEntryPoint::app_die(sprintf("Exception: %s", $e->__toString())); + } + + // Return the result + return $alreadyTaken; + } } // [EOF] diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php index 11d636c..02a99e3 100644 --- a/inc/classes/main/helper/class_BaseHelper.php +++ b/inc/classes/main/helper/class_BaseHelper.php @@ -42,9 +42,6 @@ class BaseHelper extends BaseFrameworkSystem { // Call parent constructor parent::__construct($className); - // Create unique ID number - $this->createUniqueID(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); diff --git a/inc/classes/main/helper/web/class_WebFormHelper.php b/inc/classes/main/helper/web/class_WebFormHelper.php index fc14638..00b7c0b 100644 --- a/inc/classes/main/helper/web/class_WebFormHelper.php +++ b/inc/classes/main/helper/web/class_WebFormHelper.php @@ -64,7 +64,10 @@ class WebFormHelper extends BaseHelper { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("HTML-Formularhilfsklasse"); + $this->setObjectDescription("Helper class for HTML forms"); + + // Create unique ID number + $this->createUniqueID(); } /** diff --git a/inc/classes/main/io/class_FileIoStream.php b/inc/classes/main/io/class_FileIoStream.php index c983346..ee02a8d 100644 --- a/inc/classes/main/io/class_FileIoStream.php +++ b/inc/classes/main/io/class_FileIoStream.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class FileIOStream extends BaseFrameworkSystem implements FileInputStreamer, FileOutputStreamer { +class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, FileOutputStreamer { /** * Protected constructor */ @@ -30,7 +30,7 @@ class FileIOStream extends BaseFrameworkSystem implements FileInputStreamer, Fil parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("Universal Datei-Ein-/Ausgabesystem"); + $this->setObjectDescription("Universal file I/O stream system"); // Create unique ID $this->createUniqueID(); @@ -44,11 +44,11 @@ class FileIOStream extends BaseFrameworkSystem implements FileInputStreamer, Fil * Create a file IO stream. This is a class for performing all actions * on files like creating, deleting and loading them. * - * @return $ioInstance An instance of FileIOStream + * @return $ioInstance An instance of FileIoStream */ - public final static function createFileIOStream () { + public final static function createFileIoStream () { // Create new instance - $ioInstance = new FileIOStream(); + $ioInstance = new FileIoStream(); // Return the instance return $ioInstance; diff --git a/inc/classes/main/io/class_FrameworkDirectoryPointer.php b/inc/classes/main/io/class_FrameworkDirectoryPointer.php index 5ad52ed..f05bfc0 100644 --- a/inc/classes/main/io/class_FrameworkDirectoryPointer.php +++ b/inc/classes/main/io/class_FrameworkDirectoryPointer.php @@ -40,7 +40,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("Verzeichnis-Handler"); + $this->setObjectDescription("Helper for handling directories"); // Create unique ID $this->createUniqueID(); diff --git a/inc/classes/main/io/class_FrameworkFileInputPointer.php b/inc/classes/main/io/class_FrameworkFileInputPointer.php index a38b0a3..b93c002 100644 --- a/inc/classes/main/io/class_FrameworkFileInputPointer.php +++ b/inc/classes/main/io/class_FrameworkFileInputPointer.php @@ -40,7 +40,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("Dateiausgabe-Handler"); + $this->setObjectDescription("Handler for reading from files"); // Create unique ID $this->createUniqueID(); diff --git a/inc/classes/main/io/class_FrameworkFileOutputPointer.php b/inc/classes/main/io/class_FrameworkFileOutputPointer.php index 8cc07ca..350cd72 100644 --- a/inc/classes/main/io/class_FrameworkFileOutputPointer.php +++ b/inc/classes/main/io/class_FrameworkFileOutputPointer.php @@ -40,7 +40,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("Dateiausgabe-Handler"); + $this->setObjectDescription("Handler for writing to files"); // Create unique ID $this->createUniqueID(); diff --git a/inc/classes/main/language/class_LanguageSystem.php b/inc/classes/main/language/class_LanguageSystem.php index 6a830b4..7376367 100644 --- a/inc/classes/main/language/class_LanguageSystem.php +++ b/inc/classes/main/language/class_LanguageSystem.php @@ -53,7 +53,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("Sprachsystem"); + $this->setObjectDescription("Language sub-system"); // Create unique ID number $this->createUniqueID(); @@ -66,7 +66,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage { /** * Creates an instance of the class LanguageSystem and prepares it for usage * - * @param $basePath The local base path for all language strings + * @param $basePath The local base path for all language strings * @return $langInstance An instance of LanguageSystem * @throws LanguagePathIsEmptyException If the provided $basePath is empty * @throws InvalidLanguagePathStringException If $basePath is no string diff --git a/inc/classes/main/output/class_ConsoleOutput.php b/inc/classes/main/output/class_ConsoleOutput.php index c421ec4..7eeb854 100644 --- a/inc/classes/main/output/class_ConsoleOutput.php +++ b/inc/classes/main/output/class_ConsoleOutput.php @@ -43,7 +43,7 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer { parent::__construct(__CLASS__); // Set description - $this->setObjectDescription("Console-Ausgabe-Handler"); + $this->setObjectDescription("Console output class"); // Create an unique ID $this->createUniqueID(); diff --git a/inc/classes/main/output/class_WebOutput.php b/inc/classes/main/output/class_WebOutput.php index a687cea..b1eecc9 100644 --- a/inc/classes/main/output/class_WebOutput.php +++ b/inc/classes/main/output/class_WebOutput.php @@ -38,7 +38,7 @@ class WebOutput extends BaseFrameworkSystem implements OutputStreamer { parent::__construct(__CLASS__); // Set description - $this->setObjectDescription("Web-Ausgabe-Handler"); + $this->setObjectDescription("Class for web output e.g. XHTML code"); // Create an unique ID $this->createUniqueID(); diff --git a/inc/classes/main/request/class_HttpRequest.php b/inc/classes/main/request/class_HttpRequest.php index aa337db..b95bab1 100644 --- a/inc/classes/main/request/class_HttpRequest.php +++ b/inc/classes/main/request/class_HttpRequest.php @@ -44,7 +44,7 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("HTTP-Anfrage"); + $this->setObjectDescription("HTTP request"); // Create unique ID number $this->createUniqueID(); diff --git a/inc/classes/main/resolver/web/class_WebCommandResolver.php b/inc/classes/main/resolver/web/class_WebCommandResolver.php index d1bc85e..47baef4 100644 --- a/inc/classes/main/resolver/web/class_WebCommandResolver.php +++ b/inc/classes/main/resolver/web/class_WebCommandResolver.php @@ -37,7 +37,7 @@ class WebCommandResolver extends BaseResolver implements CommandResolver { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("Lokaler Kommandoauflöser"); + $this->setObjectDescription("Resolver for local web commands"); // Create unique ID number $this->createUniqueID(); diff --git a/inc/classes/main/resolver/web/class_WebControllerResolver.php b/inc/classes/main/resolver/web/class_WebControllerResolver.php index fe03162..9e50d94 100644 --- a/inc/classes/main/resolver/web/class_WebControllerResolver.php +++ b/inc/classes/main/resolver/web/class_WebControllerResolver.php @@ -42,7 +42,7 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription(""); + $this->setObjectDescription("Resolver for local web controllers"); // Create unique ID number $this->createUniqueID(); diff --git a/inc/classes/main/response/class_HttpResponse.php b/inc/classes/main/response/class_HttpResponse.php index 39185e9..52ad2a7 100644 --- a/inc/classes/main/response/class_HttpResponse.php +++ b/inc/classes/main/response/class_HttpResponse.php @@ -60,7 +60,7 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("HTTP-Antwort"); + $this->setObjectDescription("HTTP response"); // Create unique ID number $this->createUniqueID(); diff --git a/inc/classes/main/template/class_TemplateEngine.php b/inc/classes/main/template/class_TemplateEngine.php index 79fa507..412d26a 100644 --- a/inc/classes/main/template/class_TemplateEngine.php +++ b/inc/classes/main/template/class_TemplateEngine.php @@ -123,7 +123,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate parent::__construct(__CLASS__); // Set part description - $this->setObjectDescription("Template-Engine"); + $this->setObjectDescription("Web template engine"); // Create unique ID number $this->createUniqueID(); diff --git a/inc/classes/main/user/.htaccess b/inc/classes/main/user/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/user/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/user/class_User.php b/inc/classes/main/user/class_User.php new file mode 100644 index 0000000..53e8b46 --- /dev/null +++ b/inc/classes/main/user/class_User.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 User extends BaseFrameworkSystem implements ManageableUser { + /** + * Username + */ + private $username = ""; + + // Exceptions + const EXCEPTION_USERNAME_NOT_FOUND = 0xd00; + + /** + * Private constructor + * + * @return void + */ + protected function __construct ($class = "") { + // Is the class name empty? Then this is not a specialized user class + if (empty($class)) $class = __CLASS__; + + // Call parent constructor + parent::__construct($class); + + // Set part description + $this->setObjectDescription("Generic user class"); + + // Create unique ID number + $this->createUniqueID(); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * 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. + * + * @param $username Username we need a class instance for + * @return $userInstance An instance of this user class + * @throws UsernameMissingException If the username does not exist + */ + public final static function createUserByUsername ($userName) { + // Get a new instance + $userInstance = new User(); + + // Set the username + $userInstance->setUsername($userName); + + // Check if the username exists + if (!$userInstance->ifUsernameExists()) { + // Throw an exception here + throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); + } + + // Return the instance + return $userInstance; + } + + /** + * Setter for username + * + * @param $userName The username to set + * @return void + */ + protected final function setUsername ($userName) { + $this->userNane = $userName; + } + + /** + * Getter for username + * + * @return $userName The username to set + */ + public final function getUsername () { + return $this->userNane; + } +} + +// [EOF] +?> diff --git a/inc/config.php b/inc/config.php index 4bf0ab3..d5622f3 100644 --- a/inc/config.php +++ b/inc/config.php @@ -36,6 +36,9 @@ $cfg->definePath(dirname(dirname(__FILE__)) . '/'); // DON'T MISS THE TRAILING S // CFG: DATABASE-TYPE $cfg->defineDatabaseType('local'); +// CFG: LOCAL-DB-PATH +$cfg->setConfigEntry('local_db_path', 'db/'); + // CFG: TIME-ZONE $cfg->setDefaultTimezone("Europe/Berlin"); @@ -60,11 +63,14 @@ $cfg->setConfigEntry('code_template_extension', ".ctp"); // CFG: SELECTOR-GET $cfg->setConfigEntry('app_selector_get', "app"); +// CFG: SELECTOR-PATH +$cfg->setConfigEntry('selector_path', "selector"); + // CFG: APPLICATION-HELPER $cfg->setConfigEntry('app_helper_class', "ApplicationHelper"); -// CFG: SELECTOR-PATH -$cfg->setConfigEntry('selector_path', "selector"); +// CFG: LAUNCH-METHOD +$cfg->setConfigEntry('entry_method', "entryPoint"); // CFG: TEMPLATE-BASE-PATH $cfg->setConfigEntry('tpl_base_path', "templates/"); // DON'T MISS THE TRAILING SLASH! @@ -123,9 +129,6 @@ $cfg->setConfigEntry('meta_keywords', "test,test,test"); // CFG: META-DESCRIPTION $cfg->setConfigEntry('meta_description', "A lame description for an application framework"); -// CFG: LAUNCH-METHOD -$cfg->setConfigEntry('entry_method', "entryPoint"); - // CFG: SELECTOR-MAIN-TEMPLATE $cfg->setConfigEntry('selector_main_tpl', "selector_main"); diff --git a/inc/database/lib-local.php b/inc/database/lib-local.php index 3430af5..95b0f89 100644 --- a/inc/database/lib-local.php +++ b/inc/database/lib-local.php @@ -24,25 +24,25 @@ // Zum Testen speichern wir in lokale Dateien (LocalFileDatabase) try { - $layer = LocalFileDatabase::createLocalFileDatabase(PATH . 'db/', FileIoHandler::getInstance()); + $layer = LocalFileDatabase::createLocalFileDatabase(PATH . FrameworkConfiguration::getInstance()->readConfig('local_db_path'), FileIoHandler::getInstance()); } catch (SavePathIsEmptyException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: %s
\n", + ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s
\n", $e->getMessage() )); } catch (SavePathNotFoundException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: %s
\n", + ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s
\n", $e->getMessage() )); } catch (SavePathIsNoDirectoryException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: %s
\n", + ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s
\n", $e->getMessage() )); } catch (SavePathReadProtectedException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: %s
\n", + ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s
\n", $e->getMessage() )); } catch (SavePathWriteProtectedException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: %s
\n", + ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s
\n", $e->getMessage() )); } -- 2.39.5