]> git.mxchange.org Git - hub.git/commitdiff
Code merge from latest ship-simu code
authorRoland Häder <roland@mxchange.org>
Sat, 31 May 2008 11:29:30 +0000 (11:29 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 31 May 2008 11:29:30 +0000 (11:29 +0000)
90 files changed:
.gitattributes
application/hub/class_ApplicationHelper.php
inc/classes/exceptions/helper/.htaccess [new file with mode: 0644]
inc/classes/exceptions/helper/class_FormClosedException.php [new file with mode: 0644]
inc/classes/exceptions/helper/class_FormGroupClosedException.php [new file with mode: 0644]
inc/classes/exceptions/helper/class_FormOpenedException.php [new file with mode: 0644]
inc/classes/exceptions/helper/class_InvalidFormNameException.php [new file with mode: 0644]
inc/classes/exceptions/io/class_DirPointerNotOpenedException.php
inc/classes/exceptions/io/class_FilePointerNotOpenedException.php
inc/classes/exceptions/template/class_InvalidTemplateVariableNameException.php
inc/classes/exceptions/user/.htaccess [new file with mode: 0644]
inc/classes/exceptions/user/class_UsernameMissingException.php [new file with mode: 0644]
inc/classes/interfaces/application/class_ManageableApplication.php
inc/classes/interfaces/commands/class_Commandable.php
inc/classes/interfaces/filter/.htaccess [new file with mode: 0644]
inc/classes/interfaces/filter/class_Filterable.php [new file with mode: 0644]
inc/classes/interfaces/request/class_Requestable.php
inc/classes/interfaces/resolver/class_ControllerResolver.php
inc/classes/interfaces/response/class_Responseable.php
inc/classes/interfaces/user/.htaccess [new file with mode: 0644]
inc/classes/interfaces/user/class_ManageableUser.php [new file with mode: 0644]
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/commands/class_ [new file with mode: 0644]
inc/classes/main/commands/web/class_WebDoFormCommand.php [new file with mode: 0644]
inc/classes/main/commands/web/class_WebHomeCommand.php
inc/classes/main/commands/web/class_WebRegisterCommand.php [new file with mode: 0644]
inc/classes/main/compressor/class_Bzip2Compressor.php
inc/classes/main/compressor/class_GzipCompressor.php
inc/classes/main/compressor/class_NullCompressor.php
inc/classes/main/console/class_ConsoleTools.php
inc/classes/main/controller/class_BaseController.php
inc/classes/main/controller/default/class_LocalDefaultController.php [deleted file]
inc/classes/main/controller/default/class_LocalDefaultNewsController.php [deleted file]
inc/classes/main/controller/default/class_WebDefaultController.php
inc/classes/main/controller/default/class_WebDefaultNewsController.php
inc/classes/main/controller/form/.htaccess [new file with mode: 0644]
inc/classes/main/controller/form/class_WebDoFormController.php [new file with mode: 0644]
inc/classes/main/database/classes/class_LocalFileDatabase.php
inc/classes/main/debug/class_DebugConsoleOutput.php
inc/classes/main/debug/class_DebugErrorLogOutput.php
inc/classes/main/debug/class_DebugWebOutput.php
inc/classes/main/extended/class_ObjectLimits.php
inc/classes/main/extended/class_SerializationContainer.php
inc/classes/main/factories/objects/class_ObjectFactory.php
inc/classes/main/factories/web/class_NewsFactory.php [deleted file]
inc/classes/main/factories/web/class_WebNewsFactory.php [new file with mode: 0644]
inc/classes/main/filter/.htaccess [new file with mode: 0644]
inc/classes/main/filter/class_ [new file with mode: 0644]
inc/classes/main/filter/class_AbstractFilterDecorator.php [new file with mode: 0644]
inc/classes/main/filter/class_FilterChain.php [new file with mode: 0644]
inc/classes/main/filter/validator/.htaccess [new file with mode: 0644]
inc/classes/main/filter/validator/class_UserNameValidatorFilter.php [new file with mode: 0644]
inc/classes/main/helper/.htaccess [new file with mode: 0644]
inc/classes/main/helper/class_ [new file with mode: 0644]
inc/classes/main/helper/class_BaseHelper.php [new file with mode: 0644]
inc/classes/main/helper/web/.htaccess [new file with mode: 0644]
inc/classes/main/helper/web/class_WebFormHelper.php [new file with mode: 0644]
inc/classes/main/io/class_FileIOStream.php [deleted file]
inc/classes/main/io/class_FileIoStream.php [new file with mode: 0644]
inc/classes/main/io/class_FrameworkDirectoryPointer.php
inc/classes/main/io/class_FrameworkFileInputPointer.php
inc/classes/main/io/class_FrameworkFileOutputPointer.php
inc/classes/main/language/class_LanguageSystem.php
inc/classes/main/output/class_ConsoleOutput.php
inc/classes/main/output/class_WebOutput.php
inc/classes/main/request/class_HttpRequest.php
inc/classes/main/resolver/class_BaseResolver.php
inc/classes/main/resolver/local/.htaccess [deleted file]
inc/classes/main/resolver/local/class_LocalCommandResolver.php [deleted file]
inc/classes/main/resolver/local/class_LocalControllerResolver.php [deleted file]
inc/classes/main/resolver/web/class_WebCommandResolver.php
inc/classes/main/resolver/web/class_WebControllerResolver.php
inc/classes/main/response/class_HttpResponse.php
inc/classes/main/template/class_TemplateEngine.php
inc/classes/main/user/.htaccess [new file with mode: 0644]
inc/classes/main/user/class_User.php [new file with mode: 0644]
inc/classes/middleware/compressor/class_CompressorChannel.php
inc/classes/middleware/io/class_FileIOHandler.php [deleted file]
inc/classes/middleware/io/class_FileIoHandler.php [new file with mode: 0644]
inc/config.php
inc/config/config-hubmaster.php
inc/database.php
inc/database/lib-local.php
inc/file_io.php
inc/includes.php
inc/language.php
inc/loader/class_ClassLoader.php
inc/output.php
inc/selector.php
index.php

index 073ef92f5c80c9a2650fc62ee0a2ed2ab364342b..8455a4b44e07a5c40eb3875b8f19f65199e0f48a 100644 (file)
@@ -71,6 +71,11 @@ inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php -t
 inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php -text
 inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php -text
 inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php -text
+inc/classes/exceptions/helper/.htaccess -text
+inc/classes/exceptions/helper/class_FormClosedException.php -text
+inc/classes/exceptions/helper/class_FormGroupClosedException.php -text
+inc/classes/exceptions/helper/class_FormOpenedException.php -text
+inc/classes/exceptions/helper/class_InvalidFormNameException.php -text
 inc/classes/exceptions/io/.htaccess -text
 inc/classes/exceptions/io/class_DirPointerNotOpenedException.php -text
 inc/classes/exceptions/io/class_FilePointerNotOpenedException.php -text
@@ -120,6 +125,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
@@ -141,6 +148,8 @@ inc/classes/interfaces/debug/.htaccess -text
 inc/classes/interfaces/debug/class_Debugger.php -text
 inc/classes/interfaces/extended/.htaccess -text
 inc/classes/interfaces/extended/class_LimitableObject.php -text
+inc/classes/interfaces/filter/.htaccess -text
+inc/classes/interfaces/filter/class_Filterable.php -text
 inc/classes/interfaces/io/.htaccess -text
 inc/classes/interfaces/io/class_Streamable.php -text
 inc/classes/interfaces/io/file/.htaccess -text
@@ -160,16 +169,21 @@ 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
 inc/classes/main/class_FrameworkArrayObject.php -text
 inc/classes/main/commands/.htaccess -text
+inc/classes/main/commands/class_ -text
 inc/classes/main/commands/class_BaseCommand.php -text
 inc/classes/main/commands/local/.htaccess -text
 inc/classes/main/commands/local/class_LocalHomeCommand.php -text
 inc/classes/main/commands/web/.htaccess -text
+inc/classes/main/commands/web/class_WebDoFormCommand.php -text
 inc/classes/main/commands/web/class_WebHomeCommand.php -text
+inc/classes/main/commands/web/class_WebRegisterCommand.php -text
 inc/classes/main/compressor/.htaccess -text
 inc/classes/main/compressor/class_Bzip2Compressor.php -text
 inc/classes/main/compressor/class_GzipCompressor.php -text
@@ -180,10 +194,10 @@ inc/classes/main/controller/.htaccess -text
 inc/classes/main/controller/class_ -text
 inc/classes/main/controller/class_BaseController.php -text
 inc/classes/main/controller/default/.htaccess -text
-inc/classes/main/controller/default/class_LocalDefaultController.php -text
-inc/classes/main/controller/default/class_LocalDefaultNewsController.php -text
 inc/classes/main/controller/default/class_WebDefaultController.php -text
 inc/classes/main/controller/default/class_WebDefaultNewsController.php -text
+inc/classes/main/controller/form/.htaccess -text
+inc/classes/main/controller/form/class_WebDoFormController.php -text
 inc/classes/main/controller/registration/.htaccess -text
 inc/classes/main/controller/registration/class_DefaultRegistrationController.php -text
 inc/classes/main/database/.htaccess -text
@@ -202,9 +216,20 @@ 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
+inc/classes/main/filter/class_FilterChain.php -text
+inc/classes/main/filter/validator/.htaccess -text
+inc/classes/main/filter/validator/class_UserNameValidatorFilter.php -text
+inc/classes/main/helper/.htaccess -text
+inc/classes/main/helper/class_ -text
+inc/classes/main/helper/class_BaseHelper.php -text
+inc/classes/main/helper/web/.htaccess -text
+inc/classes/main/helper/web/class_WebFormHelper.php -text
 inc/classes/main/io/.htaccess -text
-inc/classes/main/io/class_FileIOStream.php -text
+inc/classes/main/io/class_FileIoStream.php -text
 inc/classes/main/io/class_FrameworkDirectoryPointer.php -text
 inc/classes/main/io/class_FrameworkFileInputPointer.php -text
 inc/classes/main/io/class_FrameworkFileOutputPointer.php -text
@@ -217,9 +242,6 @@ inc/classes/main/request/.htaccess -text
 inc/classes/main/request/class_HttpRequest.php -text
 inc/classes/main/resolver/.htaccess -text
 inc/classes/main/resolver/class_BaseResolver.php -text
-inc/classes/main/resolver/local/.htaccess -text
-inc/classes/main/resolver/local/class_LocalCommandResolver.php -text
-inc/classes/main/resolver/local/class_LocalControllerResolver.php -text
 inc/classes/main/resolver/web/.htaccess -text
 inc/classes/main/resolver/web/class_WebCommandResolver.php -text
 inc/classes/main/resolver/web/class_WebControllerResolver.php -text
@@ -227,6 +249,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
@@ -236,7 +260,7 @@ inc/classes/middleware/database/class_DatabaseConnection.php -text
 inc/classes/middleware/debug/.htaccess -text
 inc/classes/middleware/debug/class_DebugMiddleware.php -text
 inc/classes/middleware/io/.htaccess -text
-inc/classes/middleware/io/class_FileIOHandler.php -text
+inc/classes/middleware/io/class_FileIoHandler.php -text
 inc/config.php -text
 inc/config/.htaccess -text
 inc/config/class_FrameworkConfiguration.php -text
index 94ea19675778004a411b042ea6149fff42abb509..466ff6d83a5e61443e033dfe6bbf52e2a0e1e727 100644 (file)
@@ -185,6 +185,20 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
        public final function getMasterTemplate () {
                return "hub_main";
        }
+
+       /**
+        * Handle the indexed array of fatal messages and puts them out in an
+        * acceptable fasion
+        *
+        * @param       $messageList    An array of fatal messages
+        * @return      void
+        */
+       public function handleFatalMessages (array $messageList) {
+               // Walk through all messages
+               foreach ($messageList as $message) {
+                       die("MSG:".$message);
+               }
+       }
 }
 
 // [EOF]
