Registration stub added, naming convention applied, support for PHP code (keep it...
authorRoland Häder <roland@mxchange.org>
Sat, 24 May 2008 21:48:19 +0000 (21:48 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 24 May 2008 21:48:19 +0000 (21:48 +0000)
23 files changed:
.gitattributes
application/selector/class_ApplicationHelper.php
application/selector/class_ApplicationSelector.php
application/ship-simu/init.php
application/ship-simu/templates/de/code/home.ctp [new file with mode: 0644]
application/ship-simu/templates/de/code/register.ctp [new file with mode: 0644]
application/ship-simu/templates/de/html/home.tpl [deleted file]
inc/classes/exceptions/io/class_FilePointerNotOpenedException.php
inc/classes/exceptions/template/class_InvalidTemplateVariableNameException.php
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/commands/class_ [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/database/classes/class_LocalFileDatabase.php
inc/classes/main/io/class_FileIOStream.php [deleted file]
inc/classes/main/io/class_FileIoStream.php [new file with mode: 0644]
inc/classes/main/template/class_TemplateEngine.php
inc/classes/middleware/io/class_FileIOHandler.php [deleted file]
inc/classes/middleware/io/class_FileIoHandler.php [new file with mode: 0644]
inc/database/lib-local.php
inc/file_io.php
index.php
templates/de/code/emergency_exit.ctp

index 99a5f08..ee51bff 100644 (file)
@@ -119,9 +119,10 @@ application/ship-simu/templates/.htaccess -text
 application/ship-simu/templates/de/.htaccess -text
 application/ship-simu/templates/de/code/footer.ctp -text
 application/ship-simu/templates/de/code/header.ctp -text
+application/ship-simu/templates/de/code/home.ctp -text
+application/ship-simu/templates/de/code/register.ctp -text
 application/ship-simu/templates/de/code/shipsimu_main.ctp -text
 application/ship-simu/templates/de/html/.htaccess -text
-application/ship-simu/templates/de/html/home.tpl -text
 application/ship-simu/templates/de/html/nav_advert.tpl -text
 application/ship-simu/templates/de/html/selector_ship-simu.tpl -text
 db/.htaccess -text
@@ -246,9 +247,11 @@ 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_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
@@ -281,7 +284,7 @@ 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/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
@@ -310,7 +313,7 @@ inc/classes/middleware/database/class_DatabaseConnection.php -text
 inc/classes/middleware/debug/.htaccess -text
 inc/classes/middleware/debug/class_DebugMiddleware.php -text
 inc/classes/middleware/io/.htaccess -text
-inc/classes/middleware/io/class_FileIOHandler.php -text
+inc/classes/middleware/io/class_FileIoHandler.php -text
 inc/config.php -text
 inc/config/.htaccess -text
 inc/config/class_FrameworkConfiguration.php -text
index 7f721c3..feafd24 100644 (file)
@@ -179,7 +179,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
         */
        public final function entryPoint () {
                // Get a prepared instance of ApplicationSelector
-               $selInstance = ApplicationSelector::createApplicationSelector(LanguageSystem::getInstance(), FileIOHandler::getInstance());
+               $selInstance = ApplicationSelector::createApplicationSelector(LanguageSystem::getInstance(), FileIoHandler::getInstance());
 
                // Remove the ignore list from the object
                $selInstance->removeDirIgnoreList();
index a7f3294..2af2f70 100644 (file)
@@ -80,7 +80,7 @@ class ApplicationSelector extends BaseFrameworkSystem {
         * @param               $fileIOInstance The file I/O instance
         * @return              $selInstance            An instance of ApplicationSelector
         */
-       public final static function createApplicationSelector (ManageableLanguage $langInstance, FileIOHandler $fileIOInstance) {
+       public final static function createApplicationSelector (ManageableLanguage $langInstance, FileIoHandler $fileIOInstance) {
                // Get a new instance
                $selInstance = new ApplicationSelector();
 
@@ -89,7 +89,7 @@ class ApplicationSelector extends BaseFrameworkSystem {
 
                // Set language and file I/O instances
                $selInstance->setLanguageInstance($langInstance);
-               $selInstance->setFileIOInstance($fileIOInstance);
+               $selInstance->setFileIoInstance($fileIOInstance);
 
                // Return the prepared instance
                return $selInstance;
index 1a3fc08..00df8b6 100644 (file)
@@ -49,7 +49,7 @@ require(PATH . "inc/output.php");
 
 // Initialize file i/o system
 require(PATH . "inc/file_io.php");
-$app->setFileIOInstance($io);
+$app->setFileIoInstance($io);
 
 // Include the language sub-system
 require(PATH . "inc/language.php");
diff --git a/application/ship-simu/templates/de/code/home.ctp b/application/ship-simu/templates/de/code/home.ctp
new file mode 100644 (file)
index 0000000..8625082
--- /dev/null
@@ -0,0 +1,7 @@
+<div id="content_header">
+       Willkommen zum Schiffsimulator &quot;Ship-Simu&quot;!
+</div>
+
+<div id="news_frame">
+       {?ship_simu_news?}
+</div>
diff --git a/application/ship-simu/templates/de/code/register.ctp b/application/ship-simu/templates/de/code/register.ctp
new file mode 100644 (file)
index 0000000..9c599c2
--- /dev/null
@@ -0,0 +1,13 @@
+<div id="content_header">
+       Anmeldung bei <span class="app_name">{?app_full_name?}</span>
+</div>
+
+<div id="register_box">
+       <form id="register_form" action="{register_action}" method="post">
+               <!-- You really should have at least nickname, password and email //-->
+               <!-- required for registration. If you don't think so please //-->
+               <!-- contact me and we can talk about it. The rest is optional to //-->
+               <!-- your own taste. //-->
+               <?php $this->addTextInputForm("username", 10, 255, true); ?>
+       </form>
+</div>
diff --git a/application/ship-simu/templates/de/html/home.tpl b/application/ship-simu/templates/de/html/home.tpl
deleted file mode 100644 (file)
index 8625082..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<div id="content_header">
-       Willkommen zum Schiffsimulator &quot;Ship-Simu&quot;!
-</div>
-
-<div id="news_frame">
-       {?ship_simu_news?}
-</div>
index 841782a..27fe8d1 100644 (file)
@@ -25,13 +25,13 @@ 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 c5cbce4..3f92b37 100644 (file)
@@ -25,18 +25,18 @@ class InvalidTemplateVariableNameException extends FrameworkException {
        /**
         * The constructor
         *
-        * @param               $class          An array holding our informations
+        * @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
index f341fc9..c1f216e 100644 (file)
@@ -219,8 +219,50 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        public final function __call ($methodName, $args) {
                // Implode all given arguments
-               $argsString = implode("|", $args);
-               if (empty($argsString)) $argsString = "NULL";
+               $argsString = "";
+               if (empty($args)) {
+                       // No arguments
+                       $argsString = "NULL";
+               } elseif (is_array($args)) {
+                       // Some arguments are there
+                       foreach ($args as $arg) {
+                               // Check the type
+                               if (is_bool($arg)) {
+                                       // Boolean!
+                                       if ($arg) $argsString .= "true(bool)"; else $argsString .= "false(bool)";
+                               } elseif (is_int($arg)) {
+                                       // Integer
+                                       $argsString .= $arg."(int)";
+                               } elseif (is_float($arg)) {
+                                       // Floating point
+                                       $argsString .= $arg."(float)";
+                               } elseif ($arg instanceof BaseFramework) {
+                                       // Own object instance
+                                       $argsString .= $arg->__toString()."(Object)";
+                               } elseif (is_object($arg)) {
+                                       // External object
+                                       $argsString .= "unknown object(!)";
+                               } elseif (is_array($arg)) {
+                                       // Array
+                                       $argsString .= "Array(array)";
+                               } elseif (is_string($arg)) {
+                                       // String
+                                       $argsString .= "\"".$arg."\"(string)";
+                               } else {
+                                       // Unknown type (please report!)
+                                       $argsString .= $arg."(unknown!)";
+                               }
+
+                               // Add comma
+                               $argsString .= ", ";
+                       }
+
+                       // Remove last comma
+                       if (substr($argsString, -2, 1) === ",") $argsString = substr($argsString, 0, -2);
+               } else {
+                       // Invalid arguments!
+                       $argsString = sprintf("!INVALID:%s!", $args);
+               }
 
                $this->getDebugInstance()->output(sprintf("[%s::%s] Stub! Args: %s",
                        $this->__toString(),
@@ -732,7 +774,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         *
         * @return      $fileIOInstance An instance to the file I/O sub-system
         */
-       protected final function getFileIOInstance () {
+       protected final function getFileIoInstance () {
                return $this->fileIOInstance;
        }
 
@@ -742,7 +784,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @param       $fileIOInstance An instance to the file I/O sub-system
         * @return      void
         */
-       public final function setFileIOInstance (FileIOHandler $fileIOInstance) {
+       public final function setFileIoInstance (FileIoHandler $fileIOInstance) {
                $this->fileIOInstance = $fileIOInstance;
        }
 
@@ -806,7 +848,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                if ($appInstance->getLanguageInstance() === null) {
                        // Invalid language instance
                        throw new MissingLanguageHandlerException($appInstance, self::EXCEPTION_MISSING_LANGUAGE_HANDLER);
-               } elseif ($appInstance->getFileIOInstance() === null) {
+               } elseif ($appInstance->getFileIoInstance() === null) {
                        // Invalid language instance
                        throw new MissingFileIoHandlerException($appInstance, self::EXCEPTION_MISSING_FILE_IO_HANDLER);
                }
@@ -816,7 +858,7 @@ 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"),
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]
+?>
index 9629b97..7030bd1 100644 (file)
@@ -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");
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..01ba9cd
--- /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("Anmeldeformular-Command");
+
+               // 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 84babfe..b23dbc5 100644 (file)
@@ -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);
diff --git a/inc/classes/main/io/class_FileIOStream.php b/inc/classes/main/io/class_FileIOStream.php
deleted file mode 100644 (file)
index c983346..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-<?php
-/**
- * An universal class for file input/output streams.
- *
- * @author             Roland Haeder <webmaster@mxchange.org>
- * @version            0.0.0
- * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class FileIOStream extends BaseFrameworkSystem implements FileInputStreamer, FileOutputStreamer {
-       /**
-        * Protected constructor
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set part description
-               $this->setObjectDescription("Universal Datei-Ein-/Ausgabesystem");
-
-               // Create unique ID
-               $this->createUniqueID();
-
-               // Clean-up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
-       }
-
-       /**
-        * Create a file IO stream. This is a class for performing all actions
-        * on files like creating, deleting and loading them.
-        *
-        * @return      $ioInstance     An instance of FileIOStream
-        */
-       public final static function createFileIOStream () {
-               // Create new instance
-               $ioInstance = new FileIOStream();
-
-               // Return the instance
-               return $ioInstance;
-       }
-
-       /**
-        * Saves data to a given local file
-        *
-        * @param               $fileName               The file name for the to be saved file
-        * @param               $dataArray      The data we shall store to the file
-        * @return      void
-        * @see         FileOutputStreamer
-        */
-       public final function saveFile ($fileName, $dataArray) {
-               // Try it five times
-               $dirName = ""; $fileInstance = null;
-               for ($idx = 0; $idx < 5; $idx++) {
-                       // Get a file output pointer
-                       try {
-                               $fileInstance = FrameworkFileOutputPointer::createFrameworkFileOutputPointer($fileName, 'w');
-                       } catch (FilePointerNotOpenedException $e) {
-                               // Create missing directory
-                               $dirName = dirname($fileName);
-                               for ($idx2 = 0; $idx2 < (2 - $idx); $idx2++) {
-                                       $dirName = dirname($dirName);
-                               }
-                               // Try to create it
-                               @mkdir($dirName);
-                       }
-               }
-
-               // Write a header information for validation purposes
-               $fileInstance->writeToFile(sprintf("@head^%s:%s:%s:%s\n",
-                       $dataArray[0],
-                       time(),
-                       strlen($dataArray[1]),
-                       md5($dataArray[1])
-               ));
-
-               // Encode the (maybe) binary stream with Base64
-               $b64Stream = base64_encode($dataArray[1]);
-
-               // write the data line by line
-               $line = str_repeat(" ", 50); $idx = 0;
-               while (strlen($line) == 50) {
-                       // Get 50 chars or less
-                       $line = substr($b64Stream, $idx, 50);
-
-                       // Save it to the stream
-                       $fileInstance->writeToFile(sprintf("@data^%s:%s\n",
-                               $line,
-                               md5($line)
-                       ));
-
-                       // Advance to the next 50-chars block
-                       $idx += 50;
-               }
-
-               // Close the file
-               $fileInstance->closeFile();
-       }
-
-       /**
-        * Reads from a local file
-        *
-        * @param               $fqfn   The full-qualified file-name which we shall load
-        * @return      $array  An array with the element 'header' and 'data'
-        * @see         FileInputStreamer
-        */
-       public final function loadFileContents ($fqfn) {
-               // Initialize some variables and arrays
-               $inputBuffer = "";
-               $lastBuffer = "";
-               $header = array();
-               $data = array();
-               $readData = ""; // This will contain our read data
-
-               // Get a file input handler
-               $fileInstance = FrameworkFileInputPointer::createFrameworkFileInputPointer($fqfn);
-
-               // Read all it's contents (we very and transparently decompress it below)
-               while ($readRawLine = $fileInstance->readFromFile()) {
-                       // Add the read line to the buffer
-                       $inputBuffer .= $readRawLine;
-
-                       // Break infinite loop maybe caused by the input handler
-                       if ($lastBuffer == $inputBuffer) break;
-
-                       // Remember last read line for avoiding possible infinite loops
-                       $lastBuffer = $inputBuffer;
-               }
-
-               // Close directory handle
-               $fileInstance->closeFile();
-
-               // Convert it into an array
-               $inputBuffer = explode("\n", $inputBuffer);
-
-               // Now process the read lines and verify it's content
-               foreach ($inputBuffer as $rawLine) {
-                       // Trim it a little but not the leading spaces/tab-stops
-                       $rawLine = rtrim($rawLine);
-
-                       // Analyze this line
-                       if (substr($rawLine, 0, 5) == "@head") {
-                               // Header found, so let's extract it
-                               $header = explode("^", $rawLine);
-                               $header = trim($header[1]);
-
-                               // Now we must convert it again into an array
-                               $header = explode(":", $header);
-
-                               // Is the header (maybe) valid?
-                               if (count($header) != 4) {
-                                       // Throw an exception
-                                       throw new InvalidArrayCountException(array($this, "header", count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
-                               }
-                       } elseif (substr($rawLine, 0, 5) == "@data") {
-                               // Is a data line!
-                               $data = explode("^", $rawLine);
-                               $data = $data[1];
-
-                               // First element is the data, second the MD5 checksum
-                               $data = explode(":", $data);
-
-                               // Validate the read line
-                               if (count($data) == 2) {
-                                       if (md5($data[0]) != $data[1]) {
-                                               // MD5 hash did not match!
-                                               throw new InvalidMD5ChecksumException(array($this, md5($data[0]), $data[1]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
-                                       }
-                               } else {
-                                       // Invalid count!
-                                       throw new InvalidArrayCountException(array($this, "data", count($data), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
-                               }
-
-                               // Add this to the readData string
-                               $readData .= $data[0];
-                       } else {
-                               // Other raw lines than header/data tagged lines and re-add the new-line char
-                               $readData .= $rawLine."\n";
-                       }
-               }
-
-               // Was raw lines read and no header/data?
-               if ((!empty($readData)) && (count($header) == 0) && (count($data) == 0)) {
-                       // Return raw lines back
-                       return $readData;
-               }
-
-               // Was a header found?
-               if (count($header) != 4) {
-                       // Throw an exception
-                       throw new InvalidArrayCountException(array($this, "header", count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
-               }
-
-               // Decode all from Base64
-               $readData = @base64_decode($readData);
-
-               // Does the size match?
-               if (strlen($readData) != $header[2]) {
-                       // Size did not match
-                       throw new InvalidDataLengthException(array($this, strlen($readData), $header[2]), self::EXCEPTION_UNEXPECTED_STRING_SIZE);
-               }
-
-               // Validate the decoded data with the final MD5 hash
-               if (md5($readData) != $header[3]) {
-                       // MD5 hash did not match!
-                       throw new InvalidMD5ChecksumException(array($this, md5($readData), $header[3]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
-               }
-
-               // Return all in an array
-               return array(
-                       'header' => $header,
-                       'data'   => $readData
-               );
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/io/class_FileIoStream.php b/inc/classes/main/io/class_FileIoStream.php
new file mode 100644 (file)
index 0000000..c983346
--- /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 Datei-Ein-/Ausgabesystem");
+
+               // Create unique ID
+               $this->createUniqueID();
+
+               // Clean-up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Create a file IO stream. This is a class for performing all actions
+        * on files like creating, deleting and loading them.
+        *
+        * @return      $ioInstance     An instance of FileIOStream
+        */
+       public final static function createFileIOStream () {
+               // Create new instance
+               $ioInstance = new FileIOStream();
+
+               // Return the instance
+               return $ioInstance;
+       }
+
+       /**
+        * Saves data to a given local file
+        *
+        * @param               $fileName               The file name for the to be saved file
+        * @param               $dataArray      The data we shall store to the file
+        * @return      void
+        * @see         FileOutputStreamer
+        */
+       public final function saveFile ($fileName, $dataArray) {
+               // Try it five times
+               $dirName = ""; $fileInstance = null;
+               for ($idx = 0; $idx < 5; $idx++) {
+                       // Get a file output pointer
+                       try {
+                               $fileInstance = FrameworkFileOutputPointer::createFrameworkFileOutputPointer($fileName, 'w');
+                       } catch (FilePointerNotOpenedException $e) {
+                               // Create missing directory
+                               $dirName = dirname($fileName);
+                               for ($idx2 = 0; $idx2 < (2 - $idx); $idx2++) {
+                                       $dirName = dirname($dirName);
+                               }
+                               // Try to create it
+                               @mkdir($dirName);
+                       }
+               }
+
+               // Write a header information for validation purposes
+               $fileInstance->writeToFile(sprintf("@head^%s:%s:%s:%s\n",
+                       $dataArray[0],
+                       time(),
+                       strlen($dataArray[1]),
+                       md5($dataArray[1])
+               ));
+
+               // Encode the (maybe) binary stream with Base64
+               $b64Stream = base64_encode($dataArray[1]);
+
+               // write the data line by line
+               $line = str_repeat(" ", 50); $idx = 0;
+               while (strlen($line) == 50) {
+                       // Get 50 chars or less
+                       $line = substr($b64Stream, $idx, 50);
+
+                       // Save it to the stream
+                       $fileInstance->writeToFile(sprintf("@data^%s:%s\n",
+                               $line,
+                               md5($line)
+                       ));
+
+                       // Advance to the next 50-chars block
+                       $idx += 50;
+               }
+
+               // Close the file
+               $fileInstance->closeFile();
+       }
+
+       /**
+        * Reads from a local file
+        *
+        * @param               $fqfn   The full-qualified file-name which we shall load
+        * @return      $array  An array with the element 'header' and 'data'
+        * @see         FileInputStreamer
+        */
+       public final function loadFileContents ($fqfn) {
+               // Initialize some variables and arrays
+               $inputBuffer = "";
+               $lastBuffer = "";
+               $header = array();
+               $data = array();
+               $readData = ""; // This will contain our read data
+
+               // Get a file input handler
+               $fileInstance = FrameworkFileInputPointer::createFrameworkFileInputPointer($fqfn);
+
+               // Read all it's contents (we very and transparently decompress it below)
+               while ($readRawLine = $fileInstance->readFromFile()) {
+                       // Add the read line to the buffer
+                       $inputBuffer .= $readRawLine;
+
+                       // Break infinite loop maybe caused by the input handler
+                       if ($lastBuffer == $inputBuffer) break;
+
+                       // Remember last read line for avoiding possible infinite loops
+                       $lastBuffer = $inputBuffer;
+               }
+
+               // Close directory handle
+               $fileInstance->closeFile();
+
+               // Convert it into an array
+               $inputBuffer = explode("\n", $inputBuffer);
+
+               // Now process the read lines and verify it's content
+               foreach ($inputBuffer as $rawLine) {
+                       // Trim it a little but not the leading spaces/tab-stops
+                       $rawLine = rtrim($rawLine);
+
+                       // Analyze this line
+                       if (substr($rawLine, 0, 5) == "@head") {
+                               // Header found, so let's extract it
+                               $header = explode("^", $rawLine);
+                               $header = trim($header[1]);
+
+                               // Now we must convert it again into an array
+                               $header = explode(":", $header);
+
+                               // Is the header (maybe) valid?
+                               if (count($header) != 4) {
+                                       // Throw an exception
+                                       throw new InvalidArrayCountException(array($this, "header", count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+                               }
+                       } elseif (substr($rawLine, 0, 5) == "@data") {
+                               // Is a data line!
+                               $data = explode("^", $rawLine);
+                               $data = $data[1];
+
+                               // First element is the data, second the MD5 checksum
+                               $data = explode(":", $data);
+
+                               // Validate the read line
+                               if (count($data) == 2) {
+                                       if (md5($data[0]) != $data[1]) {
+                                               // MD5 hash did not match!
+                                               throw new InvalidMD5ChecksumException(array($this, md5($data[0]), $data[1]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
+                                       }
+                               } else {
+                                       // Invalid count!
+                                       throw new InvalidArrayCountException(array($this, "data", count($data), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+                               }
+
+                               // Add this to the readData string
+                               $readData .= $data[0];
+                       } else {
+                               // Other raw lines than header/data tagged lines and re-add the new-line char
+                               $readData .= $rawLine."\n";
+                       }
+               }
+
+               // Was raw lines read and no header/data?
+               if ((!empty($readData)) && (count($header) == 0) && (count($data) == 0)) {
+                       // Return raw lines back
+                       return $readData;
+               }
+
+               // Was a header found?
+               if (count($header) != 4) {
+                       // Throw an exception
+                       throw new InvalidArrayCountException(array($this, "header", count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+               }
+
+               // Decode all from Base64
+               $readData = @base64_decode($readData);
+
+               // Does the size match?
+               if (strlen($readData) != $header[2]) {
+                       // Size did not match
+                       throw new InvalidDataLengthException(array($this, strlen($readData), $header[2]), self::EXCEPTION_UNEXPECTED_STRING_SIZE);
+               }
+
+               // Validate the decoded data with the final MD5 hash
+               if (md5($readData) != $header[3]) {
+                       // MD5 hash did not match!
+                       throw new InvalidMD5ChecksumException(array($this, md5($readData), $header[3]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
+               }
+
+               // Return all in an array
+               return array(
+                       'header' => $header,
+                       'data'   => $readData
+               );
+       }
+}
+
+// [EOF]
+?>
index 4c15006..f929b8a 100644 (file)
@@ -138,7 +138,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         *
         * @param       $basePath               The local base path for all templates
         * @param       $langInstance   An instance of LanguageSystem (default)
-        * @param       $ioInstance             An instance of FileIOHandler (default, middleware!)
+        * @param       $ioInstance             An instance of FileIoHandler (default, middleware!)
         * @return      $tplInstance    An instance of TemplateEngine
         * @throws      BasePathIsEmptyException                If the provided $basePath is empty
         * @throws      InvalidBasePathStringException  If $basePath is no string
@@ -147,7 +147,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         * @throws      BasePathReadProtectedException  If $basePath is
         *                                                                                      read-protected
         */
-       public final static function createTemplateEngine ($basePath, ManageableLanguage  $langInstance, FileIOHandler $ioInstance) {
+       public final static function createTemplateEngine ($basePath, ManageableLanguage  $langInstance, FileIoHandler $ioInstance) {
                // Get a new instance
                $tplInstance = new TemplateEngine();
 
@@ -177,7 +177,7 @@ 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"));
@@ -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)) {
@@ -612,13 +612,14 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        // 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")) {
+                               // @TODO Find a better way than ignoring our instance variable $this
+                               if (($variableMatches[1][$key] != $this->getConfigInstance()->readConfig("tpl_valid_var")) && ($variableMatches[1][$key] != "config") && ($variableMatches[1][$key] != "this")) {
                                        // Invalid variable name
                                        throw new InvalidTemplateVariableNameException(array($this, $this->getLastTemplate(), $variableMatches[1][$key], $this->getConfigInstance()), self::EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR);
+                               } elseif ($variableMatches[1][$key] != "this") {
+                                       // Try to assign it, empty strings are being ignored
+                                       $this->assignTemplateVariable($variableMatches[1][$key], $var);
                                }
-
-                               // Try to assign it, empty strings are being ignored
-                               $this->assignTemplateVariable($variableMatches[1][$key], $var);
                        }
                }
        }
@@ -990,6 +991,40 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        addslashes($this->getRawTemplateData())
                );
 
+               // 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);
+                       }
+
+                       // 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);
+               }
+
+               // 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(),
@@ -1158,6 +1193,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/middleware/io/class_FileIOHandler.php b/inc/classes/middleware/io/class_FileIOHandler.php
deleted file mode 100644 (file)
index 8c7a47a..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-<?php
-/**
- * This is a file IO handler. It handles reading from and writing to files.
- * Missing paths in writing process will be automatically created.
- *
- * @author             Roland Haeder <webmaster@mxchange.org>
- * @version            0.0.0
- * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class FileIOHandler extends BaseMiddleware {
-       /**
-        * The *real* file input class we shall use for reading data
-        */
-       private $inputStream = null;
-
-       /**
-        * The *real* file output class we shall use for reading data
-        */
-       private $outputStream = null;
-
-       /**
-        * An instance of this class
-        */
-       private static $thisInstance = null;
-
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set description
-               $this->setObjectDescription("Datei-Ein-/Ausgabe-Handler");
-
-               // Create an unique ID
-               $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
-
-               // Set own instance
-               self::$thisInstance = $this;
-       }
-
-       /**
-        * Creates an instance of this class and prepares the IO system. This is
-        * being done by setting the default file IO class
-        *
-        * @return      $ioInstance     A prepared instance of FilIOHandler
-        */
-       public final static function createFileIOHandler () {
-               // Get instance
-               $ioHandler = new FileIOHandler();
-
-               // Set the *real* file IO instances (both the same)
-               $ioHandler->setInputStream(FileIOStream::createFileIOStream());
-               $ioHandler->setOutputStream(FileIOStream::createFileIOStream());
-
-               // Return instance
-               return $ioHandler;
-       }
-
-       /**
-        * Getter for an instance of this class
-        *
-        * @return      $thisInstance   An instance of this class
-        */
-       public final static function getInstance () {
-               return self::$thisInstance;
-       }
-
-       /**
-        * Setter for the *real* file input instance
-        *
-        * @param               $inputStream    The *real* file-input class
-        */
-       public final function setInputStream (FileInputStreamer $inputStream) {
-               $this->inputStream = $inputStream;
-       }
-
-       /**
-        * Getter for the *real* file input instance
-        *
-        * @return      $inputStream    The *real* file-input class
-        */
-       public final function getInputStream () {
-               return $this->inputStream;
-       }
-
-       /**
-        * Setter for the *real* file output instance
-        *
-        * @param               $outputStream   The *real* file-output class
-        */
-       public final function setOutputStream (FileOutputStreamer $outputStream) {
-               $this->outputStream = $outputStream;
-       }
-
-       /**
-        * Getter for the *real* file output instance
-        *
-        * @return      $outputStream   The *real* file-output class
-        */
-       public final function getOutputStream () {
-               return $this->outputStream;
-       }
-
-       /**
-        * Saves a file with data by using the current output stream
-        *
-        * @see FileOutputStreamer
-        */
-       public function saveFile ($fileName, $dataArray) {
-               // Get output stream
-               $outInstance = $this->getOutputStream();
-
-               // Is it a valid stream?
-               if (is_null($outInstance)) {
-                       // No class returned
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($outInstance)) {
-                       // Not an object! ;-(
-                       throw new NoObjectException($outInstance, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($outInstance, 'saveFile')) {
-                       // Nope, so throw exception
-                       throw new MissingMethodException(array($outInstance, 'saveFile'), self::EXCEPTION_MISSING_METHOD);
-               }
-
-               // Send the fileName and dataArray to the output handler
-               $outInstance->saveFile($fileName, $dataArray);
-       }
-
-       /** Loads data from a file over the input handler
-        *
-        * @see FileInputStreamer
-        */
-       public function loadFileContents ($fqfn) {
-               // Initialize the array
-               $array = array();
-
-               // Get output stream
-               $inInstance = $this->getInputStream();
-
-               // Is it a valid stream?
-               if (is_null($inInstance)) {
-                       // No class returned
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($inInstance)) {
-                       // Not an object! ;-(
-                       throw new NoObjectException($inInstance, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($inInstance, 'loadFileContents')) {
-                       // Nope, so throw exception
-                       throw new MissingMethodException(array($inInstance, 'loadFileContents'), self::EXCEPTION_MISSING_METHOD);
-               }
-
-               // Read from the input handler
-               return $inInstance->loadFileContents($fqfn);
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/middleware/io/class_FileIoHandler.php b/inc/classes/middleware/io/class_FileIoHandler.php
new file mode 100644 (file)
index 0000000..8c7a47a
--- /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 a14e7c8..1551156 100644 (file)
@@ -24,7 +24,7 @@
 
 // Zum Testen speichern wir in lokale Dateien (LocalFileDatabase)
 try {
-       $layer = LocalFileDatabase::createLocalFileDatabase(PATH . "db/", FileIOHandler::getInstance());
+       $layer = LocalFileDatabase::createLocalFileDatabase(PATH . "db/", FileIoHandler::getInstance());
 } catch (SavePathIsEmptyException $e) {
        ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: <strong>%s</strong><br />\n",
                $e->getMessage()
index 18b0cb4..de20bf5 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 // Get the instance
-$io = FileIOHandler::createFileIOHandler();
+$io = FileIoHandler::createFileIoHandler();
 
 // [EOF]
 ?>
index 9cabcb0..1956b02 100644 (file)
--- a/index.php
+++ b/index.php
@@ -68,7 +68,7 @@ class ApplicationEntryPoint {
                // Get some instances
                $tpl = FrameworkConfiguration::getInstance()->readConfig("tpl_engine");
                $lang = LanguageSystem::getInstance();
-               $io = FileIOHandler::getInstance();
+               $io = FileIoHandler::getInstance();
 
                // Is the template engine loaded?
                if ((class_exists($tpl)) && (is_object($lang)) && (is_object($io))) {
index 4cd1cf9..d5c6f90 100644 (file)
@@ -2,7 +2,7 @@
 
 {?header:title="Problem in application framework detected!"?}
 
-{?navigation:nav_row=home;imprint;contact?}
+{?navigation?}
 
        <div id="emergency_exit message_box">
                $content[message]