Code merge from latest ship-simu code
authorRoland Häder <roland@mxchange.org>
Sat, 31 May 2008 11:13:28 +0000 (11:13 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 31 May 2008 11:13:28 +0000 (11:13 +0000)
89 files changed:
.gitattributes
application/mxchange/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_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/class_FrameworkArrayObject.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_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_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
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/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/class_BaseMiddleware.php
inc/classes/middleware/compressor/class_CompressorChannel.php
inc/classes/middleware/database/class_DatabaseConnection.php
inc/classes/middleware/debug/class_DebugMiddleware.php
inc/classes/middleware/io/class_FileIOHandler.php
inc/classes/middleware/io/class_FileIoHandler.php [new file with mode: 0644]
inc/config.php
inc/config/class_FrameworkConfiguration.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
templates/de/code/emergency_exit.ctp
templates/de/code/header.ctp

index 89c9126..9a65b24 100644 (file)
@@ -40,6 +40,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
@@ -89,6 +94,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
@@ -110,6 +117,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
@@ -129,14 +138,19 @@ 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/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
@@ -149,6 +163,8 @@ inc/classes/main/controller/class_BaseController.php -text
 inc/classes/main/controller/default/.htaccess -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
@@ -168,8 +184,21 @@ 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
@@ -189,6 +218,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
@@ -199,6 +230,7 @@ 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 435d343..28d71b7 100644 (file)
@@ -61,13 +61,18 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
        private static $thisInstance = null;
 
        /**
+        * Master template
+        */
+       private $masterTemplate = "mxchange_main";
+
+       /**
         * Private constructor
         *
         * @return      void
         */
-       private function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set description
                $this->setObjectDescription("Application-Helper");
@@ -166,6 +171,29 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
                // Not yet implemented
                trigger_error(__METHOD__.": Not yet implemented!");
        }
+
+       /**
+        * Getter for master template name
+        *
+        * @return      $masterTemplate         Name of the master template
+        */
+       public final function getMasterTemplate () {
+               return $this->masterTemplate;
+       }
+
+       /**
+        * 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 9c7a8a8..27fe8d1 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 8a3151c..01fd09f 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 f342a0a..d1d7267 100644 (file)
@@ -8,10 +8,10 @@
  * - And many more...
  *
  * @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/>.
  */
 interface ManageableApplication extends FrameworkInterface {
        /**
@@ -72,11 +72,27 @@ interface ManageableApplication extends FrameworkInterface {
        function setAppShortName ($shortName);
 
        /**
+        * Getter for master template name
+        *
+        * @return      $masterTemplate         Name of the master template
+        */
+       function getMasterTemplate ();
+
+       /**
         * Launches the application
         *
         * @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 4b3eaba..8b3392d 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 7ef0f9a..a7b39bf 100644 (file)
@@ -3,10 +3,10 @@
  * An interface for requests
  *
  * @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
@@ -19,7 +19,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/>.
  */
 interface Requestable extends FrameworkInterface {
        /**
@@ -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 e953cee..76ec16a 100644 (file)
@@ -27,7 +27,7 @@ interface ControllerResolver extends FrameworkInterface {
         *
         * @return      $controllerInstance             A controller instance for the default command
         */
-        function resolveDefaultController ();
+        function resolveCommandController ();
 }
 
 //
index 7416b94..ae9f4ae 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 4abdf29..1ccb1c2 100644 (file)
@@ -149,6 +149,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        const EXCEPTION_INVALID_CONTROLLER           = 0x032;
        const EXCEPTION_HEADERS_ALREADY_SENT         = 0x033;
        const EXCEPTION_DEFAUL_CONTROLLER_GONE       = 0x034;
+       const EXCEPTION_CLASS_NOT_FOUND              = 0x035;
 
        /**
         * In the super constructor these system classes shall be ignored or else
@@ -218,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(),
@@ -245,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
@@ -272,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')
                                )));
                        }
 
@@ -304,7 +347,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         *
         * @return      $cfhInstance - Configuration instance
         */
-       public final function getConfigInstance () {
+       protected final function getConfigInstance () {
                return self::$cfgInstance;
        }
 
@@ -731,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;
        }
 
@@ -741,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;
        }
 
@@ -796,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);
                }
@@ -815,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
                );
 
@@ -853,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;
        }
 }
 
