Code merged from ship-simu repository
authorRoland Häder <roland@mxchange.org>
Wed, 19 Nov 2008 22:34:07 +0000 (22:34 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 19 Nov 2008 22:34:07 +0000 (22:34 +0000)
111 files changed:
.gitattributes
inc/classes/exceptions/actions/class_InvalidActionException.php
inc/classes/exceptions/class_FrameworkException.php
inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php
inc/classes/exceptions/io/class_FileNotFoundException.php
inc/classes/exceptions/main/class_ClassNotFoundException.php
inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php
inc/classes/exceptions/main/class_ExceptionNotFoundException.php
inc/classes/exceptions/main/class_GetterNotFoundException.php
inc/classes/exceptions/main/class_InvalidInterfaceException.php
inc/classes/exceptions/main/class_NoArrayCreatedException.php
inc/classes/exceptions/result/class_ResultUpdateException.php
inc/classes/exceptions/template/class_ViewHelperNotFoundException.php
inc/classes/interfaces/crypto/class_Cryptable.php
inc/classes/interfaces/registration/class_UserRegister.php
inc/classes/interfaces/registry/class_Register.php
inc/classes/interfaces/request/class_Requestable.php
inc/classes/interfaces/resolver/actions/class_ActionResolver.php
inc/classes/interfaces/resolver/commands/class_CommandResolver.php
inc/classes/interfaces/result/class_SearchableResult.php
inc/classes/interfaces/user/class_ManageableAccount.php
inc/classes/main/actions/class_BaseAction.php
inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php
inc/classes/main/actions/web/class_WebLoginProfileAction.php
inc/classes/main/application/.htaccess [new file with mode: 0644]
inc/classes/main/application/class_BaseApplication.php [new file with mode: 0644]
inc/classes/main/cache/class_MemoryCache.php
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/class_FrameworkArrayObject.php
inc/classes/main/commands/web/class_ [new file with mode: 0644]
inc/classes/main/commands/web/class_WebConfirmCommand.php
inc/classes/main/commands/web/class_WebHomeCommand.php
inc/classes/main/commands/web/class_WebLoginAreaCommand.php
inc/classes/main/commands/web/class_WebLoginCommand.php
inc/classes/main/commands/web/class_WebLoginFailedCommand.php
inc/classes/main/commands/web/class_WebLogoutCommand.php
inc/classes/main/commands/web/class_WebLogoutDoneCommand.php
inc/classes/main/commands/web/class_WebRegisterCommand.php
inc/classes/main/commands/web/class_WebResendLinkCommand.php
inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php
inc/classes/main/controller/form/class_WebDoFormController.php
inc/classes/main/controller/login/class_WebLoginAreaController.php
inc/classes/main/controller/web/class_ [new file with mode: 0644]
inc/classes/main/controller/web/class_WebConfirmController.php
inc/classes/main/controller/web/class_WebDefaultNewsController.php
inc/classes/main/controller/web/class_WebLogoutController.php
inc/classes/main/criteria/class_SearchCriteria.php
inc/classes/main/crypto/class_CryptoHelper.php
inc/classes/main/database/databases/class_LocalFileDatabase.php
inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php
inc/classes/main/factories/web/class_WebNewsFactory.php
inc/classes/main/filter/auth/class_UserAuthFilter.php
inc/classes/main/filter/change/class_EmailChangeFilter.php
inc/classes/main/filter/change/class_PasswordChangeFilter.php
inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php
inc/classes/main/filter/class_
inc/classes/main/filter/class_AbstractFilterDecorator.php
inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php
inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php
inc/classes/main/filter/news/class_NewsDownloadFilter.php
inc/classes/main/filter/news/class_NewsProcessFilter.php
inc/classes/main/filter/null/class_NullFilter.php
inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php
inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php
inc/classes/main/filter/update/class_UserUpdateFilter.php
inc/classes/main/filter/validator/class_EmailValidatorFilter.php
inc/classes/main/filter/validator/class_PasswordValidatorFilter.php
inc/classes/main/filter/validator/class_UserNameValidatorFilter.php
inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php
inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php
inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php
inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php
inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php
inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php
inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php
inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php
inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php
inc/classes/main/helper/captcha/images/class_ImageHelper.php
inc/classes/main/helper/class_BaseHelper.php
inc/classes/main/helper/web/class_BaseWebHelper.php
inc/classes/main/helper/web/forms/class_WebFormHelper.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/mailer/debug/class_DebugMailer.php
inc/classes/main/points/class_UserPoints.php
inc/classes/main/registration/class_BaseRegistration.php
inc/classes/main/registry/class_Registry.php
inc/classes/main/request/class_HttpRequest.php
inc/classes/main/resolver/action/class_BaseActionResolver.php
inc/classes/main/resolver/action/web/class_WebActionResolver.php
inc/classes/main/resolver/command/class_BaseCommandResolver.php
inc/classes/main/resolver/command/image/class_ImageCommandResolver.php
inc/classes/main/resolver/command/web/class_ [new file with mode: 0644]
inc/classes/main/resolver/command/web/class_WebCommandResolver.php
inc/classes/main/resolver/controller/class_BaseControllerResolver.php
inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php
inc/classes/main/resolver/controller/web/class_WebControllerResolver.php
inc/classes/main/response/class_BaseResponse.php
inc/classes/main/result/class_DatabaseResult.php
inc/classes/main/template/class_BaseTemplateEngine.php
inc/classes/main/user/class_BaseUser.php
inc/classes/main/user/guest/class_Guest.php
inc/classes/main/user/member/class_Member.php
inc/classes/middleware/database/class_DatabaseConnection.php
inc/classes/third_party/akismet/.htaccess [new file with mode: 0644]
inc/classes/third_party/akismet/akismet.class.php [new file with mode: 0644]
inc/config.php
inc/config/class_FrameworkConfiguration.php
index.php

index 5fd7e66..6288da6 100644 (file)
@@ -239,6 +239,8 @@ inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.ph
 inc/classes/main/actions/web/.htaccess -text
 inc/classes/main/actions/web/class_WebLoginLogoutAction.php -text
 inc/classes/main/actions/web/class_WebLoginProfileAction.php -text
+inc/classes/main/application/.htaccess -text
+inc/classes/main/application/class_BaseApplication.php -text
 inc/classes/main/auth/.htaccess -text
 inc/classes/main/auth/class_CookieAuth.php -text
 inc/classes/main/cache/.htaccess -text
@@ -253,6 +255,7 @@ inc/classes/main/commands/class_BaseCommand.php -text
 inc/classes/main/commands/image/.htaccess -text
 inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php -text
 inc/classes/main/commands/web/.htaccess -text
+inc/classes/main/commands/web/class_ -text
 inc/classes/main/commands/web/class_WebConfirmCommand.php -text
 inc/classes/main/commands/web/class_WebDoFormCommand.php -text
 inc/classes/main/commands/web/class_WebHomeCommand.php -text
@@ -284,6 +287,7 @@ inc/classes/main/controller/image/class_ImageDefaultController.php -text
 inc/classes/main/controller/login/.htaccess -text
 inc/classes/main/controller/login/class_WebLoginAreaController.php -text
 inc/classes/main/controller/web/.htaccess -text
+inc/classes/main/controller/web/class_ -text
 inc/classes/main/controller/web/class_WebConfirmController.php -text
 inc/classes/main/controller/web/class_WebDefaultController.php -text
 inc/classes/main/controller/web/class_WebDefaultNewsController.php -text
@@ -434,6 +438,7 @@ inc/classes/main/resolver/command/class_BaseCommandResolver.php -text
 inc/classes/main/resolver/command/image/.htaccess -text
 inc/classes/main/resolver/command/image/class_ImageCommandResolver.php -text
 inc/classes/main/resolver/command/web/.htaccess -text
+inc/classes/main/resolver/command/web/class_ -text
 inc/classes/main/resolver/command/web/class_WebCommandResolver.php -text
 inc/classes/main/resolver/controller/.htaccess -text
 inc/classes/main/resolver/controller/class_BaseControllerResolver.php -text
@@ -480,6 +485,8 @@ inc/classes/middleware/debug/class_DebugMiddleware.php -text
 inc/classes/middleware/io/.htaccess -text
 inc/classes/middleware/io/class_FileIoHandler.php -text
 inc/classes/third_party/.htaccess -text
+inc/classes/third_party/akismet/.htaccess -text
+inc/classes/third_party/akismet/akismet.class.php -text
 inc/classes/third_party/api/.htaccess -text
 inc/classes/third_party/api/primusportal/.htaccess -text
 inc/classes/third_party/api/primusportal/class_PrimeraApi.php -text
index addebdb..96c1b73 100644 (file)
@@ -31,10 +31,11 @@ class InvalidActionException extends FrameworkException {
         */
        public function __construct(array $msgArray, $code) {
                // Prepare the message
-               $message = sprintf("[%s:%d] Cannot resolve action <span class=\"exception_reason\">%s</span>.",
+               $message = sprintf("[%s:%d] Cannot resolve action <span class=\"exception_reason\">%s (%s)</span>.",
                        $msgArray[0]->__toString(),
                        $this->getLine(),
-                       $msgArray[1]
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
                );
 
                // Call parent contructor with message
index 267744c..c3a2c1a 100644 (file)
@@ -59,11 +59,20 @@ abstract class FrameworkException extends ReflectionException {
                        );
 
                        // End here
-                       exit;
+                       exit();
                } // END - if
-
                // Make sure everything is assigned properly
                parent::__construct($message, $code);
+
+               // Log it away if DEBUG_ALL is set
+               if (defined('DEBUG_ALL')) {
+                       // Log the error
+                       error_log(sprintf("[%s:] %s (%s)",
+                               $this->__toString(),
+                               $message,
+                               $this->getHexCode()
+                       ));
+               } // END - if
        }
 
        /**
index 0422552..819b388 100644 (file)
@@ -7,7 +7,9 @@
  * @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
- * 
+ * @todo               This class is no longer used
+ * @deprecated
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
index e2e7dbc..ea31a49 100644 (file)
@@ -7,7 +7,9 @@
  * @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
- * 
+ * @todo               Rename this class to FileIoException
+ * @deprecated
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
index 1dcf9bd..3a7b995 100644 (file)
@@ -7,7 +7,9 @@
  * @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
- * 
+ * @todo               Rename this class to NoClassException
+ * @deprecated
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
index 40c3c71..76be0f1 100644 (file)
@@ -7,7 +7,9 @@
  * @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
- * 
+ * @todo               Rename this class to NoFoundEntryException
+ * @deprecated
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
index 81ff4f1..42dc611 100644 (file)
@@ -7,7 +7,9 @@
  * @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
- * 
+ * @todo               Is this exception still needed???
+ * @deprecated
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
index a632dcd..9a918c3 100644 (file)
@@ -7,7 +7,9 @@
  * @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
- * 
+ * @todo               This class is no longer needed!
+ * @deprecated
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
@@ -29,10 +31,7 @@ class GetterNotFoundException extends FrameworkException {
         * @param       $code           Code number for the exception
         * @return      void
         */
-       public function __construct ($dataArray, $code) {
-               // Cast the array
-               $dataArray = (array) $dataArray;
-
+       public function __construct (array $dataArray, $code) {
                // Add a message around the missing class
                $message = sprintf("[%s:%d] Getter-Methode f&uuml;r Attribut <span class=\"exception_reason\">%s</span> nicht gefunden.",
                        $dataArray[0]->__toString(),
index c628542..93958ed 100644 (file)
@@ -31,7 +31,7 @@ class InvalidInterfaceException extends FrameworkException {
         */
        public function __construct (array $classArray, $code) {
                // Add a message around the missing class
-               $message = sprintf("[%s:%d] Object does not implement expected interface <span class=\"exception_reason\">.",
+               $message = sprintf("[%s:%d] Object does not implement expected interface <span class=\"exception_reason\">%s</span>.",
                        $classArray[0]->__toString(),
                        $this->getLine(),
                        $classArray[1]
index e9f00de..77072fa 100644 (file)
@@ -7,6 +7,8 @@
  * @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
+ * @todo               This class is no longer needed
+ * @deprecated
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index da2ec8f..e58ab04 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * An exception thrown if the result was not updated
+ * An exception thrown if result was not updated.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
index 06dea77..37b3342 100644 (file)
@@ -7,6 +7,8 @@
  * @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
+ * @todo               Rename this class to NoViewHelperException
+ * @deprecated
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index 3d6f600..9bb6075 100644 (file)
@@ -25,8 +25,8 @@ interface Cryptable extends FrameworkInterface {
        /**
         * Hashes a string with salt and returns the hash. If an old previous hash
         * is supplied the method will use the first X chars of that hash for hashing
-        * the password. This is useful if you want to check if the password is
-        * identical for authorization purposes.
+        * the password. This is useful if you want to check if password is identical
+        * for authorization purposes.
         *
         * @param       $str            Unhashed string
         * @param       $oldHash        A hash from previous hashed string
index aa29b1a..cc15f8e 100644 (file)
@@ -23,8 +23,8 @@
  */
 interface UserRegister extends FrameworkInterface {
        /**
-        * Encrypt the given request key or throws an exception if the key was not
-        * found in the request
+        * Encrypt given request key or throws an exception if key was not found in
+        * request.
         *
         * @param       $requestKey             Key in request class
         * @return      void
index 37da876..d59051f 100644 (file)
@@ -25,8 +25,8 @@ interface Register extends FrameworkInterface {
        /**
         * Checks wether an instance key was found
         *
-        * @param       $instanceKey    The key holding an instance in the registry
-        * @return      $exists                 Wether the key exists in the registry
+        * @param       $instanceKey    The key holding an instance in registry
+        * @return      $exists                 Wether the key exists in registry
         */
        function instanceExists ($instanceKey);
 
index 5be733c..e5f9fa6 100644 (file)
@@ -40,7 +40,7 @@ interface Requestable extends FrameworkInterface {
        function isRequestElementSet ($element);
 
        /**
-        * Getter for request element or 'null' if the element was not found
+        * Getter for request element or 'null' if element was not found
         *
         * @param       $element        Name of the request element we want to check
         * @return      $value          Value of the found request element or 'null' if the
@@ -56,7 +56,7 @@ interface Requestable extends FrameworkInterface {
        function getParameterNames ();
 
        /**
-        * Getter for a header element or 'null' if the header was not found
+        * Getter for a header element or 'null' if header was not found
         *
         * @param       $headerName             Name of the header
         * @return      $headerValue    Value of the header or 'null' if not found
index 956d2b8..7a12f3d 100644 (file)
@@ -42,7 +42,7 @@ interface ActionResolver extends Resolver {
         *
         * @param       $actionName             The default action we shall execute
         * @return      $isValid                Wether the given action is valid
-        * @throws      EmptyVariableException  Thrown if the given action is not set
+        * @throws      EmptyVariableException  Thrown if given action is not set
         */
        function isActionValid ($actionName);
 }
index dd2ff06..d7f3976 100644 (file)
@@ -35,7 +35,7 @@ interface CommandResolver extends Resolver {
         *
         * @param       $commandName    The default command we shall execute
         * @return      $isValid                Wether the given command is valid
-        * @throws      EmptyVariableException  Thrown if the given command is not set
+        * @throws      EmptyVariableException  Thrown if given command is not set
         */
        function isCommandValid ($commandName);
 }
index c2c7823..c3bf26b 100644 (file)
@@ -29,6 +29,15 @@ interface SearchableResult extends FrameworkInterface {
         * @return      $result                         Found result entry
         */
        function searchEntry (LocalSearchCriteria $criteriaInstance);
+
+       /**
+        * Solver for result index value with call-back method
+        *
+        * @param       $databaseColumn         Database column where the index might be found
+        * @para        $callBack                       Call-back object for setting the index
+        * @return      void
+        */
+       function solveResultIndex ($databaseColumn, BaseDatabaseWrapper $wrapperInstance, array $callBack);
 }
 
 // [EOF]
index 3e88853..2dd0706 100644 (file)
@@ -37,8 +37,8 @@ interface ManageableAccount extends FrameworkInterface {
        function ifEmailAddressExists ();
 
        /**
-        * Checks if the supplied password hash in request matches with the stored
-        * in database.
+        * Checks if supplied password hash in request matches with stored in
+        * database.
         *
         * @param       $requestInstance        A requestable class instance
         * @return      $matches                        Wether the supplied password hash matches
index 0b2cd81..a2b1665 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 /**
- * A general action class
+ * A general action class. You shall extend this class if you are going to write
+ * your own action classes even when this class has no real content in it. We
+ * just handle the removal of some attributed here which you really don't need.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
index 068090e..15fd499 100644 (file)
@@ -63,7 +63,11 @@ class LoginAfterRegistrationAction extends BaseAction implements PerformableActi
                if ($loginInstance->ifLoginWasSuccessfull()) {
                        // Try to redirect here
                        try {
+                               // Redirect...
                                $responseInstance->redirectToConfiguredUrl('app_login_url');
+
+                               // Stop here
+                               exit();
                        } catch (FrameworkException $e) {
                                // Something went wrong here!
                                $responseInstance->addFatalMessage($e->getMessage());
index a7de7e8..0999886 100644 (file)
@@ -69,7 +69,7 @@ class WebLoginProfileAction extends BaseAction implements Commandable, Registera
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
                // Add user status filter here
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter', array($controllerInstance)));
        }
 }
 
diff --git a/inc/classes/main/application/.htaccess b/inc/classes/main/application/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/application/class_BaseApplication.php b/inc/classes/main/application/class_BaseApplication.php
new file mode 100644 (file)
index 0000000..a8d5e5c
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+/**
+ * A general application class for the ApplicationHelper classes.
+ *
+ * @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 BaseApplication extends BaseFrameworkSystem {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+
+               // Get registry instance
+               $registryInstance = Registry::getRegistry();
+
+               // Add this instance
+               $registryInstance->addInstance('application', $this);
+       }
+}
+
+// [EOF]
+?>
index 840519d..7e0dfd0 100644 (file)
@@ -82,7 +82,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable {
         * Setter for cache offset
         *
         * @param       $offset         The offset we shall set
-        * @param       $data           Data to store in the cache
+        * @param       $data           Data to store in cache
         * @return      void
         */
        public final function offsetSet ($offset, $data) {
@@ -93,7 +93,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable {
         * Getter for cache offset or "null" if not found
         *
         * @param       $offset         The offset we shall set
-        * @return      $data           Data to store in the cache
+        * @return      $data           Data to store in cache
         */
        public final function offsetGet ($offset) {
                // Default is offset not found
index 31fecee..d4eabd7 100644 (file)
@@ -79,6 +79,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        private $userInstance = null;
 
        /**
+        * A controller instance
+        */
+       private $controllerInstance = null;
+
+       /**
         * The real class name
         */
        private $realClass      = "FrameworkSystem";
@@ -192,8 +197,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Set real class
                $this->setRealClass($className);
 
-               // Initialize the class if the registry is there
+               // Initialize the class if class Registry is there
                if ((class_exists('Registry')) && (Registry::isInitialized() === false)) {
+                       // Initialize the registry automatically
                        $this->initInstance();
                } // END - if
        }
@@ -748,14 +754,24 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        /**
         * Debugs this instance by putting out it's full content
         *
+        * @param       $message        Optional message to show in debug output
         * @return      void
         */
-       public final function debugInstance () {
+       public final function debugInstance ($message = "") {
                // Restore the error handler to avoid trouble with missing array elements or undeclared variables
                restore_error_handler();
 
+               // Init content
+               $content = "";
+
+               // Is a message set?
+               if (!empty($message)) {
+                       // Construct message
+                       $content = sprintf("<div class=\"debug_message\">Message: %s</div>\n", $message);
+               } // END - if
+
                // Generate the output
-               $content = sprintf("<pre>%s</pre>",
+               $content .= sprintf("<pre>%s</pre>",
                        trim(
                                htmlentities(
                                        print_r($this, true)
@@ -818,7 +834,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                print("<pre>\n");
                debug_print_backtrace();
                print("</pre>");
-               exit;
+               exit();
        }
 
        /**
@@ -836,7 +852,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                if (is_object($debugInstance)) {
                        // Use debug output handler
                        $debugInstance->output($message);
-                       if (!$doPrint) die(); // Die here if not printed
+                       if ($doPrint === false) die(); // Die here if not printed
                } else {
                        // Put directly out
                        if ($doPrint) {
@@ -971,7 +987,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                $this->getResultInstance()->rewind();
 
                // Do we have an entry?
-               if (!$this->getResultInstance()->valid()) {
+               if ($this->getResultInstance()->valid() === false) {
                        throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), DatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
                } // END - if
 
@@ -1036,6 +1052,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        public final function getUserInstance () {
                return $this->userInstance;
        }
+
+       /**
+        * Setter for controller instance (this surely breaks a bit the MVC patterm)
+        *
+        * @param       $controllerInstance             An instance of the controller
+        * @return      void
+        */
+       public final function setControllerInstance (Controller $controllerInstance) {
+               $this->controllerInstance = $controllerInstance;
+       }
+
+       /**
+        * Getter for controller instance (this surely breaks a bit the MVC patterm)
+        *
+        * @return      $controllerInstance             An instance of the controller
+        */
+       public final function getControllerInstance () {
+               return $this->controllerInstance;
+       }
 }
 
 // [EOF]
index e7becae..167423c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
  * Class for saving arrays as an object. We need this little extension for
- * some common methods used in the whole application. Please see below if you
+ * some common methods used in whole application. Please see below if you
  * need more details.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
diff --git a/inc/classes/main/commands/web/class_ b/inc/classes/main/commands/web/class_
new file mode 100644 (file)
index 0000000..d5c0bc0
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+/**
+ * A command for 
+ *
+ * @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 Web???Command extends BaseCommand implements Commandable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $resolverInstance       An instance of a command resolver class
+        * @return      $commandInstance        An instance a prepared command class
+        */
+       public final static function createWeb???Command (CommandResolver $resolverInstance) {
+               // Get new instance
+               $commandInstance = new Web???Command();
+
+               // Set the application instance
+               $commandInstance->setResolverInstance($resolverInstance);
+
+               // Return the prepared instance
+               return $commandInstance;
+       }
+
+       /**
+        * Executes the given command with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               $this->partialStub("Unfinished method.");
+       }
+
+       /**
+        * Adds extra filters to the given controller instance
+        *
+        * @param       $controllerInstance             A controller instance
+        * @param       $requestInstance                An instance of a class with an Requestable interface
+        * @return      void
+        */
+       public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+               // Empty for now
+       }
+}
+
+// [EOF]
+?>
index db15067..ca44f8b 100644 (file)
@@ -109,7 +109,7 @@ class WebConfirmCommand extends BaseCommand implements Commandable {
                // these two calls to cache compiled templates.
                $templateInstance->compileVariables();
 
-               // Get the content back from the template engine and put it in the response class
+               // Get the content back from the template engine and put it in response class
                $templateInstance->transferToResponse($responseInstance);
        }
 
index 14a7a9c..6aad8cf 100644 (file)
@@ -100,7 +100,7 @@ class WebHomeCommand extends BaseCommand implements Commandable {
                // these two calls to cache compiled templates.
                $templateInstance->compileVariables();
 
-               // Get the content back from the template engine and put it in the response class
+               // Get the content back from the template engine and put it in response class
                $templateInstance->transferToResponse($responseInstance);
        }
 
index 9f2c1cf..749de17 100644 (file)
@@ -137,12 +137,12 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable {
                // these two calls to cache compiled templates.
                $templateInstance->compileVariables();
 
-               // Get the content back from the template engine and put it in the response class
+               // Get the content back from the template engine and put it in response class
                $templateInstance->transferToResponse($responseInstance);
        }
 
        /**
-        * Adds extra filters to the given controller instance
+        * Adds extra filters to the given controller instance. An corresponding action class must now exist!
         *
         * @param       $controllerInstance             A controller instance
         * @param       $requestInstance                An instance of a class with an Requestable interface
@@ -152,8 +152,17 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable {
                // Default is no action
                $actionInstance = null;
 
+               // Get registry
+               $registryInstance = Registry::getRegistry();
+
+               // Get our application instance from the registry
+               $appInstance = $registryInstance->getInstance('application');
+
                // Default action is the one from configuration
-               $this->actionName = sprintf("login_%s", $this->getConfigInstance()->readConfig('login_default_action'));
+               $this->actionName = sprintf("%s_login_%s",
+                       str_replace("-", "_", $appInstance->getAppShortName()),
+                       $this->getConfigInstance()->readConfig('login_default_action')
+               );
 
                // Get "action" from request
                $actReq = $requestInstance->getRequestElement('action');
@@ -161,28 +170,26 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable {
                // Do we have a "action" parameter set?
                if ((is_string($actReq)) && (!empty($actReq))) {
                        // Then use it with prefix
-                       $this->actionName = sprintf("login_%s", $actReq);
+                       $this->actionName = sprintf("%s_login_%s",
+                               str_replace("-", "_", $appInstance->getAppShortName()),
+                               $actReq
+                       );
                } // END - if
 
                // Get application instance
                $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
 
-               // Try to get an action resolver for the given action
-               try {
-                       // Get a resolver
-                       $actionResolver = WebActionResolver::createWebActionResolver($this->actionName, $applicationInstance);
+               // Get a resolver
+               $actionResolver = WebActionResolver::createWebActionResolver($this->actionName, $applicationInstance);
 
-                       // Resolve the action
-                       $actionInstance = $actionResolver->resolveAction();
+               // Resolve the action
+               $actionInstance = $actionResolver->resolveAction();
 
-                       // Add more action-specific filters
-                       $actionInstance->addExtraFilters($controllerInstance, $requestInstance);
+               // Add more action-specific filters
+               $actionInstance->addExtraFilters($controllerInstance, $requestInstance);
 
-                       // Remember this action in registry
-                       Registry::getRegistry()->addInstance('action', $actionInstance);
-               } catch (InvalidActionException $e) {
-                       // Silently ignored because no special action was found
-               }
+               // Remember this action in registry
+               Registry::getRegistry()->addInstance('action', $actionInstance);
        }
 }
 
index e02e2b5..9726e84 100644 (file)
@@ -103,7 +103,7 @@ class WebLoginCommand extends BaseCommand implements Commandable {
                // these two calls to cache compiled templates.
                $templateInstance->compileVariables();
 
-               // Get the content back from the template engine and put it in the response class
+               // Get the content back from the template engine and put it in response class
                $templateInstance->transferToResponse($responseInstance);
        }
 
index 7c74d7b..f2b6b81 100644 (file)
@@ -103,7 +103,7 @@ class WebLoginFailedCommand extends BaseCommand implements Commandable {
                // these two calls to cache compiled templates.
                $templateInstance->compileVariables();
 
-               // Get the content back from the template engine and put it in the response class
+               // Get the content back from the template engine and put it in response class
                $templateInstance->transferToResponse($responseInstance);
        }
 
index e220c51..91a9d51 100644 (file)
@@ -68,6 +68,9 @@ class WebLogoutCommand extends BaseCommand implements Commandable {
 
                // Redirect to "logout done" page
                $responseInstance->redirectToConfiguredUrl('logout_done_url');
+
+               // Exit here
+               exit();
        }
 
        /**
index bbb7f2f..8dfdee3 100644 (file)
@@ -103,7 +103,7 @@ class WebLogoutDoneCommand extends BaseCommand implements Commandable {
                // these two calls to cache compiled templates.
                $templateInstance->compileVariables();
 
-               // Get the content back from the template engine and put it in the response class
+               // Get the content back from the template engine and put it in response class
                $templateInstance->transferToResponse($responseInstance);
        }
 
index 42f9379..c23b647 100644 (file)
@@ -107,7 +107,7 @@ class WebRegisterCommand extends BaseCommand implements Commandable, Registerabl
                // these two calls to cache compiled templates.
                $templateInstance->compileVariables();
 
-               // Get the content back from the template engine and put it in the response class
+               // Get the content back from the template engine and put it in response class
                $templateInstance->transferToResponse($responseInstance);
        }
 
index 596bf89..c66a39b 100644 (file)
@@ -134,7 +134,7 @@ class WebResendLinkCommand extends BaseCommand implements Commandable {
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
                // Filter for checking if account is unconfirmed
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter', array($controllerInstance)));
        }
 }
 
index a671745..64e1a1a 100644 (file)
@@ -46,7 +46,7 @@ class ImageCodeCaptchaController extends BaseController implements Controller {
                $controllerInstance->setResolverInstance($resolverInstance);
 
                // Add filter for checking the "encrypt" string
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_encrypt_validator_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_encrypt_validator_filter', array($controllerInstance)));
 
                // Return the prepared instance
                return $controllerInstance;
index e760492..8691c3d 100644 (file)
@@ -45,7 +45,7 @@ class WebDoFormController extends BaseController implements Controller {
                // Set resolver instance
                $controllerInstance->setResolverInstance($resolverInstance);
 
-               // We need the controller instance in the resolver class so set it here
+               // We need the controller instance in resolver class so set it here
                $resolverInstance->setControllerInstance($controllerInstance);
 
                // Return the prepared instance
@@ -76,6 +76,9 @@ class WebDoFormController extends BaseController implements Controller {
                } catch (UserAuthorizationException $e) {
                        // Redirect to main page
                        $responseInstance->redirectToConfiguredUrl('login_failed_url');
+
+                       // Exit here
+                       exit();
                }
 
                // Is the request still valid? Post filters shall only be executed of
index 4e82ce1..0ad97f0 100644 (file)
@@ -37,6 +37,7 @@ class WebLoginAreaController extends BaseController implements Controller {
         *
         * @param       $resolverInstance               An instance of a command resolver class
         * @return      $controllerInstance             A prepared instance of this class
+        * @todo        Add some morer filters to this controller
         */
        public final static function createWebLoginAreaController (CommandResolver $resolverInstance) {
                // Create the instance
@@ -46,18 +47,16 @@ class WebLoginAreaController extends BaseController implements Controller {
                $controllerInstance->setResolverInstance($resolverInstance);
 
                // User auth filter
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter', array($controllerInstance)));
 
                // User update filter
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_filter', array($controllerInstance)));
 
                // News fetcher filter
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter', array($controllerInstance)));
 
                // News proccess/display-preparation
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter'));
-
-               /* @todo: Add some filters to this controller */
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter', array($controllerInstance)));
 
                // Return the prepared instance
                return $controllerInstance;
@@ -84,6 +83,9 @@ class WebLoginAreaController extends BaseController implements Controller {
                } catch (UserAuthorizationException $e) {
                        // Redirect to main page
                        $responseInstance->redirectToConfiguredUrl('login_failed_url');
+
+                       // Exit here
+                       exit();
                }
 
                // This request was valid! :-D
diff --git a/inc/classes/main/controller/web/class_ b/inc/classes/main/controller/web/class_
new file mode 100644 (file)
index 0000000..4e5bdee
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+/**
+ * Controller for 
+ *
+ * @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 Web???Controller extends BaseController implements Controller {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $resolverInstance               An instance of a command resolver class
+        * @return      $controllerInstance             A prepared instance of this class
+        * @todo        Add some filters to this controller
+        */
+       public final static function createWeb???Controller (CommandResolver $resolverInstance) {
+               // Create the instance
+               $controllerInstance = new Web???Controller();
+
+               // Set the command resolver
+               $controllerInstance->setResolverInstance($resolverInstance);
+
+               // Add filters
+               //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_filter'));
+
+               // Return the prepared instance
+               return $controllerInstance;
+       }
+
+       /**
+        * Handles the given request and response
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get the command instance from the resolver by sending a request instance to the resolver
+               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+               // Run the pre filters
+               $this->executePreFilters($requestInstance, $responseInstance);
+
+               // This request was valid! :-D
+               $requestInstance->requestIsValid();
+
+               // Execute the command
+               $commandInstance->execute($requestInstance, $responseInstance);
+
+               // Run the pre filters
+               $this->executePostFilters($requestInstance, $responseInstance);
+
+               // Flush the response out
+               $responseInstance->flushBuffer();
+       }
+}
+
+// [EOF]
+?>
index 411c59b..ebdd150 100644 (file)
@@ -47,10 +47,10 @@ class WebConfirmController extends BaseController implements Controller {
                $controllerInstance->setResolverInstance($resolverInstance);
 
                // Add filters for handling confirmation code and username
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('confirm_code_verifier_filter'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter', array($controllerInstance)));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter', array($controllerInstance)));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('confirm_code_verifier_filter', array($controllerInstance)));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_filter', array($controllerInstance)));
 
                // Return the prepared instance
                return $controllerInstance;
index d5769e9..8d7255d 100644 (file)
@@ -46,8 +46,8 @@ class WebDefaultNewsController extends BaseController implements Controller {
                $controllerInstance->setResolverInstance($resolverInstance);
 
                // Add news filters to this controller
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter', array($controllerInstance)));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter', array($controllerInstance)));
 
                // Return the prepared instance
                return $controllerInstance;
index 7d8a9ae..258d199 100644 (file)
@@ -47,10 +47,10 @@ class WebLogoutController extends BaseController implements Controller {
                $controllerInstance->setResolverInstance($resolverInstance);
 
                // Add user auth filter (we don't need an update of the user here because it will be redirected)
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter', array($controllerInstance)));
 
                // User status filter
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter', array($controllerInstance)));
 
                // Return the prepared instance
                return $controllerInstance;
index c95d853..faeb8be 100644 (file)
@@ -73,8 +73,8 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria
         * @param       $criteriaValue  Criteria value
         * @return      void
         */
-       public function addCriteria ($criteriaKey, $criteriaValue) {
-               $this->searchCriteria[$criteriaKey] = $criteriaValue;
+       public final function addCriteria ($criteriaKey, $criteriaValue) {
+               $this->searchCriteria[(string)$criteriaKey] = (string)$criteriaValue;
        }
 
        /**
@@ -84,7 +84,7 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria
         * @param       $configEntry    Configuration entry
         * @return      void
         */
-       public function addConfiguredCriteria ($criteriaKey, $configEntry) {
+       public final function addConfiguredCriteria ($criteriaKey, $configEntry) {
                // Add the configuration entry as a criteria
                $value = $this->getConfigInstance()->readConfig($configEntry);
                $this->addCriteria($criteriaKey, $value);
@@ -95,6 +95,7 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria
         *
         * @param       $limit  Search limit
         * @return      void
+        * @todo        Find a nice casting here. (int) allows until and including 32766.
         */
        public final function setLimit ($limit) {
                $this->limit = $limit;
@@ -114,6 +115,7 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria
         *
         * @param       $skip   Search skip
         * @return      void
+        * @todo        Find a nice casting here. (int) allows until and including 32766.
         */
        public final function setSkip ($skip) {
                $this->skip = $skip;
@@ -199,7 +201,7 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria
                        } // END - foreach
                } // END - foreach
 
-               // Now check if the criteria matches
+               // Now check if expected criteria counts match
                $matches = ($counted == count($this->searchCriteria));
 
                // Return the result
index 2ebafd8..0456e10 100644 (file)
@@ -119,8 +119,8 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
        /**
         * Hashes a string with salt and returns the hash. If an old previous hash
         * is supplied the method will use the first X chars of that hash for hashing
-        * the password. This is useful if you want to check if the password is
-        * identical for authorization purposes.
+        * the password. This is useful if you want to check if password is identical
+        * for authorization purposes.
         *
         * @param       $str            Unhashed string
         * @param       $oldHash        A hash from previous hashed string
@@ -241,6 +241,11 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
 
                // Get the real string out
                $strArray = explode("|", $garbageString);
+
+               // Does the element count match?
+               assert(count($strArray) == 3);
+
+               // Decode the string
                $str = base64_decode($strArray[1]);
 
                // Trim trailing nulls away
index 25cf938..dc4371e 100644 (file)
@@ -71,6 +71,11 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
        private $tableInfo = array();
 
        /**
+        * Element for index
+        */
+       private $indexKey = "__idx";
+
+       /**
         * The protected constructor. Do never instance from outside! You need to
         * set a local file path. The class will then validate it.
         *
@@ -153,13 +158,12 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
        /**
         * Setter for the last read file
         *
-        * @param               $fqfn   The FQFN of 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;
+               // Cast string and set it
+               $this->lastFile = (string) $fqfn;
        }
 
        /**
@@ -188,9 +192,8 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         * @param               $contents               An array with header and data elements
         * @return      void
         */
-       private final function setLastFileContents ($contents) {
-               // Cast array
-               $contents = (array) $contents;
+       private final function setLastFileContents (array $contents) {
+               // Set array
                $this->lastContents = $contents;
        }
 
@@ -213,6 +216,15 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
        }
 
        /**
+        * Getter for index key
+        *
+        * @return      $indexKey       Index key
+        */
+       public final function getIndexKey () {
+               return $this->indexKey;
+       }
+
+       /**
         * Reads a local data file  and returns it's contents in an array
         *
         * @param       $fqfn   The FQFN for the requested file
@@ -261,7 +273,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
        }
 
        /**
-        * Getter for table information file contents or an empty if the info file was not created
+        * Getter for table information file contents or an empty if info file was not created
         *
         * @param       $dataSetInstance        An instance of a database set class
         * @return      $infoArray                      An array with all table informations
@@ -370,6 +382,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                        // Initialize limit/skip
                        $limitFound = 0;
                        $skipFound = 0;
+                       $idx = 1;
 
                        // Read the directory with some exceptions
                        while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) && ($limitFound < $criteriaInstance->getLimit())) {
@@ -377,7 +390,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                                if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) {
                                        // Skip this file!
                                        continue;
-                               }
+                               } // END - if
 
                                // Read the file
                                $dataArray = $this->getDataArrayFromFile($pathName . $dataFile);
@@ -402,8 +415,13 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                                                                } // END - if
                                                        } // END - if
 
+                                                       // Set id number
+                                                       $dataArray[$this->getIndexKey()] = $idx;
+
                                                        // Entry found!
                                                        $resultData['rows'][] = $dataArray;
+
+                                                       // Count found entries up
                                                        $limitFound++;
                                                        break;
                                                } // END - if
@@ -412,6 +430,9 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                                        // Throw an exception here
                                        throw new SqlException(array($this, sprintf("File &#39;%s&#39; contains invalid data.", $dataFile), self::DB_CODE_DATA_FILE_CORRUPT), self::EXCEPTION_SQL_QUERY);
                                }
+
+                               // Count entry up
+                               $idx++;
                        } // END - while
 
                        // Close directory and throw the instance away
index 1bbbf03..503fbad 100644 (file)
@@ -26,6 +26,7 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper {
        const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180;
 
        // Constants for database columns
+       const DB_COLUMN_USERID       = "userid";
        const DB_COLUMN_USERNAME     = "username";
        const DB_COLUMN_EMAIL        = "email";
        const DB_COLUMN_CONFIRM_HASH = "confirm_hash";
@@ -48,8 +49,6 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper {
         * 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
@@ -63,6 +62,15 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper {
        }
 
        /**
+        * Getter for index key
+        *
+        * @return      $indexKey       Index key
+        */
+       public final function getIndexKey () {
+               return $this->getDatabaseInstance()->getIndexKey();
+       }
+
+       /**
         * Handles inserting the registration data from a registration instance into the database
         *
         * @param       $registrationInstance   An instance of a registration class
index d7307ec..1dace4e 100644 (file)
@@ -45,8 +45,29 @@ class WebNewsFactory extends BaseFactory {
         * @return      $factoryInstance        An instance of a WebNewsFactory class
         */
        public final static function createFactoryByRequest (Requestable $requestInstance) {
+               // Set default news reader class
+               $configEntry = "news_reader_class";
+
+               // Get "page"
+               $page = $requestInstance->getRequestElement('page');
+
+               // Is "page" used?
+               if (!empty($page)) {
+                       // Then add it
+                       $configEntry = sprintf("news_reader_%s_class", $page);
+
+                       // Get "action"
+                       $action = $requestInstance->getRequestElement('action');
+
+                       // Is it also there?
+                       if (!empty($action)) {
+                               // Then use both for config entry
+                               $configEntry = sprintf("news_reader_%s_%s_class", $page, $action);
+                       } // END - if
+               } // END - if
+
                // Get the news reader class name from config
-               $className = $requestInstance->getConfigInstance()->readConfig('news_reader_class');
+               $className = $requestInstance->getConfigInstance()->readConfig($configEntry);
 
                // Once we have that name, try to load initialize it
                $newsInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
index b08d0c2..c2b0ac4 100644 (file)
@@ -43,12 +43,16 @@ class UserAuthFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createUserAuthFilter () {
+       public final static function createUserAuthFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new UserAuthFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Set default auth method
                $filterInstance->setDefaultAuthMethod();
 
index 4e75421..bc481dd 100644 (file)
@@ -21,7 +21,7 @@
  * 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 EmailChangeFilter extends BaseFrameworkSystem implements Filterable {
+class EmailChangeFilter extends BaseFilter implements Filterable {
        /**
         * Protected constructor
         *
@@ -35,12 +35,16 @@ class EmailChangeFilter extends BaseFrameworkSystem implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createEmailChangeFilter () {
+       public final static function createEmailChangeFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new EmailChangeFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
@@ -94,6 +98,12 @@ class EmailChangeFilter extends BaseFrameworkSystem implements Filterable {
                        return false;
                } // END - if
 
+               // Are email and confirmation empty?
+               if ((empty($email1)) && (empty($email2))) {
+                       // No email change required!
+                       return true;
+               } // END - if
+
                // Now, get a user instance for comparison
                $userInstance = Registry::getRegistry()->getInstance('user');
 
@@ -101,10 +111,13 @@ class EmailChangeFilter extends BaseFrameworkSystem implements Filterable {
                $userEmail = $userInstance->getField('email');
 
                // Are they different?
-               if ($userEmail != $email1) {
-                       // Update the "new_email" field
-                       $this->partialStub("Unfinished part.");
+               if ($userEmail == $email1) {
+                       // Nothing has been changed is fine...
+                       return true;
                } // END - if
+
+               // Update the "new_email" field
+               $this->partialStub("Unfinished part.");
        }
 }
 
index 078d294..e7b8b50 100644 (file)
@@ -21,7 +21,7 @@
  * 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 PasswordChangeFilter extends BaseFrameworkSystem implements Filterable {
+class PasswordChangeFilter extends BaseFilter implements Filterable {
        /**
         * Protected constructor
         *
@@ -35,12 +35,16 @@ class PasswordChangeFilter extends BaseFrameworkSystem implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createPasswordChangeFilter () {
+       public final static function createPasswordChangeFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new PasswordChangeFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
@@ -82,6 +86,12 @@ class PasswordChangeFilter extends BaseFrameworkSystem implements Filterable {
                        return false;
                } // END - if
 
+               // Are password and confirmation empty?
+               if ((empty($pass1)) && (empty($pass2))) {
+                       // Don't change password here
+                       return true;
+               } // END - if
+
                // Do both match?
                if ($pass1 != $pass2) {
                        // Request is invalid!
index 85e945e..03b769a 100644 (file)
@@ -37,12 +37,16 @@ class RulesAcceptedFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createRulesAcceptedFilter () {
+       public final static function createRulesAcceptedFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new RulesAcceptedFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index 4aff513..bd14a20 100644 (file)
@@ -30,21 +30,21 @@ class ???Filter extends BaseFrameworkSystem implements Filterable {
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
        }
 
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function create???Filter () {
+       public final static function create???Filter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new ???Filter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index e11b970..e003ce2 100644 (file)
@@ -64,8 +64,8 @@ abstract class AbstractFilterDecorator extends BaseFrameworkSystem implements Fi
        /**
         * Execute the inner filter
         *
-        * @param<->$requestInstance<-->An instance of a request class
-        * @param<->$responseInstance<->An instance of a response class
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
         * @return      void
         */
        public final function execute (Requestable $requestInstance, Responseable $responseInstance) {
@@ -76,8 +76,8 @@ abstract class AbstractFilterDecorator extends BaseFrameworkSystem implements Fi
        /**
         * Do the execution of the filter
         *
-        * @param<->$requestInstance<-->An instance of a request class
-        * @param<->$responseInstance<->An instance of a response class
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
         * @return      void
         */
        abstract public function doExecute (Requestable $requestInstance, Responseable $responseInstance);
index b399a89..3a20eb2 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * A filter for checking if the "encrypt" value is set and fine
+ * A filter for checking if value "encrypt" is set and fine
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -21,7 +21,7 @@
  * 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 CaptchaEncryptFilter extends BaseFrameworkSystem implements Filterable {
+class CaptchaEncryptFilter extends BaseFilter implements Filterable {
        /**
         * Protected constructor
         *
@@ -35,12 +35,16 @@ class CaptchaEncryptFilter extends BaseFrameworkSystem implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createCaptchaEncryptFilter () {
+       public final static function createCaptchaEncryptFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new CaptchaEncryptFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index fc11b73..20155ac 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
- * A filter for checking if the username "guest" has been choosen as configured.
- * If so the password will be set to the configured password.
+ * A filter for checking if username "guest" has been choosen as configured. If
+ * so the password will be set to the configured password.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -36,12 +36,16 @@ class UserNameIsGuestFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createUserNameIsGuestFilter () {
+       public final static function createUserNameIsGuestFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new UserNameIsGuestFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index 1b57940..8799398 100644 (file)
@@ -37,12 +37,16 @@ class NewsDownloadFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createNewsDownloadFilter () {
+       public final static function createNewsDownloadFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new NewsDownloadFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index 76ebf3d..5ecb096 100644 (file)
@@ -36,12 +36,16 @@ class NewsProcessFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createNewsProcessFilter () {
+       public final static function createNewsProcessFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new NewsProcessFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index 9b145ba..3dd8382 100644 (file)
@@ -36,12 +36,16 @@ class NullFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createNullFilter () {
+       public final static function createNullFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new NullFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index 2f12e5b..38fb46e 100644 (file)
@@ -23,7 +23,7 @@
  * 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 PaymentDiscoveryFilter extends BaseFrameworkSystem implements Filterable {
+class PaymentDiscoveryFilter extends BaseFilter implements Filterable {
        /**
         * Action name for payment discovery
         */
@@ -37,10 +37,6 @@ class PaymentDiscoveryFilter extends BaseFrameworkSystem implements Filterable {
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
        }
 
        /**
index 7e30148..a7e409b 100644 (file)
@@ -21,7 +21,7 @@
  * 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 UserStatusConfimedUpdateFilter extends BaseFrameworkSystem implements Filterable {
+class UserStatusConfimedUpdateFilter extends BaseFilter implements Filterable {
        /**
         * Protected constructor
         *
@@ -35,12 +35,16 @@ class UserStatusConfimedUpdateFilter extends BaseFrameworkSystem implements Filt
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createUserStatusConfimedUpdateFilter () {
+       public final static function createUserStatusConfimedUpdateFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new UserStatusConfimedUpdateFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index be0c9a8..69c62d8 100644 (file)
@@ -22,7 +22,7 @@
  * 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 UserUpdateFilter extends BaseFrameworkSystem implements Filterable {
+class UserUpdateFilter extends BaseFilter implements Filterable {
        /**
         * Protected constructor
         *
@@ -36,12 +36,16 @@ class UserUpdateFilter extends BaseFrameworkSystem implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createUserUpdateFilter () {
+       public final static function createUserUpdateFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new UserUpdateFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index feb819e..6183b33 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /**
  * A concrete filter for validating the email address. This filter may intercept
- * the filter chain if no email address is given or if the supplied email has an
- * invalid form. It could also intercept the filter chain if the email address
- * is already used by some one if configuration requires this.
+ * the filter chain if no email address is given or if supplied email has an
+ * invalid form. It could also intercept our filter chain if email address is
+ * already used by some one if configuration requires this.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -38,12 +38,16 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createEmailValidatorFilter () {
+       public final static function createEmailValidatorFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new EmailValidatorFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
@@ -154,7 +158,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                }
 
                // Does the email exist?
-               if (!$userInstance->ifEmailAddressExists()) {
+               if ($userInstance->ifEmailAddressExists() === false) {
                        // This email has not being used yet
                        $alreadyTaken = false;
                }
index 8944f35..2591f1e 100644 (file)
@@ -36,12 +36,16 @@ class PasswordValidatorFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createPasswordValidatorFilter () {
+       public final static function createPasswordValidatorFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new PasswordValidatorFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index 522e77a..8d0445f 100644 (file)
@@ -1,9 +1,8 @@
 <?php
 /**
  * A concrete filter for validating the username. This filter may intercept the
- * filter chain if no username is given or if the supplied username has an
- * invalid form. It could also intercept the filter chain if the username is
- * already taken.
+ * filter chain if no username is given or if supplied username has an invalid
+ * form. It could also intercept our filter chain if username is already taken.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -38,12 +37,16 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createUserNameValidatorFilter () {
+       public final static function createUserNameValidatorFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new UserNameValidatorFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
@@ -125,7 +128,7 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable {
                }
 
                // Does the username exist?
-               if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) {
+               if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === false)) {
                        // This username is still available
                        $alreadyTaken = false;
                } // END - if
index eab77bd..44fdcfc 100644 (file)
@@ -36,12 +36,16 @@ class AccountPasswordVerifierFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createAccountPasswordVerifierFilter () {
+       public final static function createAccountPasswordVerifierFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new AccountPasswordVerifierFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
@@ -53,6 +57,7 @@ class AccountPasswordVerifierFilter extends BaseFilter implements Filterable {
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
         * @throws      AccountPasswordMismatchException        If the account password does not match
+        * @todo        Rewrite handling of different password fields
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get password
@@ -60,20 +65,28 @@ class AccountPasswordVerifierFilter extends BaseFilter implements Filterable {
 
                // Is the password still not set?
                if (is_null($password)) {
-                       // Not found in form so stop the filtering process
-                       $requestInstance->requestIsValid(false);
+                       // Get password from alternative location
+                       $password = $requestInstance->getRequestElement('password');
 
-                       // Add a message to the response
-                       $responseInstance->addFatalMessage('pass_old_unset');
+                       // Is the password still not set?
+                       if (is_null($password)) {
+                               // Not found in form so stop the filtering process
+                               $requestInstance->requestIsValid(false);
 
-                       // Abort here
-                       return false;
-               } elseif (empty($password)) {
+                               // Add a message to the response
+                               $responseInstance->addFatalMessage('password_unset');
+
+                               // Abort here
+                               return false;
+                       } // END - if
+               } // END - if
+
+               if (empty($password)) {
                        // Password is empty
                        $requestInstance->requestIsValid(false);
 
                        // Add a message to the response
-                       $responseInstance->addFatalMessage('pass_old_empty');
+                       $responseInstance->addFatalMessage('password_empty');
 
                        // Abort here
                        return false;
@@ -82,14 +95,14 @@ class AccountPasswordVerifierFilter extends BaseFilter implements Filterable {
                // Get a user instance
                $userInstance = Registry::getRegistry()->getInstance('user');
 
-               // Get old hash
-               $oldHash = $userInstance->getField('pass_hash');
+               // Get current hash
+               $currentHash = $userInstance->getField('pass_hash');
 
                // Get an encryption helper and encrypt the password
-               $passHash = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($password, $oldHash);
+               $passHash = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($password, $currentHash);
 
                // Does it match?
-               if ($oldHash != $passHash) {
+               if ($currentHash != $passHash) {
                        // Throw an exception here to stop the proccessing
                        throw new AccountPasswordMismatchException($this, BaseUser::EXCEPTION_USER_PASS_MISMATCH);
                } // END - if
index 98fc1e6..09a13d0 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * A filter for checking if the the supplied confirmation code is valid
+ * A filter for checking if supplied confirmation code is valid.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -35,12 +35,16 @@ class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createConfirmCodeVerifierFilter () {
+       public final static function createConfirmCodeVerifierFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new ConfirmCodeVerifierFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
@@ -99,7 +103,7 @@ class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->redirectToConfiguredUrl('confirm_code_invalid_url');
 
                        // Stop processing here
-                       exit;
+                       exit();
                } // END - if
        }
 }
index 8bb65a4..27fe8a3 100644 (file)
@@ -35,12 +35,16 @@ class GraphicalCodeCaptchaVerifierFilter extends BaseFilter implements Filterabl
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createGraphicalCodeCaptchaVerifierFilter () {
+       public final static function createGraphicalCodeCaptchaVerifierFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new GraphicalCodeCaptchaVerifierFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index f2a1520..abe338d 100644 (file)
@@ -36,12 +36,16 @@ class PasswordGuestVerifierFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createPasswordGuestVerifierFilter () {
+       public final static function createPasswordGuestVerifierFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new PasswordGuestVerifierFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index 0bd5cce..cea7d21 100644 (file)
@@ -36,12 +36,16 @@ class PasswordVerifierFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createPasswordVerifierFilter () {
+       public final static function createPasswordVerifierFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new PasswordVerifierFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index 839b1eb..8e2b952 100644 (file)
@@ -1,9 +1,8 @@
 <?php
 /**
  * A concrete filter for verfying the guest username. This filter may intercept the
- * filter chain if no username is given or if the supplied username has an
- * invalid form. It could also intercept the filter chain if the username was
- * not found.
+ * filter chain if no username is given or if supplied username has an invalid
+ * form. It could also intercept our filter chain if username was not found.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -38,12 +37,16 @@ class UserGuestVerifierFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createUserGuestVerifierFilter () {
+       public final static function createUserGuestVerifierFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new UserGuestVerifierFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
@@ -65,7 +68,7 @@ class UserGuestVerifierFilter extends BaseFilter implements Filterable {
                        $requestInstance->requestIsValid(false);
 
                        // Add a message to the response
-                       $responseInstance->addFatalMessage('username_unset');
+                       $responseInstance->addFatalMessage('username_guest_unset');
 
                        // Abort here
                        return false;
@@ -74,16 +77,16 @@ class UserGuestVerifierFilter extends BaseFilter implements Filterable {
                        $requestInstance->requestIsValid(false);
 
                        // Add a message to the response
-                       $responseInstance->addFatalMessage('username_empty');
+                       $responseInstance->addFatalMessage('username_guest_empty');
 
                        // Abort here
                        return false;
-               } elseif (!$this->ifUserGuestIsTaken($userName)) {
+               } elseif ($this->ifUserGuestIsTaken($userName) === false) {
                        // Username is already taken
                        $requestInstance->requestIsValid(false);
 
                        // Add a message to the response
-                       $responseInstance->addFatalMessage('username_not_found');
+                       $responseInstance->addFatalMessage('username_guest_not_found');
 
                        // Abort here
                        return false;
@@ -128,7 +131,7 @@ class UserGuestVerifierFilter extends BaseFilter implements Filterable {
                }
 
                // Does the username exist?
-               if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) {
+               if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === false)) {
                        // This username is still available
                        $alreadyTaken = false;
                }
index 7d0bde9..a3b12a9 100644 (file)
@@ -1,9 +1,8 @@
 <?php
 /**
  * A concrete filter for verfying the username. This filter may intercept the
- * filter chain if no username is given or if the supplied username has an
- * invalid form. It could also intercept the filter chain if the username was
- * not found.
+ * filter chain if no username is given or if supplied username has an invalid
+ * form. It could also intercept our filter chain if username was not found.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -38,12 +37,16 @@ class UserNameVerifierFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createUserNameVerifierFilter () {
+       public final static function createUserNameVerifierFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new UserNameVerifierFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
@@ -78,7 +81,7 @@ class UserNameVerifierFilter extends BaseFilter implements Filterable {
 
                        // Abort here
                        return false;
-               } elseif (!$this->ifUserNameIsTaken($userName)) {
+               } elseif ($this->ifUserNameIsTaken($userName) === false) {
                        // Username is already taken
                        $requestInstance->requestIsValid(false);
 
@@ -125,7 +128,7 @@ class UserNameVerifierFilter extends BaseFilter implements Filterable {
                }
 
                // Does the username exist?
-               if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) {
+               if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === false)) {
                        // This username is still available
                        $alreadyTaken = false;
                } // END - if
index 79e0ace..a058aa0 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * A filter for checking if the user status is GUEST or CONFIRMED
+ * A filter for checking if user status is GUEST or CONFIRMED.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -21,7 +21,7 @@
  * 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 UserStatusVerifierFilter extends BaseFrameworkSystem implements Filterable {
+class UserStatusVerifierFilter extends BaseFilter implements Filterable {
        /**
         * Protected constructor
         *
@@ -35,12 +35,16 @@ class UserStatusVerifierFilter extends BaseFrameworkSystem implements Filterable
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createUserStatusVerifierFilter () {
+       public final static function createUserStatusVerifierFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new UserStatusVerifierFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
index e36fa38..0845c85 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * A filter for checking if the user status is UNCONFIRMED
+ * A filter for checking if user status is UNCONFIRMED.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -21,7 +21,7 @@
  * 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 UserUnconfirmedVerifierFilter extends BaseFrameworkSystem implements Filterable {
+class UserUnconfirmedVerifierFilter extends BaseFilter implements Filterable {
        /**
         * Protected constructor
         *
@@ -35,12 +35,16 @@ class UserUnconfirmedVerifierFilter extends BaseFrameworkSystem implements Filte
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createUserUnconfirmedVerifierFilter () {
+       public final static function createUserUnconfirmedVerifierFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new UserUnconfirmedVerifierFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
@@ -60,7 +64,7 @@ class UserUnconfirmedVerifierFilter extends BaseFrameworkSystem implements Filte
                $userInstance = call_user_func_array(array($userClass, 'createMemberByRequest'), array($requestInstance));
 
                // Is the email address valid?
-               if (!$userInstance->ifEmailAddressExists()) {
+               if ($userInstance->ifEmailAddressExists() === false) {
                        // Request is invalid!
                        $requestInstance->requestIsValid(false);
 
index 0b5a76f..fa8bd85 100644 (file)
@@ -270,7 +270,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
        /**
         * Setter for image message string
         *
-        * @param       $imageString    A message to display in the image
+        * @param       $imageString    A message to display in image
         * @return      void
         */
        public final function setImageString ($imageString) {
@@ -280,7 +280,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
        /**
         * Getter for image message string
         *
-        * @return      $imageString    A message to display in the image
+        * @return      $imageString    A message to display in image
         */
        public final function getImageString () {
                return $this->imageStrings[$this->currString]['string'];
index 94f4ed5..b4e893f 100644 (file)
@@ -226,11 +226,12 @@ class BaseHelper extends BaseFrameworkSystem {
         *
         * @param       $groupId        Group id to open
         * @param       $content        Initial content to add to the group
+        * @param       $tag            HTML tag used to open this group
         * @return      void
         * @throws      HelperGroupAlreadyCreatedException      If the group was already created before
         */
-       protected function openGroupByIdContent ($groupId, $content) {
-               //* DEBUG: */ echo "OPEN:groupId={$groupId}<br />\n";
+       protected function openGroupByIdContent ($groupId, $content, $tag) {
+               //* DEBUG: */ echo "OPEN:groupId={$groupId},content=<pre>".htmlentities($content)."</pre>\n";
                // Is the group already there?
                if (isset($this->groups[$groupId])) {
                        // Then throw an exception here
@@ -243,7 +244,8 @@ class BaseHelper extends BaseFrameworkSystem {
                // Add the group to the stack
                $this->groups[$this->totalCounter] = $groupId;
                $this->groups[$groupId]['opened']  = true;
-               $this->groups[$groupId]['content'] = $content."\n";
+               $this->groups[$groupId]['content'] = sprintf("<!-- group %s opened (length: %s, tag: %s) //-->%s\n", $groupId, strlen($content), $tag, $content);
+               $this->groups[$groupId]['tag'] = $tag;
 
                // Mark this group as previously opened
                $this->setPreviousGroupId($groupId);
@@ -253,13 +255,19 @@ class BaseHelper extends BaseFrameworkSystem {
         * Closes the previously opened group by added given content to it or
         * throws an exception if no previous group was opened
         *
-        * @param       $content        Content for previously opened grouop
+        * @param       $content        Content for previously opened group, or empty to use tag of opener
         * @return      void
         * @throws      HelperNoPreviousOpenedGroupException    If no previously opened group was found
         */
-       public function closePreviousGroupByContent ($content) {
+       public function closePreviousGroupByContent ($content = "") {
+               // Check if any sub group was opened before
+               if ($this->ifSubGroupOpenedPreviously()) {
+                       // Close it automatically
+                       $this->closePreviousSubGroupByContent();
+               } // END - if
+
                // Check if any group was opened before
-               if (!$this->ifGroupOpenedPreviously()) {
+               if ($this->ifGroupOpenedPreviously() === false) {
                        // Then throw an exception
                        throw new HelperNoPreviousOpenedGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
                } // END - if
@@ -267,8 +275,14 @@ class BaseHelper extends BaseFrameworkSystem {
                // Get previous group
                $groupId = $this->getPreviousGroupId();
 
+               // Is the content empty?
+               if ((empty($content)) && (!empty($this->groups[$groupId]['tag']))) {
+                       // Get it from opener
+                       $content = sprintf("<!-- group %s auto-closed //--></%s>", $groupId, $this->groups[$groupId]['tag']);
+               } // END - if
+
                // Add content to it and mark it as closed
-               $this->groups[$groupId]['content'] .= $content."\n";
+               $this->groups[$groupId]['content'] .= sprintf("<!-- group %s closed (length: %s, tag: %s) //-->%s\n", $groupId, strlen($content), $this->groups[$groupId]['tag'], $content);
                $this->groups[$groupId]['opened'] = false;
 
                // Mark previous group as closed
@@ -283,10 +297,11 @@ class BaseHelper extends BaseFrameworkSystem {
         *
         * @param       $subGroupId             Sub group id to open
         * @param       $content                Initial content to add to the sub group
+        * @param       $tag                    HTML tag used to open this group
         * @return      void
         * @throws      HelperSubGroupAlreadyCreatedException   If the sub group was already created before
         */
-       protected function openSubGroupByIdContent ($subGroupId, $content) {
+       protected function openSubGroupByIdContent ($subGroupId, $content, $tag) {
                //* DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."<br />\n";
                // Is the group already there?
                if (isset($this->subGroups[$subGroupId])) {
@@ -300,7 +315,8 @@ class BaseHelper extends BaseFrameworkSystem {
                // Add the group to the stack
                $this->subGroups[$this->totalCounter] = $subGroupId;
                $this->subGroups[$subGroupId]['opened']  = true;
-               $this->subGroups[$subGroupId]['content'] = $content."\n";
+               $this->subGroups[$subGroupId]['content'] = sprintf("<!-- sub-group %s opened (length: %s, tag: %s) //-->%s\n", $subGroupId, strlen($content), $tag, $content);
+               $this->subGroups[$subGroupId]['tag'] = $tag;
 
                // Mark this group as previously opened
                $this->setPreviousSubGroupId($subGroupId);
@@ -310,13 +326,13 @@ class BaseHelper extends BaseFrameworkSystem {
         * Closes the previously opened sub group by added given content to it or
         * throws an exception if no previous sub group was opened
         *
-        * @param       $content        Content for previously opened sub grouop
+        * @param       $content        Content for previously opened sub group, or leave empty to use div/span of openener
         * @return      void
         * @throws      HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
         */
-       public function closePreviousSubGroupByContent ($content) {
+       public function closePreviousSubGroupByContent ($content = "") {
                // Check if any sub group was opened before
-               if (!$this->ifSubGroupOpenedPreviously()) {
+               if ($this->ifSubGroupOpenedPreviously() === false) {
                        // Then throw an exception
                        throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
                } // END - if
@@ -324,8 +340,14 @@ class BaseHelper extends BaseFrameworkSystem {
                // Get previous sub group
                $subGroupId = $this->getPreviousSubGroupId();
 
+               // Is the content empty?
+               if ((empty($content)) && (!empty($this->subGroups[$subGroupId]['tag']))) {
+                       // Get it from opener
+                       $content = sprintf("<!-- sub-group %s auto-closed //--></%s>", $subGroupId, $this->subGroups[$subGroupId]['tag']);
+               } // END - if
+
                // Add content to it and mark it as closed
-               $this->subGroups[$subGroupId]['content'] .= $content."\n";
+               $this->subGroups[$subGroupId]['content'] .= sprintf("<!-- sub-group %s closed (length: %s, tag: %s) //-->%s\n", $subGroupId, strlen($content), $this->subGroups[$subGroupId]['tag'], $content);
                $this->subGroups[$subGroupId]['opened'] = false;
 
                // Mark previous sub group as closed
@@ -356,19 +378,18 @@ class BaseHelper extends BaseFrameworkSystem {
                        // Is this a group and is it closed?
                        if ((isset($this->groups[$idx])) && ($this->groups[$this->groups[$idx]]['opened'] === false)) {
                                // Then add it's content
-                               $groupContent = $this->groups[$this->groups[$idx]]['content'];
+                               $groupContent = trim($this->groups[$this->groups[$idx]]['content']);
                                //* DEBUG: */ echo "group={$this->groups[$idx]},content=<pre>".htmlentities($groupContent)."</pre><br />\n";
                                $content .= $groupContent;
                        } elseif ((isset($this->subGroups[$idx])) && ($this->subGroups[$this->subGroups[$idx]]['opened'] === false)) {
                                // Then add it's content
                                $subGroupContent = $this->subGroups[$this->subGroups[$idx]]['content'];
                                //* DEBUG: */ echo "subgroup={$this->subGroups[$idx]},content=<pre>".htmlentities($subGroupContent)."</pre><br />\n";
-                               $content .= $subGroupContent;
+                               $content .= trim($subGroupContent);
                        } else {
                                // Something went wrong
-                               $this->debugInstance();
+                               $this->debugInstance(__METHOD__."(): Something unexpected happened here.");
                        }
-
                } // END - for
 
                // Is footer content there?
index 19b5be3..0da3e0a 100644 (file)
@@ -65,6 +65,16 @@ class BaseWebHelper extends BaseHelper {
        }
 
        /**
+        * Checks wether for birthday shall be asked
+        *
+        * @return      $required       Wether birthday shall be asked
+        */
+       public function ifProfileIncludesBirthDay () {
+               $required = ($this->getConfigInstance()->readConfig('profile_includes_birthday') === "Y");
+               return $required;
+       }
+
+       /**
         * Checks wether email addresses can only be once used
         *
         * @return      $isUnique
index a188251..1fffb7a 100644 (file)
@@ -378,7 +378,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                } // END - if
 
                // At least the group name should be set
-               if ((empty($groupId)) && (!$this->ifGroupOpenedPreviously())) {
+               if ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === false)) {
                        // Throw exception here
                        throw new EmptyVariableException(array($this, 'groupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } elseif (empty($groupId)) {
@@ -387,7 +387,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                }
 
                // Same group to open?
-               if ((!$this->ifGroupOpenedPreviously()) && ($groupId == $this->getPreviousGroupId())) {
+               if (($this->ifGroupOpenedPreviously() === false) && ($groupId === $this->getPreviousGroupId())) {
                        // Abort here silently
                        return false;
                } // END - if
@@ -396,7 +396,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                $content = "    </div>\n</div><!-- Group - CLOSE //-->";
 
                // Is this group opened?
-               if (!$this->ifGroupOpenedPreviously()) {
+               if ($this->ifGroupOpenedPreviously() === false) {
                        // Begin the div/span blocks
                        $content = sprintf("<!-- Group %s - OPEN //-->
 <div class=\"group_box\" id=\"%s_group_box\">
@@ -412,7 +412,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                        );
 
                        // Switch the state
-                       $this->openGroupByIdContent($groupId, $content);
+                       $this->openGroupByIdContent($groupId, $content, "div");
                } else {
                        // Is a sub group opened?
                        if ($this->ifSubGroupOpenedPreviously()) {
@@ -426,7 +426,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                        // Switch the state
                        $this->closePreviousGroupByContent($content);
 
-                       // All call it again if the group name is not empty
+                       // All call it again if group name is not empty
                        if ((!empty($groupId)) && ($groupId != $prevGroupId)) {
                                //* DEBUG: */ echo $groupId."/".$prevGroupId."<br />\n";
                                $this->addFormGroup($groupId, $groupText);
@@ -436,8 +436,8 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
 
        /**
         * Add a form sub group or close an already opened and open a new one or
-        * throws an exception if no group has been opened before or if the sub
-        * group name is empty.
+        * throws an exception if no group has been opened before or if sub group
+        * name is empty.
         *
         * @param       $subGroupId             Name of the group or last opened if empty
         * @param       $subGroupText   Text including HTML to show above this group
@@ -447,13 +447,13 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
         */
        public function addFormSubGroup ($subGroupId = "", $subGroupText = "") {
                // Is a group opened?
-               if (!$this->ifGroupOpenedPreviously()) {
+               if ($this->ifGroupOpenedPreviously() === false) {
                        // Throw exception here
                        throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP);
                } // END - if
 
                // At least the sub group name should be set
-               if ((empty($subGroupId)) && (!$this->ifSubGroupOpenedPreviously())) {
+               if ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === false)) {
                        // Throw exception here
                        throw new EmptyVariableException(array($this, 'subGroupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } elseif (empty($subGroupId)) {
@@ -462,7 +462,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                }
 
                // Same sub group to open?
-               if ((!$this->ifSubGroupOpenedPreviously()) && ($subGroupId == $this->getPreviousSubGroupId())) {
+               if (($this->ifSubGroupOpenedPreviously() === false) && ($subGroupId == $this->getPreviousSubGroupId())) {
                        // Abort here silently
                        return false;
                } // END - if
@@ -471,7 +471,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                $content = "    </div>\n</div><!-- Sub group- CLOSE //-->";
 
                // Is this group opened?
-               if (!$this->ifSubGroupOpenedPreviously()) {
+               if ($this->ifSubGroupOpenedPreviously() === false) {
                        // Begin the span block
                        $content = sprintf("<!-- Sub group %s - OPEN //-->
 <div class=\"subgroup_box\" id=\"%s_subgroup_box\">
@@ -487,7 +487,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                        );
 
                        // Switch the state and remeber the name
-                       $this->openSubGroupByIdContent($subGroupId, $content);
+                       $this->openSubGroupByIdContent($subGroupId, $content, "div");
                } else {
                        // Get previous sub group id
                        $prevSubGroupId = $this->getPreviousSubGroupId();
@@ -552,12 +552,6 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                        throw new FormClosedException (array($this, "form_notes"), self::EXCEPTION_CLOSED_FORM);
                } // END - if
 
-               // Is a group open?
-               if ($this->ifGroupOpenedPreviously()) {
-                       // Then automatically close it here
-                       $this->addFormGroup();
-               } // END - if
-
                // Generate the content
                $inputContent = sprintf("       <div id=\"form_note_%s\">
                %s
@@ -587,7 +581,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                } // END - if
 
                // Shall we close or open the sub group?
-               if ((!$this->ifSubGroupOpenedPreviously()) && ($this->getPreviousSubGroupId() !== $selectId)) {
+               if (($this->ifSubGroupOpenedPreviously() === false) && ($this->getPreviousSubGroupId() !== $selectId)) {
                        // Initialize first entry (which might be non-selectable if content is provided
                        if (!empty($firstEntry)) {
                                // Add selection around it
@@ -605,10 +599,10 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                        );
 
                        // Open the sub group
-                       $this->openSubGroupByIdContent($selectId, $content);
+                       $this->openSubGroupByIdContent($selectId, $content, "select");
                } elseif ($this->getPreviousSubGroupId() != $selectId) {
                        // Something went wrong!
-                       $this->debugInstance();
+                       $this->debugInstance(__METHOD__."(): Previous sub group id {$this->getPreviousSubGroupId()} does not match current id {$selectId}.");
                } else {
                        // Close the sub group
                        $this->closePreviousSubGroupByContent("</select>");
@@ -628,7 +622,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
         */
        public function addSelectSubOption ($subName, $subValue) {
                // Is there a sub group (shall be a selection box!)
-               if (!$this->ifSubGroupOpenedPreviously()) {
+               if ($this->ifSubGroupOpenedPreviously() === false) {
                        // Then throw an exception here
                        throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
                } // END - if
@@ -656,7 +650,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
         */
        public function addSelectOption ($optionName, $optionValue) {
                // Is there a sub group (shall be a selection box!)
-               if (!$this->ifSubGroupOpenedPreviously()) {
+               if ($this->ifSubGroupOpenedPreviously() === false) {
                        // Then throw an exception here
                        throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
                } // END - if
index 40d9c66..1a238a6 100644 (file)
@@ -63,6 +63,9 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate {
                // Set link base
                $helperInstance->setLinkBase($linkBase);
 
+               // Add default group
+               $helperInstance->openGroupByIdContent('main', "", "");
+
                // Return the prepared instance
                return $helperInstance;
        }
@@ -136,7 +139,7 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate {
                // Is a previous opened group still open?
                if ($this->ifGroupOpenedPreviously()) {
                        // Then close it
-                       $this->closePreviousGroupByContent("</div>");
+                       $this->closePreviousGroupByContent("");
                } // END - if
 
                // Get the content
@@ -155,49 +158,59 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate {
         *
         * @param       $groupId        Id string of the group
         * @param       $groupText      Text for this group to add
+        * @param       $groupCode      Code to open and close groups
         * @return      void
         */
-       public function addLinkGroup ($groupId, $groupText) {
+       public function addLinkGroup ($groupId, $groupText, $groupCode = "div") {
                // Is a group with that name open?
-               if ($this->ifGroupIsOpened($groupId)) {
+               if ($this->ifGroupOpenedPreviously()) {
                        // Then close it here
-                       $this->closePreviousGroupByContent("</div>");
-               } else {
-                       // Is a previous opened group still open?
-                       if ($this->ifGroupOpenedPreviously()) {
-                               // Then close it
-                               $this->closePreviousGroupByContent("</div>");
-                       } // END - if
-
-                       // Generate the group content
-                       $content = sprintf("<div id=\"group_%s_%s\">%s",
-                               $this->getLinkName(),
-                               $groupId,
-                               $groupText
-                       );
-
-                       // Open the new group
-                       $this->openGroupByIdContent($groupId, $content);
-               }
+                       $this->closePreviousGroupByContent("");
+               } // END - if
+
+               // Generate the group content
+               $content = sprintf("<{$groupCode} id=\"group_%s_%s\">%s",
+                       $this->getLinkName(),
+                       $groupId,
+                       $groupText
+               );
+
+               // Open the new group
+               $this->openGroupByIdContent($groupId, $content, $groupCode);
        }
 
        /**
         * Adds text (note) to the previously opened group or throws an exception
         * if no previous group was opened.
         *
+        * @param       $groupId        Group id to set
         * @param       $groupNote      Note to be added to a group
+        * @param       $groupCode      Code to open and close groups
         * @return      void
         * @throws      NoGroupOpenedException  If no previous group was opened
         */
-       public function addLinkNote ($groupNote) {
+       public function addLinkNote ($groupId, $groupNote, $groupCode = "div") {
                // Check if a previous group was opened
-               if (!$this->ifGroupOpenedPreviously()) {
+               if ($this->ifGroupOpenedPreviously() === false) {
                        // No group was opened before!
                        throw new NoGroupOpenedException(array($this, $groupNote), self::EXCEPTION_GROUP_NOT_OPENED);
                } // END - if
 
-               // Add the content to the previous group
-               $this->addContentToPreviousGroup($groupNote);
+               // Is a previous sub group open?
+               if ($this->ifSubGroupOpenedPreviously()) {
+                       // Then close it
+                       $this->closePreviousSubGroupByContent("</{$groupCode}>");
+               } // END - if
+
+               // Generate the group content
+               $content = sprintf("<{$groupCode} id=\"subgroup_%s_%s\">%s",
+                       $this->getLinkName(),
+                       $groupId,
+                       $groupNote
+               );
+
+               // Open the sub group
+               $this->openSubGroupByIdContent($groupId, $content, $groupCode);
        }
 
        /**
@@ -210,7 +223,7 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate {
         */
        public function addActionLink ($linkAction, $linkText) {
                // Check if a previous group was opened
-               if (!$this->ifGroupOpenedPreviously()) {
+               if ($this->ifGroupOpenedPreviously() === false) {
                        // No group was opened before!
                        throw new NoGroupOpenedException(array($this, $linkAction."(".$linkText.")"), self::EXCEPTION_GROUP_NOT_OPENED);
                } // END - if
@@ -239,6 +252,21 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate {
        }
 
        /**
+        * Adds a link to the previously opened group with a text from language system
+        *
+        * @param       $linkAction             Action (action=xxx) value for the link
+        * @param       $languageId             Language id string to use
+        * @return      void
+        */
+       public function addActionLinkById ($linkAction, $languageId) {
+               // Resolve the language string
+               $languageResolved = $this->getLanguageInstance()->getMessage($languageId);
+
+               // Add the action link
+               $this->addActionLink($linkAction, $languageResolved);
+       }
+
+       /**
         * Adds a default link (no extra parameters) to the content with specified
         * language id string.
         *
index e19b067..ccbb545 100644 (file)
@@ -195,7 +195,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
         * @return      void
         */
        public final function setPointer ($dirPointer) {
-               // Sanity-check if the pointer is a valid directory resource
+               // Sanity-check if pointer is a valid directory resource
                if (is_resource($dirPointer) || is_null($dirPointer)) {
                        // Is a valid resource
                        $this->dirPointer = $dirPointer;
index 172c02f..35376e9 100644 (file)
@@ -178,7 +178,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
         * @return      void
         */
        public final function setPointer ($filePointer) {
-               // Sanity-check if the pointer is a valid file resource
+               // Sanity-check if pointer is a valid file resource
                if (is_resource($filePointer) || is_null($filePointer)) {
                        // Is a valid resource
                        $this->filePointer = $filePointer;
index 37c2285..84c8ed4 100644 (file)
@@ -148,7 +148,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem {
         * @return      void
         */
        public final function setPointer ($filePointer) {
-               // Sanity-check if the pointer is a valid file resource
+               // Sanity-check if pointer is a valid file resource
                if (is_resource($filePointer) || is_null($filePointer)) {
                        // Is a valid resource
                        $this->filePointer = $filePointer;
index 042ee69..14bdd41 100644 (file)
@@ -101,7 +101,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail {
                                        // Get the field from the value instance
                                        $fieldValue = $recipientList['values'][$variable]->getField($variable);
 
-                                       // Set it in the template engine
+                                       // Set it in template engine
                                        $templateInstance->assignVariable($variable, $fieldValue);
                                }
 
index fb0f169..e7b636f 100644 (file)
@@ -80,7 +80,7 @@ class UserPoints extends BaseFrameworkSystem implements Registerable {
 
                // Do we have an entry?
                if ($resultInstance->next()) {
-                       // Load points here - TODO!
+                       // @TODO Load points here
                        $this->partialStub("Load points here for comparison.");
                } // END - if
 
index 0cc0040..1ebf7e5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * A general registration class
+ * A general registration class.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-abstract class BaseRegistration extends BaseFrameworkSystem implements UserRegister {
+class BaseRegistration extends BaseFrameworkSystem {
        /**
         * Pre-registration filter chain
         */
index 2ca0382..9a8b648 100644 (file)
@@ -86,8 +86,8 @@ class Registry extends BaseFrameworkSystem implements Register {
        /**
         * Checks wether an instance key was found
         *
-        * @param       $instanceKey    The key holding an instance in the registry
-        * @return      $exists                 Wether the key exists in the registry
+        * @param       $instanceKey    The key holding an instance in registry
+        * @return      $exists                 Wether the key exists in registry
         */
        public function instanceExists ($instanceKey) {
                // Does this key exists?
@@ -115,7 +115,7 @@ class Registry extends BaseFrameworkSystem implements Register {
         * @return      $objectInstance         An instance we shall store
         */
        public function getInstance ($instanceKey) {
-               // By default the instance is not in the registry
+               // By default the instance is not in registry
                $objectInstance = null;
 
                // Is the instance there?
index 0241cfc..0538512 100644 (file)
@@ -83,17 +83,14 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable {
         */
        public function isRequestElementSet ($element) {
                // Is this element found?
-               if (!isset($this->requestData[$element])) {
-                       // Then return false
-                       return false;
-               } // END - if
+               $isSet = isset($this->requestData[$element]);
 
-               // All clear
-               return true;
+               // Return result
+               return $isSet;
        }
 
        /**
-        * Getter for request element or 'null' if the element was not found
+        * Getter for request element or 'null' if element was not found
         *
         * @param       $element        Name of the request element we want to check
         * @return      $value          Value of the found request element or 'null' if the
@@ -124,7 +121,6 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable {
         * @return      void
         */
        public function setRequestElement ($element, $value) {
-               error_log(__METHOD__.":{$element}={$value}");
                $this->requestData[$element] = $value;
        }
 
@@ -138,7 +134,7 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable {
        }
 
        /**
-        * Getter for a header element or 'null' if the header was not found
+        * Getter for a header element or 'null' if header was not found
         *
         * @param       $headerName             Name of the header
         * @return      $headerValue    Value of the header or 'null' if not found
index eef7b46..7e462cc 100644 (file)
@@ -60,7 +60,7 @@ class BaseActionResolver extends BaseResolver {
         * @return      void
         */
        protected final function setActionName ($actionName) {
-               $this->actionName = $actionName;
+               $this->actionName = (string) $actionName;
        }
 
        /**
@@ -77,7 +77,7 @@ class BaseActionResolver extends BaseResolver {
         *
         * @param       $actionName     The default action we shall execute
         * @return      $isValid                Wether the given action is valid
-        * @throws      EmptyVariableException  Thrown if the given action is not set
+        * @throws      EmptyVariableException  Thrown if given action is not set
         */
        public function isActionValid ($actionName) {
                // By default nothing shall be valid
@@ -112,8 +112,6 @@ class BaseActionResolver extends BaseResolver {
         * "Loads" current action and instances it if not yet cached
         *
         * @return      $actionInstance                 A loaded action instance
-        * @throws      InvalidActionException  Thrown if even the default
-        *                                                                      action class is missing (bad!)
         */
        protected function loadAction () {
                // Init action instance
index 83f5ddd..6276b11 100644 (file)
@@ -46,8 +46,8 @@ class WebActionResolver extends BaseActionResolver implements ActionResolver {
         * @param       $actionName                             The default action we shall execute
         * @param       $appInstance                    An instance of a manageable application helper class
         * @return      $resolverInstance               The prepared action resolver instance
-        * @throws      EmptyVariableException  Thrown if the default action is not set
-        * @throws      InvalidActionException  Thrown if the default action is invalid
+        * @throws      EmptyVariableException  Thrown if default action is not set
+        * @throws      InvalidActionException  Thrown if default action is invalid
         */
        public final static function createWebActionResolver ($actionName, ManageableApplication $appInstance) {
                // Create the new instance
@@ -57,7 +57,7 @@ class WebActionResolver extends BaseActionResolver implements ActionResolver {
                if (empty($actionName)) {
                        // Then thrown an exception here
                        throw new EmptyVariableException(array($resolverInstance, 'defaultAction'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!$resolverInstance->isActionValid($actionName)) {
+               } elseif ($resolverInstance->isActionValid($actionName) === false) {
                        // Invalid action found
                        throw new InvalidActionException(array($resolverInstance, $actionName), self::EXCEPTION_INVALID_ACTION);
                }
@@ -91,8 +91,8 @@ class WebActionResolver extends BaseActionResolver implements ActionResolver {
                // Is the action empty? Then fall back to default action
                if (empty($actionName)) $actionName = $this->getConfigInstance()->readConfig('default_action');
 
-               // Check if the action is valid
-               if (!$this->isActionValid($actionName)) {
+               // Check if action is valid
+               if ($this->isActionValid($actionName) === false) {
                        // This action is invalid!
                        throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION);
                } // END - if
@@ -129,8 +129,8 @@ class WebActionResolver extends BaseActionResolver implements ActionResolver {
                // Is the action empty? Then fall back to default action
                if (empty($actionName)) $actionName = $this->getConfigInstance()->readConfig('default_action');
 
-               // Check if the action is valid
-               if (!$this->isActionValid($actionName)) {
+               // Check if action is valid
+               if ($this->isActionValid($actionName) === false) {
                        // This action is invalid!
                        throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION);
                }
index d1fa003..4900c61 100644 (file)
@@ -33,11 +33,6 @@ class BaseCommandResolver extends BaseResolver {
        private $commandName = "";
 
        /**
-        * A controller instance
-        */
-       private $controllerInstance = null;
-
-       /**
         * Protected constructor
         *
         * @param       $className      Name of the class
@@ -78,30 +73,11 @@ class BaseCommandResolver extends BaseResolver {
        }
 
        /**
-        * Setter for controller instance (this surely breaks a bit the MVC patterm)
-        *
-        * @param       $controllerInstance             An instance of the controller
-        * @return      void
-        */
-       public final function setControllerInstance (Controller $controllerInstance) {
-               $this->controllerInstance = $controllerInstance;
-       }
-
-       /**
-        * Getter for controller instance (this surely breaks a bit the MVC patterm)
-        *
-        * @return      $controllerInstance             An instance of the controller
-        */
-       public final function getControllerInstance () {
-               return $this->controllerInstance;
-       }
-
-       /**
         * Checks wether the given command is valid
         *
         * @param       $commandName    The default command we shall execute
         * @return      $isValid                Wether the given command is valid
-        * @throws      EmptyVariableException  Thrown if the given command is not set
+        * @throws      EmptyVariableException  Thrown if given command is not set
         */
        public function isCommandValid ($commandName) {
                // By default nothing shall be valid
index ed8492c..dc104e6 100644 (file)
@@ -46,8 +46,8 @@ class ImageCommandResolver extends BaseCommandResolver implements CommandResolve
         * @param       $commandName                            The default command we shall execute
         * @param       $appInstance                            An instance of a manageable application helper class
         * @return      $resolverInstance                       The prepared command resolver instance
-        * @throws      EmptyVariableException          Thrown if the default command is not set
-        * @throws      InvalidCommandException         Thrown if the default command is invalid
+        * @throws      EmptyVariableException          Thrown if default command is not set
+        * @throws      InvalidCommandException         Thrown if default command is invalid
         */
        public final static function createImageCommandResolver ($commandName, ManageableApplication $appInstance) {
                // Create the new instance
@@ -57,7 +57,7 @@ class ImageCommandResolver extends BaseCommandResolver implements CommandResolve
                if (empty($commandName)) {
                        // Then thrown an exception here
                        throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!$resolverInstance->isCommandValid($commandName)) {
+               } elseif ($resolverInstance->isCommandValid($commandName) === false) {
                        // Invalid command found
                        throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
                }
@@ -91,8 +91,8 @@ class ImageCommandResolver extends BaseCommandResolver implements CommandResolve
                // Is the command empty? Then fall back to default command
                if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_image_command');
 
-               // Check if the command is valid
-               if (!$this->isCommandValid($commandName)) {
+               // Check if command is valid
+               if ($this->isCommandValid($commandName) === false) {
                        // This command is invalid!
                        throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
                } // END - if
@@ -127,8 +127,8 @@ class ImageCommandResolver extends BaseCommandResolver implements CommandResolve
                // Is the command empty? Then fall back to default command
                if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_image_command');
 
-               // Check if the command is valid
-               if (!$this->isCommandValid($commandName)) {
+               // Check if command is valid
+               if ($this->isCommandValid($commandName) === false) {
                        // This command is invalid!
                        throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
                }
diff --git a/inc/classes/main/resolver/command/web/class_ b/inc/classes/main/resolver/command/web/class_
new file mode 100644 (file)
index 0000000..4808086
--- /dev/null
@@ -0,0 +1,178 @@
+<?php
+/**
+ * A command resolver for local (non-hubbed) web commands
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class Web???CommandResolver extends BaseCommandResolver implements CommandResolver {
+       /**
+        * Last successfull resolved command
+        */
+       private $lastCommandInstance = null;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set prefix to "Web"
+               $this->setCommandPrefix("Web");
+       }
+
+       /**
+        * Creates an instance of a Web command resolver with a given default command
+        *
+        * @param       $commandName                            The default command we shall execute
+        * @param       $appInstance                            An instance of a manageable application helper class
+        * @return      $resolverInstance                       The prepared command resolver instance
+        * @throws      EmptyVariableException          Thrown if the default command is not set
+        * @throws      InvalidCommandException         Thrown if the default command is invalid
+        */
+       public final static function createWeb???CommandResolver ($commandName, ManageableApplication $appInstance) {
+               // Create the new instance
+               $resolverInstance = new Web???CommandResolver();
+
+               // Is the variable $commandName set and the command is valid?
+               if (empty($commandName)) {
+                       // Then thrown an exception here
+                       throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               } elseif ($resolverInstance->isCommandValid($commandName) === false) {
+                       // Invalid command found
+                       throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
+               }
+
+               // Set the application instance
+               $resolverInstance->setApplicationInstance($appInstance);
+
+               // Return the prepared instance
+               return $resolverInstance;
+       }
+
+       /**
+        * Returns an command instance for a given request class or null if
+        * it was not found
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @return      $commandInstance        An instance of the resolved command
+        * @throws      InvalidCommandException                         Thrown if $commandName is
+        *                                                                                              invalid
+        * @throws      InvalidCommandInstanceException         Thrown if $commandInstance
+        *                                                                                              is an invalid instance
+        */
+       public function resolveCommandByRequest (Requestable $requestInstance) {
+               // Init variables
+               $commandName = "";
+               $commandInstance = null;
+
+               // This goes fine so let's resolv the command
+               $commandName = $requestInstance->getRequestElement('page');
+
+               // Is the command empty? Then fall back to default command
+               if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command');
+
+               // Check if the command is valid
+               if ($this->isCommandValid($commandName) === false) {
+                       // This command is invalid!
+                       throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+               } // END - if
+
+               // Get the command
+               $commandInstance = $this->loadCommand($commandName);
+
+               // And validate it
+               if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
+                       // This command has an invalid instance!
+                       throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+               } // END - if
+
+               // Set last command
+               $this->lastCommandInstance = $commandInstance;
+
+               // Return the resolved command instance
+               return $commandInstance;
+       }
+
+       /**
+        * Resolves the command by its direct name and returns an instance of its class
+        *
+        * @param       $commandName            The direct command name we shall resolve
+        * @return      $commandInstance        An instance of the command class
+        * @throws      InvalidCommandException         Thrown if $commandName is invalid
+        */
+       public function resolveCommand ($commandName) {
+               // Initiate the instance variable
+               $commandInstance = null;
+
+               // Is the command empty? Then fall back to default command
+               if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command');
+
+               // Check if the command is valid
+               if ($this->isCommandValid($commandName) === false) {
+                       // This command is invalid!
+                       throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+               }
+
+               // Get the command
+               $commandInstance = $this->loadCommand($commandName);
+
+               // Return the instance
+               return $commandInstance;
+       }
+
+       /**
+        * "Loads" a given command and instances it if not yet cached
+        *
+        * @param       $commandName                            A command name we shall look for
+        * @return      $commandInstance                        A loaded command instance
+        * @throws      InvalidCommandException         Thrown if even the default
+        *                                                                              command class is missing (bad!)
+        */
+       private function loadCommand ($commandName) {
+               // Cache default command
+               $defaultCommand = $this->getConfigInstance()->readConfig('default_web_command');
+
+               // Init command instance
+               $commandInstance = null;
+
+               // Create command class name
+               $this->setClassName(sprintf("Web%sCommand",
+                       $this->convertToClassName($commandName)
+               ));
+
+               // Is this class loaded?
+               if (!class_exists($this->getClassName())) {
+                       // Class not found, so throw an exception
+                       throw new InvalidCommandException(array($this, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
+               } // END - if
+
+               // Initiate the command
+               $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this));
+
+               // Return the result
+               return $commandInstance;
+       }
+}
+
+// [EOF]
+?>
index 165d2f7..42ae37a 100644 (file)
@@ -46,8 +46,8 @@ class WebCommandResolver extends BaseCommandResolver implements CommandResolver
         * @param       $commandName                            The default command we shall execute
         * @param       $appInstance                            An instance of a manageable application helper class
         * @return      $resolverInstance                       The prepared command resolver instance
-        * @throws      EmptyVariableException          Thrown if the default command is not set
-        * @throws      InvalidCommandException         Thrown if the default command is invalid
+        * @throws      EmptyVariableException          Thrown if default command is not set
+        * @throws      InvalidCommandException         Thrown if default command is invalid
         */
        public final static function createWebCommandResolver ($commandName, ManageableApplication $appInstance) {
                // Create the new instance
@@ -57,7 +57,7 @@ class WebCommandResolver extends BaseCommandResolver implements CommandResolver
                if (empty($commandName)) {
                        // Then thrown an exception here
                        throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!$resolverInstance->isCommandValid($commandName)) {
+               } elseif ($resolverInstance->isCommandValid($commandName) === false) {
                        // Invalid command found
                        throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
                }
@@ -91,8 +91,8 @@ class WebCommandResolver extends BaseCommandResolver implements CommandResolver
                // Is the command empty? Then fall back to default command
                if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command');
 
-               // Check if the command is valid
-               if (!$this->isCommandValid($commandName)) {
+               // Check if command is valid
+               if ($this->isCommandValid($commandName) === false) {
                        // This command is invalid!
                        throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
                } // END - if
@@ -127,8 +127,8 @@ class WebCommandResolver extends BaseCommandResolver implements CommandResolver
                // Is the command empty? Then fall back to default command
                if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command');
 
-               // Check if the command is valid
-               if (!$this->isCommandValid($commandName)) {
+               // Check if command is valid
+               if ($this->isCommandValid($commandName) === false) {
                        // This command is invalid!
                        throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
                }
index ec61d4e..a667fe6 100644 (file)
@@ -77,8 +77,8 @@ class BaseControllerResolver extends BaseResolver {
         *
         * @param       $controllerName         The default controller we shall execute
         * @return      $isValid                        Wether the given controller is valid
-        * @throws      EmptyVariableException  Thrown if the given controller is not set
-        * @throws      DefaultControllerException      If the default controller was not found
+        * @throws      EmptyVariableException          Thrown if given controller is not set
+        * @throws      DefaultControllerException      Thrown if default controller was not found
         */
        public function isControllerValid ($controllerName) {
                // By default nothing shall be valid
@@ -97,7 +97,7 @@ class BaseControllerResolver extends BaseResolver {
                ));
 
                // Try it hard to get an controller
-               while (!$isValid) {
+               while ($isValid === false) {
                        // Is this class already loaded?
                        if (class_exists($this->getClassName())) {
                                // This class does exist. :-)
index b2f4fcd..39d88d1 100644 (file)
@@ -51,8 +51,8 @@ class ImageControllerResolver extends BaseControllerResolver implements Controll
         * @param       $controllerName                         The controller we shall resolve
         * @param       $appInstance                            An instance of a manageable application helper class
         * @return      $resolverInstance                       The prepared controller resolver instance
-        * @throws      EmptyVariableException          Thrown if the default command is not set
-        * @throws      InvalidControllerException      Thrown if the default controller is invalid
+        * @throws      EmptyVariableException          Thrown if default command is not set
+        * @throws      InvalidControllerException      Thrown if default controller is invalid
         */
        public final static function createImageControllerResolver ($controllerName, ManageableApplication $appInstance) {
                // Create the new instance
@@ -62,7 +62,7 @@ class ImageControllerResolver extends BaseControllerResolver implements Controll
                if (empty($controllerName)) {
                        // Then thrown an exception here
                        throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!$resolverInstance->isControllerValid($controllerName)) {
+               } elseif ($resolverInstance->isControllerValid($controllerName) === false) {
                        // Invalid command found
                        throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
                }
index da09dca..5378006 100644 (file)
@@ -51,8 +51,8 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
         * @param       $controllerName                         The controller we shall resolve
         * @param       $appInstance                            An instance of a manageable application helper class
         * @return      $resolverInstance                       The prepared controller resolver instance
-        * @throws      EmptyVariableException          Thrown if the default command is not set
-        * @throws      InvalidControllerException      Thrown if the default controller is invalid
+        * @throws      EmptyVariableException          Thrown if default command is not set
+        * @throws      InvalidControllerException      Thrown if default controller is invalid
         */
        public final static function createWebControllerResolver ($controllerName, ManageableApplication $appInstance) {
                // Create the new instance
@@ -62,7 +62,7 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
                if (empty($controllerName)) {
                        // Then thrown an exception here
                        throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!$resolverInstance->isControllerValid($controllerName)) {
+               } elseif ($resolverInstance->isControllerValid($controllerName) === false) {
                        // Invalid command found
                        throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
                }
@@ -151,11 +151,26 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
                        throw new InvalidControllerException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
                } // END - if
 
+               // Set default resolver config name
+               $resolverConfigEntry = "";
+
+               // Try to read a config entry for our resolver including controller name... ;-)
+               try {
+                       // Create the resolver name
+                       $resolverConfigEntry = sprintf("web_cmd_%s_resolver_class", strtolower($controllerName));
+
+                       // Get the config, this will throw an exception if there is no special command resolver
+                       $resolverClass = $this->getConfigInstance()->readConfig($resolverConfigEntry);
+               } catch (ConfigEntryNotFoundException $e) {
+                       // Use default resolver entry
+                       $resolverConfigEntry = "web_cmd_resolver_class";
+               }
+
                // Initiate the resolver and controller
-               $resolverInstance = ObjectFactory::createObjectByConfiguredName('web_cmd_resolver_class', array($controllerName, $this->getApplicationInstance()));
+               $resolverInstance = ObjectFactory::createObjectByConfiguredName($resolverConfigEntry, array($controllerName, $this->getApplicationInstance()));
                $controllerInstance = ObjectFactory::createObjectByName($this->getClassName(), array($resolverInstance));
 
-               // Remove resolver
+               // Remove resolver (we don't need it anymore)
                unset($resolverInstance);
 
                // Return the result
index 0c3a4c7..1bbf574 100644 (file)
@@ -153,7 +153,7 @@ class BaseResponse extends BaseFrameworkSystem {
         *                                                                                                      already sent
         */
        public function flushBuffer ($force = false) {
-               if ((headers_sent()) && (!$force)) {
+               if ((headers_sent()) && ($force === false)) {
                        // Headers are already sent!
                        throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
                } elseif (!headers_sent()) {
index 3f8918b..94fe3b5 100644 (file)
@@ -52,6 +52,11 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
        private $affectedRows = 0;
 
        /**
+        * Found value
+        */
+       private $foundValue = "";
+
+       /**
         * Protected constructor
         *
         * @return      void
@@ -114,7 +119,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
 
        /**
         * "Iterator" method next() to advance to the next valid entry. This method
-        * does also check if the result is invalid
+        * does also check if result is invalid
         *
         * @return      $nextValid      Wether the next entry is valid
         */
@@ -208,16 +213,17 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
        }
 
        /**
-        * Rewind to the beginning
+        * Rewind to the beginning and clear array $currentRow
         *
         * @return      void
         */
        public function rewind () {
                $this->currentPos = -1;
+               $this->currentRow = array();
        }
 
        /**
-        * Searches for an entry in the data result and returns it
+        * Searches for an entry in data result and returns it
         *
         * @param       $criteriaInstance       The criteria to look inside the data set
         * @return      $result                         Found result entry
@@ -292,6 +298,15 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
        }
 
        /**
+        * Getter for found value of previous found() call
+        *
+        * @return      $foundValue             Found value of previous found() call
+        */
+       public final function getFoundValue () {
+               return $this->foundValue;
+       }
+
+       /**
         * Checks wether we have out-dated entries or not
         *
         * @return      $needsUpdate    Wether we have out-dated entries
@@ -308,25 +323,80 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
         * @return      void
         */
        public function addElementsToDataSet (StoreableCriteria $criteriaInstance) {
+               // Walk only through out-dated columns
+               foreach ($this->outDated as $key => $dummy) {
+                       // Does this key exist?
+                       //* DEBUG: */ echo "outDated: {$key}<br />\n";
+                       if ($this->find($key)) {
+                               // Then update it
+                               $criteriaInstance->addCriteria($key, $this->getFoundValue());
+                       } // END - if
+               } // END - foreach
+       }
+
+       /**
+        * Find a key inside the result array
+        *
+        * @param       $key    The key we shall find
+        * @return      $found  Wether the key was found or not
+        */
+       public function find ($key) {
+               // By default nothing is found
+               $found = false;
+
                // Rewind the pointer
                $this->rewind();
 
                // Walk through all entries
                while ($this->valid()) {
-                       // Get next entry
+                       // Advance to next entry
                        $this->next();
+
+                       // Get the whole array
                        $currentEntry = $this->current();
 
-                       // Walk only through out-dated columns
-                       foreach ($this->outDated as $key => $dummy) {
-                               // Does this key exist?
-                               //* DEBUG: */ echo "outDated: {$key}<br />\n";
-                               if (isset($currentEntry[$key])) {
-                                       // Then update it
-                                       $criteriaInstance->addCriteria($key, $currentEntry[$key]);
-                               } // END - foreach
-                       } // END - foreach
+                       // Is the element there?
+                       if (isset($currentEntry[$key])) {
+                               // Okay, found!
+                               $found = true;
+
+                               // So "cache" it
+                               $this->foundValue = $currentEntry[$key];
+
+                               // And stop searching
+                               break;
+                       } // END - if
                } // END - while
+
+               // Return the result
+               return $found;
+       }
+
+       /**
+        * Solver for result index value with call-back method
+        *
+        * @param       $databaseColumn         Database column where the index might be found
+        * @param       $wrapperInstance        The wrapper instance to ask for array element
+        * @para        $callBack                       Call-back object for setting the index;
+        *                                                              0=object instance,1=method name
+        * @return      void
+4       * @todo        Find a caching way without modifying the result array
+        */
+       public function solveResultIndex ($databaseColumn, BaseDatabaseWrapper $wrapperInstance, array $callBack) {
+               // By default nothing is found
+               $indexValue = 0;
+
+               // Is the element in result itself found?
+               if ($this->find($databaseColumn)) {
+                       // Use this value
+                       $indexValue = $this->getFoundValue();
+               } elseif ($this->find($wrapperInstance->getIndexKey())) {
+                       // Use this value
+                       $indexValue = $this->getFoundValue();
+               }
+
+               // Set the index
+               call_user_func_array($callBack, array($indexValue));
        }
 }
 
index 2bbec44..8690db6 100644 (file)
@@ -1172,7 +1172,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         * @return      void
         */
        public function transferToResponse (Responseable $responseInstance) {
-               // Get the content and set it in the response class
+               // Get the content and set it in response class
                $responseInstance->writeToBody($this->getCompiledData());
        }
 
index 0a3432d..b00a073 100644 (file)
@@ -33,6 +33,11 @@ class BaseUser extends BaseFrameworkSystem {
        private $userName = "";
 
        /**
+        * User id of current user
+        */
+       private $userId = 0;
+
+       /**
         * Email of current user
         */
        private $email = "";
@@ -59,26 +64,46 @@ class BaseUser extends BaseFrameworkSystem {
         * @return      void
         */
        public final function setUserName ($userName) {
-               $this->userName = $userName;
+               $this->userName = (string) $userName;
        }
 
        /**
-        * Setter for email
+        * Getter for username
         *
-        * @param       $email  The email to set
+        * @return      $userName       The username to get
+        */
+       public final function getUserName () {
+               return $this->userName;
+       }
+
+       /**
+        * Setter for user id
+        *
+        * @param       $userId         The user id to set
         * @return      void
+        * @todo        Find a way of casting here. "(int)" might destroy the user id > 32766
         */
-       protected final function setEmail ($email) {
-               $this->email = $email;
+       public final function setUserId ($userId) {
+               $this->userId = $userId;
        }
 
        /**
-        * Getter for username
+        * Getter for user id
         *
-        * @return      $userName       The username to get
+        * @return      $userId The user id to get
         */
-       public final function getUsername () {
-               return $this->userName;
+       public final function getUserId () {
+               return $this->userId;
+       }
+
+       /**
+        * Setter for email
+        *
+        * @param       $email  The email to set
+        * @return      void
+        */
+       protected final function setEmail ($email) {
+               $this->email = (string) $email;
        }
 
        /**
@@ -108,15 +133,21 @@ class BaseUser extends BaseFrameworkSystem {
                        $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
 
                        // Add the username as a criteria and set limit to one entry
-                       $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUsername());
+                       $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
                        $criteriaInstance->setLimit(1);
 
                        // Get a search result
-                       $this->setResultInstance($wrapperInstance->doSelectByCriteria($criteriaInstance));
-               } else {
-                       // Rewind it
-                       $this->getResultInstance()->rewind();
-               }
+                       $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+                       // Set the index "solver"
+                       $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId'));
+
+                       // And finally set it
+                       $this->setResultInstance($resultInstance);
+               } // END - if
+
+               // Rewind it
+               $this->getResultInstance()->rewind();
 
                // Search for it
                if ($this->getResultInstance()->next()) {
@@ -149,12 +180,18 @@ class BaseUser extends BaseFrameworkSystem {
                        $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail());
                        $criteriaInstance->setLimit(1);
 
-                       // Get a search resultInstance
-                       $this->setResultInstance($wrapperInstance->doSelectByCriteria($criteriaInstance));
-               } else {
-                       // Rewind it
-                       $this->getResultInstance()->rewind();
-               }
+                       // Get a search result
+                       $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+                       // Set the index "solver"
+                       $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId'));
+
+                       // And finally set it
+                       $this->setResultInstance($resultInstance);
+               } // END - if
+
+               // Rewind it
+               $this->getResultInstance()->rewind();
 
                // Search for it
                if ($this->getResultInstance()->next()) {
@@ -176,8 +213,8 @@ class BaseUser extends BaseFrameworkSystem {
        }
 
        /**
-        * Checks if the supplied password hash in request matches with the stored
-        * in database.
+        * Checks if supplied password hash in request matches with the stored in
+        * database.
         *
         * @param       $requestInstance        A requestable class instance
         * @return      $matches                        Wether the supplied password hash matches
@@ -186,27 +223,36 @@ class BaseUser extends BaseFrameworkSystem {
                // By default nothing matches... ;)
                $matches = false;
 
-               // Get a UserDatabaseWrapper instance
-               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+               // Is a previous result there?
+               if (is_null($this->getResultInstance())) {
+                       // Get a UserDatabaseWrapper instance
+                       $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+
+                       // Create a search criteria
+                       $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+                       // 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
+                       $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
 
-               // Create a search criteria
-               $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+                       // Set the index "solver"
+                       $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId'));
 
-               // Add the username as a criteria and set limit to one entry
-               $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
-               $criteriaInstance->setLimit(1);
+                       // And finally set it
+                       $this->setResultInstance($resultInstance);
+               } // END - if
 
-               // Get a search resultInstance
-               $this->setResultInstance($wrapperInstance->doSelectByCriteria($criteriaInstance));
+               // Rewind it
+               $this->getResultInstance()->rewind();
 
                // Search for it
-               if ($this->getResultInstance()->next()) {
-                       // Get the current entry (can only be one!)
-                       $entry = $this->getResultInstance()->current();
-
+               if ($this->getResultInstance()->find('pass_hash')) {
                        // So does the hashes match?
                        //* DEBUG: */ echo $requestInstance->getRequestElement('pass_hash')."/".$entry['pass_hash'];
-                       $matches = ($requestInstance->getRequestElement('pass_hash') === $entry['pass_hash']);
+                       $matches = ($requestInstance->getRequestElement('pass_hash') === $this->getResultInstance()->getFoundValue());
                } // END - if
 
                // Return the status
index 84405dc..2362921 100644 (file)
@@ -39,8 +39,8 @@ class Guest extends BaseUser implements ManageableGuest, Registerable {
 
        /**
         * Creates an instance of this user class by a provided username. This
-        * factory method will check if the username is already taken and if not
-        * so it will throw an exception.
+        * factory method will check if username is already taken and if not so it
+        * will throw an exception.
         *
         * @param       $userName               Username we need a class instance for
         * @return      $userInstance   An instance of this user class
@@ -53,11 +53,11 @@ class Guest extends BaseUser implements ManageableGuest, Registerable {
                // Set the username
                $userInstance->setUserName($userName);
 
-               // Check if the username exists
-               if (!$userInstance->ifUsernameExists()) {
+               // Check if username exists
+               if ($userInstance->ifUsernameExists() === false) {
                        // Throw an exception here
                        throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
-               }
+               } // END - if
 
                // Return the instance
                return $userInstance;
@@ -65,7 +65,7 @@ class Guest extends BaseUser implements ManageableGuest, Registerable {
 
        /**
         * Creates an instance of this user class by a provided email address. This
-        * factory method will not check if the email address is there.
+        * factory method will not check if email address is there.
         *
         * @param       $email                  Email address of the user
         * @return      $userInstance   An instance of this user class
index 726e850..b67ad88 100644 (file)
@@ -47,8 +47,8 @@ class Member extends BaseUser implements ManageableMember, Registerable, Updatea
 
        /**
         * Creates an instance of this user class by a provided username. This
-        * factory method will check if the username is already taken and if not
-        * so it will throw an exception.
+        * factory method will check if username is already taken and if not so it
+        * will throw an exception.
         *
         * @param       $userName               Username we need a class instance for
         * @return      $userInstance   An instance of this user class
@@ -61,11 +61,11 @@ class Member extends BaseUser implements ManageableMember, Registerable, Updatea
                // Set the username
                $userInstance->setUserName($userName);
 
-               // Check if the username exists
-               if (!$userInstance->ifUsernameExists()) {
+               // Check if username exists
+               if ($userInstance->ifUsernameExists() === false) {
                        // Throw an exception here
                        throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
-               }
+               } // END - if
 
                // Return the instance
                return $userInstance;
@@ -73,7 +73,7 @@ class Member extends BaseUser implements ManageableMember, Registerable, Updatea
 
        /**
         * Creates an instance of this user class by a provided email address. This
-        * factory method will not check if the email address is there.
+        * factory method will not check if email address is there.
         *
         * @param       $email                  Email address of the user
         * @return      $userInstance   An instance of this user class
index 736ea4b..6f0a4e1 100644 (file)
@@ -99,6 +99,15 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re
        }
 
        /**
+        * Getter for index key
+        *
+        * @return      $indexKey       Index key
+        */
+       public final function getIndexKey () {
+               return $this->dbLayer->getIndexKey();
+       }
+
+       /**
         * Runs a "select" statement on the database layer with given table name
         * and criteria. If this doesn't fail the result will be returned
         *
diff --git a/inc/classes/third_party/akismet/.htaccess b/inc/classes/third_party/akismet/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/third_party/akismet/akismet.class.php b/inc/classes/third_party/akismet/akismet.class.php
new file mode 100644 (file)
index 0000000..021447e
--- /dev/null
@@ -0,0 +1,388 @@
+<?php
+/**
+ * 01.07.2008 22:32:28est
+ * 
+ * Akismet PHP4 class
+ * 
+ * <b>Usage</b>
+ * <code>
+ *    $comment = array(
+ *           'author'    => 'viagra-test-123',
+ *           'email'     => 'test@example.com',
+ *           'website'   => 'http://www.example.com/',
+ *           'body'      => 'This is a test comment',
+ *           'permalink' => 'http://yourdomain.com/yourblogpost.url',
+ *        );
+ *
+ *    $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment);
+ *
+ *    if($akismet->errorsExist()) {
+ *        echo"Couldn't connected to Akismet server!";
+ *    } else {
+ *        if($akismet->isSpam()) {
+ *            echo"Spam detected";
+ *        } else {
+ *            echo"yay, no spam!";
+ *        }
+ *    }
+ * </code>
+ * 
+ * @author Bret Kuhns {@link www.miphp.net}
+ * @link http://www.miphp.net/blog/view/new_akismet_class/
+ * @version 0.3.4
+ * @license http://www.opensource.org/licenses/mit-license.php MIT License
+ */
+
+
+
+// Error constants
+define("AKISMET_SERVER_NOT_FOUND",     0);
+define("AKISMET_RESPONSE_FAILED",      1);
+define("AKISMET_INVALID_KEY",          2);
+
+
+
+// Base class to assist in error handling between Akismet classes
+class AkismetObject {
+       var $errors = array();
+       
+       
+       /**
+        * Add a new error to the errors array in the object
+        *
+        * @param       String  $name   A name (array key) for the error
+        * @param       String  $string The error message
+        * @return void
+        */ 
+       // Set an error in the object
+       function setError($name, $message) {
+               $this->errors[$name] = $message;
+       }
+       
+
+       /**
+        * Return a specific error message from the errors array
+        *
+        * @param       String  $name   The name of the error you want
+        * @return mixed        Returns a String if the error exists, a false boolean if it does not exist
+        */
+       function getError($name) {
+               if($this->isError($name)) {
+                       return $this->errors[$name];
+               } else {
+                       return false;
+               }
+       }
+       
+       
+       /**
+        * Return all errors in the object
+        *
+        * @return String[]
+        */ 
+       function getErrors() {
+               return (array)$this->errors;
+       }
+       
+       
+       /**
+        * Check if a certain error exists
+        *
+        * @param       String  $name   The name of the error you want
+        * @return boolean
+        */ 
+       function isError($name) {
+               return isset($this->errors[$name]);
+       }
+       
+       
+       /**
+        * Check if any errors exist
+        *
+        * @return boolean
+        */
+       function errorsExist() {
+               return (count($this->errors) > 0);
+       }
+       
+       
+}
+
+
+
+
+
+// Used by the Akismet class to communicate with the Akismet service
+class AkismetHttpClient extends AkismetObject {
+       var $akismetVersion = '1.1';
+       var $con;
+       var $host;
+       var $port;
+       var $apiKey;
+       var $blogUrl;
+       var $errors = array();
+       
+       
+       // Constructor
+       function AkismetHttpClient($host, $blogUrl, $apiKey, $port = 80) {
+               $this->host = $host;
+               $this->port = $port;
+               $this->blogUrl = $blogUrl;
+               $this->apiKey = $apiKey;
+       }
+       
+       
+       // Use the connection active in $con to get a response from the server and return that response
+       function getResponse($request, $path, $type = "post", $responseLength = 1160) {
+               $this->_connect();
+               
+               if($this->con && !$this->isError(AKISMET_SERVER_NOT_FOUND)) {
+                       $request  = 
+                                       strToUpper($type)." /{$this->akismetVersion}/$path HTTP/1.1\r\n" .
+                                       "Host: ".((!empty($this->apiKey)) ? $this->apiKey."." : null)."{$this->host}\r\n" .
+                                       "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" .
+                                       "Content-Length: ".strlen($request)."\r\n" .
+                                       "User-Agent: Akismet PHP4 Class\r\n" .
+                                       "\r\n" .
+                                       $request
+                               ;
+                       $response = "";
+
+                       @fwrite($this->con, $request);
+
+                       while(!feof($this->con)) {
+                               $response .= @fgets($this->con, $responseLength);
+                       }
+
+                       $response = explode("\r\n\r\n", $response, 2);
+                       return $response[1];
+               } else {
+                       $this->setError(AKISMET_RESPONSE_FAILED, "The response could not be retrieved.");
+               }
+               
+               $this->_disconnect();
+       }
+       
+       
+       // Connect to the Akismet server and store that connection in the instance variable $con
+       function _connect() {
+               if(!($this->con = @fsockopen($this->host, $this->port))) {
+                       $this->setError(AKISMET_SERVER_NOT_FOUND, "Could not connect to akismet server.");
+               }
+       }
+       
+       
+       // Close the connection to the Akismet server
+       function _disconnect() {
+               @fclose($this->con);
+       }
+       
+       
+}
+
+
+
+
+
+// The controlling class. This is the ONLY class the user should instantiate in
+// order to use the Akismet service!
+class Akismet extends AkismetObject {
+       var $apiPort = 80;
+       var $akismetServer = 'rest.akismet.com';
+       var $akismetVersion = '1.1';
+       var $http;
+       
+       var $ignore = array(
+                       'HTTP_COOKIE',
+                       'HTTP_X_FORWARDED_FOR',
+                       'HTTP_X_FORWARDED_HOST',
+                       'HTTP_MAX_FORWARDS',
+                       'HTTP_X_FORWARDED_SERVER',
+                       'REDIRECT_STATUS',
+                       'SERVER_PORT',
+                       'PATH',
+                       'DOCUMENT_ROOT',
+                       'SERVER_ADMIN',
+                       'QUERY_STRING',
+                       'PHP_SELF',
+                       'argv'
+               );
+       
+       var $blogUrl = "";
+       var $apiKey  = "";
+       var $comment = array();
+       
+       
+       /**
+        * Constructor
+        * 
+        * Set instance variables, connect to Akismet, and check API key
+        * 
+        * @param       String  $blogUrl        The URL to your own blog
+        * @param       String  $apiKey         Your wordpress API key
+        * @param       String[]        $comment        A formatted comment array to be examined by the Akismet service
+        * @return      Akismet
+        */
+       function Akismet($blogUrl, $apiKey, $comment = array()) {
+               $this->blogUrl = $blogUrl;
+               $this->apiKey  = $apiKey;
+               $this->setComment($comment);
+               
+               // Connect to the Akismet server and populate errors if they exist
+               $this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey);
+               if($this->http->errorsExist()) {
+                       $this->errors = array_merge($this->errors, $this->http->getErrors());
+               }
+               
+               // Check if the API key is valid
+               if(!$this->_isValidApiKey($apiKey)) {
+                       $this->setError(AKISMET_INVALID_KEY, "Your Akismet API key is not valid.");
+               }
+       }
+       
+       
+       /**
+        * Query the Akismet and determine if the comment is spam or not
+        * 
+        * @return      boolean
+        */
+       function isSpam() {
+               $response = $this->http->getResponse($this->_getQueryString(), 'comment-check');
+               
+               return ($response == "true");
+       }
+       
+       
+       /**
+        * Submit this comment as an unchecked spam to the Akismet server
+        * 
+        * @return      void
+        */
+       function submitSpam() {
+               $this->http->getResponse($this->_getQueryString(), 'submit-spam');
+       }
+       
+       
+       /**
+        * Submit a false-positive comment as "ham" to the Akismet server
+        *
+        * @return      void
+        */
+       function submitHam() {
+               $this->http->getResponse($this->_getQueryString(), 'submit-ham');
+       }
+       
+       
+       /**
+        * Manually set the comment value of the instantiated object.
+        *
+        * @param       Array   $comment
+        * @return      void
+        */
+       function setComment($comment) {
+               $this->comment = $comment;
+               if(!empty($comment)) {
+                       $this->_formatCommentArray();
+                       $this->_fillCommentValues();
+               }
+       }
+       
+       
+       /**
+        * Returns the current value of the object's comment array.
+        *
+        * @return      Array
+        */
+       function getComment() {
+               return $this->comment;
+       }
+       
+       
+       /**
+        * Check with the Akismet server to determine if the API key is valid
+        *
+        * @access      Protected
+        * @param       String  $key    The Wordpress API key passed from the constructor argument
+        * @return      boolean
+        */
+       function _isValidApiKey($key) {
+               $keyCheck = $this->http->getResponse("key=".$this->apiKey."&blog=".$this->blogUrl, 'verify-key');
+                       
+               return ($keyCheck == "valid");
+       }
+       
+       
+       /**
+        * Format the comment array in accordance to the Akismet API
+        *
+        * @access      Protected
+        * @return      void
+        */
+       function _formatCommentArray() {
+               $format = array(
+                               'type' => 'comment_type',
+                               'author' => 'comment_author',
+                               'email' => 'comment_author_email',
+                               'website' => 'comment_author_url',
+                               'body' => 'comment_content'
+                       );
+               
+               foreach($format as $short => $long) {
+                       if(isset($this->comment[$short])) {
+                               $this->comment[$long] = $this->comment[$short];
+                               unset($this->comment[$short]);
+                       }
+               }
+       }
+       
+       
+       /**
+        * Fill any values not provided by the developer with available values.
+        *
+        * @return      void
+        */
+       function _fillCommentValues() {
+               if(!isset($this->comment['user_ip'])) {
+                       $this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR');
+               }
+               if(!isset($this->comment['user_agent'])) {
+                       $this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
+               }
+               if(!isset($this->comment['referrer'])) {
+                       $this->comment['referrer'] = $_SERVER['HTTP_REFERER'];
+               }
+               if(!isset($this->comment['blog'])) {
+                       $this->comment['blog'] = $this->blogUrl;
+               }
+       }
+       
+       
+       /**
+        * Build a query string for use with HTTP requests
+        *
+        * @access      Protected
+        * @return      String
+        */
+       function _getQueryString() {
+               foreach($_SERVER as $key => $value) {
+                       if(!in_array($key, $this->ignore)) {
+                               if($key == 'REMOTE_ADDR') {
+                                       $this->comment[$key] = $this->comment['user_ip'];
+                               } else {
+                                       $this->comment[$key] = $value;
+                               }
+                       }
+               }
+
+               $query_string = '';
+
+               foreach($this->comment as $key => $data) {
+                       $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
+               }
+
+               return $query_string;
+       }
+       
+       
+}
+?>
\ No newline at end of file
index 1cf6715..143ad06 100644 (file)
@@ -33,7 +33,7 @@
 $cfg = FrameworkConfiguration::getInstance();
 
 // CFG: SERVER-PATH
-$cfg->setConfigEntry('base_path', (dirname(dirname(__FILE__)) . '/')); // DON'T MISS THE TRAILING SLASH!!!
+$cfg->setConfigEntry('base_path', (dirname(dirname(__FILE__)) . '/'));
 
 // CFG: BASE-URL
 $cfg->setConfigEntry('base_url', $cfg->detectBaseUrl());
@@ -72,19 +72,19 @@ $cfg->setConfigEntry('app_helper_class', "ApplicationHelper");
 $cfg->setConfigEntry('entry_method', "entryPoint");
 
 // CFG: TEMPLATE-BASE-PATH
-$cfg->setConfigEntry('tpl_base_path', "templates/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('tpl_base_path', "templates/");
 
 // CFG: LANGUAGE-BASE-PATH
-$cfg->setConfigEntry('lang_base_path', "inc/language/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('lang_base_path', "inc/language/");
 
 // CFG: COMPRESSOR-BASE-PATH
-$cfg->setConfigEntry('compressor_base_path', "inc/classes/main/compressor/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('compressor_base_path', "inc/classes/main/compressor/");
 
 // CFG: APPLICATION-PATH
 $cfg->setConfigEntry('application_path', $cfg->readConfig('base_path') . "application/");
 
 // CFG: COMPILE-OUTPUT-PATH
-$cfg->setConfigEntry('compile_output_path', "templates/_compiled/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('compile_output_path', "templates/_compiled/");
 
 // CFG: TEMPLATE-ENGINE
 $cfg->setConfigEntry('template_class', "WebTemplateEngine");
@@ -281,5 +281,8 @@ $cfg->setConfigEntry('db_update_primary_forced', "Y");
 // CFG: GERMAN-DATE-TIME
 $cfg->setConfigEntry('german_date_time', "%3\$s.%2\$s.%1\$s, %4\$s:%5\$s:%6\$s");
 
+// CFG: PRODUCT-INSTALL-MODE
+$cfg->setConfigEntry('product_install_mode', "debug");
+
 // [EOF]
 ?>
index 2261c0f..e320260 100644 (file)
@@ -2,8 +2,8 @@
 /**
  * A class for the configuration stuff implemented in a singleton design paddern
  *
- * NOTE: We cannot put this in inc/classes/ because it would be loaded (again)
- * in the class loader. See inc/loader/class_ClassLoader.php for instance
+ * NOTE: We cannot put this in inc/classes/ because it would be loaded (again) in
+ * class loader. See inc/loader/class_ClassLoader.php for instance
  *
  * @see                        ClassLoader
  * @author             Roland Haeder <webmaster@ship-simu.org>
index 5b3894a..a6846bf 100644 (file)
--- a/index.php
+++ b/index.php
@@ -49,12 +49,13 @@ class ApplicationEntryPoint {
        /**
         * The application's emergency exit
         *
-        * @param       $message        The optional message we shall output on exit
-        * @param       $code           Error code from exception
-        * @param       $extraData      Extra information from exceptions
+        * @param       $message                The optional message we shall output on exit
+        * @param       $code                   Error code from exception
+        * @param       $extraData              Extra information from exceptions
+        * @param       $silentMode             Wether not silent mode is turned on
         * @return      void
         */
-       public static function app_die ($message = "", $code = false, $extraData = "") {
+       public static function app_die ($message = "", $code = false, $extraData = "", $silentMode = false) {
                // Is this method already called?
                if (defined('EMERGENCY_EXIT_CALLED')) {
                        // Then output the text directly
@@ -70,6 +71,15 @@ class ApplicationEntryPoint {
                        $message = "No message provided!";
                } // END - if
 
+               // Get config instance
+               $configInstance = FrameworkConfiguration::getInstance();
+
+               // Do we have debug installation?
+               if (($configInstance->readConfig('product_install_mode') == "productive") || ($silentMode === true)) {
+                       // Abort here
+                       die();
+               } // END - if
+
                // Get some instances
                $tpl = FrameworkConfiguration::getInstance()->readConfig('template_class');
                $lang = LanguageSystem::getInstance();
@@ -85,7 +95,7 @@ class ApplicationEntryPoint {
                                // Get the template instance from our object factory
                                $templateInstance = ObjectFactory::createObjectByName($tpl, array(FrameworkConfiguration::getInstance()->readConfig('tpl_base_path'), $lang, $io));
                        } catch (FrameworkException $e) {
-                               die(sprintf("[Main:] Could not initialize template engine for reason: <strong>%s</strong>",
+                               die(sprintf("[Main:] Could not initialize template engine for reason: <span class=\"exception_reason\">%s</span>",
                                        $e->getMessage()
                                ));
                        }