]> git.mxchange.org Git - hub.git/commitdiff
Code merge from latest Ship-Simu code
authorRoland Häder <roland@mxchange.org>
Sat, 31 May 2008 21:39:42 +0000 (21:39 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 31 May 2008 21:39:42 +0000 (21:39 +0000)
39 files changed:
.gitattributes
inc/classes/exceptions/criteria/.htaccess [new file with mode: 0644]
inc/classes/exceptions/criteria/class_FrameworkException.php [new file with mode: 0644]
inc/classes/exceptions/database/wrapper/.htaccess [new file with mode: 0644]
inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php [new file with mode: 0644]
inc/classes/exceptions/main/class_ClassNotFoundException.php
inc/classes/interfaces/cache/.htaccess [new file with mode: 0644]
inc/classes/interfaces/cache/class_Cacheable.php [new file with mode: 0644]
inc/classes/interfaces/criteria/.htaccess [new file with mode: 0644]
inc/classes/interfaces/criteria/class_Criteria.php [new file with mode: 0644]
inc/classes/interfaces/criteria/extended/.htaccess [new file with mode: 0644]
inc/classes/interfaces/criteria/extended/class_LocalCriteria.php [new file with mode: 0644]
inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php
inc/classes/main/cache/.htaccess [new file with mode: 0644]
inc/classes/main/cache/class_MemoryCache.php [new file with mode: 0644]
inc/classes/main/class_
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/controller/class_BaseController.php
inc/classes/main/criteria/.htaccess [new file with mode: 0644]
inc/classes/main/criteria/class_SearchCriteria.php [new file with mode: 0644]
inc/classes/main/database/class_ [new file with mode: 0644]
inc/classes/main/database/class_BaseDatabaseWrapper.php [new file with mode: 0644]
inc/classes/main/database/databases/.htaccess [new file with mode: 0644]
inc/classes/main/database/databases/class_LocalFileDatabase.php [new file with mode: 0644]
inc/classes/main/database/wrapper/.htaccess [new file with mode: 0644]
inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php [new file with mode: 0644]
inc/classes/main/factories/cache/.htaccess [new file with mode: 0644]
inc/classes/main/factories/cache/class_CacheFactory.php [new file with mode: 0644]
inc/classes/main/factories/class_BaseFactory.php
inc/classes/main/factories/objects/class_ObjectFactory.php
inc/classes/main/factories/web/class_WebNewsFactory.php
inc/classes/main/filter/validator/class_UserNameValidatorFilter.php
inc/classes/main/user/class_User.php
inc/classes/middleware/class_BaseMiddleware.php
inc/classes/middleware/compressor/class_CompressorChannel.php
inc/classes/middleware/database/class_DatabaseConnection.php
inc/classes/middleware/io/class_FileIoHandler.php
inc/config.php
inc/file_io.php

index 8455a4b44e07a5c40eb3875b8f19f65199e0f48a..9eed639065df801bfc40e9eda95b3f3096e4df61 100644 (file)
@@ -65,12 +65,16 @@ inc/classes/exceptions/container/class_ContainerItemIsNullException.php -text
 inc/classes/exceptions/container/class_ContainerMaybeDamagedException.php -text
 inc/classes/exceptions/controller/.htaccess -text
 inc/classes/exceptions/controller/class_DefaultControllerException.php -text
+inc/classes/exceptions/criteria/.htaccess -text
+inc/classes/exceptions/criteria/class_FrameworkException.php -text
 inc/classes/exceptions/database/.htaccess -text
 inc/classes/exceptions/database/local_file/.htaccess -text
 inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php -text
 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/database/wrapper/.htaccess -text
+inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php -text
 inc/classes/exceptions/helper/.htaccess -text
 inc/classes/exceptions/helper/class_FormClosedException.php -text
 inc/classes/exceptions/helper/class_FormGroupClosedException.php -text
@@ -130,6 +134,8 @@ 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
+inc/classes/interfaces/cache/.htaccess -text
+inc/classes/interfaces/cache/class_Cacheable.php -text
 inc/classes/interfaces/class_ -text
 inc/classes/interfaces/class_FrameworkInterface.php -text
 inc/classes/interfaces/commands/.htaccess -text
@@ -138,6 +144,10 @@ inc/classes/interfaces/compressor/.htaccess -text
 inc/classes/interfaces/compressor/class_Compressor.php -text
 inc/classes/interfaces/controller/.htaccess -text
 inc/classes/interfaces/controller/class_Controller.php -text
+inc/classes/interfaces/criteria/.htaccess -text
+inc/classes/interfaces/criteria/class_Criteria.php -text
+inc/classes/interfaces/criteria/extended/.htaccess -text
+inc/classes/interfaces/criteria/extended/class_LocalCriteria.php -text
 inc/classes/interfaces/database/.htaccess -text
 inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php -text
 inc/classes/interfaces/database/frontend/.htaccess -text
@@ -172,6 +182,8 @@ 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/cache/.htaccess -text
+inc/classes/main/cache/class_MemoryCache.php -text
 inc/classes/main/class_ -text
 inc/classes/main/class_BaseFrameworkSystem.php -text
 inc/classes/main/class_FrameworkArrayObject.php -text
@@ -200,10 +212,18 @@ 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/criteria/.htaccess -text
+inc/classes/main/criteria/class_SearchCriteria.php -text
 inc/classes/main/database/.htaccess -text
+inc/classes/main/database/class_ -text
 inc/classes/main/database/class_BaseDatabaseFrontend.php -text
+inc/classes/main/database/class_BaseDatabaseWrapper.php -text
 inc/classes/main/database/classes/.htaccess -text
 inc/classes/main/database/classes/class_LocalFileDatabase.php -text
+inc/classes/main/database/databases/.htaccess -text
+inc/classes/main/database/databases/class_LocalFileDatabase.php -text
+inc/classes/main/database/wrapper/.htaccess -text
+inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php -text
 inc/classes/main/debug/.htaccess -text
 inc/classes/main/debug/class_DebugConsoleOutput.php -text
 inc/classes/main/debug/class_DebugErrorLogOutput.php -text
@@ -212,6 +232,8 @@ inc/classes/main/extended/.htaccess -text
 inc/classes/main/extended/class_ObjectLimits.php -text
 inc/classes/main/extended/class_SerializationContainer.php -text
 inc/classes/main/factories/.htaccess -text
+inc/classes/main/factories/cache/.htaccess -text
+inc/classes/main/factories/cache/class_CacheFactory.php -text
 inc/classes/main/factories/class_BaseFactory.php -text
 inc/classes/main/factories/objects/.htaccess -text
 inc/classes/main/factories/objects/class_ObjectFactory.php -text
diff --git a/inc/classes/exceptions/criteria/.htaccess b/inc/classes/exceptions/criteria/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/exceptions/criteria/class_FrameworkException.php b/inc/classes/exceptions/criteria/class_FrameworkException.php
new file mode 100644 (file)
index 0000000..d9e977f
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * An exception thrown when a criteria was not supported
+ *
+ * @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 UnsupportedCriteriaException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $classArray             The non-optional message for the exception
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct (array $classArray, $code = 0) {
+               // Construct the message
+               $message = sprintf("[%s:%d] Unsupported criteria <u>%s</u> detected.",
+                       $classArray[0]->__toString(),
+                       $this->getLine(),
+                       $classArray[1]->__toString()
+               );
+
+               // make sure everything is assigned properly
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/exceptions/database/wrapper/.htaccess b/inc/classes/exceptions/database/wrapper/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php b/inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php
new file mode 100644 (file)
index 0000000..0804803
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * An exception thrown when the database wrapper has not found the username
+ *
+ * @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 WrapperUserNameNotFoundException extends FrameworkException {
+       /**
+        * The constructor
+        *
+        * @param               $msgArray               Message from the exception
+        * @param               $code           Code number for the exception
+        * @return      void
+        */
+       public function __construct (array $msgArray, $code) {
+               // Add a message around the missing class
+               $message = sprintf("[%s:%d] Username <u>%s</u> was not found. Requesting class: <u>%s</u>",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1]->getUserName(),
+                       $msgArray[1]->__toString()
+               );
+
+               // Call parent constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
index 304d7cd8c2b03bac833648ebcaeb4d78b3737159..34f0ed3c36d3dea146563c2219552519d83564e8 100644 (file)
@@ -25,13 +25,17 @@ class ClassNotFoundException extends FrameworkException {
        /**
         * The constructor
         *
-        * @param               $message                Message from the exception
+        * @param               $msgArray       Message from the exception
         * @param               $code           Code number for the exception
         * @return      void
         */
-       public function __construct (BaseFrameworkSystem $class, $code) {
+       public function __construct (array $msgArray, $code) {
                // Add a message around the missing class
-               $message = sprintf("Die interne Script-Klasse <u>%s</u> konnte nicht gefunden werden!", $class);
+               $message = sprintf("[%s:%d] Internal class <u>%s</u> not found.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1]
+               );
 
                // Call parent constructor
                parent::__construct($message, $code);
diff --git a/inc/classes/interfaces/cache/.htaccess b/inc/classes/interfaces/cache/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/cache/class_Cacheable.php b/inc/classes/interfaces/cache/class_Cacheable.php
new file mode 100644 (file)
index 0000000..c6fa237
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+/**
+ * An interface for classes which are "able" to cache
+ *
+ * @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 Cacheable extends FrameworkInterface {
+       /**
+        * Does the specified offset exist in cache?
+        *
+        * @param       $offset         The offsrt we are looking for
+        * @return      $exists         Wether the offset exists
+        */
+       function offsetExists ($offset);
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/interfaces/criteria/.htaccess b/inc/classes/interfaces/criteria/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/criteria/class_Criteria.php b/inc/classes/interfaces/criteria/class_Criteria.php
new file mode 100644 (file)
index 0000000..d69efad
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/**
+ * An interface for criterias
+ *
+ * @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 Criteria extends FrameworkInterface {
+       /**
+        * Add extra criteria
+        *
+        * @param       $criteriaKey    Criteria key
+        * @param       $criteriaValue  Criteria value
+        * @return      void
+        */
+       function addCriteria ($criteriaKey, $criteriaValue);
+}
+
+//
+?>
diff --git a/inc/classes/interfaces/criteria/extended/.htaccess b/inc/classes/interfaces/criteria/extended/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/criteria/extended/class_LocalCriteria.php b/inc/classes/interfaces/criteria/extended/class_LocalCriteria.php
new file mode 100644 (file)
index 0000000..2ac9efd
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * An interface for local criterias
+ *
+ * @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 LocalCriteria extends Criteria {
+}
+
+//
+?>
index 9b44eabe1c255346f54c3bc4303c5be8eea76c1c..14e89d99856885532bb5cb7e06a9a7be76ed7491 100644 (file)
@@ -36,6 +36,24 @@ interface DatabaseFrontendInterface extends FrameworkDatabaseInterface {
         *                                      ObjectContainer
         */
        function loadObject ();
+
+       /**
+        * Makes sure that the database connection is alive
+        *
+        * @return      void
+        */
+       function connectToDatabase ();
+
+       /**
+        * Starts a SELECT query on the database by given return type, table name
+        * and search criteria
+        *
+        * @param       $resultType             Result type ("array", "object" and "indexed" are valid)
+        * @param       $tableName              Name of the database table
+        * @param       $criteria               Search criteria class
+        * @return      $resultData             Result data of the query
+        */
+       function querySelect ($resultType, $tableName, Criteria $criteriaInstance);
 }
 
 // [EOF]
diff --git a/inc/classes/main/cache/.htaccess b/inc/classes/main/cache/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/cache/class_MemoryCache.php b/inc/classes/main/cache/class_MemoryCache.php
new file mode 100644 (file)
index 0000000..7da2e16
--- /dev/null
@@ -0,0 +1,120 @@
+<?php
+/**
+ * A simple memory cache (similar to a registry)
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.3.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
+ *
+ * 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 MemoryCache extends BaseFrameworkSystem implements Cacheable {
+       /**
+        * The "memory cache" is simply a wrapped object array
+        */
+       private $dataCache = null;
+
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Memory cache");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $cacheInstance  An instance of this cache class
+        */
+       public final static function createMemoryCache () {
+               // Get a new instance
+               $cacheInstance = new MemoryCache();
+
+               // Initialize the cache
+               $cacheInstance->initCache();
+
+               // Return the prepared instance
+               return $cacheInstance;
+       }
+
+       /**
+        * Initialize this cache by creating an object array
+        *
+        * @return      void
+        */
+       protected function initCache () {
+               // Now create the "data cache"
+               $this->dataCache = new FrameworkArrayObject();
+       }
+
+       /**
+        * Does the specified offset exist in cache?
+        *
+        * @param       $offset         The offset we are looking for
+        * @return      $exists         Wether the offset exists
+        */
+       public final function offsetExists ($offset) {
+               $exists = $this->dataCache->offsetExists($offset);
+               return $exists;
+       }
+
+       /**
+        * Setter for cache offset
+        *
+        * @param       $offset         The offset we shall set
+        * @param       $data           Data to store in the cache
+        * @return      void
+        */
+       public final function offsetSet ($offset, $data) {
+               $this->dataCache->offsetSet($offset, $data);
+       }
+
+       /**
+        * Getter for cache offset or "null" if not found
+        *
+        * @param       $offset         The offset we shall set
+        * @return      $data           Data to store in the cache
+        */
+       public final function offsetget ($offset) {
+               // Default is offset not found
+               $data = null;
+
+               // Is the offset there?
+               if ($this->offsetExists($offset)) {
+                       // Then get the data from it
+                       $data = $this->dataCache->offsetGet($offset);
+               }
+
+               // Return data
+               return $data;
+       }
+}
+
+// [EOF]
+?>
index c7a35e7d32ef4bb0901b5c7a829c0cc8aa59d473..84434608897e137df38a865b9ffcf6d7fe0d5fe2 100644 (file)
@@ -27,9 +27,9 @@ class  extends BaseFrameworkSystem {
         *
         * @return      void
         */
-       private function __construct () {
+       protected function __construct () {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set part description
                $this->setObjectDescription("");
index 1ccb1c2c765fdb5d588fad9b0a122e9cd0676dc2..28627720d238a7c104d3e13e4fdcb717faecc7c2 100644 (file)
@@ -150,6 +150,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        const EXCEPTION_HEADERS_ALREADY_SENT         = 0x033;
        const EXCEPTION_DEFAUL_CONTROLLER_GONE       = 0x034;
        const EXCEPTION_CLASS_NOT_FOUND              = 0x035;
+       const EXCEPTION_REQUIRED_INTERFACE_MISSING   = 0x036;
 
        /**
         * In the super constructor these system classes shall be ignored or else
@@ -236,7 +237,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                                } elseif (is_float($arg)) {
                                        // Floating point
                                        $argsString .= $arg."(float)";
-                               } elseif ($arg instanceof BaseFramework) {
+                               } elseif ($arg instanceof BaseFrameworkSystem) {
                                        // Own object instance
                                        $argsString .= $arg->__toString()."(Object)";
                                } elseif (is_object($arg)) {
index a2bf81158444abaea1aef399342006ba2683eee4..409ded2b9eba7a60ee8893b1818947fce167013b 100644 (file)
@@ -53,8 +53,8 @@ class BaseController extends BaseFrameworkSystem {
                $this->removeSystemArray();
 
                // Initialize both filter chains
-               $this->preFilterChain  = FilterChain::createFilterChain();
-               $this->postFilterChain = FilterChain::createFilterChain();
+               $this->preFilterChain  = ObjectFactory::createObjectByConfiguredName('filter_chain');
+               $this->postFilterChain = ObjectFactory::createObjectByConfiguredName('filter_chain');
        }
 
        /**
diff --git a/inc/classes/main/criteria/.htaccess b/inc/classes/main/criteria/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/criteria/class_SearchCriteria.php b/inc/classes/main/criteria/class_SearchCriteria.php
new file mode 100644 (file)
index 0000000..a2f0910
--- /dev/null
@@ -0,0 +1,136 @@
+<?php
+/**
+ * Search criteria for e.g. searching in databases. Do not use this class if
+ * you are looking for a ship or company, or what ever. Instead use this class
+ * for looking in storages like the database.
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.3.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
+ *
+ * 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 SearchCriteria extends BaseFrameworkSystem implements LocalCriteria {
+       /**
+        * Criteria to handle
+        */
+       private $searchCriteria = array();
+
+       /**
+        * Limitation for the search
+        */
+       private $limit = 0;
+
+       /**
+        * Skip these entries before using them
+        */
+       private $skip = 0;
+
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Search criteria class");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Create an instance of this class
+        *
+        * @return      $criteriaInstance       An instance of this criteria
+        */
+       public final static function createSearchCriteria () {
+               // Get a new instance
+               $criteriaInstance = new SearchCriteria();
+
+               // Return this instance
+               return $criteriaInstance;
+       }
+
+       /**
+        * Add extra criteria
+        *
+        * @param       $criteriaKey    Criteria key
+        * @param       $criteriaValue  Criteria value
+        * @return      void
+        */
+       public function addCriteria ($criteriaKey, $criteriaValue) {
+               $this->searchCriteria[$criteriaKey] = $criteriaValue;
+       }
+
+       /**
+        * Setter for limit
+        *
+        * @param       $limit  Search limit
+        * @return      void
+        */
+       public final function setLimit ($limit) {
+               $this->limit = $limit;
+       }
+
+       /**
+        * Setter for skip
+        *
+        * @param       $skip   Search skip
+        * @return      void
+        */
+       public final function setSkip ($skip) {
+               $this->skip = $skip;
+       }
+
+       /**
+        * "Getter" for a cache key
+        *
+        * @return      $cacheKey       The key suitable for the cache system
+        */
+       public function getCacheKey () {
+               // Initialize the key
+               $cacheKey = "";
+
+               // Now walk through all criterias
+               foreach ($this->searchCriteria as $criteriaKey => $criteriaValue) {
+                       // Add the value URL encoded to avoid any trouble with special characters
+                       $cacheKey .= sprintf("%s=%s;",
+                               $criteriaKey,
+                               urlencode($criteriaValue)
+                       );
+               }
+
+               // Add limit and skip values
+               $cacheKey .= sprintf("%%limit%%=%s;%%skip%%=%s",
+                       $this->limit,
+                       $this->skip
+               );
+
+               // Return the cache key
+               return $cacheKey;
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/database/class_ b/inc/classes/main/database/class_
new file mode 100644 (file)
index 0000000..661b38f
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+/**
+ * 
+ *
+ * @see                        DatabaseFrontendInterface - An interface for database frontends (front-end to the application)
+ * @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 BaseDatabaseFrontend {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct($class) {
+               // Call parent constructor
+               parent::constructor(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/database/class_BaseDatabaseWrapper.php b/inc/classes/main/database/class_BaseDatabaseWrapper.php
new file mode 100644 (file)
index 0000000..9c42999
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+/**
+ * A generic database wrapper
+ *
+ * @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 BaseDatabaseWrapper extends BaseFrameworkSystem {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct($class) {
+               // Call parent constructor
+               parent::__construct($class);
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/database/databases/.htaccess b/inc/classes/main/database/databases/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php
new file mode 100644 (file)
index 0000000..16314e1
--- /dev/null
@@ -0,0 +1,521 @@
+<?php
+/**
+ * Database backend class for storing objects in locally created files.
+ *
+ * This class serializes objects and saves them to local files.
+ *
+ * @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 LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontendInterface {
+       /**
+        * Save path for "file database"
+        */
+       private $savePath = "";
+
+       /**
+        * The file's extension
+        */
+       private $fileExtension = "serialized";
+
+       /**
+        * The last read file's name
+        */
+       private $lastFile = "";
+
+       /**
+        * The last read file's content including header information
+        */
+       private $lastContents = array();
+
+       /**
+        * Wether the "connection is already up
+        */
+       private $alreadyConnected = false;
+
+       /**
+        * The private constructor. Do never instance from outside!
+        * You need to set a local file path. The class will then validate it.
+        *
+        * @return      void
+        */
+       protected function __construct() {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set description
+               $this->setObjectDescription("Class for local file databases");
+
+               // Create unique ID
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Create an object of LocalFileDatabase and set the save path for local files.
+        * This method also validates the given file path.
+        *
+        * @param               $savePath                                       The local file path string
+        * @param               $ioInstance                             The input/output handler. This
+        *                                                                      should be FileIoHandler
+        * @return      $dbInstance                             An instance of LocalFileDatabase
+        */
+       public final static function createLocalFileDatabase ($savePath, FileIoHandler $ioInstance) {
+               // Get an instance
+               $dbInstance = new LocalFileDatabase();
+
+               // Set save path and IO instance
+               $dbInstance->setSavePath($savePath);
+               $dbInstance->setFileIoInstance($ioInstance);
+
+               // "Connect" to the database
+               $dbInstance->connectToDatabase();
+
+               // Return database instance
+               return $dbInstance;
+       }
+
+       /**
+        * Setter for save path
+        *
+        * @param               $savePath               The local save path where we shall put our serialized classes
+        * @return      void
+        */
+       public final function setSavePath ($savePath) {
+               // Secure string
+               $savePath = (string) $savePath;
+
+               // Set save path
+               $this->savePath = $savePath;
+       }
+
+       /**
+        * Getter for save path
+        *
+        * @return      $savePath               The local save path where we shall put our serialized classes
+        */
+       public final function getSavePath () {
+               return $this->savePath;
+       }
+
+       /**
+        * Saves a given object to the local file system by serializing and
+        * transparently compressing it
+        *
+        * @param               $object                         The object we shall save to the local file system
+        * @return      void
+        * @throws      NullPointerException    If the object instance is null
+        * @throws      NoObjectException               If the parameter $object is not
+        *                                                              an object
+        */
+       public final function saveObject ($object) {
+               // Some tests on the parameter...
+               if (is_null($object)) {
+                       // Is null, throw exception
+                       throw new NullPointerException($object, self::EXCEPTION_IS_NULL_POINTER);
+               } elseif (!is_object($object)) {
+                       // Is not an object, throw exception
+                       throw new NoObjectException($object, self::EXCEPTION_IS_NO_OBJECT);
+               } elseif (!method_exists($object, '__toString')) {
+                       // A highly required method was not found... :-(
+                       throw new MissingMethodException(array($object, '__toString'), self::EXCEPTION_MISSING_METHOD);
+               }
+
+               // Get a string containing the serialized object. We cannot exchange
+               // $this and $object here because $object does not need to worry
+               // about it's limitations... ;-)
+               $serialized = $this->serializeObject($object);
+
+               // Get a path name plus file name and append the extension
+               $fqfn = $this->getSavePath() . $object->getPathFileNameFromObject() . "." . $this->getFileExtension();
+
+               // 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));
+       }
+
+       /**
+        * Get a serialized string from the given object
+        *
+        * @param               $object         The object we want to serialize and transparently
+        *                                              compress
+        * @return      $serialized     A string containing the serialzed/compressed object
+        * @see         ObjectLimits    An object holding limition information
+        * @see         SerializationContainer  A special container class for e.g.
+        *                                                              attributes from limited objects
+        */
+       private function serializeObject ($object) {
+               // If there is no limiter instance we serialize the whole object
+               // otherwise only in the limiter object (ObjectLimits) specified
+               // attributes summarized in a special container class
+               if ($this->getLimitInstance() === null) {
+                       // Serialize the whole object. This tribble call is the reason
+                       // why we need a fall-back implementation in CompressorChannel
+                       // of the methods compressStream() and decompressStream().
+                       $serialized = $this->getCompressorChannel()->getCompressor()->compressStream(serialize($object));
+               } else {
+                       // Serialize only given attributes in a special container
+                       $container = SerializationContainer::createSerializationContainer($this->getLimitInstance(), $object);
+
+                       // Serialize the container
+                       $serialized = $this->getCompressorChannel()->getCompressor()->compressStream(serialize($container));
+               }
+
+               // Return the serialized object string
+               return $serialized;
+       }
+
+       /**
+        * Analyses if a unique ID has already been used or not by search in the
+        * local database folder.
+        *
+        * @param               $uniqueID               A unique ID number which shall be checked
+        *                                              before it will be used
+        * @param               $inConstructor  If we got called in a de/con-structor or
+        *                                              from somewhere else
+        * @return      $isUnused               true    = The unique ID was not found in the database,
+        *                                              false = It is already in use by an other object
+        * @throws      NoArrayCreatedException If explode() fails to create an array
+        * @throws      InvalidArrayCountException      If the array contains less or
+        *                                                                      more than two elements
+        */
+       public function isUniqueIdUsed ($uniqueID, $inConstructor = false) {
+               // Currently not used... ;-)
+               $isUsed = false;
+
+               // Split the unique ID up in path and file name
+               $pathFile = explode("@", $uniqueID);
+
+               // Are there two elements? Index 0 is the path, 1 the file name + global extension
+               if (!is_array($pathFile)) {
+                       // No array found
+                       if ($inConstructor) {
+                               return false;
+                       } else {
+                               throw new NoArrayCreatedException(array($this, "pathFile"), self::EXCEPTION_ARRAY_EXPECTED);
+                       }
+               } elseif (count($pathFile) != 2) {
+                       // Invalid ID returned!
+                       if ($inConstructor) {
+                               return false;
+                       } else {
+                               throw new InvalidArrayCountException(array($this, "pathFile", count($pathFile), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+                       }
+               }
+
+               // Create full path name
+               $pathName = $this->getSavePath() . $pathFile[0];
+
+               // Check if the file is there with a file handler
+               if ($inConstructor) {
+                       // No exceptions in constructors and destructors!
+                       $dirInstance = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($pathName, true);
+
+                       // Has an object being created?
+                       if (!is_object($dirInstance)) return false;
+               } else {
+                       // Outside a constructor
+                       try {
+                               $dirInstance = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($pathName);
+                       } catch (PathIsNoDirectoryException $e) {
+                               // Okay, path not found
+                               return false;
+                       }
+               }
+
+               // Initialize the search loop
+               $isValid = false;
+               while ($dataFile = $dirInstance->readDirectoryExcept(array(".", ".."))) {
+                       // Generate FQFN for testing
+                       $fqfn = sprintf("%s/%s", $pathName, $dataFile);
+                       $this->setLastFile($fqfn);
+
+                       // Get instance for file handler
+                       $inputHandler = $this->getFileIoInstance();
+
+                       // Try to read from it. This makes it sure that the file is
+                       // readable and a valid database file
+                       $this->setLastFileContents($inputHandler->loadFileContents($fqfn));
+
+                       // Extract filename (= unique ID) from it
+                       $ID = substr(basename($fqfn), 0, -(strlen($this->getFileExtension()) + 1));
+
+                       // Is this the required unique ID?
+                       if ($ID == $pathFile[1]) {
+                               // Okay, already in use!
+                               $isUsed = true;
+                       }
+               }
+
+               // Close the directory handler
+               $dirInstance->closeDirectory();
+
+               // Now the same for the file...
+               return $isUsed;
+       }
+
+       /**
+        * Setter for the last read file
+        *
+        * @param               $fqfn   The FQFN of the last read file
+        * @return      void
+        */
+       private final function setLastFile ($fqfn) {
+               // Cast string
+               $fqfn = (string) $fqfn;
+               $this->lastFile = $fqfn;
+       }
+
+       /**
+        * Getter for last read file
+        *
+        * @return      $lastFile               The last read file's name with full path
+        */
+       public final function getLastFile () {
+               return $this->lastFile;
+       }
+
+       /**
+        * Setter for contents of the last read file
+        *
+        * @param               $contents               An array with header and data elements
+        * @return      void
+        */
+       private final function setLastFileContents ($contents) {
+               // Cast array
+               $contents = (array) $contents;
+               $this->lastContents = $contents;
+       }
+
+       /**
+        * Getter for last read file's content as an array
+        *
+        * @return      $lastContent    The array with elements 'header' and 'data'.
+        */
+       public final function getLastContents () {
+               return $this->lastContents;
+       }
+
+       /**
+        * Getter for file extension
+        *
+        * @return      $fileExtension  The array with elements 'header' and 'data'.
+        */
+       public final function getFileExtension () {
+               return $this->fileExtension;
+       }
+
+       /**
+        * Get cached (last fetched) data from the local file database
+        *
+        * @param       $uniqueID       The ID number for looking up the data
+        * @return      $object         The restored object from the maybe compressed
+        *                                              serialized data
+        * @throws      MismatchingCompressorsException         If the compressor from
+        *                                                                      the loaded file
+        *                                                                      mismatches with the
+        *                                                                      current used one.
+        * @throws      NullPointerException    If the restored object
+        *                                                                      is null
+        * @throws      NoObjectException               If the restored "object"
+        *                                                                      is not an object instance
+        * @throws      MissingMethodException  If the required method
+        *                                                                      toString() is missing
+        */
+       public final function getObjectFromCachedData ($uniqueID) {
+               // Get instance for file handler
+               $inputHandler = $this->getFileIoInstance();
+
+               // Get last file's name and contents
+               $fqfn = $this->repairFQFN($this->getLastFile(), $uniqueID);
+               $contents = $this->repairContents($this->getLastContents(), $fqfn);
+
+               // Let's decompress it. First we need the instance
+               $compressInstance = $this->getCompressorChannel();
+
+               // Is the compressor's extension the same as the one from the data?
+               if ($compressInstance->getCompressorExtension() != $contents['header'][0]) {
+                       /**
+                        * @todo        For now we abort here but later we need to make this a little more dynamic.
+                        */
+                       throw new MismatchingCompressorsException(array($this, $contents['header'][0], $fqfn, $compressInstance->getCompressorExtension()), self::EXCEPTION_MISMATCHING_COMPRESSORS);
+               }
+
+               // Decompress the data now
+               $serialized = $compressInstance->getCompressor()->decompressStream($contents['data']);
+
+               // And unserialize it...
+               $object = unserialize($serialized);
+
+               // This must become a valid object, so let's check it...
+               if (is_null($object)) {
+                       // Is null, throw exception
+                       throw new NullPointerException($object, self::EXCEPTION_IS_NULL_POINTER);
+               } elseif (!is_object($object)) {
+                       // Is not an object, throw exception
+                       throw new NoObjectException($object, self::EXCEPTION_IS_NO_OBJECT);
+               } elseif (!$object instanceof FrameworkInterface) {
+                       // A highly required method was not found... :-(
+                       throw new MissingMethodException(array($object, '__toString'), self::EXCEPTION_MISSING_METHOD);
+               }
+
+               // And return the object
+               return $object;
+       }
+
+       /**
+        * Private method for re-gathering (repairing) the FQFN
+        *
+        * @param               $fqfn           The current FQFN we shall validate
+        * @param               $uniqueID               The unique ID number
+        * @return      $fqfn           The repaired FQFN when it is empty
+        * @throws      NoArrayCreatedException         If explode() has not
+        *                                                                      created an array
+        * @throws      InvalidArrayCountException      If the array count is not
+        *                                                                      as the expected
+        */
+       private function repairFQFN ($fqfn, $uniqueID) {
+               // Cast both strings
+               $fqfn     = (string) $fqfn;
+               $uniqueID = (string) $uniqueID;
+
+               // Is there pre-cached data available?
+               if (empty($fqfn)) {
+                       // Split the unique ID up in path and file name
+                       $pathFile = explode("@", $uniqueID);
+
+                       // Are there two elements? Index 0 is the path, 1 the file name + global extension
+                       if (!is_array($pathFile)) {
+                               // No array found
+                               throw new NoArrayCreatedException(array($this, "pathFile"), self::EXCEPTION_ARRAY_EXPECTED);
+                       } elseif (count($pathFile) != 2) {
+                               // Invalid ID returned!
+                               throw new InvalidArrayCountException(array($this, "pathFile", count($pathFile), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+                       }
+
+                       // Create full path name
+                       $pathName = $this->getSavePath() . $pathFile[0];
+
+                       // Nothing cached, so let's create a FQFN first
+                       $fqfn = sprintf("%s/%s.%s", $pathName, $pathFile[1], $this->getFileExtension());
+                       $this->setLastFile($fqfn);
+               }
+
+               // Return repaired FQFN
+               return $fqfn;
+       }
+
+       /**
+        * Private method for re-gathering the contents of a given file
+        *
+        * @param               $contents               The (maybe) already cached contents as an array
+        * @param               $fqfn           The current FQFN we shall validate
+        * @return      $contents               The repaired contents from the given file
+        */
+       private function repairContents ($contents, $fqfn) {
+               // Is there some content and header (2 indexes) in?
+               if ((!is_array($contents)) || (count($contents) != 2) || (!isset($contents['header'])) || (!isset($contents['data']))) {
+                       // No content found so load the file again
+                       $contents = $inputHandler->loadFileContents($fqfn);
+
+                       // And remember all data for later usage
+                       $this->setLastContents($contents);
+               }
+
+               // Return the repaired contents
+               return $contents;
+       }
+
+       /**
+        * Makes sure that the database connection is alive
+        *
+        * @return      void
+        */
+       public function connectToDatabase () {
+               // @TODO Do some checks on the database directory and files here
+       }
+
+       /**
+        * Loads data saved with saveObject from the database and re-creates a
+        * full object from it.
+        * If limitObject() was called before a new object ObjectContainer with
+        * all requested attributes will be returned instead.
+        *
+        * @return      Object  The fully re-created object or instance to
+        *                                      ObjectContainer
+        * @throws      SavePathIsEmptyException                If the given save path is an
+        *                                                                                      empty string
+        * @throws      SavePathIsNoDirectoryException  If the save path is no
+        *                                                                                      path (e.g. a file)
+        * @throws      SavePathReadProtectedException  If the save path is read-
+        *                                                                                      protected
+        * @throws      SavePathWriteProtectedException If the save path is write-
+        *                                                                                      protected
+        */
+       public function loadObject () {
+               // Already connected? Then abort here
+               if ($this->alreadyConnected === true) return true;
+
+               // Get the save path
+               $savePath = $this->getSavePath();
+
+               if (empty($savePath)) {
+                       // Empty string
+                       throw new SavePathIsEmptyException($dbInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               } elseif (!is_dir($savePath)) {
+                       // Is not a dir
+                       throw new SavePathIsNoDirectoryException($savePath, self::EXCEPTION_INVALID_PATH_NAME);
+               } elseif (!is_readable($savePath)) {
+                       // Path not readable
+                       throw new SavePathReadProtectedException($savePath, self::EXCEPTION_READ_PROTECED_PATH);
+               } elseif (!is_writeable($savePath)) {
+                       // Path not writeable
+                       throw new SavePathWriteProtectedException($savePath, self::EXCEPTION_WRITE_PROTECED_PATH);
+               }
+
+               // "Connection" established... ;-)
+               $this->alreadyConnected = true;
+       }
+
+       /**
+        * Starts a SELECT query on the database by given return type, table name
+        * and search criteria
+        *
+        * @param       $resultType             Result type ("array", "object" and "indexed" are valid)
+        * @param       $tableName              Name of the database table
+        * @param       $criteria               Local search criteria class
+        * @return      $resultData             Result data of the query
+        * @throws      UnsupportedCriteriaException    If the criteria is unsupported
+        */
+       public function querySelect ($resultType, $tableName, Criteria $criteriaInstance) {
+               // Is this criteria supported?
+               if (!$criteriaInstance instanceof LocalCriteria) {
+                       // Not supported by this database layer
+                       throw new UnsupportedCriteriaException(array($this, $criteriaInstance), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
+               }
+
+               // A "select" query on local files is not that easy, so begin slowly with it...
+               $this->partialStub(sprintf("type=%s,table=%s,criteria=%s", $resultType, $tableName, $criteriaInstance));
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/database/wrapper/.htaccess b/inc/classes/main/database/wrapper/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php
new file mode 100644 (file)
index 0000000..c8eb465
--- /dev/null
@@ -0,0 +1,119 @@
+<?php
+/**
+ * A database wrapper for the User class
+ *
+ * @see                        DatabaseFrontendInterface - An interface for database frontends (front-end to the application)
+ * @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 UserDatabaseWrapper extends BaseDatabaseWrapper {
+       /**
+        * Cache instance
+        */
+       private $cacheInstance = null;
+
+       // Constants for exceptions
+       const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0xe00;
+
+       // Constants for database columns
+       const DB_COLUMN_USERNAME = "username";
+
+       // Constants for database table names
+       const DB_TABLE_USER = "user";
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct() {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Database wrapper for user objects");
+
+               // Create unique ID number
+               $this->createUniqueID();
+       }
+
+       /**
+        * Creates an instance of this database wrapper by a provided user class
+        *
+        * @return      $wrapperInstance        An instance of the created wrapper class
+        * @throws      WrapperUserNameNotFoundException        If the supplied username
+        *                                                                                              does not exist
+        */
+       public final static function createUserDatabaseWrapper () {
+               // Get a new instance
+               $wrapperInstance = new UserDatabaseWrapper();
+
+               // Initialize the cache instance
+               $wrapperInstance->initCacheInstance();
+
+               // Return the instance
+               return $wrapperInstance;
+       }
+
+       /**
+        * Initializes the cache instance with a new object
+        *
+        * @return      void
+        */
+       protected function initCacheInstance () {
+               // Set the new instance
+               $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache();
+       }
+
+       /**
+        * Do a "select" query on the user table with the given search criteria and
+        * store it in cache for later usage
+        *
+        * @param       $criteriaInstance       An instance of a Criteria class
+        * @return      $resultInstance         An instance of a database result class
+        */
+       public function doSelectByCriteria (Criteria $criteriaInstance) {
+               // First get a key suitable for our cache and extend it with this class name
+               $cacheKey = sprintf("%s@%s",
+                       $this->__toString(),
+                       $criteriaInstance->getCacheKey()
+               );
+
+               // Does this key exists in cache?
+               if ($this->cacheInstance->offsetExists($cacheKey)) {
+                       // Then use this result
+                       $result = $cacheInstance->offsetGet($cacheKey);
+               } else {
+                       // Now it's time to ask the database layer for this select statement
+                       $result = $this->getDatabaseInstance()->doSelectByTableCriteria(self::DB_TABLE_USER, $criteriaInstance);
+
+                       // Cache the result
+                       $this->cacheInstance->offsetSet($cacheKey, $result);
+               }
+
+               // Create an instance of a DatabaseResult class with the given result
+               $resultInstance = DatabaseResult::createDatabaseResult($result);
+
+               // And return the instance
+               return $resultInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/factories/cache/.htaccess b/inc/classes/main/factories/cache/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/factories/cache/class_CacheFactory.php b/inc/classes/main/factories/cache/class_CacheFactory.php
new file mode 100644 (file)
index 0000000..087b942
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+/**
+ * A cache factory
+ *
+ * @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 CacheFactory extends BaseFactory {
+       /**
+        * Singleton instance
+        */
+       private static $selfInstance = null;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set object description
+               $this->setObjectDescription("Factory for cache objects");
+
+               // Create unique ID number
+               $this->createUniqueID();
+       }
+
+       /**
+        * Singleton getter for this class
+        *
+        * @return      $selfInstance   An instance of this class
+        */
+       public final static function getFactory () {
+               // Is the instance null?
+               if (is_null(self::$selfInstance)) {
+                       // Set a new one
+                       self::$selfInstance = new CacheFactory();
+               }
+
+               // Return the instance
+               return self::$selfInstance;
+       }
+
+       /**
+        * Creates a configured cache instance
+        *
+        * @return      $cacheInstance  An instance of the configured cache
+        */
+       public function createConfiguredCache () {
+               // Read the config entry
+               $cacheType = $this->getConfigInstance()->readConfig("cache_type");
+
+               // And get a new instance
+               $cacheInstance = ObjectFactory::createObjectByName($cacheType);
+
+               // Return the instance
+               return $cacheInstance;
+       }
+}
+
+// [EOF]
+?>
index db2611c28913aa784557c8d4b945eda19865cf59..68a856d3958bec8d70fd3fe63291e88447919f43 100644 (file)
@@ -37,9 +37,6 @@ class BaseFactory extends BaseFrameworkSystem {
                // Call parent constructor
                parent::__construct($class);
 
-               // Create unique ID number
-               $this->createUniqueID();
-
                // Clean up a little
                $this->removeNumberFormaters();
                $this->removeSystemArray();
index 5dda5fb904b8e177b3f7a70286a2d693ee1dee04..3f8ac7fa61b116b5dd93c4d5b9735f8bec1fc0de 100644 (file)
@@ -25,7 +25,6 @@ class ObjectFactory extends BaseFactory {
        /**
         * Protected constructor
         *
-        * @param       $class  Name of the real class (not BaseFactory)
         * @return      void
         */
        protected function __construct () {
@@ -34,6 +33,9 @@ class ObjectFactory extends BaseFactory {
 
                // Set object description
                $this->setObjectDescription("Simple generic object factory");
+
+               // Create unique ID number
+               $this->createUniqueID();
        }
 
        /**
@@ -56,7 +58,7 @@ class ObjectFactory extends BaseFactory {
                        throw new EmptyVariableException(array($factoryInstance, 'className'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } elseif (!class_exists($className)) {
                        // Then throw an exception
-                       throw new ClassNotFoundException($className, self::EXCEPTION_CLASS_NOT_FOUND);
+                       throw new ClassNotFoundException(array($factoryInstance, $className), self::EXCEPTION_CLASS_NOT_FOUND);
                }
 
                // Then Prepare the eval() command
@@ -71,6 +73,23 @@ class ObjectFactory extends BaseFactory {
                // Return the prepared instance
                return $objectInstance;
        }
+
+       /**
+        * Creates an object by it's configured name
+        *
+        * @param       $configEnttry                   Configuration entry to read
+        * @return      $objectInstance                 An instance of the requested object
+        */
+       public final static function createObjectByConfiguredName ($configEntry) {
+               // Read the configuration entry
+               $className = FrameworkConfiguration::getInstance()->readConfig($configEntry);
+
+               // Send this to the other factory...
+               $objectInstance = self::createObjectByName($className);
+
+               // Return the instance
+               return $objectInstance;
+       }
 }
 
 // [EOF]
index 5a604a77981b4af97d7efde20dbc83634bf9c85b..946f96b406f50866916d41553bd67b2c3b13175e 100644 (file)
@@ -38,6 +38,9 @@ class WebNewsFactory extends BaseFactory {
 
                // Set part description
                $this->setObjectDescription("Factory for webpages with news");
+
+               // Create unique ID number
+               $this->createUniqueID();
        }
 
        /**
index 1c7c54afc820da98a0e2332fafd82737f416aa5a..165a9ef92de86504ef80a0ebf203ea5737f0e388 100644 (file)
@@ -117,9 +117,6 @@ class UserNameValidatorFilter extends BaseFrameworkSystem implements Filterable
                } 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
index 53e8b46efec3e7910a5e9b1372b10835bac52a2c..280adec1600d86e43d65fc161b223fbe348da7eb 100644 (file)
@@ -92,11 +92,43 @@ class User extends BaseFrameworkSystem implements ManageableUser {
        /**
         * Getter for username
         *
-        * @return      $userName       The username to set
+        * @return      $userName       The username to get
         */
        public final function getUsername () {
                return $this->userNane;
        }
+
+       /**
+        * Determines wether the username exists or not
+        *
+        * @return      $exists         Wether the username exists
+        */
+       protected function ifUsernameExists () {
+               // By default the username does exist
+               $exists = true;
+
+               // Get a UserDatabaseWrapper instance
+               $wrapperInstance = UserDatabaseWrapper::createUserDatabaseWrapper();
+
+               // Create a search criteria
+               $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria');
+
+               // Add the username as a criteria and set limit to one entry
+               $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUsername());
+               $criteriaInstance->setLimit(1);
+
+               // Get a search result
+               $result = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+               // Search for it
+               if ($result->next()) {
+                       // Entry found, so all is fine
+                       $exists = true;
+               }
+
+               // Return the status
+               return $exists;
+       }
 }
 
 // [EOF]
index 470f6f9bbf782c695b55df856c9b82948400e5ea..6dc346bd6f1a7e542bb38400a5fdabb7d45dd6f9 100644 (file)
@@ -33,6 +33,7 @@ class BaseMiddleware extends BaseFrameworkSystem {
 
                // Clean up a little
                $this->removeNumberFormaters();
+               $this->removeSystemArray();
        }
 }
 
index d1c80ca5e4bf70da3dd11be7ea61718159b21779..e48e091a3784c2d201cc389c83953514896dada6 100644 (file)
@@ -98,8 +98,8 @@ class CompressorChannel extends BaseMiddleware {
                        || (!method_exists($cInstance->getCompressor(), 'compressStream'))
                        || (!method_exists($cInstance->getCompressor(), 'decompressStream'))
                ) {
-                       // Set the null compressor handler
-                       $cInstance->setCompressor(NullCompressor::createNullCompressor());
+                       // Set the null compressor handler. This should not be configureable!
+                       $cInstance->setCompressor(ObjectFactory::createObjectByName('NullCompressor'));
                }
 
                // Return the compressor instance
index 636206903c0d2deb192e0fde2d9b296897bd7f98..ebb6933556de1731255326236e34a8b816da5217 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, LimitableObject {
-       // Array for connection data
-       private $connectData = array();
+       /**
+        * Array for connection data
+        */
+       private $connectData = array(
+               'login' => "",
+               'pass'  => "",
+               'dbase' => "",
+               'host'  => ""
+       );
 
        // The real database layer
        private $dbLayer = null;
@@ -31,7 +38,11 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
        // An instance of this class
        private static $thisInstance = null;
 
-       // Private constructor
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
        protected function __construct() {
                // Call parent constructor
                parent::__construct(__CLASS__);
@@ -41,9 +52,6 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
 
                // Create an unique ID
                $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeSystemArray();
        }
 
        // Create new database connection layer
@@ -70,7 +78,7 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
        }
 
        // Public setter for database connection
-       public final function setConnectionData ($login, $pass, $dbase, $host) {
+       public final function setConnectionData ($login, $pass, $dbase, $host="localhost") {
                // Transfer connection data
                $this->connectData['login'] = (string) $login;
                $this->connectData['pass']  = (string) $pass;
@@ -83,23 +91,10 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
         *
         * @param               $object The object we shall save
         * @return      void
-        * @throws      NullPointerException    If $limitInstance is null
-        * @throws      NoObjectException               If $limitInstance is not an object
-        * @throws      MissingMethodException  If the required method
-        *                                                              saveObject() was not found
         */
-       public final function saveObject ($object) {
-               // Some sanity checks
-               if (is_null($this->dbLayer)) {
-                       // Is null
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($this->dbLayer)) {
-                       // Is not an object
-                       throw new NoObjectException($this->dbLayer, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($this->dbLayer, 'saveObject')) {
-                       // Does not have the required instance
-                       throw new MissingMethodException(array($this->dbLayer, 'saveObject'), self::EXCEPTION_MISSING_METHOD);
-               }
+       public function saveObject ($object) {
+               // Connect to the database
+               $this->dbLayer->connectToDatabase();
 
                // For now just pipe it through to the database layer
                $this->dbLayer->saveObject($object);
@@ -113,26 +108,10 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
         *                                              elements we shall exclusivly include in
         *                                              saving process
         * @return      void
-        * @throws      NullPointerException    If $limitInstance is null
-        * @throws      NoObjectException               If $limitInstance is not an object
-        * @throws      MissingMethodException  If the required method
-        *                                                              limitObject() was not found
         */
-       public final function limitObject (ObjectLimits $limitInstance) {
-               // Get real database connection
-               $this->dbLayer = $this->getDatabaseInstance();
-
-               // Some sanity checks
-               if (is_null($this->dbLayer)) {
-                       // Is null
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($this->dbLayer)) {
-                       // Is not an object
-                       throw new NoObjectException($object, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($this->dbLayer, 'limitObject')) {
-                       // Does not have the required instance
-                       throw new MissingMethodException(array($this->dbLayer, 'limitObject'), self::EXCEPTION_MISSING_METHOD);
-               }
+       public function limitObject (ObjectLimits $limitInstance) {
+               // Connect to the database
+               $this->dbLayer->connectToDatabase();
 
                // For now we pipe this through to the real database instance
                $this->dbLayer->limitObject($limitInstance);
@@ -142,29 +121,16 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
         * Analyses if a unique ID has already been used or not. This method does
         * only pass the given ID through to the "real" database layer.
         *
-        * @param               $uniqueID               A unique ID number which shall be checked
-        *                                              before it will be used
-        * @param               $inConstructor  If called from a constructor or from
-        *                                              somewhere else
+        * @param       $uniqueID               A unique ID number which shall be checked
+        *                                                      before it will be used
+        * @param       $inConstructor  If called from a constructor or from
+        *                                                      somewhere else
         * @return      $isUnused               true    = The unique ID was not found in the database,
-        *                                              false = It is already in use by an other object
-        * @throws      NullPointerException    If $this->dbLayer is null
-        * @throws      NoObjectException               If $this->dbLayer is not an object
-        * @throws      MissingMethodException  If the required method
-        *                                                              isUniqueIdUsed() was not found
+        *                                                      false = It is already in use by an other object
         */
-       public final function isUniqueIdUsed ($uniqueID, $inConstructor = false) {
-               // Some sanity checks
-               if (is_null($this->dbLayer)) {
-                       // Is null
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($this->dbLayer)) {
-                       // Is not an object
-                       throw new NoObjectException($object, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($this->dbLayer, 'isUniqueIdUsed')) {
-                       // Does not have the required instance
-                       throw new MissingMethodException(array($this->dbLayer, 'isUniqueIdUsed'), self::EXCEPTION_MISSING_METHOD);
-               }
+       public function isUniqueIdUsed ($uniqueID, $inConstructor = false) {
+               // Connect to the database
+               $this->dbLayer->connectToDatabase();
 
                // Pass the returning result through
                return $this->dbLayer->isUniqueIdUsed($uniqueID, $inConstructor);
@@ -173,28 +139,15 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
        /**
         * Gets cached data from the database layer and if not found fetch it from
         * the database again. This method does not return the header stuff because
-        * The underlaying database class will return only the requested content.
+        * the underlaying database class will return only the requested content.
         *
-        * @param               $idNumber               The ID number which we need for looking up
-        *                                              the requested data
+        * @param       $idNumber               The ID number which we need for looking up
+        *                                                      the requested data
         * @return      $cachedArray    The maybe cached data from the database
-        * @throws      NullPointerException    If $this->dbLayer is null
-        * @throws      NoObjectException               If $this->dbLayer is not an object
-        * @throws      MissingMethodException  If the required method
-        *                                                              isUniqueIdUsed() was not found
         */
-       public final function getObjectFromCachedData ($idNumber) {
-               // Some sanity checks
-               if (is_null($this->dbLayer)) {
-                       // Is null
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($this->dbLayer)) {
-                       // Is not an object
-                       throw new NoObjectException($object, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($this->dbLayer, 'getObjectFromCachedData')) {
-                       // Does not have the required instance
-                       throw new MissingMethodException(array($this->dbLayer, 'getObjectFromCachedData'), self::EXCEPTION_MISSING_METHOD);
-               }
+       public function getObjectFromCachedData ($idNumber) {
+               // Connect to the database
+               $this->dbLayer->connectToDatabase();
 
                // Pass the returning result through
                return $this->dbLayer->getObjectFromCachedData($idNumber);
@@ -202,12 +155,31 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
 
        /**
         * Setter for the real database layer
-        * @param               $dbLayer                An instance of the real database layer
+        * @param       $dbLayer        An instance of the real database layer
         * @return      void
         */
        public final function setDatabaseLayer (DatabaseFrontendInterface $dbLayer) {
                $this->dbLayer = $dbLayer;
        }
+
+       /**
+        * Runs a "select" statement on the database layer with given table name
+        * and criteria. If this doesn't fail the result will be returned
+        *
+        * @param       $tableName                      Name of the "table" we shall query
+        * @param       $criteriaInstance       An instance of a Criteria class
+        * @return      $result                         The result as an array
+        */
+       public function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance) {
+               // Connect to the database
+               $this->dbLayer->connectToDatabase();
+
+               // Get result from query
+               $result = $this->dbLayer->querySelect("array", $tableName, $criteriaInstance);
+
+               // Return the result
+               return $result;
+       }
 }
 
 // [EOF]
index 16c5b87dae69d7d87ddb8d4b3d272f50944ebd3e..8e1b4b3bd3037a0d3ceb7abc2c6f74920e5ab1d4 100644 (file)
@@ -53,10 +53,6 @@ class FileIoHandler extends BaseMiddleware {
                // Create an unique ID
                $this->createUniqueID();
 
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
-
                // Set own instance
                self::$thisInstance = $this;
        }
@@ -72,8 +68,8 @@ class FileIoHandler extends BaseMiddleware {
                $ioHandler = new FileIoHandler();
 
                // Set the *real* file IO instances (both the same)
-               $ioHandler->setInputStream(FileIoStream::createFileIoStream());
-               $ioHandler->setOutputStream(FileIoStream::createFileIoStream());
+               $ioHandler->setInputStream(ObjectFactory::createObjectByConfiguredName('file_input_stream'));
+               $ioHandler->setOutputStream(ObjectFactory::createObjectByConfiguredName('file_output_stream'));
 
                // Return instance
                return $ioHandler;
index 52bed7d1c53eb62f6948ecddf37b70fb66015790..e918a66b5d1822fab8ba25bc7c2d9a9e13027fa6 100644 (file)
@@ -37,7 +37,7 @@ $cfg->definePath(dirname(dirname(__FILE__)) . '/'); // DON'T MISS THE TRAILING S
 $cfg->defineDatabaseType('local');
 
 // CFG: LOCAL-DB-PATH
-$cfg->setConfigEntry('local_db_path', 'db/');
+$cfg->setConfigEntry('local_db_path', "db/");
 
 // CFG: TIME-ZONE
 $cfg->setDefaultTimezone("Europe/Berlin");
@@ -144,5 +144,23 @@ $cfg->setConfigEntry('default_application', "selector");
 // CFG: VERBOSE-LEVEL
 $cfg->setConfigEntry('verbose_level', 0);
 
+// CFG: CACHE-TYPE
+$cfg->setConfigEntry('cache_type', "MemoryCache");
+
+// CFG: SEARCH-CRITERIA
+$cfg->setConfigEntry('search_criteria', "SearchCriteria");
+
+// CFG: FILE-IO-HANDLER
+$cfg->setConfigEntry('file_io_handler', "FileIoHandler");
+
+// CFG: FILTER-CHAIN
+$cfg->setConfigEntry('filter_chain', "FilterChain");
+
+// CFG: FILE-INPUT-STREAM
+$cfg->setConfigEntry('file_input_stream', "FileIoStream");
+
+// CFG: FILE-OUTPUT-STREAM
+$cfg->setConfigEntry('file_output_stream', "FileIoStream");
+
 // [EOF]
 ?>
index 5e4ba6a38292fb633f55954385e810c4bcdbdb53..e9472bbb4573367e8f9bdaed7f3609df762e3ba9 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 // Get the instance
-$io = FileIoHandler::createFileIoHandler();
+$io = ObjectFactory::createObjectByConfiguredName('file_io_handler');
 
 // [EOF]
 ?>