diff --git a/inc/classes/exceptions/helper/.htaccess b/inc/classes/exceptions/helper/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/exceptions/helper/class_FormClosedException.php b/inc/classes/exceptions/helper/class_FormClosedException.php
new file mode 100644 (file)
index 0000000..9390911
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * An exception thrown when the form is still closed but input field shall be
+ * added to it. This should normally not happen, but well, who knows?
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class FormClosedException extends FrameworkException {
+       /**
+        * The constructor
+        *
+        * @param               $classArray             Class throwing the exception
+        * @param               $code                   Code number for the exception
+        * @return      void
+        */
+       public function __construct (array $classArray, $code) {
+               // Add a message around the missing class
+               $message = sprintf("[%s:%d] Could not add form element <u>%s</u> because form is closed.",
+                       $classArray[0]->__toString(),
+                       $this->getLine(),
+                       $classArray[1]
+               );
+
+               // Call parent constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/exceptions/helper/class_FormGroupClosedException.php b/inc/classes/exceptions/helper/class_FormGroupClosedException.php
new file mode 100644 (file)
index 0000000..608228d
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * An exception thrown when a form group is still closed.
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class FormGroupClosedException extends FrameworkException {
+       /**
+        * The constructor
+        *
+        * @param               $classArray             Class throwing the exception
+        * @param               $code                   Code number for the exception
+        * @return      void
+        */
+       public function __construct (array $classArray, $code) {
+               // Add a message around the missing class
+               $message = sprintf("[%s:%d] Could not add sub group <u>%s</u> because no form group has been opened before.",
+                       $classArray[0]->__toString(),
+                       $this->getLine(),
+                       $classArray[1]
+               );
+
+               // Call parent constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/exceptions/helper/class_FormOpenedException.php b/inc/classes/exceptions/helper/class_FormOpenedException.php
new file mode 100644 (file)
index 0000000..e964c7c
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * An exception thrown when the form is still opened but we e.g. shall flush
+ * the content.
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class FormOpenedException extends FrameworkException {
+       /**
+        * The constructor
+        *
+        * @param               $class          Class throwing the exception
+        * @param               $code                   Code number for the exception
+        * @return      void
+        */
+       public function __construct (BaseFrameworkSystem $class, $code) {
+               // Add a message around the missing class
+               $message = sprintf("[%s:%d] Form is not yet closed. Close it with method <u>%s::addFormTag()</u> and add no parameters.",
+                       $class->__toString(),
+                       $this->getLine(),
+                       $class->__toString()
+               );
+
+               // Call parent constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/exceptions/helper/class_InvalidFormNameException.php b/inc/classes/exceptions/helper/class_InvalidFormNameException.php
new file mode 100644 (file)
index 0000000..85b5137
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * An exception thrown when the form name is invalid (set to false)
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class InvalidFormNameException extends FrameworkException {
+       /**
+        * The constructor
+        *
+        * @param               $class          Class throwing the exception
+        * @param               $code           Code number for the exception
+        * @return      void
+        */
+       public function __construct (BaseFrameworkSystem $class, $code) {
+               // Add a message around the missing class
+               $message = sprintf("[%s:%d] Form name not set.",
+                       $class->__toString(),
+                       $this->getLine()
+               );
+
+               // Call parent constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
index 060b01709529dab432c17049bf30382f08b8f43e..3292d4bbc5311e516045e78dd73d50b6cf81adc1 100644 (file)
@@ -25,8 +25,8 @@ class DirPointerNotOpenedException extends FrameworkException {
        /**
         * The constructor
         *
-        * @param               $message                Message from the exception
-        * @param               $code           Code number for the exception
+        * @param       $path   Message from the exception
+        * @param       $code   Code number for the exception
         * @return      void
         */
        public function __construct ($path, $code) {
index 9c7a8a8914b584173b9e501ae00a6307beb23cf0..27fe8d1d40b9c1f78ef6fa7e1a872c749b898c58 100644 (file)
@@ -3,10 +3,10 @@
  * An exception thrown when a file pointer is not opened
  *
  * @author             Roland Haeder <webmaster@mxchange.org>
- * @version            0.3.0
+ * @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.mxchange.org
+ * @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
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class FilePointerNotOpenedException extends FrameworkException {
        /**
         * The constructor
         *
-        * @param               $message                Message from the exception
+        * @param               $fqfn           Full-qualified file name of (maybe) missing file
         * @param               $code           Code number for the exception
         * @return      void
         */
-       public function __construct ($path, $code) {
+       public function __construct ($fqfn, $code) {
                // Add a message around the missing class
-               $message = sprintf("F&uuml;r die Datei <u>%s</u> konnte kein Pointer initialisiert werden. M&ouml;glicherweise ist die Datei nicht lesbar oder fehlt!", $path);
+               $message = sprintf("Not able to initialize a pointer for the file <u>%s</u>. Maybe the file is missing.", $fqfn);
 
                // Call parent constructor
                parent::__construct($message, $code);
index 8a3151cc0db682272295a9a8655f8e6e12c5ca2c..01fd09fa434cb65dba4248015473f9d6fc568a10 100644 (file)
@@ -3,10 +3,11 @@
  * An exception thrown when a template variable name is invalid
  *
  * @author             Roland Haeder <webmaster@mxchange.org>
- * @version            0.3.0
+ * @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.mxchange.org
+ * @link               http://www.ship-simu.org
+ * @deprecated
  * 
  * 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
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class InvalidTemplateVariableNameException extends FrameworkException {
        /**
         * The constructor
         *
-        * @param               $class          An array holding our informations
-        * @param               $code           Code number for the exception
+        * @param               $classArray             An array holding our informations
+        * @param               $code                   Code number for the exception
         * @return      void
         */
-       public function __construct (BaseFrameworkSystem $class, $code) {
+       public function __construct (array $classArray, $code) {
                // Add a message around the missing class
-               $message = sprintf("[%s:%d] Die im Template <u>%s</u> gefundene Variable <u>%s</u> ist nicht g&uuml;ltig! G&uuml;ltige Variablennamen sind nur <u>%s</strong>.",
-                       $class[0]->__toString(),
+               $message = sprintf("[%s:%d] The template <u>%s</u> contains an invalid variable called <u>%s</u>. Valid variable names are only <u>%s</u>.",
+                       $classArray[0]->__toString(),
                        $this->getLine(),
-                       basename($class[1]),
-                       $class[2],
-                       $class[3]->readConfig("tpl_valid_var")
+                       basename($classArray[1]),
+                       $classArray[2],
+                       $classArray[3]->readConfig('tpl_valid_var')
                );
 
                // Call parent constructor
diff --git a/inc/classes/exceptions/user/.htaccess b/inc/classes/exceptions/user/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..8016cf3
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * A class for non-existing usernames
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 <u>%s</u> was not found.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1]
+               );
+
+               // Make sure everything is assigned properly
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
index 5bb3dac1bba97009a9d59ae746943e404093bb3d..d1d7267aad8c656f4c44f678de95b3cc2ce296c9 100644 (file)
@@ -84,6 +84,15 @@ interface ManageableApplication extends FrameworkInterface {
         * @return      void
         */
        function entryPoint ();
+
+       /**
+        * Handle the indexed array of fatal messages and puts them out in an
+        * acceptable fasion
+        *
+        * @param       $messageList    An array of fatal messages
+        * @return      void
+        */
+       function handleFatalMessages (array $messageList);
 }
 
 // [EOF]
index 4b3eaba9f8bcb5a43232a31c35a2f164dde9eec0..8b3392df8136567efab878e0a983ca277c6a1716 100644 (file)
@@ -23,7 +23,7 @@
  */
 interface Commandable extends FrameworkInterface {
        /**
-        * Executes the given command with given request and response objects
+        * 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
diff --git a/inc/classes/interfaces/filter/.htaccess b/inc/classes/interfaces/filter/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/filter/class_Filterable.php b/inc/classes/interfaces/filter/class_Filterable.php
new file mode 100644 (file)
index 0000000..bc4bb30
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/**
+ * A class for pre and post filters
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface Filterable extends FrameworkInterface {
+       /**
+        * 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
+        */
+       function execute (Requestable $requestInstance, Responseable $responseInstance);
+}
+
+//
+?>
index 08dd5b170b13e4f7c32cf6fa74e4d878127794f9..a7b39bf581028251e4f728ac86160ab191edbbf4 100644 (file)
@@ -62,6 +62,14 @@ interface Requestable extends FrameworkInterface {
         * @return      $headerValue    Value of the header or 'null' if not found
         */
        function getHeader ($headerName);
+
+       /**
+        * Sets wether the request was valid (default: true)
+        *
+        * @param       $isValid                Wether the request is valid
+        * @return      void
+        */
+       function requestIsValid ($isValid = true);
 }
 
 //
index e953ceee2ecc60f0d666806efcc6f9f66dd4e1fb..76ec16a244cc42527ff8d05ed578cd40b12163da 100644 (file)
@@ -27,7 +27,7 @@ interface ControllerResolver extends FrameworkInterface {
         *
         * @return      $controllerInstance             A controller instance for the default command
         */
-        function resolveDefaultController ();
+        function resolveCommandController ();
 }
 
 //
index 7416b948ca056b16bc0cc53dace0b811d8edb671..ae9f4ae91f14f3f45d17a8ebb3f87ee836d2f4e7 100644 (file)
@@ -57,6 +57,15 @@ interface Responseable extends FrameworkInterface {
         *                                                                                                      already sent
         */
        function flushBuffer($force=false);
+
+       /**
+        * Adds a fatal message id to the response. The added messages can then be
+        * processed and outputed to the world
+        *
+        * @param       $messageId      The message id we shall add
+        * @return      void
+        */
+       function addFatalMessage ($messageId);
 }
 
 //
diff --git a/inc/classes/interfaces/user/.htaccess b/inc/classes/interfaces/user/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..eef4ef8
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * An interface for manageable users
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface ManageableUser extends FrameworkInterface {
+}
+
+//
+?>
index f341fc9d33f2335b07cd8966133fc15df9a36337..1ccb1c2c765fdb5d588fad9b0a122e9cd0676dc2 100644 (file)
@@ -219,8 +219,50 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        public final function __call ($methodName, $args) {
                // Implode all given arguments
-               $argsString = implode("|", $args);
-               if (empty($argsString)) $argsString = "NULL";
+               $argsString = "";
+               if (empty($args)) {
+                       // No arguments
+                       $argsString = "NULL";
+               } elseif (is_array($args)) {
+                       // Some arguments are there
+                       foreach ($args as $arg) {
+                               // Check the type
+                               if (is_bool($arg)) {
+                                       // Boolean!
+                                       if ($arg) $argsString .= "true(bool)"; else $argsString .= "false(bool)";
+                               } elseif (is_int($arg)) {
+                                       // Integer
+                                       $argsString .= $arg."(int)";
+                               } elseif (is_float($arg)) {
+                                       // Floating point
+                                       $argsString .= $arg."(float)";
+                               } elseif ($arg instanceof BaseFramework) {
+                                       // Own object instance
+                                       $argsString .= $arg->__toString()."(Object)";
+                               } elseif (is_object($arg)) {
+                                       // External object
+                                       $argsString .= "unknown object(!)";
+                               } elseif (is_array($arg)) {
+                                       // Array
+                                       $argsString .= "Array(array)";
+                               } elseif (is_string($arg)) {
+                                       // String
+                                       $argsString .= "\"".$arg."\"(string)";
+                               } else {
+                                       // Unknown type (please report!)
+                                       $argsString .= $arg."(unknown!)";
+                               }
+
+                               // Add comma
+                               $argsString .= ", ";
+                       }
+
+                       // Remove last comma
+                       if (substr($argsString, -2, 1) === ",") $argsString = substr($argsString, 0, -2);
+               } else {
+                       // Invalid arguments!
+                       $argsString = sprintf("!INVALID:%s!", $args);
+               }
 
                $this->getDebugInstance()->output(sprintf("[%s::%s] Stub! Args: %s",
                        $this->__toString(),
@@ -246,16 +288,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        // Initialize debug instance
                        if (is_null($this->getDebugInstance())) {
                                // Set the debug output system if it is not debug class ;)
-                               $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig("debug_engine")));
+                               $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig('debug_engine')));
                        }
 
                        // Initialize web instance
                        if (is_null($this->getWebOutputInstance())) {
                                // Generate the eval() command
                                $eval = sprintf("\$this->setWebOutputInstance(%s::create%s(\"%s\"));",
-                                       $this->getConfigInstance()->readConfig("web_engine"),
-                                       $this->getConfigInstance()->readConfig("web_engine"),
-                                       $this->getConfigInstance()->readConfig("web_content_type")
+                                       $this->getConfigInstance()->readConfig('web_engine'),
+                                       $this->getConfigInstance()->readConfig('web_engine'),
+                                       $this->getConfigInstance()->readConfig('web_content_type')
                                );
 
                                // Debug message
@@ -273,7 +315,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                                // Set the compressor channel
                                $this->setCompressorChannel(CompressorChannel::createCompressorChannel(sprintf("%s%s",
                                        PATH,
-                                       $this->getConfigInstance()->readConfig("compressor_base_path")
+                                       $this->getConfigInstance()->readConfig('compressor_base_path')
                                )));
                        }
 
@@ -732,7 +774,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         *
         * @return      $fileIOInstance An instance to the file I/O sub-system
         */
-       protected final function getFileIOInstance () {
+       protected final function getFileIoInstance () {
                return $this->fileIOInstance;
        }
 
@@ -742,7 +784,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @param       $fileIOInstance An instance to the file I/O sub-system
         * @return      void
         */
-       public final function setFileIOInstance (FileIOHandler $fileIOInstance) {
+       public final function setFileIoInstance (FileIoHandler $fileIOInstance) {
                $this->fileIOInstance = $fileIOInstance;
        }
 
@@ -797,16 +839,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Generate FQFN for all application templates
                $fqfn = sprintf("%s%s/%s/%s",
                        PATH,
-                       $this->getConfigInstance()->readConfig("application_path"),
+                       $this->getConfigInstance()->readConfig('application_path'),
                        strtolower($appInstance->getAppShortName()),
-                       $this->getConfigInstance()->readConfig("tpl_base_path")
+                       $this->getConfigInstance()->readConfig('tpl_base_path')
                );
 
                // Are both instances set?
                if ($appInstance->getLanguageInstance() === null) {
                        // Invalid language instance
                        throw new MissingLanguageHandlerException($appInstance, self::EXCEPTION_MISSING_LANGUAGE_HANDLER);
-               } elseif ($appInstance->getFileIOInstance() === null) {
+               } elseif ($appInstance->getFileIoInstance() === null) {
                        // Invalid language instance
                        throw new MissingFileIoHandlerException($appInstance, self::EXCEPTION_MISSING_FILE_IO_HANDLER);
                }
@@ -816,10 +858,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                $eval = sprintf("\$tplEngine = %s::create%s(
        \"%s\",
        \$appInstance->getLanguageInstance(),
-       \$appInstance->getFileIOInstance()
+       \$appInstance->getFileIoInstance()
 );",
-                       $this->getConfigInstance()->readConfig("tpl_engine"),
-                       $this->getConfigInstance()->readConfig("tpl_engine"),
+                       $this->getConfigInstance()->readConfig('tpl_engine'),
+                       $this->getConfigInstance()->readConfig('tpl_engine'),
                        $fqfn
                );
 
@@ -854,10 +896,76 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        public final function debugInstance () {
                // Generate the output
-               $content = "<pre>".trim(print_r($this, true))."</pre>";
+               $content = sprintf("<pre>%s</pre>",
+                       trim(print_r($this, true))
+               );
 
                // Output it
-               ApplicationEntryPoint::app_die("<strong>Debug output:</strong>".$content);
+               ApplicationEntryPoint::app_die(sprintf("<strong>%s debug output:</strong>%s", $this->__toString(), $content));
+       }
+
+       /**
+        * Output a partial stub message for the caller method
+        *
+        * @param       $message        An optional message to display
+        * @return      void
+        */
+       protected function partialStub ($message = "") {
+               // Get the backtrace
+               $backtrace = debug_backtrace();
+
+               // Generate the class::method string
+               $methodName = "UnknownClass::unknownMethod";
+               if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) {
+                       $methodName = $backtrace[1]['class']."::".$backtrace[1]['function'];
+               }
+
+               // Construct the full message
+               $stubMessage = sprintf("[%s:] Partial stub!",
+                       $methodName
+               );
+
+               // Is the extra message given?
+               if (!empty($message)) {
+                       // Then add it as well
+                       $stubMessage .= sprintf(" Message: <u>%s</u>", $message);
+               }
+
+               // Debug instance is there?
+               if (!is_null($this->getDebugInstance())) {
+                       // Output stub message
+                       $this->getDebugInstance()->output($stubMessage);
+               } else {
+                       // Trigger an error
+                       trigger_error($stubMessage."<br />\n");
+               }
+       }
+
+       /**
+        * Converts e.g. a command from URL to a valid class by keeping out bad characters
+        *
+        * @param       $str            The string, what ever it is needs to be converted
+        * @return      $className      Generated class name
+        */
+       public function convertToClassName ($str) {
+               $className = "";
+               foreach (explode("_", $str) as $strPart) {
+                       $className .= ucfirst(strtolower($strPart));
+               }
+               return $className;
+       }
+
+       /**
+        * Outputs a debug backtrace and stops further script execution
+        *
+        * @return      void
+        */
+       public function debugBacktrace () {
+               // Sorry, there is no other way getting this nice backtrace
+               print "<pre>\n";
+               debug_print_backtrace();
+               print "</pre>";
+               exit;
        }
 }
 
diff --git a/inc/classes/main/commands/class_ b/inc/classes/main/commands/class_
new file mode 100644 (file)
index 0000000..cbb5b60
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+/**
+ * 
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class ???Command extends BaseCommand implements Commandable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set special description
+               $this->setObjectDescription("");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeSystemArray();
+       }
+
+       /**
+        * 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 create???Command (CommandResolver $resolverInstance) {
+               // Get new instance
+               $commandInstance = new ???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
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/commands/web/class_WebDoFormCommand.php b/inc/classes/main/commands/web/class_WebDoFormCommand.php
new file mode 100644 (file)
index 0000000..e4c2300
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+/**
+ * A command for the "home" page
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class WebDoFormCommand extends BaseCommand implements Commandable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set special description
+               $this->setObjectDescription("Command for handling forms on a centralized place");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeSystemArray();
+       }
+
+       /**
+        * 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 createWebDoFormCommand (CommandResolver $resolverInstance) {
+               // Get new instance
+               $commandInstance = new WebDoFormCommand();
+
+               // 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
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Should never be executed...
+               echo "<strong>This should never be executed!</strong><pre>";
+               debug_print_backtrace();
+               die("</pre>Good bye...");
+       }
+}
+
+// [EOF]
+?>
index 9629b9742d54b8f00261a19ee64c26e3f4b8b33c..0b7e9c41a39e5951d492abf5106bfda76a334c0f 100644 (file)
@@ -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 &quot;home&quot; page");
 
                // Create unique ID number
                $this->createUniqueID();
@@ -90,7 +90,7 @@ class WebHomeCommand extends BaseCommand implements Commandable {
                $templateInstance->assignTemplateWithVariable("footer", "footer");
 
                // Load the home template
-               $templateInstance->loadWebTemplate("home");
+               $templateInstance->loadCodeTemplate("home");
 
                // Assign the home template with the master template as a content ... ;)
                $templateInstance->assignTemplateWithVariable("home", "content");
@@ -99,9 +99,9 @@ class WebHomeCommand extends BaseCommand implements Commandable {
                $templateInstance->loadCodeTemplate($masterTemplate);
 
                // Set title
-               $title = ucfirst($requestInstance->getRequestElement($this->getConfigInstance()->readConfig("command_parameter")));
+               $title = ucfirst($requestInstance->getRequestElement($this->getConfigInstance()->readConfig('command_parameter')));
                if (empty($title)) $title = "Home";
-               $templateInstance->assignVariable("title", $title);
+               $templateInstance->assignVariable('title', $title);
 
                // ... and all variables. This should be merged together in a pattern
                // to make things easier. A cache mechanism should be added between
diff --git a/inc/classes/main/commands/web/class_WebRegisterCommand.php b/inc/classes/main/commands/web/class_WebRegisterCommand.php
new file mode 100644 (file)
index 0000000..af1d748
--- /dev/null
@@ -0,0 +1,121 @@
+<?php
+/**
+ * A command class for the registration form
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class WebRegisterCommand extends BaseCommand implements Commandable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set special description
+               $this->setObjectDescription("Command for the registration form");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeSystemArray();
+       }
+
+       /**
+        * 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 createWebRegisterCommand (CommandResolver $resolverInstance) {
+               // Get new instance
+               $commandInstance = new WebRegisterCommand();
+
+               // 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
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get the application instance
+               $appInstance = $this->getResolverInstance()->getApplicationInstance();
+
+               // Prepare a template instance
+               $templateInstance = $this->prepareTemplateEngine($appInstance);
+
+               // Assign all the application's data with template variables
+               $templateInstance->assignApplicationData($appInstance);
+
+               // Load the master template
+               $masterTemplate = $appInstance->getMasterTemplate();
+
+               // Load header template
+               $templateInstance->loadCodeTemplate("header");
+
+               // Compile and assign it with a variable
+               $templateInstance->compileTemplate();
+               $templateInstance->assignTemplateWithVariable("header", "header");
+
+               // Load footer template
+               $templateInstance->loadCodeTemplate("footer");
+
+               // Compile and assign it with a variable
+               $templateInstance->compileTemplate();
+               $templateInstance->assignTemplateWithVariable("footer", "footer");
+
+               // Load the register template
+               $templateInstance->loadCodeTemplate("register");
+
+               // Assign the register template with the master template as a content ... ;)
+               $templateInstance->compileTemplate();
+               $templateInstance->assignTemplateWithVariable("register", "content");
+
+               // Load the master template
+               $templateInstance->loadCodeTemplate($masterTemplate);
+
+               // Set title
+               $title = ucfirst($requestInstance->getRequestElement($this->getConfigInstance()->readConfig('command_parameter')));
+               if (empty($title)) $title = "Register";
+               $templateInstance->assignVariable('title', $title);
+
+               // ... and all variables. This should be merged together in a pattern
+               // to make things easier. A cache mechanism should be added between
+               // these two calls to cache compiled templates.
+               $templateInstance->compileVariables();
+
+               // Get the content back from the template engine and put it in the response class
+               $templateInstance->transferToResponse($responseInstance);
+       }
+}
+
+// [EOF]
+?>
index 88322b60c499484237dece225877fdf5fb1eb93e..24566b91d880cab3fcc3348ece9c26f5bff53c61 100644 (file)
@@ -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();
index 4e95f801f95ef6214b85777c0396e438d6a6e919..08b1a6ded09325ec2350f8b2056fbb7b61ebc611 100644 (file)
@@ -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();
index a8a570c581487ca464c9f05002e2f2576dbe13ee..157dc1a9ea41d0c270adcae6552bed674ca35a2e 100644 (file)
@@ -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();
index 78dc94c90599370005620523741ce8311248bf40..054c8c7db37d8e003cf97bdb13aa34047f79ad61 100644 (file)
@@ -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();
index f7aea5c307922c9a30552ed64bc1ea21d72f7790..a2bf81158444abaea1aef399342006ba2683eee4 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 /**
- * A generic controller class
+ * A generic controller class. You should extend this base class if you want to
+ * write your own controller. You get the advantage that you can use the pre and
+ * post filters.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseController extends BaseFrameworkSystem {
+       /**
+        * Instance of a CommandResolver class
+        */
+       private $resolverInstance = null;
+
+       /**
+        * Pre filter chain instance
+        */
+       private $preFilterChain = null;
+
+       /**
+        * Post filter chain instance
+        */
+       private $postFilterChain = null;
+
        /**
         * Protected constructor
         *
@@ -33,6 +50,76 @@ class BaseController extends BaseFrameworkSystem {
 
                // Clean up a little
                $this->removeNumberFormaters();
+               $this->removeSystemArray();
+
+               // Initialize both filter chains
+               $this->preFilterChain  = FilterChain::createFilterChain();
+               $this->postFilterChain = FilterChain::createFilterChain();
+       }
+
+       /**
+        * Getter for a command resolver instance
+        *
+        * @return      $resolverInstance       An instance of a command resolver class
+        */
+       public final function getResolverInstance () {
+               return $this->resolverInstance;
+       }
+
+       /**
+        * Setter for a command resolver instance
+        *
+        * @param       $resolverInstance       An instance of a command resolver class
+        * @return      void
+        */
+       public final function setResolverInstance (CommandResolver $resolverInstance) {
+               $this->resolverInstance = $resolverInstance;
+       }
+
+       /**
+        * Adds a filter to the pre filter chain
+        *
+        * @param       $filterInstance         An instance of a filter
+        * @return      void
+        */
+       public function addPreFilter (Filterable $filterInstance) {
+               // Add the pre filter
+               $this->preFilterChain->addFilter($filterInstance);
+       }
+
+       /**
+        * Adds a filter to the post filter chain
+        *
+        * @param       $filterInstance         An instance of a filter
+        * @return      void
+        */
+       public function addPostFilter (Filterable $filterInstance) {
+               // Add the post filter
+               $this->postFilterChain->addFilter($filterInstance);
+       }
+
+       /**
+        * Executes all pre filters
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) {
+               // Execute all pre filters
+               $this->preFilterChain->processFilters($requestInstance, $responseInstance);
+       }
+
+       /**
+        * Executes all post filters
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) {
+               // Execute all post filters
+               $this->postFilterChain->processFilters($requestInstance, $responseInstance);
        }
 }
 
diff --git a/inc/classes/main/controller/default/class_LocalDefaultController.php b/inc/classes/main/controller/default/class_LocalDefaultController.php
deleted file mode 100644 (file)
index a79243a..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-/**
- * The default controller for all other requests
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class LocalLocalDefaultController extends BaseController implements Controller {
-       /**
-        * Instance of a CommandResolver class
-        */
-       private $resolverInstance = null;
-
-       /**
-        * Private constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set part description
-               $this->setObjectDescription("Standart-Controller f&uuml;r alle &uuml;brigen Anfragen");
-
-               // Create unique ID number
-               $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeSystemArray();
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @param       $resolverInstance               An instance of a command resolver class
-        * @return      $controllerInstance             A prepared instance of this class
-        */
-       public final static function createLocalDefaultController (CommandResolver $resolverInstance) {
-               // Create the instance
-               $controllerInstance = new LocalDefaultController();
-
-               // Set the command resolver
-               $controllerInstance->setResolverInstance($resolverInstance);
-
-               // Return the prepared instance
-               return $controllerInstance;
-       }
-
-       /**
-        * Setter for a command resolver instance
-        *
-        * @param       $resolverInstance       An instance of a command resolver class
-        * @return      void
-        */
-       public final function setResolverInstance (CommandResolver $resolverInstance) {
-               $this->resolverInstance = $resolverInstance;
-       }
-
-       /**
-        * 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
-               $commandInstance = $this->resolverInstance->resolvCommandByRequest($requestInstance);
-
-               // Execute the command
-               $commandInstance->execute($requestInstance, $responseInstance);
-
-               // Flush the response out
-               $responseInstance->flushResponse();
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/controller/default/class_LocalDefaultNewsController.php b/inc/classes/main/controller/default/class_LocalDefaultNewsController.php
deleted file mode 100644 (file)
index 90d3ec7..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-<?php
-/**
- * The default controller with news for e.g. home or news page
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class LocalDefaultNewsController extends BaseController implements Controller {
-       /**
-        * Instance of a CommandResolver class
-        */
-       private $resolverInstance = null;
-
-       /**
-        * Private constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set part description
-               $this->setObjectDescription("Standart-Controller mit News-Auflistung");
-
-               // Create unique ID number
-               $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeSystemArray();
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @param       $resolverInstance               An instance of a command resolver class
-        * @return      $controllerInstance             A prepared instance of this class
-        */
-       public final static function createLocalDefaultNewsController (CommandResolver $resolverInstance) {
-               // Create the instance
-               $controllerInstance = new LocalDefaultNewsController();
-
-               // Set the command resolver
-               $controllerInstance->setResolverInstance($resolverInstance);
-
-               // Return the prepared instance
-               return $controllerInstance;
-       }
-
-       /**
-        * Setter for a command resolver instance
-        *
-        * @param       $resolverInstance       An instance of a command resolver class
-        * @return      void
-        */
-       public final function setResolverInstance (CommandResolver $resolverInstance) {
-               $this->resolverInstance = $resolverInstance;
-       }
-
-       /**
-        * 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
-               $commandInstance = $this->resolverInstance->resolvCommandByRequest($requestInstance);
-
-               // Get the news page variable from the request instance
-               $newsPage = $requestInstance->getRequestElement("news_page");
-
-               // Load the news here
-               $this->loadNews($newsPage);
-
-               // Execute the command
-               $commandInstance->execute($requestInstance, $responseInstance);
-
-               // Flush the response out
-               $responseInstance->flushResponse();
-       }
-
-       /**
-        * Loads news from the connected database for later usage
-        *
-        * @param       $newsPage       Page of listed news we want to read
-        * @return      void
-        */
-       private function loadNews ($newsPage) {
-       }
-}
-
-// [EOF]
-?>
index 9830891940ee7417009244ca9ca43d72b412032d..9d60e6178668eea76ec086bc6b3fe76fca8d5188 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class WebWebDefaultController extends BaseController implements Controller {
-       /**
-        * Instance of a CommandResolver class
-        */
-       private $resolverInstance = null;
-
        /**
         * Protected constructor
         *
@@ -37,13 +32,10 @@ class WebWebDefaultController extends BaseController implements Controller {
                parent::__construct(__CLASS__);
 
                // Set part description
-               $this->setObjectDescription("Standart-Controller f&uuml;r alle &uuml;brigen Anfragen");
+               $this->setObjectDescription("Default controller for all other requests");
 
                // Create unique ID number
                $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeSystemArray();
        }
 
        /**
@@ -63,16 +55,6 @@ class WebWebDefaultController extends BaseController implements Controller {
                return $controllerInstance;
        }
 
-       /**
-        * Setter for a command resolver instance
-        *
-        * @param       $resolverInstance       An instance of a command resolver class
-        * @return      void
-        */
-       public final function setResolverInstance (CommandResolver $resolverInstance) {
-               $this->resolverInstance = $resolverInstance;
-       }
-
        /**
         * Handles the given request and response
         *
@@ -82,7 +64,10 @@ class WebWebDefaultController extends BaseController implements Controller {
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
                // Get the command instance
-               $commandInstance = $this->resolverInstance->resolvCommandByRequest($requestInstance);
+               $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
+
+               // This request was valid! :-D
+               $requestInstance->requestIsValid();
 
                // Execute the command
                $commandInstance->execute($requestInstance, $responseInstance);
index ea690a9ec85d13399fadf5d64537cdb4142f8bda..b8bbc05544c0ea0d7482b47de98ed63e1f52d9e8 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class WebDefaultNewsController extends BaseController implements Controller {
-       /**
-        * Instance of a CommandResolver class
-        */
-       private $resolverInstance = null;
-
        /**
         * Protected constructor
         *
@@ -37,13 +32,10 @@ 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();
-
-               // Clean up a little
-               $this->removeSystemArray();
        }
 
        /**
@@ -63,16 +55,6 @@ class WebDefaultNewsController extends BaseController implements Controller {
                return $controllerInstance;
        }
 
-       /**
-        * Setter for a command resolver instance
-        *
-        * @param       $resolverInstance       An instance of a command resolver class
-        * @return      void
-        */
-       public final function setResolverInstance (CommandResolver $resolverInstance) {
-               $this->resolverInstance = $resolverInstance;
-       }
-
        /**
         * Handles the given request and response
         *
@@ -82,11 +64,14 @@ class WebDefaultNewsController extends BaseController implements Controller {
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
                // Get the command instance from the resolver by sending a request instance to the resolver
-               $commandInstance = $this->resolverInstance->resolvCommandByRequest($requestInstance);
+               $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
 
                // Load the news here
                $this->loadNewsByRequest($requestInstance);
 
+               // This request was valid! :-D
+               $requestInstance->requestIsValid();
+
                // Execute the command
                $commandInstance->execute($requestInstance, $responseInstance);
 
@@ -102,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/controller/form/.htaccess b/inc/classes/main/controller/form/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/controller/form/class_WebDoFormController.php b/inc/classes/main/controller/form/class_WebDoFormController.php
new file mode 100644 (file)
index 0000000..9ffcf78
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+/**
+ * A controller for handling sent forms
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class WebDoFormController extends BaseController implements Controller {
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Controller for handling forms");
+
+               // Create unique ID number
+               $this->createUniqueID();
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $resolverInstance               An instance of a resolver class
+        * @return      $controllerInstance             A prepared instance of this class
+        */
+       public final static function createWebDoFormController (CommandResolver $resolverInstance) {
+               // Create the instance
+               $controllerInstance = new WebDoFormController();
+
+               // Set resolver instance
+               $controllerInstance->setResolverInstance($resolverInstance);
+
+               // We need the controller instance in the resolver class so set it here
+               $resolverInstance->setControllerInstance($controllerInstance);
+
+               // 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 "form action"
+               $formAction = $requestInstance->getRequestElement('form');
+
+               // Get command instance from resolver
+               $commandInstance = $this->getResolverInstance()->resolveCommand($formAction);
+
+               // Execute *very* generic pre filters
+               $this->executePreFilters($requestInstance, $responseInstance);
+
+               // Is the request still valid? Post filters shall only be executed of
+               // the request is valid
+               if ($requestInstance->isRequestValid()) {
+                       // Execute the command
+                       $commandInstance->execute($requestInstance, $responseInstance);
+
+                       // Execute *very* generic ppost filters
+                       $this->executePostFilters($requestInstance, $responseInstance);
+               }
+
+               // Flush the buffer out
+               $responseInstance->flushBuffer();
+       }
+}
+
+// [EOF]
+?>
index 84babfeafd6d6d0fcf8d1a0e1c23da517cbd0203..dbe55ac36d4690125e36dfa9f74569cfaca4ccf9 100644 (file)
@@ -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();
@@ -70,7 +70,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         *
         * @param               $savePath                                       The local file path string
         * @param               $ioInstance                             The input/output handler. This
-        *                                                                      should be FileIOHandler
+        *                                                                      should be FileIoHandler
         * @return      $dbInstance                             An instance of LocalFileDatabase
         * @throws      SavePathIsEmptyException                If the given save path is an
         *                                                                      empty string
@@ -81,7 +81,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         * @throws      SavePathWriteProtectedException If the save path is write-
         *                                                                              protected
         */
-       public final static function createLocalFileDatabase ($savePath, FileIOHandler $ioInstance) {
+       public final static function createLocalFileDatabase ($savePath, FileIoHandler $ioInstance) {
                // Get an instance
                $dbInstance = new LocalFileDatabase();
 
@@ -101,7 +101,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
 
                // Set save path and IO instance
                $dbInstance->setSavePath($savePath);
-               $dbInstance->setFileIOInstance($ioInstance);
+               $dbInstance->setFileIoInstance($ioInstance);
 
                // Return database instance
                return $dbInstance;
@@ -163,7 +163,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
 
                // Save the file to disc we don't care here if the path is there,
                // this must be done in later methods.
-               $this->getFileIOInstance()->saveFile($fqfn, array($this->getCompressorChannel()->getCompressorExtension(), $serialized));
+               $this->getFileIoInstance()->saveFile($fqfn, array($this->getCompressorChannel()->getCompressorExtension(), $serialized));
        }
 
        /**
@@ -263,7 +263,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                        $this->setLastFile($fqfn);
 
                        // Get instance for file handler
-                       $inputHandler = $this->getFileIOInstance();
+                       $inputHandler = $this->getFileIoInstance();
 
                        // Try to read from it. This makes it sure that the file is
                        // readable and a valid database file
@@ -356,7 +356,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         */
        public final function getObjectFromCachedData ($uniqueID) {
                // Get instance for file handler
-               $inputHandler = $this->getFileIOInstance();
+               $inputHandler = $this->getFileIoInstance();
 
                // Get last file's name and contents
                $fqfn = $this->repairFQFN($this->getLastFile(), $uniqueID);
index dfcfd36b4dbd22bcff7b182587f9b3a0ce983247..e9be4a5910b617e06daa63f632f94a8614829f6b 100644 (file)
@@ -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();
index 26b099d4134f229405717659190c14993ddb6d65..1a1723fd698e39683722a131711225e44d3ca429 100644 (file)
@@ -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();
index 17faa197707408781efadb98fa0e3d3083ce863b..0c763e010b73f25e34262271779be9e7034ac9ca 100644 (file)
@@ -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();
index 75925c64820cdb87489453e5e44e33f5e5b2f051..3c23f805ae64cd44ea00bce911c10436983efa5f 100644 (file)
@@ -39,7 +39,7 @@ class ObjectLimits extends BaseFrameworkSystem {
                parent::__construct(__CLASS__);
 
                // Set part description
-               $this->setObjectDescription("Limitierungsobjekt");
+               $this->setObjectDescription("Class for &quot;limiting&quot; other classes. See description for details.");
 
                // Create unique ID number
                $this->createUniqueID();
index a0980e3d61f93fec58993f7ed775f3cbe1303ba4..7924d4c92e38cde0c25c68bea0ef53057e4ee0e7 100644 (file)
@@ -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();
 
index fd983cac70f5da31b2ee42980200fc46a741960a..5dda5fb904b8e177b3f7a70286a2d693ee1dee04 100644 (file)
@@ -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_NewsFactory.php
deleted file mode 100644 (file)
index 3da66f9..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-<?php
-/**
- * A news factory for web pages
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class NewsFactory extends BaseFactory {
-       /**
-        * Instance of a request class
-        */
-       private $requestInstance = null;
-
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set part description
-               $this->setObjectDescription("News-Fabrik f&uuml;r Webseiten");
-       }
-
-       /**
-        * Singleton getter for a special factory instance depending on the given
-        * request
-        *
-        * @param       $requestInstance        An instance of a request class
-        * @return      $factoryInstance        An instance of a NewsFactory class
-        */
-       public final static function createFactoryByRequest (Requestable $requestInstance) {
-               // Generate the new instance
-               $factoryInstance = new NewsFactory();
-
-               // Get the element name from configuration
-               $element = FrameworkConfiguration::getInstance()->readConfig("app_selector_get");
-
-               // Analyze the request, first get the Uni* application name (short one from URL)
-               $appName = $requestInstance->getRequestElement($element);
-
-               // Initialize some variables
-               $className = "";
-               $className2 = $appName;
-
-               // Then construct the class name
-               foreach (array("_", "-") as $exp) {
-                       $array = explode($exp, $className2);
-                       foreach ($array as $el) {
-                               $className .= ucfirst(strtolower($el));
-                       }
-
-                       // Copy it back and clear the class name
-                       $className2 = $className;
-                       $className = "";
-               }
-
-               // After all is done, copy it back and add this class' name
-               $className = $className2 . $factoryInstance->__toString();
-
-               // Once we have that name, try to load initialize it
-               $realFactoryInstance = ObjectFactory::createObjectByName($className);
-
-               // And assign it with the factory
-               $factoryInstance->setRealFactoryInstance($realFactoryInstance);
-
-               // Remember the request we have used for later usage
-               $factoryInstance->setRequestInstance($requestInstance);
-
-               // Return the prepared factory instance
-               return $factoryInstance;
-       }
-
-       /**
-        * Setter for the request instance
-        *
-        * @param       $requestInstance        An instance of a request object
-        * @return      void
-        */
-       public final function setRequestInstance (Requestable $requestInstance) {
-               $this->requestInstance = $requestInstance;
-       }
-
-       /**
-        * Creates a new object instance and returns it
-        *
-        * @return      $newsInstance   An instance of a news object
-        */
-       public function createNewsObject () {
-               // Ask the real factory class for doing this
-               $newsInstance = $this->getRealFactoryInstance()->createNewObject($this->requestInstance);
-
-               // And return it
-               return $newsInstance;
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/factories/web/class_WebNewsFactory.php b/inc/classes/main/factories/web/class_WebNewsFactory.php
new file mode 100644 (file)
index 0000000..5a604a7
--- /dev/null
@@ -0,0 +1,117 @@
+<?php
+/**
+ * A news factory for web pages
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class WebNewsFactory extends BaseFactory {
+       /**
+        * Instance of a request class
+        */
+       private $requestInstance = null;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Factory for webpages with news");
+       }
+
+       /**
+        * Singleton getter for a special factory instance depending on the given
+        * request
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @return      $factoryInstance        An instance of a WebNewsFactory class
+        */
+       public final static function createFactoryByRequest (Requestable $requestInstance) {
+               // Generate the new instance
+               $factoryInstance = new WebNewsFactory();
+
+               // Get the element name from configuration
+               $element = FrameworkConfiguration::getInstance()->readConfig('app_selector_get');
+
+               // Analyze the request, first get the Uni* application name (short one from URL)
+               $appName = $requestInstance->getRequestElement($element);
+
+               // Initialize some variables
+               $className = "";
+               $className2 = $appName;
+
+               // Then construct the class name
+               foreach (array("_", "-") as $exp) {
+                       $array = explode($exp, $className2);
+                       foreach ($array as $el) {
+                               $className .= ucfirst(strtolower($el));
+                       }
+
+                       // Copy it back and clear the class name
+                       $className2 = $className;
+                       $className = "";
+               }
+
+               // After all is done, copy it back and add this class' name
+               $className = $className2 . $factoryInstance->__toString();
+
+               // Once we have that name, try to load initialize it
+               $realFactoryInstance = ObjectFactory::createObjectByName($className);
+
+               // And assign it with the factory
+               $factoryInstance->setRealFactoryInstance($realFactoryInstance);
+
+               // Remember the request we have used for later usage
+               $factoryInstance->setRequestInstance($requestInstance);
+
+               // Return the prepared factory instance
+               return $factoryInstance;
+       }
+
+       /**
+        * Setter for the request instance
+        *
+        * @param       $requestInstance        An instance of a request object
+        * @return      void
+        */
+       public final function setRequestInstance (Requestable $requestInstance) {
+               $this->requestInstance = $requestInstance;
+       }
+
+       /**
+        * Creates a new object instance and returns it
+        *
+        * @return      $newsInstance   An instance of a news object
+        */
+       public function createNewsObject () {
+               // Ask the real factory class for doing this
+               $newsInstance = $this->getRealFactoryInstance()->createNewObject($this->requestInstance);
+
+               // And return it
+               return $newsInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/filter/.htaccess b/inc/classes/main/filter/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/filter/class_ b/inc/classes/main/filter/class_
new file mode 100644 (file)
index 0000000..b79b83d
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * 
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class ???Filter extends BaseFrameworkSystem implements Filterable {
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("A concrete filter");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // 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 create???Filter () {
+               // Get a new instance
+               $filterInstance = new ???Filter();
+
+               // 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
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Implement this!
+               $this->partialStub("Please implement this method.");
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/filter/class_AbstractFilterDecorator.php b/inc/classes/main/filter/class_AbstractFilterDecorator.php
new file mode 100644 (file)
index 0000000..a9a1d4a
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+/**
+ * An abstract filter decorator for decorating filters with other filters
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+abstract class AbstractFilterDecorator extends BaseFrameworkSystem implements Filterable {
+       /**
+        * The decorated filter instance
+        */
+       private $filterInstance = null;
+
+       /**
+        * Private constructor
+        *
+        * @param       $className      Name of the real class' name
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Setter for the decorated filter instance
+        *
+        * @param       $filterInstance         An instance of a filter
+        * @return      void
+        */
+       protected final function setFilterInstance (Filterable $filterInstance) {
+               $this->filterInstance = $filterInstance;
+       }
+
+       /**
+        * Getter for the decorated filter instance
+        *
+        * @return      $filterInstance         An instance of a filter
+        */
+       protected final function getFilterInstance () {
+               return $this->filterInstance;
+       }
+
+       /**
+        * Execute the inner filter
+        *
+        * @param<->$requestInstance<-->An instance of a request class
+        * @param<->$responseInstance<->An instance of a response class
+        * @return      void
+        */
+       public final function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               $this->getFilterInstance()->execute($requestInstance, $responseInstance);
+       }
+
+
+       /**
+        * Do the execution of the filter
+        *
+        * @param<->$requestInstance<-->An instance of a request class
+        * @param<->$responseInstance<->An instance of a response class
+        * @return      void
+        */
+       abstract public function doExecute (Requestable $requestInstance, Responseable $responseInstance);
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/filter/class_FilterChain.php b/inc/classes/main/filter/class_FilterChain.php
new file mode 100644 (file)
index 0000000..cf2ff3b
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+/**
+ * A filter chain for pre and post filters
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class FilterChain extends BaseFrameworkSystem {
+       /**
+        * All filters together
+        */
+       private $filters = array();
+
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("A filter chain class");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $chainInstance  An instance of this class
+        */
+       public final static function createFilterChain () {
+               // Get a new instance
+               $chainInstance = new FilterChain();
+
+               // Return the prepared instance
+               return $chainInstance;
+       }
+
+       /**
+        * Add a new filter
+        *
+        * @param       $filerInstance  An instance of a filter class
+        * @return      void
+        */
+       public final function addFilter (Filterable $filterInstance) {
+               $this->filters[] = $filterInstance;
+       }
+
+       /**
+        * Process all added filters
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       public function processFilters (Requestable $requestInstance, Responseable $responseInstance) {
+               // Run all filters
+               //* DEBUG */ echo "COUNT=".count($this->filters)."<br />\n";
+               foreach ($this->filters as $filterInstance) {
+                       // Execute this filter
+                       //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing started.<br />\n";
+                               $filterInstance->execute($requestInstance, $responseInstance);
+                       //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing ended.<br />\n";
+               }
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/filter/validator/.htaccess b/inc/classes/main/filter/validator/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php
new file mode 100644 (file)
index 0000000..1c7c54a
--- /dev/null
@@ -0,0 +1,131 @@
+<?php
+/**
+ * A concrete filter for validating the username. This filter may intercept the
+ * filter chain if no username is given or if the supplied username has an
+ * invalid form. It could also intercept the filter chain if the username is
+ * already taken.
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class UserNameValidatorFilter extends BaseFrameworkSystem implements Filterable {
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("A filter for username validation");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // 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 createUserNameValidatorFilter () {
+               // Get a new instance
+               $filterInstance = new UserNameValidatorFilter();
+
+               // 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
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get username from request
+               $userName = $requestInstance->getRequestElement('username');
+
+               // Is the username set?
+               if (is_null($userName)) {
+                       // Not found in form so stop the filtering process
+                       $requestInstance->requestIsValid(false);
+
+                       // Set a message for the response
+                       $responseInstance->addFatalMessage('username_unset');
+
+                       // Abort here
+                       return false;
+               } elseif (empty($userName)) {
+                       // Empty field!
+                       $requestInstance->requestIsValid(false);
+
+                       // Set a message for the response
+                       $responseInstance->addFatalMessage('username_empty');
+
+                       // Abort here
+                       return false;
+               } elseif ($this->ifUserNameIsTaken($userName)) {
+                       // Username is already taken
+                       $requestInstance->requestIsValid(false);
+
+                       // Set a message for the response
+                       $responseInstance->addFatalMessage('username_taken');
+
+                       // Abort here
+                       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/.htaccess b/inc/classes/main/helper/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/helper/class_ b/inc/classes/main/helper/class_
new file mode 100644 (file)
index 0000000..8a1892b
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/**
+ * 
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class  extends BaseHelper {
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("");
+       }
+
+       /**
+        * Creates the helper class
+        *
+        * @return      $helperInstance         A preparedf instance of this class
+        */
+       public final static function createHelper () {
+               // Get new instance
+               $helperInstance = new Helper();
+
+               // Return the prepared instance
+               return $helperInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php
new file mode 100644 (file)
index 0000000..02a99e3
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+/**
+ * A generic helper class with generic methods
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class BaseHelper extends BaseFrameworkSystem {
+       /**
+        * Template engine instance
+        */
+       private $templateInstance = null;
+
+       /**
+        * Rendered content created by the helper class
+        */
+       private $content = "";
+
+       /**
+        * Private constructor
+        *
+        * @param       $className      Real name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Setter for template engine instances
+        *
+        * @param       $templateInstance       An instance of a template engine class
+        * @return      void
+        */
+       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
+               $this->templateInstance = $templateInstance;
+       }
+
+       /**
+        * Getter for template engine instances
+        *
+        * @return      $templateInstance       An instance of a template engine class
+        */
+       protected final function getTemplateInstance () {
+               return $this->templateInstance;
+       }
+
+       /**
+        * Add content
+        *
+        * @param       $newContent             New content to add
+        * @return      void
+        */
+       protected final function addContent ($newContent) {
+               $this->content .= (string) trim($newContent)."\r\n";
+       }
+
+       /**
+        * Getter for content
+        *
+        * @return      $content        The rendered content by this helper
+        */
+       protected final function getContent () {
+               return $this->content;
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/helper/web/.htaccess b/inc/classes/main/helper/web/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/helper/web/class_WebFormHelper.php b/inc/classes/main/helper/web/class_WebFormHelper.php
new file mode 100644 (file)
index 0000000..fb0f1b2
--- /dev/null
@@ -0,0 +1,589 @@
+<?php
+/**
+ * A helper for constructing web forms
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class WebFormHelper extends BaseHelper {
+       /**
+        * Wether the form tag is opened (keep at false or else your forms will
+        * never work!)
+        */
+       private $formOpened = false;
+
+       /**
+        * Name of the form
+        */
+       private $formName = "";
+
+       /**
+        * Wether the group is opened or not
+        */
+       private $groupOpened = false;
+
+       /**
+        * Wether the sub group is opened or not
+        */
+       private $subGroupOpened = false;
+
+       /**
+        * Name of the sub group
+        */
+       private $subGroupName = "";
+
+       // Class Constants
+       const EXCEPTION_FORM_NAME_INVALID       = 0xb00;
+       const EXCEPTION_CLOSED_FORM             = 0xb01;
+       const EXCEPTION_OPENED_FORM             = 0xb02;
+       const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0xb03;
+
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Helper class for HTML forms");
+
+               // Create unique ID number
+               $this->createUniqueID();
+       }
+
+       /**
+        * Creates the helper class with the given template engine instance and form name
+        *
+        * @param       $templateInstance       An instance of a valid template engine
+        * @param       $formName                       Name of the form
+        * @param       $formId                         Value for "id" attribute (default: $formName)
+        * @return      $helperInstance         A preparedf instance of this class
+        */
+       public final static function createWebFormHelper (CompileableTemplate $templateInstance, $formName, $formId = false) {
+               // Get new instance
+               $helperInstance = new WebFormHelper();
+
+               // Set template instance
+               $helperInstance->setTemplateInstance($templateInstance);
+
+               // Is the form id not set?
+               if ($formId === false) {
+                       // Use form id from form name
+                       $formId = $formName;
+               }
+
+               // Create the form
+               $helperInstance->addFormTag($formName, $formId);
+
+               // Return the prepared instance
+               return $helperInstance;
+       }
+
+       /**
+        * Add the form tag or close it an already opened form tag
+        *
+        * @param       $formName       Name of the form (default: false)
+        * @param       $formId         Id of the form (attribute "id"; default: false)
+        * @return      void
+        * @throws      InvalidFormNameException        If the form name is invalid (=false)
+        */
+       public function addFormTag ($formName = false, $formId = false) {
+               // When the form is not yet opened at least form name must be valid
+               if (($this->formOpened === false) && ($formName === false)) {
+                       // Thrown an exception
+                       throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID);
+               }
+
+               // Close the form is default
+               $formContent = "</form>";
+
+               // Check wether we shall open or close the form
+               if ($this->formOpened === false) {
+                       // Add HTML code
+                       $formContent = sprintf("<form name=\"%s\" class=\"forms\" action=\"%s\" method=\"%s\" target=\"%s\"",
+                               $formName,
+                               $this->getConfigInstance()->readConfig('form_action'),
+                               $this->getConfigInstance()->readConfig('form_method'),
+                               $this->getConfigInstance()->readConfig('form_target')
+                       );
+
+                       // Is the form id set?
+                       if ($formId !== false) {
+                               // Then add it as well
+                               $formContent .= sprintf(" id=\"%s_form\"",
+                                       $formId
+                               );
+                       }
+
+                       // Add close bracket
+                       $formContent .= ">";
+
+                       // Open the form and remeber the form name
+                       $this->formOpened = true;
+                       $this->formName = $formName;
+               } else {
+                       // Add the hidden field required to identify safely this form
+                       $this->addInputHiddenField('form', $this->formName);
+
+                       // Is a group open?
+                       if ($this->groupOpened === true) {
+                               // Then automatically close it here
+                               $this->addFormGroup("", "");
+                       }
+
+                       // @TODO Add some unique PIN here to bypass problems with some browser and/or extensions
+                       // Simply close it
+                       $this->formOpened = false;
+               }
+
+               // Add it to the content
+               $this->addContent($formContent);
+       }
+
+       /**
+        * Add a text input tag to the form or throw an exception if it is not yet
+        * opened. The field's name will be set as id.
+        *
+        * @param       $fieldName                      Input field name
+        * @param       $fieldValue                     Input default value (default: empty)
+        * @return      void
+        * @throws      FormClosedException             If the form is not yet opened
+        */
+       public function addInputTextField ($fieldName, $fieldValue = "") {
+               // Is the form opened?
+               if ($this->formOpened === false) {
+                       // Throw an exception
+                       throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
+               }
+
+               // Generate the content
+               $inputContent = sprintf("<input type=\"text\" class=\"textfield\" id=\"%s\" name=\"%s\" value=\"%s\" />",
+                       $fieldName,
+                       $fieldName,
+                       $fieldValue
+               );
+
+               // And add it maybe with a "li" tag
+               $this->addContent($inputContent);
+       }
+
+       /**
+        * Add a password input tag to the form or throw an exception if it is not
+        * yet opened. The field's name will be set as id.
+        *
+        * @param       $fieldName                      Input field name
+        * @param       $fieldValue                     Input default value (default: empty)
+        * @return      void
+        * @throws      FormClosedException             If the form is not yet opened
+        */
+       public function addInputPasswordField ($fieldName, $fieldValue = "") {
+               // Is the form opened?
+               if ($this->formOpened === false) {
+                       // Throw an exception
+                       throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
+               }
+
+               // Generate the content
+               $inputContent = sprintf("<input type=\"password\" class=\"password\" id=\"%s\" name=\"%s\" value=\"%s\" />",
+                       $fieldName,
+                       $fieldName,
+                       $fieldValue
+               );
+
+               // And add it
+               $this->addContent($inputContent);
+       }
+
+       /**
+        * Add a hidden input tag to the form or throw an exception if it is not
+        * yet opened. The field's name will be set as id.
+        *
+        * @param       $fieldName                      Input field name
+        * @param       $fieldValue                     Input default value (default: empty)
+        * @return      void
+        * @throws      FormClosedException             If the form is not yet opened
+        */
+       public function addInputHiddenField ($fieldName, $fieldValue = "") {
+               // Is the form opened?
+               if ($this->formOpened === false) {
+                       // Throw an exception
+                       throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
+               }
+
+               // Generate the content
+               $inputContent = sprintf("<input type=\"hidden\" name=\"%s\" value=\"%s\" />",
+                       $fieldName,
+                       $fieldValue
+               );
+
+               // And add it
+               $this->addContent($inputContent);
+       }
+
+       /**
+        * Add a checkbox input tag to the form or throw an exception if it is not
+        * yet opened. The field's name will be set as id.
+        *
+        * @param       $fieldName                      Input field name
+        * @param       $fieldChecked           Wether the field is checked (defaut: checked)
+        * @return      void
+        * @throws      FormClosedException             If the form is not yet opened
+        */
+       public function addInputCheckboxField ($fieldName, $fieldChecked = true) {
+               // Is the form opened?
+               if ($this->formOpened === false) {
+                       // Throw an exception
+                       throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
+               }
+
+               // Set wether the check box is checked...
+               $checked = " checked=\"checked\"";
+               if ($fieldChecked === false) $checked = " ";
+
+               // Generate the content
+               $inputContent = sprintf("<input type=\"checkbox\" name=\"%s\" class=\"checkbox\" id=\"%s\" value=\"1\"%s/>",
+                       $fieldName,
+                       $fieldName,
+                       $checked
+               );
+
+               // And add it
+               $this->addContent($inputContent);
+       }
+
+       /**
+        * Add a reset input tag to the form or throw an exception if it is not
+        * yet opened. The field's name will be set as id.
+        *
+        * @param       $buttonText             Text displayed on the button
+        * @return      void
+        * @throws      FormClosedException             If the form is not yet opened
+        */
+       public function addInputResetButton ($buttonText) {
+               // Is the form opened?
+               if ($this->formOpened === false) {
+                       // Throw an exception
+                       throw new FormClosedException (array($this, "reset"), self::EXCEPTION_CLOSED_FORM);
+               }
+
+               // Generate the content
+               $inputContent = sprintf("<input type=\"reset\" class=\"reset_button\" id=\"%s_reset\" value=\"%s\" />",
+                       $this->formName,
+                       $buttonText
+               );
+
+               // And add it
+               $this->addContent($inputContent);
+       }
+
+       /**
+        * Add a reset input tag to the form or throw an exception if it is not
+        * yet opened. The field's name will be set as id.
+        *
+        * @param       $buttonText                     Text displayed on the button
+        * @return      void
+        * @throws      FormClosedException             If the form is not yet opened
+        */
+       public function addInputSubmitButton ($buttonText) {
+               // Is the form opened?
+               if ($this->formOpened === false) {
+                       // Throw an exception
+                       throw new FormClosedException (array($this, "submit"), self::EXCEPTION_CLOSED_FORM);
+               }
+
+               // Generate the content
+               $inputContent = sprintf("<input type=\"submit\" class=\"submit_button\" id=\"%s_submit\" name=\"%s_button\" value=\"%s\" />",
+                       $this->formName,
+                       $this->formName,
+                       $buttonText
+               );
+
+               // And add it
+               $this->addContent($inputContent);
+       }
+
+       /**
+        * Add a form group or close an already opened and open a new one
+        *
+        * @param       $groupName      Name of the group
+        * @param       $groupText      Text including HTML to show above this group
+        * @return      void
+        * @throws      FormClosedException             If no form has been opened before
+        * @throws      EmptyVariableException  If $groupName is not set
+        */
+       public function addFormGroup ($groupName, $groupText) {
+               // Is a form opened?
+               if ($this->formOpened === false) {
+                       // Throw exception here
+                       throw new FormClosedException(array($this, $groupName), self::EXCEPTION_CLOSED_FORM);
+               }
+
+               // At least the group name should be set
+               if ((empty($groupName)) && ($this->groupOpened === false)) {
+                       // Throw exception here
+                       throw new EmptyVariableException(array($this, 'groupName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               }
+
+               // Initialize content with closing div by default
+               $content = "    </div>\n</div><!-- Group - CLOSE //-->";
+
+               // Is this group opened?
+               if ($this->groupOpened === false) {
+                       // Begin the div/span blocks
+                       $content = sprintf("<!-- Group %s - OPEN //-->
+<div class=\"group_box\" id=\"%s_group_box\">
+       <span class=\"group_text\" id=\"%s_group_text\">
+               %s
+       </span>
+       <div class=\"group_field\" id=\"%s_group_field\">",
+                               $groupName,
+                               $groupName,
+                               $groupName,
+                               $groupText,
+                               $groupName
+                       );
+
+                       // Add the content
+                       $this->addContent($content);
+
+                       // Switch the state
+                       $this->groupOpened = true;
+               } else {
+                       // Is a sub group opened?
+                       if ($this->subGroupOpened === true) {
+                               // Close it here
+                               $this->addFormSubGroup("", "");
+                       }
+
+                       // Add the content
+                       $this->addContent($content);
+
+                       // Switch the state
+                       $this->groupOpened = false;
+
+                       // All call it again if the group name is not empty
+                       if (!empty($groupName)) {
+                               $this->addFormGroup($groupName, $groupText);
+                       }
+               }
+       }
+
+       /**
+        * 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.
+        *
+        * @param       $subGroupName   Name of the group
+        * @param       $subGroupText   Text including HTML to show above this group
+        * @return      void
+        * @throws      FormGroupClosedException        If no group has been opened before
+        * @throws      EmptyVariableException          If $subGroupName is not set
+        */
+       public function addFormSubGroup ($subGroupName, $subGroupText) {
+               // Is a group opened?
+               if ($this->groupOpened === false) {
+                       // Throw exception here
+                       throw new FormGroupClosedException(array($this, $subGroupName), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP);
+               }
+
+               // At least the sub group name should be set
+               if ((empty($subGroupName)) && ($this->subGroupOpened === false)) {
+                       // Throw exception here
+                       throw new EmptyVariableException(array($this, 'groupName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               }
+
+               // Initialize content with closing div by default
+               $content = "    </div>\n</div><!-- Sub group- CLOSE //-->";
+
+               // Is this group opened?
+               if ($this->subGroupOpened === false) {
+                       // Begin the span block
+                       $content = sprintf("<!-- Sub group %s - OPEN //-->
+<div class=\"subgroup_box\" id=\"%s_subgroup_box\">
+       <span class=\"subgroup_text\" id=\"%s_subgroup_text\">
+               %s
+       </span>
+       <div class=\"subgroup_field\" id=\"%s_subgroup_field\">",
+                               $subGroupName,
+                               $subGroupName,
+                               $subGroupName,
+                               $subGroupText,
+                               $subGroupName
+                       );
+
+                       // Add the content
+                       $this->addContent($content);
+
+                       // Switch the state and remeber the name
+                       $this->subGroupOpened = true;
+                       $this->subGroupName = $subGroupName;
+               } else {
+                       // Add the content
+                       $this->addContent($content);
+
+                       // Switch the state
+                       $this->subGroupOpened = false;
+
+                       // All call it again if sub group name is not empty
+                       if (!empty($subGroupName)) {
+                               $this->addFormSubGroup($subGroupName, $subGroupText);
+                       }
+               }
+       }
+
+       /**
+        * Add text surrounded by a span block when there is a group opened before
+        * or else by a div block.
+        *
+        * @param       $fieldName                      Field name
+        * @param       $fieldText                      Text for the field
+        * @return      void
+        * @throws      FormClosedException             If the form is not yet opened
+        */
+       public function addFieldText ($fieldName, $fieldText) {
+               // Is the form opened?
+               if ($this->formOpened === false) {
+                       // Throw an exception
+                       throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
+               }
+
+               // Set the block type
+               $block = "div";
+               if ($this->groupOpened === true) $block = "span";
+
+               // Generate the content
+               $inputContent = sprintf("       <%s id=\"%s_text\">
+               %s
+       </%s>",
+                       $block,
+                       $fieldName,
+                       $fieldText,
+                       $block
+               );
+
+               // And add it
+               $this->addContent($inputContent);
+       }
+
+       /**
+        * Add text (notes) surrounded by a div block. Still opened groups or sub
+        * groups will be automatically closed.
+        *
+        * @param       $formNotes      The form notes we shell addd
+        * @return      void
+        * @throws      FormClosedException             If the form is not yet opened
+        */
+       public function addFormNote ($formNotes) {
+               // Is the form opened?
+               if ($this->formOpened === false) {
+                       // Throw an exception
+                       throw new FormClosedException (array($this, "form_notes"), self::EXCEPTION_CLOSED_FORM);
+               }
+
+               // Is a group open?
+               if ($this->groupOpened === true) {
+                       // Then automatically close it here
+                       $this->addFormGroup("unknown", "");
+               }
+
+               // Generate the content
+               $inputContent = sprintf("       <div id=\"form_note\">
+               %s
+       </div>",
+                       $formNotes
+               );
+
+               // And add it
+               $this->addContent($inputContent);
+       }
+
+       /**
+        * Checks wether the registration requires a valid email address
+        *
+        * @return      $required       Wether the email address is required
+        */
+       public function ifRegisterRequiresEmailVerification () {
+               $required = ($this->getConfigInstance()->readConfig('register_requires_email') == "Y");
+               return $required;
+       }
+
+       /**
+        * Checks wether profile data shall be asked
+        *
+        * @return      $required       Wether profile shall be asked
+        */
+       public function ifRegisterIncludesProfile () {
+               $required = ($this->getConfigInstance()->readConfig('register_includes_profile') == "Y");
+               return $required;
+       }
+
+       /**
+        * Checks wether personal data shall be asked
+        *
+        * @return      $required       Wether personal data shall be asked
+        */
+       public function ifRegisterIncludesPersonaData () {
+               $required = ($this->getConfigInstance()->readConfig('register_personal_data') == "Y");
+               return $required;
+       }
+
+       /**
+        * Checks wether email addresses can only be once used
+        *
+        * @return      $isUnique
+        */
+       public function ifEmailMustBeUnique () {
+               $isUnique = ($this->getConfigInstance()->readConfig('register_email_unique') == "Y");
+               return $isUnique;
+       }
+
+       /**
+        * Checks wether the specified chat protocol is enabled in this form
+        *
+        * @return      $required       Wether the specified chat protocol is enabled
+        */
+       public function ifChatEnabled ($chatProtocol) {
+               $required = ($this->getConfigInstance()->readConfig(sprintf("chat_enabled_%s", $chatProtocol)) == "Y");
+               return $required;
+       }
+
+       /**
+        * Flushs the content out (not yet secured against open forms, etc.!) or
+        * throw an exception if it is not yet closed
+        *
+        * @return      void
+        * @throws      FormOpenedException             If the form is still open
+        */
+       public function flushContent () {
+               // Is the form still open?
+               if ($this->formOpened === true) {
+                       // Throw an exception
+                       throw new FormOpenedException ($this, self::EXCEPTION_OPENED_FORM);
+               }
+
+               // Send content to template engine
+               $this->getTemplateInstance()->assignVariable($this->formName, $this->getContent());
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/io/class_FileIOStream.php b/inc/classes/main/io/class_FileIOStream.php
deleted file mode 100644 (file)
index c983346..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-<?php
-/**
- * An universal class for file input/output streams.
- *
- * @author             Roland Haeder <webmaster@mxchange.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class FileIOStream extends BaseFrameworkSystem implements FileInputStreamer, FileOutputStreamer {
-       /**
-        * Protected constructor
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set part description
-               $this->setObjectDescription("Universal Datei-Ein-/Ausgabesystem");
-
-               // Create unique ID
-               $this->createUniqueID();
-
-               // Clean-up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
-       }
-
-       /**
-        * 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
-        */
-       public final static function createFileIOStream () {
-               // Create new instance
-               $ioInstance = new FileIOStream();
-
-               // Return the instance
-               return $ioInstance;
-       }
-
-       /**
-        * Saves data to a given local file
-        *
-        * @param               $fileName               The file name for the to be saved file
-        * @param               $dataArray      The data we shall store to the file
-        * @return      void
-        * @see         FileOutputStreamer
-        */
-       public final function saveFile ($fileName, $dataArray) {
-               // Try it five times
-               $dirName = ""; $fileInstance = null;
-               for ($idx = 0; $idx < 5; $idx++) {
-                       // Get a file output pointer
-                       try {
-                               $fileInstance = FrameworkFileOutputPointer::createFrameworkFileOutputPointer($fileName, 'w');
-                       } catch (FilePointerNotOpenedException $e) {
-                               // Create missing directory
-                               $dirName = dirname($fileName);
-                               for ($idx2 = 0; $idx2 < (2 - $idx); $idx2++) {
-                                       $dirName = dirname($dirName);
-                               }
-                               // Try to create it
-                               @mkdir($dirName);
-                       }
-               }
-
-               // Write a header information for validation purposes
-               $fileInstance->writeToFile(sprintf("@head^%s:%s:%s:%s\n",
-                       $dataArray[0],
-                       time(),
-                       strlen($dataArray[1]),
-                       md5($dataArray[1])
-               ));
-
-               // Encode the (maybe) binary stream with Base64
-               $b64Stream = base64_encode($dataArray[1]);
-
-               // write the data line by line
-               $line = str_repeat(" ", 50); $idx = 0;
-               while (strlen($line) == 50) {
-                       // Get 50 chars or less
-                       $line = substr($b64Stream, $idx, 50);
-
-                       // Save it to the stream
-                       $fileInstance->writeToFile(sprintf("@data^%s:%s\n",
-                               $line,
-                               md5($line)
-                       ));
-
-                       // Advance to the next 50-chars block
-                       $idx += 50;
-               }
-
-               // Close the file
-               $fileInstance->closeFile();
-       }
-
-       /**
-        * Reads from a local file
-        *
-        * @param               $fqfn   The full-qualified file-name which we shall load
-        * @return      $array  An array with the element 'header' and 'data'
-        * @see         FileInputStreamer
-        */
-       public final function loadFileContents ($fqfn) {
-               // Initialize some variables and arrays
-               $inputBuffer = "";
-               $lastBuffer = "";
-               $header = array();
-               $data = array();
-               $readData = ""; // This will contain our read data
-
-               // Get a file input handler
-               $fileInstance = FrameworkFileInputPointer::createFrameworkFileInputPointer($fqfn);
-
-               // Read all it's contents (we very and transparently decompress it below)
-               while ($readRawLine = $fileInstance->readFromFile()) {
-                       // Add the read line to the buffer
-                       $inputBuffer .= $readRawLine;
-
-                       // Break infinite loop maybe caused by the input handler
-                       if ($lastBuffer == $inputBuffer) break;
-
-                       // Remember last read line for avoiding possible infinite loops
-                       $lastBuffer = $inputBuffer;
-               }
-
-               // Close directory handle
-               $fileInstance->closeFile();
-
-               // Convert it into an array
-               $inputBuffer = explode("\n", $inputBuffer);
-
-               // Now process the read lines and verify it's content
-               foreach ($inputBuffer as $rawLine) {
-                       // Trim it a little but not the leading spaces/tab-stops
-                       $rawLine = rtrim($rawLine);
-
-                       // Analyze this line
-                       if (substr($rawLine, 0, 5) == "@head") {
-                               // Header found, so let's extract it
-                               $header = explode("^", $rawLine);
-                               $header = trim($header[1]);
-
-                               // Now we must convert it again into an array
-                               $header = explode(":", $header);
-
-                               // Is the header (maybe) valid?
-                               if (count($header) != 4) {
-                                       // Throw an exception
-                                       throw new InvalidArrayCountException(array($this, "header", count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
-                               }
-                       } elseif (substr($rawLine, 0, 5) == "@data") {
-                               // Is a data line!
-                               $data = explode("^", $rawLine);
-                               $data = $data[1];
-
-                               // First element is the data, second the MD5 checksum
-                               $data = explode(":", $data);
-
-                               // Validate the read line
-                               if (count($data) == 2) {
-                                       if (md5($data[0]) != $data[1]) {
-                                               // MD5 hash did not match!
-                                               throw new InvalidMD5ChecksumException(array($this, md5($data[0]), $data[1]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
-                                       }
-                               } else {
-                                       // Invalid count!
-                                       throw new InvalidArrayCountException(array($this, "data", count($data), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
-                               }
-
-                               // Add this to the readData string
-                               $readData .= $data[0];
-                       } else {
-                               // Other raw lines than header/data tagged lines and re-add the new-line char
-                               $readData .= $rawLine."\n";
-                       }
-               }
-
-               // Was raw lines read and no header/data?
-               if ((!empty($readData)) && (count($header) == 0) && (count($data) == 0)) {
-                       // Return raw lines back
-                       return $readData;
-               }
-
-               // Was a header found?
-               if (count($header) != 4) {
-                       // Throw an exception
-                       throw new InvalidArrayCountException(array($this, "header", count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
-               }
-
-               // Decode all from Base64
-               $readData = @base64_decode($readData);
-
-               // Does the size match?
-               if (strlen($readData) != $header[2]) {
-                       // Size did not match
-                       throw new InvalidDataLengthException(array($this, strlen($readData), $header[2]), self::EXCEPTION_UNEXPECTED_STRING_SIZE);
-               }
-
-               // Validate the decoded data with the final MD5 hash
-               if (md5($readData) != $header[3]) {
-                       // MD5 hash did not match!
-                       throw new InvalidMD5ChecksumException(array($this, md5($readData), $header[3]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
-               }
-
-               // Return all in an array
-               return array(
-                       'header' => $header,
-                       'data'   => $readData
-               );
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/io/class_FileIoStream.php b/inc/classes/main/io/class_FileIoStream.php
new file mode 100644 (file)
index 0000000..ee02a8d
--- /dev/null
@@ -0,0 +1,232 @@
+<?php
+/**
+ * An universal class for file input/output streams.
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, FileOutputStreamer {
+       /**
+        * Protected constructor
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Universal file I/O stream system");
+
+               // Create unique ID
+               $this->createUniqueID();
+
+               // Clean-up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * 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
+        */
+       public final static function createFileIoStream () {
+               // Create new instance
+               $ioInstance = new FileIoStream();
+
+               // Return the instance
+               return $ioInstance;
+       }
+
+       /**
+        * Saves data to a given local file
+        *
+        * @param               $fileName               The file name for the to be saved file
+        * @param               $dataArray      The data we shall store to the file
+        * @return      void
+        * @see         FileOutputStreamer
+        */
+       public final function saveFile ($fileName, $dataArray) {
+               // Try it five times
+               $dirName = ""; $fileInstance = null;
+               for ($idx = 0; $idx < 5; $idx++) {
+                       // Get a file output pointer
+                       try {
+                               $fileInstance = FrameworkFileOutputPointer::createFrameworkFileOutputPointer($fileName, 'w');
+                       } catch (FilePointerNotOpenedException $e) {
+                               // Create missing directory
+                               $dirName = dirname($fileName);
+                               for ($idx2 = 0; $idx2 < (2 - $idx); $idx2++) {
+                                       $dirName = dirname($dirName);
+                               }
+                               // Try to create it
+                               @mkdir($dirName);
+                       }
+               }
+
+               // Write a header information for validation purposes
+               $fileInstance->writeToFile(sprintf("@head^%s:%s:%s:%s\n",
+                       $dataArray[0],
+                       time(),
+                       strlen($dataArray[1]),
+                       md5($dataArray[1])
+               ));
+
+               // Encode the (maybe) binary stream with Base64
+               $b64Stream = base64_encode($dataArray[1]);
+
+               // write the data line by line
+               $line = str_repeat(" ", 50); $idx = 0;
+               while (strlen($line) == 50) {
+                       // Get 50 chars or less
+                       $line = substr($b64Stream, $idx, 50);
+
+                       // Save it to the stream
+                       $fileInstance->writeToFile(sprintf("@data^%s:%s\n",
+                               $line,
+                               md5($line)
+                       ));
+
+                       // Advance to the next 50-chars block
+                       $idx += 50;
+               }
+
+               // Close the file
+               $fileInstance->closeFile();
+       }
+
+       /**
+        * Reads from a local file
+        *
+        * @param               $fqfn   The full-qualified file-name which we shall load
+        * @return      $array  An array with the element 'header' and 'data'
+        * @see         FileInputStreamer
+        */
+       public final function loadFileContents ($fqfn) {
+               // Initialize some variables and arrays
+               $inputBuffer = "";
+               $lastBuffer = "";
+               $header = array();
+               $data = array();
+               $readData = ""; // This will contain our read data
+
+               // Get a file input handler
+               $fileInstance = FrameworkFileInputPointer::createFrameworkFileInputPointer($fqfn);
+
+               // Read all it's contents (we very and transparently decompress it below)
+               while ($readRawLine = $fileInstance->readFromFile()) {
+                       // Add the read line to the buffer
+                       $inputBuffer .= $readRawLine;
+
+                       // Break infinite loop maybe caused by the input handler
+                       if ($lastBuffer == $inputBuffer) break;
+
+                       // Remember last read line for avoiding possible infinite loops
+                       $lastBuffer = $inputBuffer;
+               }
+
+               // Close directory handle
+               $fileInstance->closeFile();
+
+               // Convert it into an array
+               $inputBuffer = explode("\n", $inputBuffer);
+
+               // Now process the read lines and verify it's content
+               foreach ($inputBuffer as $rawLine) {
+                       // Trim it a little but not the leading spaces/tab-stops
+                       $rawLine = rtrim($rawLine);
+
+                       // Analyze this line
+                       if (substr($rawLine, 0, 5) == "@head") {
+                               // Header found, so let's extract it
+                               $header = explode("^", $rawLine);
+                               $header = trim($header[1]);
+
+                               // Now we must convert it again into an array
+                               $header = explode(":", $header);
+
+                               // Is the header (maybe) valid?
+                               if (count($header) != 4) {
+                                       // Throw an exception
+                                       throw new InvalidArrayCountException(array($this, "header", count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+                               }
+                       } elseif (substr($rawLine, 0, 5) == "@data") {
+                               // Is a data line!
+                               $data = explode("^", $rawLine);
+                               $data = $data[1];
+
+                               // First element is the data, second the MD5 checksum
+                               $data = explode(":", $data);
+
+                               // Validate the read line
+                               if (count($data) == 2) {
+                                       if (md5($data[0]) != $data[1]) {
+                                               // MD5 hash did not match!
+                                               throw new InvalidMD5ChecksumException(array($this, md5($data[0]), $data[1]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
+                                       }
+                               } else {
+                                       // Invalid count!
+                                       throw new InvalidArrayCountException(array($this, "data", count($data), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+                               }
+
+                               // Add this to the readData string
+                               $readData .= $data[0];
+                       } else {
+                               // Other raw lines than header/data tagged lines and re-add the new-line char
+                               $readData .= $rawLine."\n";
+                       }
+               }
+
+               // Was raw lines read and no header/data?
+               if ((!empty($readData)) && (count($header) == 0) && (count($data) == 0)) {
+                       // Return raw lines back
+                       return $readData;
+               }
+
+               // Was a header found?
+               if (count($header) != 4) {
+                       // Throw an exception
+                       throw new InvalidArrayCountException(array($this, "header", count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+               }
+
+               // Decode all from Base64
+               $readData = @base64_decode($readData);
+
+               // Does the size match?
+               if (strlen($readData) != $header[2]) {
+                       // Size did not match
+                       throw new InvalidDataLengthException(array($this, strlen($readData), $header[2]), self::EXCEPTION_UNEXPECTED_STRING_SIZE);
+               }
+
+               // Validate the decoded data with the final MD5 hash
+               if (md5($readData) != $header[3]) {
+                       // MD5 hash did not match!
+                       throw new InvalidMD5ChecksumException(array($this, md5($readData), $header[3]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
+               }
+
+               // Return all in an array
+               return array(
+                       'header' => $header,
+                       'data'   => $readData
+               );
+       }
+}
+
+// [EOF]
+?>
index 5ad52ed709ec177ba36b7168d91f4a569aab0181..f05bfc0275ce80e1253ae610cc049fa5965f7f19 100644 (file)
@@ -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();
index a38b0a3d1d08e83270157aef05370ee931c9990f..b93c0026b50467832b6c5e81fd09816a442e7b4d 100644 (file)
@@ -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();
index 8cc07caaa78e8977afcc880e260611396aa08836..350cd7241afa6ae24b066ae7d78649292893076f 100644 (file)
@@ -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();
index 35db75c562c4a81abd44dac09078ed656249e1b7..73763676b8289b20d8b2d5b8815e9a5a83a93f6e 100644 (file)
@@ -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
@@ -101,7 +101,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage {
                $langInstance->initLanguageStrings();
 
                // Set language code from default config
-               $langInstance->setLanguageCode(FrameworkConfiguration::getInstance()->readConfig("default_lang"));
+               $langInstance->setLanguageCode(FrameworkConfiguration::getInstance()->readConfig('default_lang'));
 
                // Remember this instance
                self::$thisInstance = $langInstance;
@@ -120,26 +120,37 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage {
        }
 
        /**
-        * Initialize the array-object for all later language strings
+        * Setter for base path
         *
+        * @param               $basePath               The local base path for all templates
         * @return      void
         */
-       public function initLanguageStrings () {
-               $this->langStrings = new FrameworkArrayObject();
+       protected final function setBasePath ($basePath) {
+               // And set it
+               $this->basePath = (string) $basePath;
        }
 
        /**
-        * Setter for base path
+        * Setter for language code
         *
-        * @param               $basePath               The local base path for all templates
+        * @param               $langCode               The language code for the current application
         * @return      void
         */
-       public final function setBasePath ($basePath) {
+       protected final function setLanguageCode ($langCode) {
                // Cast it
-               $basePath = (string) $basePath;
+               $langCode = (string) $langCode;
 
-               // And set it
-               $this->basePath = $basePath;
+               // And set it (only 2 chars)
+               $this->langCode = substr($langCode, 0, 2);
+       }
+
+       /**
+        * Initialize the array-object for all later language strings
+        *
+        * @return      void
+        */
+       public function initLanguageStrings () {
+               $this->langStrings = new FrameworkArrayObject();
        }
 
        /**
@@ -152,17 +163,25 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage {
        }
 
        /**
-        * Setter for language code
+        * Get the plain message from the cache variable for the given message id
         *
-        * @param               $langCode               The language code for the current application
-        * @return      void
+        * @param       $messageId              The message id we shall find in the cache variable
+        * @return      $messageText    The plain message text
         */
-       public final function setLanguageCode ($langCode) {
-               // Cast it
-               $langCode = (string) $langCode;
+       public function getMessage ($messageId) {
+               // Default is missing message text
+               $messageText = sprintf("!%s!",
+                       $messageId
+               );
+
+               // Try to look it up in the cache variable
+               if ($this->langStrings->offsetExists($messageId)) {
+                       // Return the message string
+                       $messageText = $this->langStrings->offsetGet($messageId);
+               }
 
-               // And set it (only 2 chars)
-               $this->langCode = substr($langCode, 0, 2);
+               // Return the text
+               return $messageText;
        }
 }
 
index 5d2b1c13528ffd600544f6334dcdb0db0a9a1092..7eeb854eeb926fdb3e2be7e6a72c511dba91d21e 100644 (file)
@@ -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();
@@ -81,7 +81,7 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer {
         */
        public final static function getInstance() {
                if (is_null(self::$consoleInstance)) {
-                       $contentType = FrameworkConfiguration::getInstance()->readConfig("web_content_type");
+                       $contentType = FrameworkConfiguration::getInstance()->readConfig('web_content_type');
                        self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType);
                }
                return self::$consoleInstance;
index a687cea24ddacb6f1ddde77442573558e3f92035..b1eecc9f36ef37046556a9adeab8192c61d29c66 100644 (file)
@@ -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();
index 6826d76b71dbdeea91a4774103c4c03e65341252..b95bab1bbdb790dad06dc6e5ece4a94da4c847fc 100644 (file)
@@ -27,6 +27,13 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable {
         */
        private $requestData = array();
 
+       /**
+        * Wether this request is valid and can be further processed. The default is
+        * valid so make sure your intercepting filters sets this attribute to false
+        * when they need to intercept the data flow.
+        */
+       private $requestIsValid = true;
+
        /**
         * Protected constructor
         *
@@ -37,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();
@@ -145,6 +152,34 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable {
                // Return the value
                return $headerValue;
        }
+
+       /**
+        * Getter for request method. This getter might be useful for security filters
+        *
+        * @return      $requestMethod  Used request method
+        */
+       public final function getRequestMethod () {
+               return $_SERVER['REQUEST_METHOD'];
+       }
+
+       /**
+        * Sets wether the request was valid (default: true)
+        *
+        * @param       $isValid                Wether the request is valid
+        * @return      void
+        */
+       public final function requestIsValid ($isValid = true) {
+               $this->requestIsValid = (bool) $isValid;
+       }
+
+       /**
+        * Returns wether this request is valid
+        *
+        * @return      $requestIsValid         Wether this request is valid
+        */
+       public final function isRequestValid () {
+               return $this->requestIsValid;
+       }
 }
 
 // [EOF]
index d947d89e318df1e89495e419d8d9f3fa06088edb..9345109a8ac24b99b46e841dc6daf41cd6cd7f60 100644 (file)
@@ -32,6 +32,11 @@ class BaseResolver extends BaseFrameworkSystem {
         */
        private $commandPrefix = "";
 
+       /**
+        * A controller instance
+        */
+       private $controllerInstance = null;
+
        /**
         * Protected constructor
         *
@@ -42,9 +47,29 @@ class BaseResolver extends BaseFrameworkSystem {
                parent::__construct($class);
 
                // Clean up a little
+               $this->removeNumberFormaters();
                $this->removeSystemArray();
        }
 
+       /**
+        * Setter for controller instance (this surely breaks a bit the MVC patterm)
+        *
+        * @param       $controllerInstance             An instance of the controller
+        * @return      void
+        */
+       public final function setControllerInstance (Controller $controllerInstance) {
+               $this->controllerInstance = $controllerInstance;
+       }
+
+       /**
+        * Getter for controller instance (this surely breaks a bit the MVC patterm)
+        *
+        * @return      $controllerInstance             An instance of the controller
+        */
+       public final function getControllerInstance () {
+               return $this->controllerInstance;
+       }
+
        /**
         * Setter for command name
         *
@@ -94,7 +119,7 @@ class BaseResolver extends BaseFrameworkSystem {
                // Now, let us create the full name of the command class
                $class = sprintf("%s%sCommand",
                        $this->commandPrefix,
-                       ucfirst(strtolower($commandName))
+                       $this->convertToClassName($commandName)
                );
 
                // Is this class already loaded?
@@ -103,6 +128,13 @@ class BaseResolver extends BaseFrameworkSystem {
                        $isValid = true;
                }
 
+               // Debug output
+               //echo "<strong>----- ".__METHOD__." -----</strong><br />\n";
+               //print($class."<pre>");
+               //debug_print_backtrace();
+               //var_dump($isValid);
+               //print("</pre>");
+
                // Set command name
                $this->setCommandName($commandName);
 
diff --git a/inc/classes/main/resolver/local/.htaccess b/inc/classes/main/resolver/local/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/inc/classes/main/resolver/local/class_LocalCommandResolver.php b/inc/classes/main/resolver/local/class_LocalCommandResolver.php
deleted file mode 100644 (file)
index 87e0d69..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-<?php
-/**
- * A command resolver for local (non-hubbed) commands
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class LocalCommandResolver extends BaseResolver implements CommandResolver {
-       /**
-        * Last successfull resolved command
-        */
-       private $lastCommandInstance = "";
-
-       /**
-        * Private constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set part description
-               $this->setObjectDescription("Lokaler Kommandoaufl&ouml;ser");
-
-               // Create unique ID number
-               $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
-
-               // Set prefix to "Local"
-               $this->setCommandPrefix("Local");
-       }
-
-       /**
-        * Creates an instance of a local command resolver with a given default command
-        *
-        * @param       $defaultCommand                         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 createLocalCommandResolver ($defaultCommand, ManageableApplication $appInstance) {
-               // Create the new instance
-               $resolverInstance = new LocalCommandResolver();
-
-               // Is the variable $defaultCommand set and the command is valid?
-               if (empty($defaultCommand)) {
-                       // Then thrown an exception here
-                       throw new EmptyVariableException(array($resolverInstance, 'defaultCommand'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!$resolverInstance->isCommandValid($defaultCommand)) {
-                       // Invalid command found
-                       throw new InvalidCommandException(array($resolverInstance, $defaultCommand), 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
-        * MissingArrayElementsException was thrown
-        *
-        * @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 resolvCommandByRequest (Requestable $requestInstance) {
-               // Init variables
-               $commandName = "";
-               $commandInstance = null;
-
-               // Test if the required parameter is set
-               try {
-                       // This goes fine so let's resolv the command
-                       $commandName = $requestInstance->getRequestElement($this->getConfigInstance()->readConfig("command_parameter"));
-
-                       // Is the command empty? Then fall back to default command
-                       if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig("default_command");
-
-                       // Check if the command is valid
-                       if (!$this->isCommandValid($commandName)) {
-                               // This command is invalid!
-                               throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
-                       }
-
-                       // 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);
-                       }
-
-                       // Set last command
-                       $this->lastCommandInstance = $commandInstance;
-               } catch (MissingArrayElementsException $e) {
-                       // Just catch it here...
-               }
-
-               // Return the resolved command 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_command");
-
-               // Init command instance
-               $commandInstance = null;
-
-               // Create command class name
-               $class = sprintf("Local%sCommand",
-                       ucfirst(strtolower($commandName))
-               );
-
-               // Is this class loaded?
-               if (!class_exists($class)) {
-                       // Class not found, so try the default one or throw exception
-                       if ($commandName != $defaultCommand) {
-                               // Try the default command
-                               return $this->loadCommand($defaultCommand);
-                       } else {
-                               // Still not found?
-                               throw new InvalidCommandException(array($this, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
-                       }
-               }
-
-               // Initiate the command
-               $eval = sprintf("\$commandInstance = %s::create%s(\$this);",
-                       $class,
-                       $class
-               );
-
-               // Run the command
-               eval($eval);
-
-               // Is the instance valid?
-               if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
-                       // Something is wrong
-                       $commandInstance = null;
-               }
-
-               // Return the result
-               return $commandInstance;
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/resolver/local/class_LocalControllerResolver.php b/inc/classes/main/resolver/local/class_LocalControllerResolver.php
deleted file mode 100644 (file)
index 9c94209..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-<?php
-/**
- * A resolver for resolving controllers locally
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class LocalControllerResolver extends BaseResolver implements ControllerResolver {
-       /**
-        * Last successfull resolved controller
-        */
-       private $lastControllerName = "";
-
-       /**
-        * Private constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set part description
-               $this->setObjectDescription("");
-
-               // Create unique ID number
-               $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
-
-               // Set prefix to "Local"
-               $this->setCommandPrefix("Local");
-       }
-
-       /**
-        * Creates an instance of a resolver class with a given 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 createLocalControllerResolver ($commandName, ManageableApplication $appInstance) {
-               // Create the new instance
-               $resolverInstance = new LocalControllerResolver();
-
-               // 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)) {
-                       // 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;
-       }
-
-       /**
-        * Resolves the default controller of the given command
-        *
-        * @return      $controllerInstance             A controller instance for the default
-        *                                                                      command
-        * @throws      InvalidCommandException                         Thrown if $commandName is
-        *                                                                                              invalid
-        * @throws      InvalidControllerInstanceException      Thrown if $commandInstance
-        *                                                                                              is invalid
-        */
-       public function resolveDefaultController () {
-               // Init variables
-               $commandName = "";
-               $controllerInstance = null;
-
-               // Try to resolv the command
-               try {
-                       // Get the command name 
-                       $commandName = $this->getCommandName();
-
-                       // Check if the command is valid
-                       if (!$this->isCommandValid($commandName)) {
-                               // This command is invalid!
-                               throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
-                       }
-
-                       // Get the command
-                       $controllerInstance = $this->loadController($commandName);
-
-                       // And validate it
-                       if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
-                               // This command has an invalid instance!
-                               throw new InvalidControllerInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_CONTROLLER);
-                       }
-
-                       // Set last command
-                       $this->lastCommandInstance = $controllerInstance;
-               } catch (MissingArrayElementsException $e) {
-                       // Just catch it here...
-               }
-
-               // Return the maybe resolved instance
-               return $controllerInstance;
-       }
-
-       /**
-        * "Loads" a given controller and instances it if not yet cached
-        *
-        * @param       $commandName                    A controller name we shall look for
-        * @return      $controllerInstance             A loaded controller instance
-        * @throws      DefaultControllerException      Thrown if even the default
-        *                                                                              controller class is missing (bad!)
-        */
-       private function loadController ($commandName) {
-               // Cache default command
-               $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
-
-               // Init controller instance
-               $controllerInstance = null;
-
-               // Default controller
-               $class = "LocalDefaultController";
-
-               // Generate the class name
-               if ($commandName != $defaultCommand) {
-                       // Create controller class name
-                       $class = sprintf("Local%sController",
-                               ucfirst(strtolower($commandName))
-                       );
-               } elseif ($this->getConfigInstance()->readConfig("home_with_news") == "Y") {
-                       // Yes, display news in home then set default controller with news
-                       $class = "LocalDefaultNewsController";
-               }
-
-               // Is this class loaded?
-               if (!class_exists($class)) {
-                       // Class not found, so try the default one or throw exception
-                       if ($commandName != $defaultCommand) {
-                               // Try the default controller
-                               return $this->loadController($defaultCommand);
-                       } else {
-                               // Still not found?
-                               throw new DefaultControllerException($this, self::EXCEPTION_DEFAUL_CONTROLLER_GONE);
-                       }
-               }
-
-               // Initiate the controller
-               $eval = sprintf("\$controllerInstance = %s::create%s(LocalCommandResolver::createLocalCommandResolver(\$commandName, \$this->getApplicationInstance()));",
-                       $class,
-                       $class
-               );
-
-               // Run the command
-               eval($eval);
-
-               // Is the instance valid?
-               if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
-                       // Something is wrong
-                       $controllerInstance = null;
-               }
-
-               // Return the result
-               return $controllerInstance;
-       }
-}
-
-// [EOF]
-?>
index 2ab4e50035275e81cff71b98f26c6673a72d4dad..47baef47bfc4cceabea389d6e49aa602e24413cd 100644 (file)
@@ -37,15 +37,11 @@ class WebCommandResolver extends BaseResolver implements CommandResolver {
                parent::__construct(__CLASS__);
 
                // Set part description
-               $this->setObjectDescription("Lokaler Kommandoaufl&ouml;ser");
+               $this->setObjectDescription("Resolver for local web commands");
 
                // Create unique ID number
                $this->createUniqueID();
 
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
-
                // Set prefix to "Web"
                $this->setCommandPrefix("Web");
        }
@@ -53,23 +49,23 @@ class WebCommandResolver extends BaseResolver implements CommandResolver {
        /**
         * Creates an instance of a Web command resolver with a given default command
         *
-        * @param       $defaultCommand                         The default command we shall execute
+        * @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 createWebCommandResolver ($defaultCommand, ManageableApplication $appInstance) {
+       public final static function createWebCommandResolver ($commandName, ManageableApplication $appInstance) {
                // Create the new instance
                $resolverInstance = new WebCommandResolver();
 
-               // Is the variable $defaultCommand set and the command is valid?
-               if (empty($defaultCommand)) {
+               // Is the variable $commandName set and the command is valid?
+               if (empty($commandName)) {
                        // Then thrown an exception here
                        throw new EmptyVariableException(array($resolverInstance, 'defaultCommand'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!$resolverInstance->isCommandValid($defaultCommand)) {
+               } elseif (!$resolverInstance->isCommandValid($commandName)) {
                        // Invalid command found
-                       throw new InvalidCommandException(array($resolverInstance, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
+                       throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
                }
 
                // Set the application instance
@@ -98,10 +94,10 @@ class WebCommandResolver extends BaseResolver implements CommandResolver {
                // Test if the required parameter is set
                try {
                        // This goes fine so let's resolv the command
-                       $commandName = $requestInstance->getRequestElement($this->getConfigInstance()->readConfig("command_parameter"));
+                       $commandName = $requestInstance->getRequestElement($this->getConfigInstance()->readConfig('command_parameter'));
 
                        // Is the command empty? Then fall back to default command
-                       if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig("default_command");
+                       if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_command');
 
                        // Check if the command is valid
                        if (!$this->isCommandValid($commandName)) {
@@ -128,6 +124,33 @@ class WebCommandResolver extends BaseResolver implements CommandResolver {
                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_command');
+
+               // Check if the command is valid
+               if (!$this->isCommandValid($commandName)) {
+                       // 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
         *
@@ -138,18 +161,18 @@ class WebCommandResolver extends BaseResolver implements CommandResolver {
         */
        private function loadCommand ($commandName) {
                // Cache default command
-               $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
+               $defaultCommand = $this->getConfigInstance()->readConfig('default_command');
 
                // Init command instance
                $commandInstance = null;
 
                // Create command class name
-               $class = sprintf("Web%sCommand",
-                       ucfirst(strtolower($commandName))
+               $className = sprintf("Web%sCommand",
+                       $this->convertToClassName($commandName)
                );
 
                // Is this class loaded?
-               if (!class_exists($class)) {
+               if (!class_exists($className)) {
                        // Class not found, so try the default one or throw exception
                        if ($commandName != $defaultCommand) {
                                // Try the default command
@@ -162,8 +185,8 @@ class WebCommandResolver extends BaseResolver implements CommandResolver {
 
                // Initiate the command
                $eval = sprintf("\$commandInstance = %s::create%s(\$this);",
-                       $class,
-                       $class
+                       $className,
+                       $className
                );
 
                // Run the command
index 16ad0c2c40dbbbcbfa2e7a46eeb7b352cbd6a97b..9e50d94516dfe8a99b592f7a8a73b33257257eaa 100644 (file)
  */
 class WebControllerResolver extends BaseResolver implements ControllerResolver {
        /**
-        * Last successfull resolved controller
+        * Last successfull resolved controller (name)
         */
        private $lastControllerName = "";
 
+       /**
+        * Last successfull resolved controller (instance)
+        */
+       private $lastControllerInstance = null;
+
        /**
         * Protected constructor
         *
@@ -37,15 +42,11 @@ 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();
 
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
-
                // Set prefix to "Web"
                $this->setCommandPrefix("Web");
        }
@@ -89,7 +90,7 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
         * @throws      InvalidControllerInstanceException      Thrown if $commandInstance
         *                                                                                              is invalid
         */
-       public function resolveDefaultController () {
+       public function resolveCommandController () {
                // Init variables
                $commandName = "";
                $controllerInstance = null;
@@ -114,8 +115,8 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
                                throw new InvalidControllerInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_CONTROLLER);
                        }
 
-                       // Set last command
-                       $this->lastCommandInstance = $controllerInstance;
+                       // Set last controller
+                       $this->lastControllerInstance = $controllerInstance;
                } catch (MissingArrayElementsException $e) {
                        // Just catch it here...
                }
@@ -133,8 +134,14 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
         *                                                                              controller class is missing (bad!)
         */
        private function loadController ($commandName) {
+                // Debug message
+                //print("<strong>----- ".__METHOD__." -----</strong><pre>");
+                //debug_print_backtrace();
+                //print("</pre>");
+                //
+
                // Cache default command
-               $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
+               $defaultCommand = $this->getConfigInstance()->readConfig('default_command');
 
                // Init controller instance
                $controllerInstance = null;
@@ -146,11 +153,14 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
                if ($commandName != $defaultCommand) {
                        // Create controller class name
                        $class = sprintf("Web%sController",
-                               ucfirst(strtolower($commandName))
+                               $this->convertToClassName($commandName)
                        );
-               } elseif ($this->getConfigInstance()->readConfig("home_with_news") == "Y") {
+               } elseif ($this->getConfigInstance()->readConfig('home_with_news') == "Y") {
                        // Yes, display news in home then set default controller with news
                        $class = "WebDefaultNewsController";
+               } else {
+                       // No nes at "home" page
+                       $class = "WebDefaultController";
                }
 
                // Is this class loaded?
index 8172191acf66aedd2b36cacce1658213a4b82c00..52ad2a76db0ad226d10c7312a8e3ec5445d6e769 100644 (file)
@@ -45,6 +45,11 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable {
         */
        private $templateEngine = null;
 
+       /**
+        * Fatal resolved messages from filters and so on
+        */
+       private $fatalMessages = array();
+
        /**
         * Protected constructor
         *
@@ -55,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();
@@ -75,6 +80,9 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable {
                // Get a new instance
                $responseInstance = new HttpResponse();
 
+               // Set the application instance
+               $responseInstance->setApplicationInstance($appInstance);
+
                // Initialize the template engine here
                $responseInstance->initTemplateEngine($appInstance);
 
@@ -103,6 +111,15 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable {
                $this->responseHeaders[$name] = $value;
        }
 
+       /**
+        * Reset the header array
+        *
+        * @return      void
+        */
+       public final function resetResponseHeaders () {
+               $this->responseHeaders = array();
+       }
+
        /**
         * "Writes" data to the response body
         *
@@ -113,6 +130,16 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable {
                $this->responseBody .= $output;
        }
 
+       /**
+        * Sets the response body to something new
+        *
+        * @param       $output         Output we shall sent in the HTTP response
+        * @return      void
+        */
+       public function setReponseBody ($output) {
+               $this->responseBody = $output;
+       }
+
        /**
         * Flushs the cached HTTP response to the outer world
         *
@@ -128,7 +155,7 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable {
                        throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
                } elseif (!headers_sent()) {
                        // Send headers out
-                       header("HTTP/1.0 {$this->responseStatus}");
+                       header("HTTP/1.1 {$this->responseStatus}");
 
                        // Used later
                        $now = gmdate('D, d M Y H:i:s') . ' GMT';
@@ -147,10 +174,21 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable {
                        }
                }
 
-               // Flush the output to the world
-               $this->getWebOutputInstance()->output($this->responseBody);
-               $this->reponseBody = "";
-               $this->responseHeaders = array();
+               // Are there some error messages?
+               if (count($this->fatalMessages) == 0) {
+                       // Flush the output to the world
+                       $this->getWebOutputInstance()->output($this->responseBody);
+               } else {
+                       // Display all error messages
+                       $this->getApplicationInstance()->handleFatalMessages($this->fatalMessages);
+
+                       // Send the error messages out to the world
+                       $this->getWebOutputInstance()->output($this->responseBody);
+               }
+
+               // Clear response header and body
+               $this->setReponseBody("");
+               $this->resetResponseHeaders();
        }
 
        /**
@@ -171,6 +209,18 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable {
        public final function getTemplateEngine () {
                return $this->templateEngine;
        }
+
+       /**
+        * Adds a fatal message id to the response. The added messages can then be
+        * processed and outputed to the world
+        *
+        * @param       $messageId      The message id we shall add
+        * @return      void
+        */
+       public final function addFatalMessage ($messageId) {
+               // Adds the resolved message id to the fatal message list
+               $this->fatalMessages[] = $this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId);
+       }
 }
 
 // [EOF]
index 4c1500625a55fdf0b5d297927517d569997b9308..412d26ac442936a6847cf3a32392c73eb3827a53 100644 (file)
@@ -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();
@@ -138,7 +138,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         *
         * @param       $basePath               The local base path for all templates
         * @param       $langInstance   An instance of LanguageSystem (default)
-        * @param       $ioInstance             An instance of FileIOHandler (default, middleware!)
+        * @param       $ioInstance             An instance of FileIoHandler (default, middleware!)
         * @return      $tplInstance    An instance of TemplateEngine
         * @throws      BasePathIsEmptyException                If the provided $basePath is empty
         * @throws      InvalidBasePathStringException  If $basePath is no string
@@ -147,7 +147,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         * @throws      BasePathReadProtectedException  If $basePath is
         *                                                                                      read-protected
         */
-       public final static function createTemplateEngine ($basePath, ManageableLanguage  $langInstance, FileIOHandler $ioInstance) {
+       public final static function createTemplateEngine ($basePath, ManageableLanguage  $langInstance, FileIoHandler $ioInstance) {
                // Get a new instance
                $tplInstance = new TemplateEngine();
 
@@ -177,14 +177,14 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
 
                // Set the language and IO instances
                $tplInstance->setLanguageInstance($langInstance);
-               $tplInstance->setFileIOInstance($ioInstance);
+               $tplInstance->setFileIoInstance($ioInstance);
 
                // Set template extensions
-               $tplInstance->setRawTemplateExtension($cfgInstance->readConfig("raw_template_extension"));
-               $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig("code_template_extension"));
+               $tplInstance->setRawTemplateExtension($cfgInstance->readConfig('raw_template_extension'));
+               $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig('code_template_extension'));
 
                // Absolute output path for compiled templates
-               $tplInstance->setCompileOutputPath(PATH . $cfgInstance->readConfig("compile_output_path"));
+               $tplInstance->setCompileOutputPath(PATH . $cfgInstance->readConfig('compile_output_path'));
 
                // Return the prepared instance
                return $tplInstance;
@@ -518,7 +518,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                $ext = $this->getRawTemplateExtension();
 
                // If we shall load a code-template we need to switch the file extension
-               if ($this->getTemplateType() == $this->getConfigInstance()->readConfig("code_template_type")) {
+               if ($this->getTemplateType() == $this->getConfigInstance()->readConfig('code_template_type')) {
                        // Switch over to the code-template extension
                        $ext = $this->getCodeTemplateExtension();
                }
@@ -548,7 +548,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         */
        private function loadRawTemplateData ($fqfn) {
                // Get a input/output instance from the middleware
-               $ioInstance = $this->getFileIOInstance();
+               $ioInstance = $this->getFileIoInstance();
 
                // Validate the instance
                if (is_null($ioInstance)) {
@@ -596,9 +596,6 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         *
         * @param       $rawData        The raw template data we shall analyze
         * @return      void
-        * @throws      InvalidTemplateVariableNameException    If a variable name
-        *                                                                                                      in a template is
-        *                                                                                                      invalid
         */
        private function extractVariablesFromRawData ($rawData) {
                // Cast to string
@@ -611,12 +608,6 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) {
                        // Initialize all missing variables
                        foreach ($variableMatches[3] as $key=>$var) {
-                               // Is the variable name valid?
-                               if (($variableMatches[1][$key] != $this->getConfigInstance()->readConfig("tpl_valid_var")) && ($variableMatches[1][$key] != "config")) {
-                                       // Invalid variable name
-                                       throw new InvalidTemplateVariableNameException(array($this, $this->getLastTemplate(), $variableMatches[1][$key], $this->getConfigInstance()), self::EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR);
-                               }
-
                                // Try to assign it, empty strings are being ignored
                                $this->assignTemplateVariable($variableMatches[1][$key], $var);
                        }
@@ -651,24 +642,24 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        // RECURSIVE PROTECTION! BE CAREFUL HERE!
                        if ((!isset($this->loadedRawData[$template])) && (!in_array($template, $this->loadedTemplates))) {
 
-                               // Then try to search for code-templates first
-                               try {
-                                       // Load the code template and remember it's contents
-                                       $this->loadCodeTemplate($template);
-                                       $this->loadedRawData[$template] = $this->getRawTemplateData();
+                               // Template not found, but maybe variable assigned?
+                               if ($this->isVariableAlreadySet($template) !== false) {
+                                       // Use that content here
+                                       $this->loadedRawData[$template] = $this->readVariable($template);
 
-                                       // Remember this template for recursion detection
-                                       // RECURSIVE PROTECTION!
+                                       // Recursive protection:
                                        $this->loadedTemplates[] = $template;
-                               } catch (FilePointerNotOpenedException $e) {
-                                       // Template not found, but maybe variable assigned?
-                                       if ($this->isVariableAlreadySet($template) !== false) {
-                                               // Use that content here
-                                               $this->loadedRawData[$template] = $this->readVariable($template);
-
-                                               // Recursive protection:
+                               } else {
+                                       // Then try to search for code-templates
+                                       try {
+                                               // Load the code template and remember it's contents
+                                               $this->loadCodeTemplate($template);
+                                               $this->loadedRawData[$template] = $this->getRawTemplateData();
+
+                                               // Remember this template for recursion detection
+                                               // RECURSIVE PROTECTION!
                                                $this->loadedTemplates[] = $template;
-                                       } else {
+                                       } catch (FilePointerNotOpenedException $e) {
                                                // Even this is not done... :/
                                                $this->rawTemplates[] = $template;
                                        }
@@ -914,7 +905,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         */
        public final function loadWebTemplate ($template) {
                // Set template type
-               $this->setTemplateType($this->getConfigInstance()->readConfig("web_template_type"));
+               $this->setTemplateType($this->getConfigInstance()->readConfig('web_template_type'));
 
                // Load the special template
                $this->loadTemplate($template);
@@ -929,7 +920,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         */
        public final function loadEmailTemplate ($template) {
                // Set template type
-               $this->setTemplateType($this->getConfigInstance()->readConfig("email_template_type"));
+               $this->setTemplateType($this->getConfigInstance()->readConfig('email_template_type'));
 
                // Load the special template
                $this->loadTemplate($template);
@@ -944,7 +935,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         */
        public final function loadCodeTemplate ($template) {
                // Set template type
-               $this->setTemplateType($this->getConfigInstance()->readConfig("code_template_type"));
+               $this->setTemplateType($this->getConfigInstance()->readConfig('code_template_type'));
 
                // Load the special template
                $this->loadTemplate($template);
@@ -957,7 +948,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         */
        public final function compileVariables () {
                // Initialize the $content array
-               $validVar = $this->getConfigInstance()->readConfig("tpl_valid_var");
+               $validVar = $this->getConfigInstance()->readConfig('tpl_valid_var');
                $dummy = array();
 
                // Iterate through all variables
@@ -982,22 +973,64 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                unset($idx);
                unset($currVariable);
 
-               // Finalize the compilation of template variables
-               $this->finalizeVariableCompilation();
+               // Run the compilation twice to get content from helper classes in
+               $cnt = 0;
+               while ($cnt < 3) {
+                       // Finalize the compilation of template variables
+                       $this->finalizeVariableCompilation();
 
-               // Prepare the eval() command for comiling the template
-               $eval = sprintf("\$result = \"%s\";",
-                       addslashes($this->getRawTemplateData())
-               );
+                       // Prepare the eval() command for comiling the template
+                       $eval = sprintf("\$result = \"%s\";",
+                               addslashes($this->getRawTemplateData())
+                       );
 
-               // Debug message
-               if ((defined('DEBUG_EVAL')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command: <pre><em>%s</em></pre><br />\n",
-                       $this->__toString(),
-                       htmlentities($eval)
-               ));
+                       // This loop does remove the backslashes (\) in PHP parameters
+                       // @TODO Make this some nicer...
+                       while (strpos($eval, "<?") !== false) {
+                               // Get left part before "<?"
+                               $evalLeft = substr($eval, 0, strpos($eval, "<?"));
+
+                               // Get all from right of "<?"
+                               $evalRight = substr($eval, (strpos($eval, "<?") + 2));
+
+                               // Is this a full PHP tag?
+                               if (substr(strtolower($evalRight), 0, 3) == "php") {
+                                       // Remove "php" string from full PHP tag
+                                       $evalRight = substr($evalRight, 3);
+                               } // END - if
+
+                               // Cut middle part out and remove escapes
+                               $evalMiddle = trim(substr($evalRight, 0, strpos($evalRight, "?>")));
+                               $evalMiddle = stripslashes($evalMiddle);
+
+                               // Remove the middle part from right one
+                               $evalRight = substr($evalRight, (strpos($evalRight, "?>") + 2));
+
+                               // And put all together
+                               $eval = sprintf("%s<%%php %s %%>%s", $evalLeft, $evalMiddle, $evalRight);
+                       } // END - while
+
+                       // Prepare PHP code for eval() command
+                       $eval = str_replace(
+                               "<%php", "\";",
+                               str_replace(
+                                       "%>", "\$result .= \"", $eval
+                               )
+                       );
+
+                       // Debug message
+                       if ((defined('DEBUG_EVAL')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command: <pre><em>%s</em></pre><br />\n",
+                               $this->__toString(),
+                               htmlentities($eval)
+                       ));
+
+                       // Run the constructed command. This will "compile" all variables in
+                       eval($eval);
 
-               // Run the constructed command. This will "compile" all variables in
-               eval($eval);
+                       // Set raw template data
+                       $this->setRawTemplateData($result);
+                       $cnt++;
+               }
 
                // Set the new content
                $this->setCompiledData($result);
@@ -1008,15 +1041,15 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         *
         * @return      void
         * @throws      UnexpectedTemplateTypeException If the template type is
-        *                                                                              not "code"
+        *                                                                                      not "code"
         * @throws      InvalidArrayCountException              If an unexpected array
-        *                                                                              count has been found
+        *                                                                                      count has been found
         */
        public final function compileTemplate () {
                // We will only work with template type "code" from configuration
-               if ($this->getTemplateType() != $this->getConfigInstance()->readConfig("code_template_type")) {
+               if ($this->getTemplateType() != $this->getConfigInstance()->readConfig('code_template_type')) {
                        // Abort here
-                       throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->readConfig("code_template_type")), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED);
+                       throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->readConfig('code_template_type')), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED);
                } // END - if
 
                // Get the raw data.
@@ -1158,6 +1191,23 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                // Get the content and set it in the response class
                $responseInstance->writeToBody($this->getCompiledData());
        }
+
+       /**
+        * Assigns all the application data with template variables
+        *
+        * @param       $appInstance    A manageable application instance
+        * @return      void
+        */
+       public function assignApplicationData (ManageableApplication $appInstance) {
+               // Get long name and assign it
+               $this->assignVariable("app_full_name" , $appInstance->getAppName());
+
+               // Get short name and assign it
+               $this->assignVariable("app_short_name", $appInstance->getAppShortName());
+
+               // Get version number and assign it
+               $this->assignVariable("app_version"   , $appInstance->getAppVersion());
+       }
 }
 
 // [EOF]
diff --git a/inc/classes/main/user/.htaccess b/inc/classes/main/user/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..53e8b46
--- /dev/null
@@ -0,0 +1,103 @@
+<?php
+/**
+ * A generic class for handling users
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index fd04ac118bdc9bde22430a9bd6faf09c4e096a4e..1b33041fd86b45946f8f2c8ca801f818e38fe4af 100644 (file)
@@ -55,7 +55,7 @@ class CompressorChannel extends BaseMiddleware {
                        // Read all directories but no sub directories
                        while ($dir = $dirPointer->readDirectoryExcept(array("..", ".", ".htaccess"))) {
                                // Is this a class file?
-                               if ((substr($dir, 0, 6) == "class_") && (substr($dir, -4, 4) == FrameworkConfiguration::getInstance()->readConfig("php_extension"))) {
+                               if ((substr($dir, 0, 6) == "class_") && (substr($dir, -4, 4) == FrameworkConfiguration::getInstance()->readConfig('php_extension'))) {
                                        // Get the compressor's name. That's why you must name
                                        // your files like your classes and also that's why you
                                        // must keep on class in one file.
diff --git a/inc/classes/middleware/io/class_FileIOHandler.php b/inc/classes/middleware/io/class_FileIOHandler.php
deleted file mode 100644 (file)
index 8c7a47a..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-<?php
-/**
- * This is a file IO handler. It handles reading from and writing to files.
- * Missing paths in writing process will be automatically created.
- *
- * @author             Roland Haeder <webmaster@mxchange.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class FileIOHandler extends BaseMiddleware {
-       /**
-        * The *real* file input class we shall use for reading data
-        */
-       private $inputStream = null;
-
-       /**
-        * The *real* file output class we shall use for reading data
-        */
-       private $outputStream = null;
-
-       /**
-        * An instance of this class
-        */
-       private static $thisInstance = null;
-
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set description
-               $this->setObjectDescription("Datei-Ein-/Ausgabe-Handler");
-
-               // Create an unique ID
-               $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
-
-               // Set own instance
-               self::$thisInstance = $this;
-       }
-
-       /**
-        * Creates an instance of this class and prepares the IO system. This is
-        * being done by setting the default file IO class
-        *
-        * @return      $ioInstance     A prepared instance of FilIOHandler
-        */
-       public final static function createFileIOHandler () {
-               // Get instance
-               $ioHandler = new FileIOHandler();
-
-               // Set the *real* file IO instances (both the same)
-               $ioHandler->setInputStream(FileIOStream::createFileIOStream());
-               $ioHandler->setOutputStream(FileIOStream::createFileIOStream());
-
-               // Return instance
-               return $ioHandler;
-       }
-
-       /**
-        * Getter for an instance of this class
-        *
-        * @return      $thisInstance   An instance of this class
-        */
-       public final static function getInstance () {
-               return self::$thisInstance;
-       }
-
-       /**
-        * Setter for the *real* file input instance
-        *
-        * @param               $inputStream    The *real* file-input class
-        */
-       public final function setInputStream (FileInputStreamer $inputStream) {
-               $this->inputStream = $inputStream;
-       }
-
-       /**
-        * Getter for the *real* file input instance
-        *
-        * @return      $inputStream    The *real* file-input class
-        */
-       public final function getInputStream () {
-               return $this->inputStream;
-       }
-
-       /**
-        * Setter for the *real* file output instance
-        *
-        * @param               $outputStream   The *real* file-output class
-        */
-       public final function setOutputStream (FileOutputStreamer $outputStream) {
-               $this->outputStream = $outputStream;
-       }
-
-       /**
-        * Getter for the *real* file output instance
-        *
-        * @return      $outputStream   The *real* file-output class
-        */
-       public final function getOutputStream () {
-               return $this->outputStream;
-       }
-
-       /**
-        * Saves a file with data by using the current output stream
-        *
-        * @see FileOutputStreamer
-        */
-       public function saveFile ($fileName, $dataArray) {
-               // Get output stream
-               $outInstance = $this->getOutputStream();
-
-               // Is it a valid stream?
-               if (is_null($outInstance)) {
-                       // No class returned
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($outInstance)) {
-                       // Not an object! ;-(
-                       throw new NoObjectException($outInstance, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($outInstance, 'saveFile')) {
-                       // Nope, so throw exception
-                       throw new MissingMethodException(array($outInstance, 'saveFile'), self::EXCEPTION_MISSING_METHOD);
-               }
-
-               // Send the fileName and dataArray to the output handler
-               $outInstance->saveFile($fileName, $dataArray);
-       }
-
-       /** Loads data from a file over the input handler
-        *
-        * @see FileInputStreamer
-        */
-       public function loadFileContents ($fqfn) {
-               // Initialize the array
-               $array = array();
-
-               // Get output stream
-               $inInstance = $this->getInputStream();
-
-               // Is it a valid stream?
-               if (is_null($inInstance)) {
-                       // No class returned
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($inInstance)) {
-                       // Not an object! ;-(
-                       throw new NoObjectException($inInstance, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($inInstance, 'loadFileContents')) {
-                       // Nope, so throw exception
-                       throw new MissingMethodException(array($inInstance, 'loadFileContents'), self::EXCEPTION_MISSING_METHOD);
-               }
-
-               // Read from the input handler
-               return $inInstance->loadFileContents($fqfn);
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/middleware/io/class_FileIoHandler.php b/inc/classes/middleware/io/class_FileIoHandler.php
new file mode 100644 (file)
index 0000000..c41f7cb
--- /dev/null
@@ -0,0 +1,181 @@
+<?php
+/**
+ * This is a file IO handler. It handles reading from and writing to files.
+ * Missing paths in writing process will be automatically created.
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class FileIoHandler extends BaseMiddleware {
+       /**
+        * The *real* file input class we shall use for reading data
+        */
+       private $inputStream = null;
+
+       /**
+        * The *real* file output class we shall use for reading data
+        */
+       private $outputStream = null;
+
+       /**
+        * An instance of this class
+        */
+       private static $thisInstance = null;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set description
+               $this->setObjectDescription("Datei-Ein-/Ausgabe-Handler");
+
+               // Create an unique ID
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+
+               // Set own instance
+               self::$thisInstance = $this;
+       }
+
+       /**
+        * Creates an instance of this class and prepares the IO system. This is
+        * being done by setting the default file IO class
+        *
+        * @return      $ioInstance     A prepared instance of FilIOHandler
+        */
+       public final static function createFileIoHandler () {
+               // Get instance
+               $ioHandler = new FileIoHandler();
+
+               // Set the *real* file IO instances (both the same)
+               $ioHandler->setInputStream(FileIoStream::createFileIoStream());
+               $ioHandler->setOutputStream(FileIoStream::createFileIoStream());
+
+               // Return instance
+               return $ioHandler;
+       }
+
+       /**
+        * Getter for an instance of this class
+        *
+        * @return      $thisInstance   An instance of this class
+        */
+       public final static function getInstance () {
+               return self::$thisInstance;
+       }
+
+       /**
+        * Setter for the *real* file input instance
+        *
+        * @param               $inputStream    The *real* file-input class
+        */
+       public final function setInputStream (FileInputStreamer $inputStream) {
+               $this->inputStream = $inputStream;
+       }
+
+       /**
+        * Getter for the *real* file input instance
+        *
+        * @return      $inputStream    The *real* file-input class
+        */
+       public final function getInputStream () {
+               return $this->inputStream;
+       }
+
+       /**
+        * Setter for the *real* file output instance
+        *
+        * @param               $outputStream   The *real* file-output class
+        */
+       public final function setOutputStream (FileOutputStreamer $outputStream) {
+               $this->outputStream = $outputStream;
+       }
+
+       /**
+        * Getter for the *real* file output instance
+        *
+        * @return      $outputStream   The *real* file-output class
+        */
+       public final function getOutputStream () {
+               return $this->outputStream;
+       }
+
+       /**
+        * Saves a file with data by using the current output stream
+        *
+        * @see FileOutputStreamer
+        */
+       public function saveFile ($fileName, $dataArray) {
+               // Get output stream
+               $outInstance = $this->getOutputStream();
+
+               // Is it a valid stream?
+               if (is_null($outInstance)) {
+                       // No class returned
+                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+               } elseif (!is_object($outInstance)) {
+                       // Not an object! ;-(
+                       throw new NoObjectException($outInstance, self::EXCEPTION_IS_NO_OBJECT);
+               } elseif (!method_exists($outInstance, 'saveFile')) {
+                       // Nope, so throw exception
+                       throw new MissingMethodException(array($outInstance, 'saveFile'), self::EXCEPTION_MISSING_METHOD);
+               }
+
+               // Send the fileName and dataArray to the output handler
+               $outInstance->saveFile($fileName, $dataArray);
+       }
+
+       /** Loads data from a file over the input handler
+        *
+        * @see FileInputStreamer
+        */
+       public function loadFileContents ($fqfn) {
+               // Initialize the array
+               $array = array();
+
+               // Get output stream
+               $inInstance = $this->getInputStream();
+
+               // Is it a valid stream?
+               if (is_null($inInstance)) {
+                       // No class returned
+                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+               } elseif (!is_object($inInstance)) {
+                       // Not an object! ;-(
+                       throw new NoObjectException($inInstance, self::EXCEPTION_IS_NO_OBJECT);
+               } elseif (!method_exists($inInstance, 'loadFileContents')) {
+                       // Nope, so throw exception
+                       throw new MissingMethodException(array($inInstance, 'loadFileContents'), self::EXCEPTION_MISSING_METHOD);
+               }
+
+               // Read from the input handler
+               return $inInstance->loadFileContents($fqfn);
+       }
+}
+
+// [EOF]
+?>
index 9b307c07cb3e87a934504594ca006d41303d8b46..d5622f3cbb35351f0d3030323a5da32e4f949f36 100644 (file)
  */
 
 // Load the class from inc/config direktory
-@require_once(dirname(__FILE__) . "/config/class_FrameworkConfiguration.php");
+@require_once(dirname(__FILE__) . '/config/class_FrameworkConfiguration.php');
 
 // Get a new configuration instance
 $cfg = FrameworkConfiguration::createFrameworkConfiguration();
 
 // CFG: SERVER-PATH
-$cfg->definePath(dirname(dirname(__FILE__)) . "/"); // DON'T MISS THE TRAILING SLASH!!!
+$cfg->definePath(dirname(dirname(__FILE__)) . '/'); // DON'T MISS THE TRAILING SLASH!!!
 
 // CFG: DATABASE-TYPE
-$cfg->defineDatabaseType("local");
+$cfg->defineDatabaseType('local');
+
+// CFG: LOCAL-DB-PATH
+$cfg->setConfigEntry('local_db_path', 'db/');
 
 // CFG: TIME-ZONE
 $cfg->setDefaultTimezone("Europe/Berlin");
@@ -43,106 +46,103 @@ $cfg->setDefaultTimezone("Europe/Berlin");
 $cfg->setMagicQuotesRuntime(false);
 
 // CFG: PHP-SCRIPT-EXTENSION
-$cfg->setConfigEntry("php_extension", ".php");
+$cfg->setConfigEntry('php_extension', ".php");
 
 // CFG: CLASS-PREFIX
-$cfg->setConfigEntry("class_prefix", "class_");
+$cfg->setConfigEntry('class_prefix', "class_");
 
 // CFG: CLASS-SUFFIX
-$cfg->setConfigEntry("class_suffix", ".php");
+$cfg->setConfigEntry('class_suffix', ".php");
 
 // CFG: RAW-TEMPLATE-EXTENSION
-$cfg->setConfigEntry("raw_template_extension", ".tpl");
+$cfg->setConfigEntry('raw_template_extension', ".tpl");
 
 // CFG: CODE-TEMPLATE-EXTENSION
-$cfg->setConfigEntry("code_template_extension", ".ctp");
+$cfg->setConfigEntry('code_template_extension', ".ctp");
 
 // CFG: SELECTOR-GET
-$cfg->setConfigEntry("app_selector_get", "app");
+$cfg->setConfigEntry('app_selector_get', "app");
+
+// CFG: SELECTOR-PATH
+$cfg->setConfigEntry('selector_path', "selector");
 
 // CFG: APPLICATION-HELPER
-$cfg->setConfigEntry("app_helper_class", "ApplicationHelper");
+$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!
+$cfg->setConfigEntry('tpl_base_path', "templates/"); // DON'T MISS THE TRAILING SLASH!
 
 // CFG: LANGUAGE-BASE-PATH
-$cfg->setConfigEntry("lang_base_path", "inc/language/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('lang_base_path', "inc/language/"); // DON'T MISS THE TRAILING SLASH!
 
 // CFG: COMPRESSOR-BASE-PATH
-$cfg->setConfigEntry("compressor_base_path", "inc/classes/main/compressor/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('compressor_base_path', "inc/classes/main/compressor/"); // DON'T MISS THE TRAILING SLASH!
 
 // CFG: APPLICATION-PATH
-$cfg->setConfigEntry("application_path", "application");
+$cfg->setConfigEntry('application_path', "application");
 
 // CFG: COMPILE-OUTPUT-PATH
-$cfg->setConfigEntry("compile_output_path", "templates/_compiled/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('compile_output_path', "templates/_compiled/"); // DON'T MISS THE TRAILING SLASH!
 
 // CFG: TEMPLATE-ENGINE
-$cfg->setConfigEntry("tpl_engine", "TemplateEngine");
+$cfg->setConfigEntry('tpl_engine', "TemplateEngine");
 
 // CFG: DEBUG-ENGINE
-$cfg->setConfigEntry("debug_engine", "DebugWebOutput");
+$cfg->setConfigEntry('debug_engine', "DebugWebOutput");
 
 // CFG: DEFAULT-LANGUAGE
-$cfg->setConfigEntry("default_lang", "de"); // A two-char language string: de for german, en for english and so on
+$cfg->setConfigEntry('default_lang', "de"); // A two-char language string: de for german, en for english and so on
 
 // CFG: WEB-TEMPLATE-TYPE
-$cfg->setConfigEntry("web_template_type", "html");
+$cfg->setConfigEntry('web_template_type', "html");
 
 // CFG: EMAIL-TEMPLATE-TYPE
-$cfg->setConfigEntry("email_template_type", "emails");
+$cfg->setConfigEntry('email_template_type', "emails");
 
 // CFG: CODE-TEMPLATE-TYPE
-$cfg->setConfigEntry("code_template_type", "code");
+$cfg->setConfigEntry('code_template_type', "code");
 
 // CFG: WEB-ENGINE
-$cfg->setConfigEntry("web_engine", "WebOutput");
+$cfg->setConfigEntry('web_engine', "WebOutput");
 
 // CFG: SELECTOR-TEMPLATE-PREFIX
-$cfg->setConfigEntry("tpl_selector_prefix", "selector");
+$cfg->setConfigEntry('tpl_selector_prefix', "selector");
 
 // CFG: WEB-CONTENT-TYPE
-$cfg->setConfigEntry("web_content_type", "text/html");
+$cfg->setConfigEntry('web_content_type', "text/html");
 
 // CFG: VALID-TEMPLATE-VARIABLE
-$cfg->setConfigEntry("tpl_valid_var", "content");
+$cfg->setConfigEntry('tpl_valid_var', "content");
 
 // CFG: META-AUTHOR
-$cfg->setConfigEntry("meta_author", "Roland H&auml;der");
+$cfg->setConfigEntry('meta_author', "Roland H&auml;der");
 
 // CFG: META-PUBLISHER
-$cfg->setConfigEntry("meta_publisher", "Roland H&auml;der");
+$cfg->setConfigEntry('meta_publisher', "Roland H&auml;der");
 
 // CFG: META-KEYWORDS
-$cfg->setConfigEntry("meta_keywords", "test,test,test");
+$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->setConfigEntry('meta_description', "A lame description for an application framework");
 
 // CFG: SELECTOR-MAIN-TEMPLATE
-$cfg->setConfigEntry("selector_main_tpl", "selector_main");
+$cfg->setConfigEntry('selector_main_tpl', "selector_main");
 
 // CFG: SELECTOR-APPS-TEMPLATE
-$cfg->setConfigEntry("selector_apps_tpl", "selector_apps");
+$cfg->setConfigEntry('selector_apps_tpl', "selector_apps");
 
 // CFG: SELECTOR-NAME
-$cfg->setConfigEntry("selector_name", "selector");
+$cfg->setConfigEntry('selector_name', "selector");
 
 // CFG: DEFAULT-APPLICATION
-$cfg->setConfigEntry("default_application", "selector");
+$cfg->setConfigEntry('default_application', "selector");
 
 // CFG: VERBOSE-LEVEL
-$cfg->setConfigEntry("verbose_level", 0);
-
-// CFG: COMMAND-PARAMETER
-$cfg->setConfigEntry("command_parameter", "page");
+$cfg->setConfigEntry('verbose_level', 0);
 
 // [EOF]
 ?>
index 1ec81dfae8b8509bc3fbe23cb14e31c282c77785..0c59d29df3eb4438e0f760c3c825d49bdeb91a46 100644 (file)
 $cfg = FrameworkConfiguration::getInstance();
 
 // CFG: HUB-LISTEN-ADDR
-$cfg->setConfigEntry("hub_listen_addr", "0.0.0.0");
+$cfg->setConfigEntry('hub_listen_addr', "0.0.0.0");
 
 // CFG: HUB-LISTEN-PORT (zero = auto-choose)
-$cfg->setConfigEntry("hub_listen_port", 9060);
+$cfg->setConfigEntry('hub_listen_port', 9060);
 
 // CFG: HUB-MAX-AUTH-TRIES
-$cfg->setConfigEntry("hub_max_auth_tries", 3);
+$cfg->setConfigEntry('hub_max_auth_tries', 3);
 
 // CFG: HUB-MSG-AUTH-TRIES
-$cfg->setConfigEntry("hub_msg_auth_tries", "AUTH_MAX_TRIES");
+$cfg->setConfigEntry('hub_msg_auth_tries', "AUTH_MAX_TRIES");
 
 // CFG: HUB-MSG-SPOOFING
-$cfg->setConfigEntry("hub_msg_spoofing", "SPOOFING");
+$cfg->setConfigEntry('hub_msg_spoofing', "SPOOFING");
 
 // CFG: HUB-MSG-AUTH-REPLY
-$cfg->setConfigEntry("hub_msg_auth_reply_timeout", "TIMEOUT_AUTH");
+$cfg->setConfigEntry('hub_msg_auth_reply_timeout', "TIMEOUT_AUTH");
 
 // CFG: HUB-MSG-BYE
-$cfg->setConfigEntry("hub_msg_bye", "BYE");
+$cfg->setConfigEntry('hub_msg_bye', "BYE");
 
 // CFG: HUB-MASTER-IP
-$cfg->setConfigEntry("hub_master_ip", "192.168.1.17");
+$cfg->setConfigEntry('hub_master_ip', "192.168.1.17");
 
 // CFG: HUB-MASTER-PORT
-$cfg->setConfigEntry("hub_master_port", 9060);
+$cfg->setConfigEntry('hub_master_port', 9060);
 
 // CFG: HUB-AUTH-REQUEST
-$cfg->setConfigEntry("hub_auth_request", "AUTH");
+$cfg->setConfigEntry('hub_auth_request', "AUTH");
 
 // CFG: HUB-AUTH-REQUEST-TIMEOUT (5 seconds for whole auth procedure shall be fine)
-$cfg->setConfigEntry("hub_auth_request_timeout", 5);
+$cfg->setConfigEntry('hub_auth_request_timeout', 5);
 
 // CFG: HUB-PEER-HELLO
-$cfg->setConfigEntry("hub_peer_hello", "HELLO");
+$cfg->setConfigEntry('hub_peer_hello', "HELLO");
 
 // CFG: HUB-HELLO-REPLY
-$cfg->setConfigEntry("hub_hello_reply", "ELHO");
+$cfg->setConfigEntry('hub_hello_reply', "ELHO");
 
 // CFG: HUB-HELLO-TIMEOUT
-$cfg->setConfigEntry("hub_hello_timeout", 30);
+$cfg->setConfigEntry('hub_hello_timeout', 30);
 
 // CFG: HUB-HELLO-RETRIES
-$cfg->setConfigEntry("hub_hello_retires", 3);
+$cfg->setConfigEntry('hub_hello_retires', 3);
 
 // CFG: HUB-PEER-PING
-$cfg->setConfigEntry("hub_peer_ping", "PING");
+$cfg->setConfigEntry('hub_peer_ping', "PING");
 
 // CFG: HUB-PING-REPLY
-$cfg->setConfigEntry("hub_ping_reply", "PONG");
+$cfg->setConfigEntry('hub_ping_reply', "PONG");
 
 // CFG: HUB-PING-TIMEOUT
-$cfg->setConfigEntry("hub_ping_timeout", 10);
+$cfg->setConfigEntry('hub_ping_timeout', 10);
 
 // CFG: HUB-PING-MAXDROPS
-$cfg->setConfigEntry("hub_ping_maxdrops", 3);
+$cfg->setConfigEntry('hub_ping_maxdrops', 3);
 
 // CFG: HUB-PEER-MISS-PONG
-$cfg->setConfigEntry("hub_peer_miss_pong", "PONG_MISS");
+$cfg->setConfigEntry('hub_peer_miss_pong', "PONG_MISS");
 
 // [EOF]
 ?>
index ad29f0e495bf58a3c731bd70e596c30de1701f8d..62e64fb92b36f3bdf108530c8bfdce742adc8690 100644 (file)
@@ -34,7 +34,11 @@ This will choose the local-file-based database type (layer)");
 }
 
 // Generate FQFN for the database layer
-$INC = sprintf("%sinc/database/lib-%s%s", PATH, _DB_TYPE, FrameworkConfiguration::getInstance()->readConfig("php_extension"));
+$INC = sprintf("%sinc/database/lib-%s%s",
+       PATH,
+       _DB_TYPE,
+       FrameworkConfiguration::getInstance()->readConfig('php_extension')
+);
 
 // Load the database layer include
 if ((file_exists($INC)) && (is_file($INC)) && (is_readable($INC))) {
index a689fed4bc556e1c2bb7482568e7e0302231f681..95b0f895417079d1762c1e59b4edd5433ff68ac7 100644 (file)
@@ -3,10 +3,10 @@
  * Initializes the local file database class
  *
  * @author             Roland Haeder <webmaster@mxchange.org>
- * @version            0.3.0
+ * @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.mxchange.org
+ * @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
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
 // 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: <strong>%s</strong><br />\n",
+       ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong><br />\n",
                $e->getMessage()
        ));
 } catch (SavePathNotFoundException $e) {
-       ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: <strong>%s</strong><br />\n",
+       ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong><br />\n",
                $e->getMessage()
        ));
 } catch (SavePathIsNoDirectoryException $e) {
-       ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: <strong>%s</strong><br />\n",
+       ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong><br />\n",
                $e->getMessage()
        ));
 } catch (SavePathReadProtectedException $e) {
-       ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: <strong>%s</strong><br />\n",
+       ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong><br />\n",
                $e->getMessage()
        ));
 } catch (SavePathWriteProtectedException $e) {
-       ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: <strong>%s</strong><br />\n",
+       ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong><br />\n",
                $e->getMessage()
        ));
 }
index 92c96b6c417498d36dd16857c860713f05dde013..de20bf54ca2f348bb2f05706e53d7384fcc56971 100644 (file)
@@ -5,10 +5,10 @@
  * instances will we generated.
  *
  * @author             Roland Haeder <webmaster@mxchange.org>
- * @version            0.3.0
+ * @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.mxchange.org
+ * @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
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
 // Get the instance
-$io = FileIOHandler::createFileIOHandler();
+$io = FileIoHandler::createFileIoHandler();
 
 // [EOF]
 ?>
index c9158581e7c6ffdce0e64538e0687ef2e1926d15..b699ea9118090292564bfc7d27bea711be980266 100644 (file)
@@ -3,10 +3,10 @@
  * Loads more include files by using the generic class loader
  *
  * @author             Roland Haeder <webmaster@mxchange.org>
- * @version            0.3.0
+ * @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.mxchange.org
+ * @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
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
 // Include the class loader function
-require(sprintf("%sinc/loader/class_ClassLoader%s", PATH, FrameworkConfiguration::getInstance()->readConfig("php_extension")));
+require(sprintf("%sinc/loader/class_ClassLoader%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
 
 /**
  * Is the devel package included?
@@ -32,7 +32,7 @@ if (is_dir(sprintf("%sdevel", PATH))) {
        /**
         * Load all development includes
         */
-       ClassLoader::getInstance()->loadClasses("devel");
+       ClassLoader::getInstance()->loadClasses('devel');
 }
 
 // Shall we include additional configs where you can configure some things? Then
index 552dc45894955c2c4be3bdd27f58e03f0760b070..60c9e28ebc9bbc667a4d4796a5bbe57a74737088 100644 (file)
@@ -23,7 +23,7 @@
 try {
        $lang = LanguageSystem::createLanguageSystem(sprintf("%s%s",
                PATH,
-               FrameworkConfiguration::getInstance()->readConfig("lang_base_path")
+               FrameworkConfiguration::getInstance()->readConfig('lang_base_path')
        ));
 } catch (LanguagePathIsEmptyException $e) {
        ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <strong>%s</strong>",
index 736649689127d55193e5c1a07dc5a9d085253f8a..edbe3cb2ff768186b9afff4c18e134c47ef9da88 100644 (file)
@@ -101,8 +101,8 @@ class ClassLoader {
                $this->dirList = new ArrayObject();
 
                // Set suffix and prefix from configuration
-               $this->suffix = $cfgInstance->readConfig("class_suffix");
-               $this->prefix = $cfgInstance->readConfig("class_prefix");
+               $this->suffix = $cfgInstance->readConfig('class_suffix');
+               $this->prefix = $cfgInstance->readConfig('class_prefix');
 
                // Estimate length of prefix and suffix for substr() function (cache)
                $this->sufLen = strlen($this->suffix);
@@ -289,9 +289,9 @@ class ClassLoader {
 }
 
 // Initial load of core classes and the FrameworkDirectoryPointer class
-require_once(sprintf("%sinc/classes/interfaces/class_FrameworkInterface%s", PATH, FrameworkConfiguration::getInstance()->readConfig("php_extension")));
-require_once(sprintf("%sinc/classes/main/class_BaseFrameworkSystem%s", PATH, FrameworkConfiguration::getInstance()->readConfig("php_extension")));
-require_once(sprintf("%sinc/classes/main/io/class_FrameworkDirectoryPointer%s", PATH, FrameworkConfiguration::getInstance()->readConfig("php_extension")));
+require_once(sprintf("%sinc/classes/interfaces/class_FrameworkInterface%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
+require_once(sprintf("%sinc/classes/main/class_BaseFrameworkSystem%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
+require_once(sprintf("%sinc/classes/main/io/class_FrameworkDirectoryPointer%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
 
 // Initialize the class loader
 $loader = new ClassLoader(FrameworkConfiguration::getInstance());
index 20f3fe8f5b7741944e64a20680a6b2f86298bcd4..7b9302a0a6dc29516cd021f9095591e82e22caba 100644 (file)
@@ -23,7 +23,7 @@
  */
 
 // Get a debugger instance
-$debug = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getInstance()->readConfig("debug_engine"));
+$debug = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getInstance()->readConfig('debug_engine'));
 
 // Empty string should be ignored and used for testing the middleware
 DebugMiddleware::getInstance()->output("");
index 2133c11e742dbc7babcdf75dd93bd3f9d41e7e87..e608de177a80c7966a4085546e3e8fd4cb7230c0 100644 (file)
  */
 
 // Does the user has an application specified?
-if (!empty($_GET[FrameworkConfiguration::getInstance()->readConfig("app_selector_get")])) {
+if (!empty($_GET[FrameworkConfiguration::getInstance()->readConfig('app_selector_get')])) {
        // Set the application from string
-       $application = (string) $_GET[FrameworkConfiguration::getInstance()->readConfig("app_selector_get")];
+       $application = (string) $_GET[FrameworkConfiguration::getInstance()->readConfig('app_selector_get')];
 } elseif (!empty($_SERVER['argv'][1])) {
        // Set the application from string
        $application = (string) $_SERVER['argv'][1];
-       $app = explode("=", trim($application));
-       if ($app[0] == FrameworkConfiguration::getInstance()->readConfig("app_selector_get")) {
+       $app = explode('=', trim($application));
+       if ($app[0] == FrameworkConfiguration::getInstance()->readConfig('app_selector_get')) {
                // Application is valid!
                $application = trim($app[1]);
        } else {
                // Invalid entry found, first must be "app"!
-               $application = FrameworkConfiguration::getInstance()->readConfig("default_application");
+               $application = FrameworkConfiguration::getInstance()->readConfig('default_application');
        }
 } else {
        // Set the "application selector" application
-       $application = FrameworkConfiguration::getInstance()->readConfig("default_application");
+       $application = FrameworkConfiguration::getInstance()->readConfig('default_application');
 }
 
 // Secure it, by keeping out tags
@@ -50,7 +50,7 @@ $application = preg_replace('/([^a-z_-])+/i', "", $application);
 
 // Try to load these includes in the given order
 $configAppIncludes = array(
-       sprintf("class_%s", FrameworkConfiguration::getInstance()->readConfig("app_helper_class")), // The ApplicationHelper class
+       sprintf("class_%s", FrameworkConfiguration::getInstance()->readConfig('app_helper_class')), // The ApplicationHelper class
        "config",               // The application's own configuration
        "init",                 // The application initializer
        "loader",               // The application's class loader
@@ -70,20 +70,20 @@ foreach ($configAppIncludes as $inc) {
        // Generate a FQFN for the helper class
        $fqfn = sprintf("%s%s/%s/%s%s",
                PATH,
-               FrameworkConfiguration::getInstance()->readConfig("application_path"),
+               FrameworkConfiguration::getInstance()->readConfig('application_path'),
                $application,
                $inc,
-               FrameworkConfiguration::getInstance()->readConfig("php_extension")
+               FrameworkConfiguration::getInstance()->readConfig('php_extension')
        );
 
        // Does the include file exists?
        if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) {
                // Load it
                require_once($fqfn);
-       } elseif (FrameworkConfiguration::getInstance()->readConfig("verbose_level") > 0) {
+       } elseif (FrameworkConfiguration::getInstance()->readConfig('verbose_level') > 0) {
                // File is missing
                trigger_error(sprintf("Cannot load application script %s! File is missing or read-protected.",
-                       $inc . FrameworkConfiguration::getInstance()->readConfig("php_extension")
+                       $inc . FrameworkConfiguration::getInstance()->readConfig('php_extension')
                ));
        }
 }
index 86b8c446eee1fe7a23977e4d6c4cca8afe599af1..9cabcb0a844cabeadea6e465976870f6ee4bf10d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -8,10 +8,10 @@
  * But good little boys and girls would always initialize their variables... ;-)
  *
  * @author             Roland Haeder <webmaster@mxchange.org>
- * @version            0.3.0
+ * @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.mxchange.org
+ * @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
@@ -24,7 +24,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class ApplicationEntryPoint {
        /**
@@ -50,6 +50,15 @@ class ApplicationEntryPoint {
         * @return      void
         */
        public static function app_die ($message = "") {
+               // Is this method already called?
+               if (defined('EMERGENCY_EXIT_CALLED')) {
+                       // Then output the text directly
+                       die($message);
+               }
+
+               // This method shall not be called twice
+               define('EMERGENCY_EXIT_CALLED', true);
+
                // Is a message set?
                if (empty($message)) {
                        // No message provided
@@ -65,7 +74,7 @@ class ApplicationEntryPoint {
                if ((class_exists($tpl)) && (is_object($lang)) && (is_object($io))) {
                        // Use the template engine for putting out (nicer look) the message
                        try {
-                               $eval = sprintf("\$tplEngine = %s::create%s(\"%s%s\", LanguageSystem::getInstance(), FileIOHandler::getInstance());",
+                               $eval = sprintf("\$tplEngine = %s::create%s(\"%s%s\", \$lang, \$io);",
                                        FrameworkConfiguration::getInstance()->readConfig("tpl_engine"),
                                        FrameworkConfiguration::getInstance()->readConfig("tpl_engine"),
                                        PATH,
@@ -90,8 +99,19 @@ class ApplicationEntryPoint {
                                ));
                        }
 
-                       // Assign message
+                       // Backtrace holen und aufbereiten
+                       $backtraceArray = debug_backtrace();
+                       $backtrace = "";
+                       foreach ($backtraceArray as $key=>$trace) {
+                               if (!isset($trace['file'])) $trace['file'] = __FILE__;
+                               if (!isset($trace['line'])) $trace['line'] = 5;
+                               if (!isset($trace['args'])) $trace['args'] = array();
+                               $backtrace .= "<span class=\"backtrace_file\">".basename($trace['file'])."</span>:".$trace['line'].", <span class=\"backtrace_function\">".$trace['function']."(".count($trace['args']).")</span><br />";
+                       }
+
+                       // Assign variables
                        $tplEngine->assignVariable("message", $message);
+                       $tplEngine->assignVariable("backtrace", $backtrace);
 
                        // Load the template
                        $tplEngine->loadCodeTemplate("emergency_exit");
@@ -109,7 +129,7 @@ class ApplicationEntryPoint {
                        exit();
                } else {
                        // Output message and die
-                       die(sprintf("[Main:] Emergency exit reached: <strong>%s</strong>",
+                       die(sprintf("[Main:] Emergency exit reached: <span class=\"emergency_span\">%s</span>",
                                $message
                        ));
                }