State (see State Pattern) prepared, a lot reworked/refactured
authorRoland Häder <roland@mxchange.org>
Tue, 11 Aug 2009 21:17:24 +0000 (21:17 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 11 Aug 2009 21:17:24 +0000 (21:17 +0000)
- New interfaces and exceptions added for states
- Dead-loop fixed (was caused by previous refacturing
- Misc cleanups/fixes

27 files changed:
.gitattributes
inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php
inc/classes/exceptions/io/class_InvalidResourceException.php [new file with mode: 0644]
inc/classes/exceptions/state/.htaccess [new file with mode: 0644]
inc/classes/exceptions/state/class_InvalidStateException.php [new file with mode: 0644]
inc/classes/interfaces/resolver/state/.htaccess [new file with mode: 0644]
inc/classes/interfaces/resolver/state/class_StateResolver.php [new file with mode: 0644]
inc/classes/interfaces/state/.htaccess [new file with mode: 0644]
inc/classes/interfaces/state/class_Stateable.php [new file with mode: 0644]
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/commands/web/class_WebResendLinkCommand.php
inc/classes/main/crypto/class_CryptoHelper.php
inc/classes/main/database/class_BaseDatabaseFrontend.php
inc/classes/main/database/databases/class_LocalFileDatabase.php
inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php
inc/classes/main/helper/web/links/class_WebLinkHelper.php
inc/classes/main/io/class_FrameworkDirectoryPointer.php
inc/classes/main/io/class_FrameworkFileInputPointer.php
inc/classes/main/io/class_FrameworkFileOutputPointer.php
inc/classes/main/registry/class_Registry.php
inc/classes/main/resolver/class_BaseResolver.php
inc/classes/main/resolver/command/web/class_
inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php
inc/classes/main/resolver/controller/web/class_WebControllerResolver.php
inc/classes/middleware/debug/class_DebugMiddleware.php
inc/loader/class_ClassLoader.php
inc/selector.php

index cdcec14..4827646 100644 (file)
@@ -63,6 +63,7 @@ inc/classes/exceptions/io/class_FileReadProtectedException.php -text
 inc/classes/exceptions/io/class_InvalidDataLengthException.php -text
 inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php -text
 inc/classes/exceptions/io/class_InvalidMD5ChecksumException.php -text
+inc/classes/exceptions/io/class_InvalidResourceException.php -text
 inc/classes/exceptions/io/class_PathIsEmptyException.php -text
 inc/classes/exceptions/io/class_PathIsNoDirectoryException.php -text
 inc/classes/exceptions/io/class_PathReadProtectedException.php -text
@@ -103,6 +104,8 @@ inc/classes/exceptions/result/class_InvalidDatabaseResultException.php -text
 inc/classes/exceptions/result/class_ResultUpdateException.php -text
 inc/classes/exceptions/socket/.htaccess -text
 inc/classes/exceptions/socket/class_InvalidSocketException.php -text
+inc/classes/exceptions/state/.htaccess -text
+inc/classes/exceptions/state/class_InvalidStateException.php -text
 inc/classes/exceptions/template/.htaccess -text
 inc/classes/exceptions/template/class_BasePathIsEmptyException.php -text
 inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php -text
@@ -199,11 +202,15 @@ inc/classes/interfaces/resolver/commands/.htaccess -text
 inc/classes/interfaces/resolver/commands/class_CommandResolver.php -text
 inc/classes/interfaces/resolver/controller/.htaccess -text
 inc/classes/interfaces/resolver/controller/class_ControllerResolver.php -text
+inc/classes/interfaces/resolver/state/.htaccess -text
+inc/classes/interfaces/resolver/state/class_StateResolver.php -text
 inc/classes/interfaces/response/.htaccess -text
 inc/classes/interfaces/response/class_Responseable.php -text
 inc/classes/interfaces/result/.htaccess -text
 inc/classes/interfaces/result/class_SearchableResult.php -text
 inc/classes/interfaces/result/class_UpdateableResult.php -text
+inc/classes/interfaces/state/.htaccess -text
+inc/classes/interfaces/state/class_Stateable.php -text
 inc/classes/interfaces/streams/.htaccess -text
 inc/classes/interfaces/streams/class_Streamable.php -text
 inc/classes/interfaces/streams/crypto/.htaccess -text
index f043078..8499434 100644 (file)
@@ -7,6 +7,8 @@
  * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
+ * @deprecated
+ * @see                        InvalidResourceException
  * 
  * 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
diff --git a/inc/classes/exceptions/io/class_InvalidResourceException.php b/inc/classes/exceptions/io/class_InvalidResourceException.php
new file mode 100644 (file)
index 0000000..7546920
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * An exception thrown when a given resource is invalid
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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 InvalidResourceException extends FrameworkException {
+       /**
+        * The constructor
+        *
+        * @param       $class  Class throwing this exception
+        * @param       $code   Code number for the exception
+        * @return      void
+        */
+       public function __construct (FrameworkInterface $class, $code) {
+               // Add a message around the missing class
+               $message = sprintf("[%s:%d] Has an invalid resource.",
+                       $class->__toString(),
+                       $this->getLine()
+               );
+
+               // Call parent constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/exceptions/state/.htaccess b/inc/classes/exceptions/state/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/exceptions/state/class_InvalidStateException.php b/inc/classes/exceptions/state/class_InvalidStateException.php
new file mode 100644 (file)
index 0000000..1aeefef
--- /dev/null
@@ -0,0 +1,450 @@
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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 InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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 InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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 InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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 InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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 InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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 InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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 InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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 InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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 InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/interfaces/resolver/state/.htaccess b/inc/classes/interfaces/resolver/state/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/resolver/state/class_StateResolver.php b/inc/classes/interfaces/resolver/state/class_StateResolver.php
new file mode 100644 (file)
index 0000000..cb882c1
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * An instance for state resolver classes
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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 StateResolver extends Resolver {
+       /**
+        * Returns an state instance for a given package class and raw data
+        *
+        * @param       $packageInstance        An instance of a package class
+        * @param       $rawData                        The raw data to handle
+        * @return      $stateInstance          An instance of the resolved state
+        */
+       function resolveStateByPackage (Networkable $packageInstance, $rawData);
+
+       /**
+        * Checks wether the given state is valid
+        *
+        * @param       $stateName      The default state we shall execute
+        * @return      $isValid        Wether the given state is valid
+        * @throws      EmptyVariableException  Thrown if given state is not set
+        */
+       function isStateValid ($stateName);
+}
+
+//
+?>
diff --git a/inc/classes/interfaces/state/.htaccess b/inc/classes/interfaces/state/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/state/class_Stateable.php b/inc/classes/interfaces/state/class_Stateable.php
new file mode 100644 (file)
index 0000000..c6621fd
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * A Stateable interface
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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 Stateable extends FrameworkInterface {
+}
+
+//
+?>
index 9e7f247..e15af40 100644 (file)
@@ -128,7 +128,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        const EXCEPTION_WRITE_PROTECED_PATH          = 0x018;
        const EXCEPTION_DIR_POINTER_INVALID          = 0x019;
        const EXCEPTION_FILE_POINTER_INVALID         = 0x01a;
-       const EXCEPTION_INVALID_DIRECTORY_POINTER    = 0x01b;
+       const EXCEPTION_INVALID_RESOURCE             = 0x01b;
        const EXCEPTION_UNEXPECTED_OBJECT            = 0x01c;
        const EXCEPTION_LIMIT_ELEMENT_IS_UNSUPPORTED = 0x01d;
        const EXCEPTION_GETTER_IS_MISSING            = 0x01e;
@@ -171,10 +171,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Set real class
                $this->setRealClass($className);
 
-               // Initialize the class if class Registry is there
-               if ((class_exists('Registry')) && (Registry::isInitialized() === false)) {
-                       // Initialize the registry automatically
-                       $this->initInstance();
+               // Set configuration instance if no registry
+               if (!$this instanceof Register) {
+                       // Because registries doesn't need to be configured
+                       $this->setConfigInstance(FrameworkConfiguration::getInstance());
                } // END - if
        }
 
@@ -246,16 +246,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        }
 
        /**
-        * Private initializer for this class
-        *
-        * @return      void
-        */
-       private final function initInstance () {
-               // Set configuration instance
-               $this->setConfigInstance(FrameworkConfiguration::getInstance());
-       }
-
-       /**
         * Setter for database result instance
         *
         * @param       $resultInstance         An instance of a database result class
@@ -388,7 +378,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $debugInstance  Instance to class DebugConsoleOutput or DebugWebOutput
         */
        public final function getDebugInstance () {
+               // Get debug instance
                $debugInstance = Registry::getRegistry()->getInstance('debug');
+
+               // Return it
                return $debugInstance;
        }
 
@@ -429,13 +422,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $dbInstance     The database layer instance
         */
        public final function getDatabaseInstance () {
-               // Default is invalid db instance
-               $dbInstance = null;
-
-               // Is the registry there and initialized?
-               if ((class_exists('Registry')) && (Registry::isInitialized() === true)) {
-                       $dbInstance = Registry::getRegistry()->getInstance('db_instance');
-               } // END - if
+               // Get instance
+               $dbInstance = Registry::getRegistry()->getInstance('db_instance');
 
                // Return instance
                return $dbInstance;
index 73aa535..633a201 100644 (file)
@@ -55,18 +55,11 @@ class WebResendLinkCommand extends BaseCommand implements Commandable {
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
-        * @throws      InvalidInterfaceException       If the user class does not implement ManageableMember
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get user instance from registry
                $userInstance = Registry::getRegistry()->getInstance('user');
 
-               // Does the user instance implement ManageableMember?
-               if (!$userInstance instanceof ManageableMember) {
-                       // Throw exception here
-                       throw new InvalidInterfaceException(array($userInstance, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
-               } // END - if
-
                // Get an application instance
                $appInstance = $this->getResolverInstance()->getApplicationInstance();
 
index cbac7d7..db35284 100644 (file)
@@ -183,7 +183,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         */
        public function encryptString ($str) {
                // Encrypt the string through the stream
-               $encryted = $this->cryptoStreamInstance->encryptStream($str);
+               $encrypted = $this->cryptoStreamInstance->encryptStream($str);
 
                // Return the string
                return $encrypted;
index 514b8ec..bc1c7f6 100644 (file)
@@ -40,9 +40,6 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implements Datab
        protected function __construct ($className) {
                // Call parent constructor
                parent::__construct($className);
-
-               // Clean up a little
-               $this->removeNumberFormaters();
        }
 }
 
index d4c45e9..1298ff8 100644 (file)
@@ -99,17 +99,23 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         */
        public final static function createLocalFileDatabase ($savePath, FileIoHandler $ioInstance) {
                // Get an instance
-               $dbInstance = new LocalFileDatabase();
+               $databaseInstance = new LocalFileDatabase();
 
                // Set save path and IO instance
-               $dbInstance->setSavePath($savePath);
-               $dbInstance->setFileIoInstance($ioInstance);
+               $databaseInstance->setSavePath($savePath);
+               $databaseInstance->setFileIoInstance($ioInstance);
+
+               // Set the compressor channel
+               $databaseInstance->setCompressorChannel(CompressorChannel::createCompressorChannel(
+                       $databaseInstance->getConfigInstance()->getConfigEntry('base_path').
+                       $databaseInstance->getConfigInstance()->getConfigEntry('compressor_base_path')
+               ));
 
                // "Connect" to the database
-               $dbInstance->connectToDatabase();
+               $databaseInstance->connectToDatabase();
 
                // Return database instance
-               return $dbInstance;
+               return $databaseInstance;
        }
 
        /**
@@ -119,11 +125,8 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         * @return      void
         */
        public final function setSavePath ($savePath) {
-               // Secure string
-               $savePath = (string) $savePath;
-
                // Set save path
-               $this->savePath = $savePath;
+               $this->savePath = (string) $savePath;
        }
 
        /**
index 7702aab..6086de8 100644 (file)
@@ -51,7 +51,6 @@ class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable {
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
-        * @throws      NullPointerException    If the user instance from registry is null
         * @throws      FilterChainException    If this filter fails to operate
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
@@ -82,12 +81,6 @@ class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable {
                // Get a user instance from registry
                $userInstance = Registry::getRegistry()->getInstance('user');
 
-               // Is the instance there?
-               if (is_null($userInstance)) {
-                       // Throw an exception here
-                       throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER);
-               } // END - if
-
                // Get the confirm code from user for comparison
                $userCode = $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH);
 
index 484d2fe..69eeb7e 100644 (file)
@@ -59,7 +59,6 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate {
         * @param       $linkName                       Name of the link we shall generate
         * @param       $linkBase                       Link base for the link. This parameter is deprecated.
         * @return      $helperInstance         A prepared instance of this helper
-        * @throws      NullPointerException    Thrown if an instance is null
         * @throws      ConfigEntryNotFoundException    A deprecated exception at this point
         */
        public final static function createWebLinkHelper (CompileableTemplate $templateInstance, $linkName, $linkBase = null) {
@@ -75,12 +74,6 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate {
                // Get the application instance
                $applicationInstance = Registry::getRegistry()->getInstance('application');
 
-               // Sanity-check on it
-               if (is_null($applicationInstance)) {
-                       // Throw an exception here
-                       throw new NullPointerException($helperInstance, self::EXCEPTION_IS_NULL_POINTER);
-               } // END - if
-
                // Get the request instance
                $requestInstance = $applicationInstance->getRequestInstance();
 
index 98fe305..c25e97b 100644 (file)
@@ -196,7 +196,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
                        $this->dirPointer = $dirPointer;
                } else {
                        // Throw exception
-                       throw new InvalidDirectoryResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
        }
 
index 7f4466c..b296421 100644 (file)
@@ -105,7 +105,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
         * @return      mixed   The result of fread()
         * @throws      NullPointerException    If the file pointer instance
         *                                                                      is not set by setPointer()
-        * @throws      InvalidFileResourceException    If there is being set
+        * @throws      InvalidResourceException        If there is being set
         *                                                                      an invalid file resource
         */
        public function readFromFile () {
@@ -114,7 +114,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_resource($this->getPointer())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
 
                // Read data from the file pointer and return it
@@ -127,7 +127,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
         * @return      mixed   The result of fread()
         * @throws      NullPointerException    If the file pointer instance
         *                                                                      is not set by setPointer()
-        * @throws      InvalidFileResourceException    If there is being set
+        * @throws      InvalidResourceException        If there is being set
         *                                                                      an invalid file resource
         */
        public function readLinesFromFile () {
@@ -136,7 +136,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_resource($this->getPointer())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
                }
 
                // Read data from the file pointer and return it
@@ -150,7 +150,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
         * @return      void
         * @throws      NullPointerException    If the file pointer instance
         *                                                                      is not set by setPointer()
-        * @throws      InvalidFileResourceException    If there is being set
+        * @throws      InvalidResourceException        If there is being set
         */
        public function closeFile () {
                if (is_null($this->getPointer())) {
@@ -158,7 +158,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_resource($this->getPointer())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
 
                // Close the file pointer and reset the instance variable
@@ -180,7 +180,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
                        $this->filePointer = $filePointer;
                } else {
                        // Throw exception
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
        }
 
index 8ea8a0d..bc69bea 100644 (file)
@@ -97,7 +97,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem {
         * @return      mixed                   The result of fwrite()
         * @throws      NullPointerException    If the file pointer instance
         *                                                                      is not set by setPointer()
-        * @throws      InvalidFileResourceException    If there is being set
+        * @throws      InvalidResourceException        If there is being set
         *                                                                                      an invalid file resource
         */
        public function writeToFile ($dataStream) {
@@ -106,7 +106,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem {
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_resource($this->getPointer())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
 
                // Read data from the file pointer and return it
@@ -120,7 +120,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem {
         * @return      void
         * @throws      NullPointerException    If the file pointer instance
         *                                                                      is not set by setPointer()
-        * @throws      InvalidFileResourceException    If there is being set
+        * @throws      InvalidResourceException        If there is being set
         */
        public function closeFile () {
                if (is_null($this->getPointer())) {
@@ -128,7 +128,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem {
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_resource($this->getPointer())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
 
                // Close the file pointer and reset the instance variable
@@ -150,7 +150,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem {
                        $this->filePointer = $filePointer;
                } else {
                        // Throw exception
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
        }
 
index 876f7e3..35867f0 100644 (file)
@@ -29,11 +29,6 @@ class Registry extends BaseFrameworkSystem implements Register {
        private static $registryInstance = null;
 
        /**
-        * Wether the registry is initialized
-        */
-       private static $initialized = false;
-
-       /**
         * Instance registry
         */
        private $instanceRegistry = array();
@@ -66,26 +61,6 @@ class Registry extends BaseFrameworkSystem implements Register {
        }
 
        /**
-        * Checks or sets wether the registry has been initialized. This had only
-        * be done once.
-        *
-        * @param       $initialized    Wether the registry is initialized
-        * @return      $initialized    Wether the registry is initialized
-        */
-       public final static function isInitialized ($initialized = null) {
-               // If no parameter (null by default) is provided we want to get the
-               // parameter. If set to e.g. 'OK' then the registry is set to
-               // "initialized".
-               if (is_null($initialized)) {
-                       // Get status if initialized
-                       return self::$initialized;
-               } else {
-                       // Registry is initialized!
-                       self::$initialized = true;
-               }
-       }
-
-       /**
         * Checks wether an instance key was found
         *
         * @param       $instanceKey    The key holding an instance in registry
@@ -115,6 +90,7 @@ class Registry extends BaseFrameworkSystem implements Register {
         *
         * @param       $instanceKey            The key to identify the instance
         * @return      $objectInstance         An instance we shall store
+        * @throws      NullPointerException    If the requested key is not found
         */
        public function getInstance ($instanceKey) {
                // By default the instance is not in registry
@@ -125,6 +101,12 @@ class Registry extends BaseFrameworkSystem implements Register {
                        $objectInstance = $this->instanceRegistry[$instanceKey];
                } // END - if
 
+               // Still not fetched?
+               if (is_null($objectInstance)) {
+                       // This might happen if a non-registered key was requested
+                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+               } // END - if
+
                // Return the result
                return $objectInstance;
        }
index d15ef31..c485a61 100644 (file)
@@ -31,6 +31,7 @@ class BaseResolver extends BaseFrameworkSystem {
        const EXCEPTION_INVALID_COMMAND    = 0x1d0;
        const EXCEPTION_INVALID_CONTROLLER = 0x1d1;
        const EXCEPTION_INVALID_ACTION     = 0x1d2;
+       const EXCEPTION_INVALID_STATE      = 0x1d3;
 
        /**
         * Protected constructor
index 2f6a2b3..57955f9 100644 (file)
@@ -36,8 +36,8 @@ class Web???CommandResolver extends BaseCommandResolver implements CommandResolv
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set prefix to "Web"
-               $this->setCommandPrefix("Web");
+               // Set prefix to 'Web'
+               $this->setCommandPrefix('Web');
        }
 
        /**
index fea3a82..7cbdfbc 100644 (file)
@@ -41,8 +41,8 @@ class ImageControllerResolver extends BaseControllerResolver implements Controll
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set prefix to "Image"
-               $this->setControllerPrefix("Image");
+               // Set prefix to 'Image'
+               $this->setControllerPrefix('Image');
        }
 
        /**
index b43274d..5cf6b41 100644 (file)
@@ -41,8 +41,8 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set prefix to "Web"
-               $this->setControllerPrefix("Web");
+               // Set prefix to 'Web'
+               $this->setControllerPrefix('Web');
        }
 
        /**
index dec9b06..e794598 100644 (file)
@@ -45,6 +45,9 @@ class DebugMiddleware extends BaseMiddleware implements Registerable {
 
                // Set own instance
                self::$thisInstance = $this;
+
+               // Set it so all can use it
+               $this->setDebugInstance($this);
        }
 
        /**
index 97a477e..06e1b1d 100644 (file)
@@ -229,23 +229,6 @@ class ClassLoader {
        }
 
        /**
-        * Fall-back method. Please replace loadClasses() with scanClassPath() !
-        *
-        * @param       $basePath               The relative base path to 'base_path' constant for all classes
-        * @param       $ignoreList             An optional list (array forced) of directory and file names which shall be ignored
-        * @return      void
-        * @deprecated
-        * @todo        Rewrite your apps to scanClassPath()
-        */
-       public function loadClasses ($basePath, array $ignoreList = array() ) {
-               // This outputs an ugly message because you need to change to scanClassPath
-               print __METHOD__." is deprecated. Use scanClassPath() to make this warning go away.<br />\n";
-
-               // Call our new method
-               $this->scanClassPath($basePath, $ignoreList);
-       }
-
-       /**
         * Scans recursively a local path for class files which must have a prefix and a suffix as given by $this->suffix and $this->prefix
         *
         * @param       $basePath               The relative base path to 'base_path' constant for all classes
index a441daf..1898557 100644 (file)
 // Try to load these includes in the given order
 $configAppIncludes = array(
        'class_' . FrameworkConfiguration::getInstance()->getConfigEntry('app_helper_class'), // The ApplicationHelper class
+       'debug',                // Some debugging stuff
+       'exceptions',   // The application's own exception handler
+       'loader',               // The application's class loader
        'config',               // The application's own configuration
        'data',                 // Application data
        'init',                 // The application initializer
-       'loader',               // The application's class loader
-       'debug',                // Some debugging stuff
-       'exceptions',   // The application's own exception handler
        'starter',              // The application starter (calls entryPoint(), etc.)
 );