index 85397a4..d97f403 100644 (file)
  */
 class FrameworkArrayObject extends ArrayObject {
        /**
-        * Constructor for smooth coding style ;-)
-        *
-        * @param               $class  The class's real name
-        * @return      void
-        */
-       public function constructor ($class) {
-               // $class will be ignored for backward compatiblity
-       }
-
-       /**
         * Get real class' name back
         *
         * @return      $realClass      The class' real name
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 f45b0d7..0b7e9c4 100644 (file)
@@ -23,7 +23,7 @@
  */
 class WebHomeCommand extends BaseCommand implements Commandable {
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
@@ -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 88322b6..24566b9 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 4e95f80..08b1a6d 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 a8a570c..157dc1a 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 175102a..054c8c7 100644 (file)
@@ -3,10 +3,10 @@
  * This class contains static helper functions for console applications
  *
  * @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 ConsoleTools extends BaseFrameworkSystem {
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
-       private function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set description
-               $this->setObjectDescription("Console-Tools");
+               $this->setObjectDescription("General console tools");
 
                // Create an unique ID
                $this->createUniqueID();
index f7aea5c..a2bf811 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
  */
 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
         *
         * @return      void
@@ -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);
        }
 }
 
index 38d92ce..9d60e61 100644 (file)
  */
 class WebWebDefaultController extends BaseController implements Controller {
        /**
-        * Instance of a CommandResolver class
-        */
-       private $resolverInstance = null;
-
-       /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
@@ -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();
        }
 
        /**
@@ -64,16 +56,6 @@ class WebWebDefaultController extends BaseController implements Controller {
        }
 
        /**
-        * 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
@@ -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 ff86531..b8bbc05 100644 (file)
  */
 class WebDefaultNewsController extends BaseController implements Controller {
        /**
-        * Instance of a CommandResolver class
-        */
-       private $resolverInstance = null;
-
-       /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
@@ -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();
        }
 
        /**
@@ -64,16 +56,6 @@ class WebDefaultNewsController extends BaseController implements Controller {
        }
 
        /**
-        * 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
@@ -82,13 +64,13 @@ 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);
-
-               // Get the news page variable from the request instance
-               $newsPage = $requestInstance->getRequestElement("news_page");
+               $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
 
                // Load the news here
-               $this->loadNews($newsPage);
+               $this->loadNewsByRequest($requestInstance);
+
+               // This request was valid! :-D
+               $requestInstance->requestIsValid();
 
                // Execute the command
                $commandInstance->execute($requestInstance, $responseInstance);
@@ -98,12 +80,14 @@ class WebDefaultNewsController extends BaseController implements Controller {
        }
 
        /**
-        * Loads news from the connected database for later usage
+        * Loads news by a given request
         *
-        * @param       $newsPage       Page of listed news we want to read
+        * @param       $requestInstance        An instance of a request class
         * @return      void
         */
-       private function loadNews ($newsPage) {
+       private function loadNewsByRequest (Requestable $requestInstance) {
+               // Generate a new news object but not carring about which concrete we have
+               $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 84babfe..dbe55ac 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 8efe0b5..e9be4a5 100644 (file)
@@ -3,10 +3,10 @@
  * A debug output class for the console (e.g. hub software)
  *
  * @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 DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer {
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
-       private function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               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 a11a9f7..1a1723f 100644 (file)
@@ -3,10 +3,10 @@
  * A debug output class for PHP's error_log() command
  *
  * @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 DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer {
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
-       private function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               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 844605f..0c763e0 100644 (file)
@@ -3,10 +3,10 @@
  * A debug output class for the web browser
  *
  * @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 DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer {
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
-       private function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set description
-               $this->setObjectDescription("Debug-Ausgabe auf Konsole");
+               $this->setObjectDescription("Debug output for webpages");
 
                // Create an unique ID
                $this->createUniqueID();
index 13a658a..3c23f80 100644 (file)
@@ -4,10 +4,10 @@
  * objects to the datatabase connection or else a lot heap would be saved.
  *
  * @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
@@ -20,7 +20,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 ObjectLimits extends BaseFrameworkSystem {
        /**
@@ -30,16 +30,16 @@ class ObjectLimits extends BaseFrameworkSystem {
        private $limitArray = null;
 
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
-       private final function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               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 a0980e3..7924d4c 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 fd983ca..5dda5fb 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_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]
+?>
index 155774a..aea932f 100644 (file)
@@ -25,9 +25,9 @@ class FileIOStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
        /**
         * Private constructor
         */
-       private function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set part description
                $this->setObjectDescription("Universal Datei-Ein-/Ausgabesystem");
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 f02faf9..f05bfc0 100644 (file)
@@ -3,10 +3,10 @@
  * A class for directory reading and getting its contents
  *
  * @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
@@ -19,7 +19,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 FrameworkDirectoryPointer extends BaseFrameworkSystem {
        /**
@@ -33,14 +33,14 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
        private $dirPointer = null;
 
        /**
-        * Private constructor
+        * Protected constructor
         */
-       private function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set part description
-               $this->setObjectDescription("Verzeichnis-Handler");
+               $this->setObjectDescription("Helper for handling directories");
 
                // Create unique ID
                $this->createUniqueID();
index c66d76d..b93c002 100644 (file)
@@ -3,10 +3,10 @@
  * A class for reading files
  *
  * @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
@@ -19,7 +19,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 FrameworkFileInputPointer extends BaseFrameworkSystem {
        /**
@@ -33,14 +33,14 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
        private $filePointer = null;
 
        /**
-        * Private constructor
+        * Protected constructor
         */
-       private final function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set part description
-               $this->setObjectDescription("Dateiausgabe-Handler");
+               $this->setObjectDescription("Handler for reading from files");
 
                // Create unique ID
                $this->createUniqueID();
index 9705137..350cd72 100644 (file)
@@ -3,10 +3,10 @@
  * A class for writing files
  *
  * @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
@@ -19,7 +19,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 FrameworkFileOutputPointer extends BaseFrameworkSystem {
        /**
@@ -33,14 +33,14 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem {
        private $filePointer = null;
 
        /**
-        * Private constructor
+        * Protected constructor
         */
-       private final function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set part description
-               $this->setObjectDescription("Dateiausgabe-Handler");
+               $this->setObjectDescription("Handler for writing to files");
 
                // Create unique ID
                $this->createUniqueID();
index baac159..7376367 100644 (file)
@@ -4,10 +4,10 @@
  * application and whole framework
  *
  * @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
@@ -20,7 +20,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 LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage {
        /**
@@ -44,16 +44,16 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage {
        private static $thisInstance = null;
 
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
-       private final function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               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($langInstance->getConfigInstance()->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 3bf27fc..7eeb854 100644 (file)
@@ -4,10 +4,10 @@
  * for console output
  *
  * @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
@@ -20,7 +20,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 ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer {
        /**
@@ -34,16 +34,16 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer {
        private $vars = array();
 
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
-       private function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               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 27e5c83..b1eecc9 100644 (file)
@@ -4,10 +4,10 @@
  * browser
  *
  * @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
@@ -20,7 +20,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 WebOutput extends BaseFrameworkSystem implements OutputStreamer {
        /**
@@ -29,16 +29,16 @@ class WebOutput extends BaseFrameworkSystem implements OutputStreamer {
        private static $webInstance = null;
 
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
-       private function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               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 6826d76..b95bab1 100644 (file)
@@ -28,6 +28,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
         *
         * @return      void
@@ -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 d442ef3..9345109 100644 (file)
@@ -33,7 +33,12 @@ class BaseResolver extends BaseFrameworkSystem {
        private $commandPrefix = "";
 
        /**
-        * Private constructor
+        * A controller instance
+        */
+       private $controllerInstance = null;
+
+       /**
+        * Protected constructor
         *
         * @return      void
         */
@@ -42,10 +47,30 @@ 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
         *
         * @param       $commandName    Last validated 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);
 
index 30b31b5..47baef4 100644 (file)
@@ -28,7 +28,7 @@ class WebCommandResolver extends BaseResolver implements CommandResolver {
        private $lastCommandInstance = "";
 
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
@@ -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)) {
@@ -129,6 +125,33 @@ class WebCommandResolver extends BaseResolver implements CommandResolver {
        }
 
        /**
+        * 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
         *
         * @param       $commandName                            A command name we shall look for
@@ -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 c3bebd5..9e50d94 100644 (file)
  */
 class WebControllerResolver extends BaseResolver implements ControllerResolver {
        /**
-        * Last successfull resolved controller
+        * Last successfull resolved controller (name)
         */
        private $lastControllerName = "";
 
        /**
-        * Private constructor
+        * Last successfull resolved controller (instance)
+        */
+       private $lastControllerInstance = null;
+
+       /**
+        * Protected constructor
         *
         * @return      void
         */
@@ -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 05e6f98..52ad2a7 100644 (file)
@@ -20,6 +20,9 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The extended headers are taken from phpMyAdmin setup tool, written by
+ * Michal Cihar <michal@cihar.com>, licensed under GNU GPL 2.0.
  */
 class HttpResponse extends BaseFrameworkSystem implements Responseable {
        /**
@@ -43,6 +46,11 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable {
        private $templateEngine = null;
 
        /**
+        * Fatal resolved messages from filters and so on
+        */
+       private $fatalMessages = array();
+
+       /**
         * Protected constructor
         *
         * @return      void
@@ -52,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();
@@ -72,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);
 
@@ -101,6 +112,15 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable {
        }
 
        /**
+        * Reset the header array
+        *
+        * @return      void
+        */
+       public final function resetResponseHeaders () {
+               $this->responseHeaders = array();
+       }
+
+       /**
         * "Writes" data to the response body
         *
         * @param       $output         Output we shall sent in the HTTP response
@@ -111,6 +131,16 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable {
        }
 
        /**
+        * 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
         *
         * @param       $foce   Wether we shall force the output or abort if headers are
@@ -125,16 +155,40 @@ 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';
+
+                       // General header for no caching
+                       $this->addHeader('Expired', $now); // rfc2616 - Section 14.21
+                       $this->addHeader('Last-Modified', $now);
+                       $this->addHeader('Cache-Control:', 'no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
+                       $this->addHeader('Pragma:', 'no-cache'); // HTTP/1.0
+
+                       // Define the charset to be used
+                       $this->addHeader('Content-Type:', 'text/html; charset=utf-8');
+
                        foreach ($this->responseHeaders as $name=>$value) {
                                header("{$name}: {$value}");
                        }
                }
 
-               // 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();
        }
 
        /**
@@ -155,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 e11b84d..412d26a 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();
 
@@ -167,7 +167,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                }
 
                // Get configuration instance
-               $cfgInstance = $tplInstance->getConfigInstance();
+               $cfgInstance = FrameworkConfiguration::getInstance();
 
                // Set the base path
                $tplInstance->setBasePath($basePath);
@@ -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 88bc16e..59d90ad 100644 (file)
@@ -27,23 +27,13 @@ class BaseMiddleware extends BaseFrameworkSystem {
         *
         * @return      void
         */
-       private function __construct ($class) {
+       protected function __construct ($class) {
                // Call parent constructor
-               parent::constructor($class);
+               parent::__construct($class);
 
                // Clean up a little
                $this->removeNumberFormaters();
        }
-
-       /**
-        * Public constructor
-        *
-        * @return      void
-        */
-       public function constructor ($class) {
-               // Just call the private constructor
-               $this->__construct($class);
-       }
 }
 
 // [EOF]
index 8dae607..1b33041 100644 (file)
@@ -3,10 +3,10 @@
  * Middleware class for selecting the right compressor channel
  *
  * @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 CompressorChannel extends BaseMiddleware {
        // Output handler instance
        private $compressor = null;
 
        // Public constructor
-       private function __construct () {
+       protected function __construct () {
                // Call parent constructor!
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set description
                $this->setObjectDescription("Komprimierungshandler");
@@ -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) == $cInstance->getConfigInstance()->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.
index d7db9d8..14255d7 100644 (file)
@@ -32,9 +32,9 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
        private static $thisInstance = null;
 
        // Private constructor
-       private final function __construct() {
+       protected function __construct() {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set description
                $this->setObjectDescription("Datenbank-Mittelschicht");
index 2cc4882..3e1d66d 100644 (file)
@@ -39,9 +39,9 @@ class DebugMiddleware extends BaseMiddleware {
         *
         * @return      void
         */
-       private final function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set description
                $this->setObjectDescription("Debug-Ausgabe-Handler");
index 7e0d35a..c514a4a 100644 (file)
@@ -43,9 +43,9 @@ class FileIOHandler extends BaseMiddleware {
         *
         * @return      void
         */
-       private function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set description
                $this->setObjectDescription("Datei-Ein-/Ausgabe-Handler");
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 ab944bf..d5622f3 100644 (file)
@@ -5,10 +5,10 @@
  * configuration entries there.
  *
  * @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/>.
  */
 
 // 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,103 +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->setConfigEntry('verbose_level', 0);
 
 // [EOF]
 ?>
index fc92040..6c81052 100644 (file)
@@ -7,10 +7,10 @@
  *
  * @see                        ClassLoader
  * @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
@@ -23,7 +23,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 FrameworkConfiguration {
        /**
@@ -43,9 +43,9 @@ class FrameworkConfiguration {
        const EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND = 0xc01;
 
        /**
-        * Private constructor
+        * Protected constructor
         */
-       private function __construct () {
+       protected function __construct () {
                // Empty for now
        }
 
index 1ec81df..0c59d29 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 ad29f0e..62e64fb 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 a689fed..95b0f89 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 92c96b6..de20bf5 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 c915858..b699ea9 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 552dc45..60c9e28 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 79389f6..edbe3cb 100644 (file)
@@ -3,10 +3,10 @@
  * This class loads class include files with a specific prefix and suffix
  *
  * @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
@@ -19,7 +19,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/>.
  *
  * ----------------------------------
  * 1.1
@@ -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 20f3fe8..7b9302a 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 7af8aa0..e608de1 100644 (file)
@@ -3,10 +3,10 @@
  * The application selector main include file
  *
  * @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/>.
  */
 
 // 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 06cbde4..d5c6f90 100644 (file)
@@ -8,4 +8,13 @@
                $content[message]
        </div>
 
+       <div id="emergency_exit backtrace_box">
+               <div id="backtrace_header">
+                       Backtrace:
+               </div>
+               <div id="backtrace_content">
+                       $content[backtrace]
+               </div>
+       </div>
+
 {?footer_msg:footer_msg="Please contact the support and supply the full above message, if you think you are not qualified to fix this problem."?}
index 2b2457d..cce8460 100644 (file)
@@ -1,5 +1,5 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
        <title>
                $content[title]