]> git.mxchange.org Git - shipsimu.git/commitdiff
Intercepting filter basicly added, generic form processor implemented (unfinished...
authorRoland Häder <roland@mxchange.org>
Tue, 27 May 2008 17:25:33 +0000 (17:25 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 27 May 2008 17:25:33 +0000 (17:25 +0000)
25 files changed:
.gitattributes
application/ship-simu/class_ApplicationHelper.php
application/ship-simu/templates/de/code/register.ctp
inc/classes/interfaces/commands/class_Commandable.php
inc/classes/interfaces/filter/.htaccess [new file with mode: 0644]
inc/classes/interfaces/filter/class_Filterable.php [new file with mode: 0644]
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/commands/web/class_WebDoFormCommand.php [new file with mode: 0644]
inc/classes/main/controller/class_BaseController.php
inc/classes/main/controller/default/class_WebDefaultController.php
inc/classes/main/controller/default/class_WebDefaultNewsController.php
inc/classes/main/controller/form/.htaccess [new file with mode: 0644]
inc/classes/main/controller/form/class_WebDoFormController.php [new file with mode: 0644]
inc/classes/main/controller/registration/.htaccess [deleted file]
inc/classes/main/controller/registration/class_DefaultRegistrationController.php [deleted file]
inc/classes/main/filter/.htaccess [new file with mode: 0644]
inc/classes/main/filter/class_ [new file with mode: 0644]
inc/classes/main/filter/class_AbstractFilterDecorator.php [new file with mode: 0644]
inc/classes/main/filter/class_FilterChain.php [new file with mode: 0644]
inc/classes/main/filter/validator/.htaccess [new file with mode: 0644]
inc/classes/main/filter/validator/class_UserNameValidatorFilter.php [new file with mode: 0644]
inc/classes/main/helper/web/class_WebFormHelper.php
inc/classes/main/resolver/class_BaseResolver.php
inc/classes/main/resolver/web/class_WebCommandResolver.php
inc/classes/main/resolver/web/class_WebControllerResolver.php

index afa5c070965b9415e1661427887d35beb542b741..8c469f262b313ffdefeb6ca6272715c7b90bd876 100644 (file)
@@ -228,6 +228,8 @@ inc/classes/interfaces/debug/.htaccess -text
 inc/classes/interfaces/debug/class_Debugger.php -text
 inc/classes/interfaces/extended/.htaccess -text
 inc/classes/interfaces/extended/class_LimitableObject.php -text
+inc/classes/interfaces/filter/.htaccess -text
+inc/classes/interfaces/filter/class_Filterable.php -text
 inc/classes/interfaces/io/.htaccess -text
 inc/classes/interfaces/io/class_Streamable.php -text
 inc/classes/interfaces/io/file/.htaccess -text
@@ -255,6 +257,7 @@ inc/classes/main/commands/.htaccess -text
 inc/classes/main/commands/class_ -text
 inc/classes/main/commands/class_BaseCommand.php -text
 inc/classes/main/commands/web/.htaccess -text
+inc/classes/main/commands/web/class_WebDoFormCommand.php -text
 inc/classes/main/commands/web/class_WebHomeCommand.php -text
 inc/classes/main/commands/web/class_WebRegisterCommand.php -text
 inc/classes/main/compressor/.htaccess -text
@@ -269,8 +272,8 @@ inc/classes/main/controller/class_BaseController.php -text
 inc/classes/main/controller/default/.htaccess -text
 inc/classes/main/controller/default/class_WebDefaultController.php -text
 inc/classes/main/controller/default/class_WebDefaultNewsController.php -text
-inc/classes/main/controller/registration/.htaccess -text
-inc/classes/main/controller/registration/class_DefaultRegistrationController.php -text
+inc/classes/main/controller/form/.htaccess -text
+inc/classes/main/controller/form/class_WebDoFormController.php -text
 inc/classes/main/database/.htaccess -text
 inc/classes/main/database/class_BaseDatabaseFrontend.php -text
 inc/classes/main/database/classes/.htaccess -text
@@ -288,6 +291,12 @@ inc/classes/main/factories/objects/.htaccess -text
 inc/classes/main/factories/objects/class_ObjectFactory.php -text
 inc/classes/main/factories/web/.htaccess -text
 inc/classes/main/factories/web/class_NewsFactory.php -text
+inc/classes/main/filter/.htaccess -text
+inc/classes/main/filter/class_ -text
+inc/classes/main/filter/class_AbstractFilterDecorator.php -text
+inc/classes/main/filter/class_FilterChain.php -text
+inc/classes/main/filter/validator/.htaccess -text
+inc/classes/main/filter/validator/class_UserNameValidatorFilter.php -text
 inc/classes/main/helper/.htaccess -text
 inc/classes/main/helper/class_ -text
 inc/classes/main/helper/class_BaseHelper.php -text
index 75373862f40ca89aeb65ecd34ed0ef64a1781c05..b5ad8ee96d39e0dcffe234699570ef283f5dccfa 100644 (file)
@@ -183,11 +183,19 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
                // ... and a new response object
                $responseInstance = HttpResponse::createHttpResponse($this);
 
-               // Get default command
-               $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
+               // Get command parameter
+               $commandPara = $this->getConfigInstance()->readConfig("command_parameter");
+
+               // Get the parameter from the request
+               $commandName = $requestInstance->getRequestElement($commandPara);
+
+               // If it is null then get default command
+               if (is_null($commandName)) {
+                       $commandName = $this->getConfigInstance()->readConfig("default_command");
+               }
 
                // Get a resolver
-               $resolverInstance = WebControllerResolver::createWebControllerResolver($defaultCommand, $this);
+               $resolverInstance = WebControllerResolver::createWebControllerResolver($commandName, $this);
 
                // Get a new controller instance as well
                $controllerInstance = $resolverInstance->resolveDefaultController();
index adc4561d38e9ec4022216f3c53477ed3a5233ba0..4511dfc079d2c931874499c6bc912256bbcd3b03 100644 (file)
@@ -9,19 +9,19 @@ $helper = WebFormHelper::createWebFormHelper($this, "shipsimu_register");
 $helper->addFormGroup("login", "Bitte gebe hier gew&uuml;nschten Nickname und dein Zugangspasswort ein.");
 $helper->addFormSubGroup("username", "Dein Nickname wird erst nach Absenden des Formulares gepr&uuml;ft. Sp&auml;ter bauen wir dann einen automatischen Test ein, der dir sofort zeigt, ob der Nickname bereits vergeben ist.");
 $helper->addFieldText("username", "Nickname im Spiel:");
-$helper->addInputTextField("username", 10, 255);
+$helper->addInputTextField("username");
 $helper->addFormSubGroup("password", "Dein Passwort sollte nicht zu leicht erratbar sein. Sp&auml;ter bauen wir hier noch einen automatischen Test ein, der dir sofort die Passwortst&auml;rke anzeigt.");
 $helper->addFieldText("pass1", "Passwort:");
-$helper->addInputPasswordField("pass1", 5, 255);
+$helper->addInputPasswordField("pass1");
 $helper->addFieldText("pass2", "Passwortwiederholung:");
-$helper->addInputPasswordField("pass2", 5, 255);
+$helper->addInputPasswordField("pass2");
 
 if ($helper->ifRegisterRequiresEmailVerification()) {
        $helper->addFormGroup("email", "Bitte gebe deine Email zweimal (ein zweites Mal zur Best&auml;tigung) ein, damit wir dir deinen Freischaltlink zusenden k&ouml;nnen.");
        $helper->addFieldText("email1", "Email-Adresse:");
-       $helper->addInputTextField("email1", 15, 255);
+       $helper->addInputTextField("email1");
        $helper->addFieldText("email2", "Wiederholung Email-Adresse:");
-       $helper->addInputTextField("email2", 15, 255);
+       $helper->addInputTextField("email2");
 } // END - email verification
 
 if ($helper->ifRegisterIncludesProfile()) {
@@ -29,46 +29,46 @@ if ($helper->ifRegisterIncludesProfile()) {
        if (!$helper->ifRegisterRequiresEmailVerification()) {
                $helper->addFormSubGroup("email", "Die Angabe deiner Email-Adresse ist nur dann n&ouml;tig, wenn du auch Email-Benachrichtigungen (<span id=\"add_note\">*1</span>) haben m&ouml;chtest.");
                $helper->addFieldText("email1", "Email-Adresse:");
-               $helper->addInputTextField("email1", 15, 255);
+               $helper->addInputTextField("email1");
        } // END - No email verification
 
        // Persoenliche Daten mit in der Anmeldung abfragen?
        if ($helper->ifRegisterIncludesPersonaData()) {
                $helper->addFormSubGroup("persona", "Wenn du magst, dann vervollst&auml;ndige deine komplette Adresse mit deinem Namen.");
                $helper->addFieldText("surname", "Dein Vorname:");
-               $helper->addInputTextField("surname", 10, 255);
+               $helper->addInputTextField("surname");
                $helper->addFieldText("family", "Dein Nachname:");
-               $helper->addInputTextField("family", 10, 255);
+               $helper->addInputTextField("family");
                $helper->addFieldText("street", "Strasse und Hausnummer:");
-               $helper->addInputTextField("street", 10, 255);
+               $helper->addInputTextField("street");
                $helper->addFieldText("city", "Wohnort:");
-               $helper->addInputTextField("city", 10, 255);
+               $helper->addInputTextField("city");
        } // END - Persona data
 
        $helper->addFormSubGroup("zip", "Magst du uns auch deine Postleitzahl verraten?");
        $helper->addFieldText("zip", "Postleitzahl:");
-       $helper->addInputTextField("zip", 10, 255);
+       $helper->addInputTextField("zip");
 
        $helper->addFormSubGroup("chat", "Gebe hier deine Nicknames bzw. Nummern an:");
        if ($helper->ifChatEnabled("icq")) {
                $helper->addFieldText("icq", "ICQ-Nummer:");
-               $helper->addInputTextField("icq", 10, 15);
+               $helper->addInputTextField("icq");
        }
        if ($helper->ifChatEnabled("jabber")) {
                $helper->addFieldText("jabber", "Jabber:");
-               $helper->addInputTextField("jabber", 15, 50);
+               $helper->addInputTextField("jabber");
        }
        if ($helper->ifChatEnabled("yahoo")) {
                $helper->addFieldText("yahoo", "Yahoo!:");
-               $helper->addInputTextField("yahoo", 15, 50);
+               $helper->addInputTextField("yahoo");
        }
        if ($helper->ifChatEnabled("aol")) {
                $helper->addFieldText("aol", "AOL-Screenname:");
-               $helper->addInputTextField("aol", 15, 50);
+               $helper->addInputTextField("aol");
        }
        if ($helper->ifChatEnabled("msn")) {
                $helper->addFieldText("msn", "MSN:");
-               $helper->addInputTextField("msn", 15, 50);
+               $helper->addInputTextField("msn");
        }
 
        if (!$helper->ifRegisterRequiresEmailVerification()) {
index 4b3eaba9f8bcb5a43232a31c35a2f164dde9eec0..8b3392df8136567efab878e0a983ca277c6a1716 100644 (file)
@@ -23,7 +23,7 @@
  */
 interface Commandable extends FrameworkInterface {
        /**
-        * Executes the given command with given request and response objects
+        * Executes the command with given request and response objects
         *
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
diff --git a/inc/classes/interfaces/filter/.htaccess b/inc/classes/interfaces/filter/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/filter/class_Filterable.php b/inc/classes/interfaces/filter/class_Filterable.php
new file mode 100644 (file)
index 0000000..bc4bb30
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/**
+ * A class for pre and post filters
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Filterable extends FrameworkInterface {
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        */
+       function execute (Requestable $requestInstance, Responseable $responseInstance);
+}
+
+//
+?>
index f460986a655c35dac483daf9449a78037bf20b68..0db6d280177635b337afad2730293252e5513607 100644 (file)
@@ -905,9 +905,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        /**
         * Output a partial stub message for the caller method
         *
+        * @param       $message        An optional message to display
         * @return      void
         */
-       protected function partialStub () {
+       protected function partialStub ($message = "") {
                // Get the backtrace
                $backtrace = debug_backtrace();
 
@@ -917,16 +918,39 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        $methodName = $backtrace[1]['class']."::".$backtrace[1]['function'];
                }
 
+               // Construct the full message
+               $stubMessage = sprintf("[%s:] Partial stub!",
+                       $methodName
+               );
+
+               // Is the extra message given?
+               if (!empty($message)) {
+                       // Then add it as well
+                       $stubMessage .= sprintf(" Message: <u>%s</u>", $message);
+               }
+
                // Debug instance is there?
                if (!is_null($this->getDebugInstance())) {
                        // Output stub message
-                       $this->getDebugInstance()->output(sprintf("[%s:] Partial stub!<br />\n",
-                               $methodName
-                       ));
+                       $this->getDebugInstance()->output($stubMessage);
                } else {
                        // Trigger an error
-                       trigger_error(sprintf("[%s:] Partial stub!", $methodName));
+                       trigger_error($stubMessage."<br />\n");
+               }
+       }
+
+       /**
+        * Converts e.g. a command from URL to a valid class by keeping out bad characters
+        *
+        * @param       $str            The string, what ever it is needs to be converted
+        * @return      $className      Generated class name
+        */
+       public function convertToClassName ($str) {
+               $className = "";
+               foreach (explode("_", $str) as $strPart) {
+                       $className .= ucfirst(strtolower($strPart));
                }
+               return $className;
        }
 }
 
diff --git a/inc/classes/main/commands/web/class_WebDoFormCommand.php b/inc/classes/main/commands/web/class_WebDoFormCommand.php
new file mode 100644 (file)
index 0000000..1b41b49
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+/**
+ * A command for the "home" page
+ *
+ * @author             Roland Haeder <webmaster@mxchange.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class WebDoFormCommand extends BaseCommand implements Commandable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set special description
+               $this->setObjectDescription("Home-Command");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $resolverInstance               An instance of a command resolver class
+        * @return      $commandInstance                An instance a prepared command class
+        */
+       public final static function createWebDoFormCommand (CommandResolver $resolverInstance) {
+               // Get new instance
+               $commandInstance = new WebDoFormCommand();
+
+               // Set the application instance
+               $commandInstance->setResolverInstance($resolverInstance);
+
+               // Return the prepared instance
+               return $commandInstance;
+       }
+
+       /**
+        * Executes the given command with given request and response objects
+        *
+        * @param       $requestInstance                An instance of a class with an Requestable interface
+        * @param       $responseInstance               An instance of a class with an Responseable interface
+        * @return      void
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               die(__METHOD__.": Stub!");
+       }
+}
+
+// [EOF]
+?>
index f7aea5c307922c9a30552ed64bc1ea21d72f7790..607e042af3541c0177bf87c042d6ee5c40ba3e23 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseController extends BaseFrameworkSystem {
+       /**
+        * Instance of a CommandResolver class
+        */
+       private $resolverInstance = null;
+
+       /**
+        * Pre filter chain instance
+        */
+       private $preFilterChain = null;
+
+       /**
+        * Post filter chain instance
+        */
+       private $postFilterChain = null;
+
        /**
         * Protected constructor
         *
@@ -33,6 +48,75 @@ class BaseController extends BaseFrameworkSystem {
 
                // Clean up a little
                $this->removeNumberFormaters();
+               $this->removeSystemArray();
+
+               // Initialize both filter chains
+               $this->preFilterChain  = FilterChain::createFilterChain();
+               $this->postFilterChain = FilterChain::createFilterChain();
+       }
+
+       /**
+        * Getter for a command resolver instance
+        *
+        * @
+        * @return      $resolverInstance       An instance of a command resolver class
+        */
+       public final function getResolverInstance () {
+               return $this->resolverInstance;
+       }
+
+       /**
+        * Setter for a command resolver instance
+        *
+        * @param       $resolverInstance       An instance of a command resolver class
+        * @return      void
+        */
+       public final function setResolverInstance (CommandResolver $resolverInstance) {
+               $this->resolverInstance = $resolverInstance;
+       }
+
+       /**
+        * Adds a filter to the pre filter chain
+        *
+        * @param       $filterInstance         An instance of a filter
+        * @return      void
+        */
+       public function addPreFilter (Filterable $filterInstance) {
+               // Add the pre filter
+               $this->preFilterChain->addFilter($filterInstance);
+       }
+
+       /**
+        * Adds a filter to the post filter chain
+        *
+        * @param       $filterInstance         An instance of a filter
+        * @return      void
+        */
+       public function addPostFilter (Filterable $filterInstance) {
+               // Add the post filter
+               $this->postFilterChain->addFilter($filterInstance);
+       }
+
+       /**
+        * Executes all pre filters
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) {
+               $this->preFilterChain->processFilters($requestInstance, $responseInstance);
+       }
+
+       /**
+        * Executes all post filters
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) {
+               $this->postFilterChain->processFilters($requestInstance, $responseInstance);
        }
 }
 
index 9830891940ee7417009244ca9ca43d72b412032d..d16713e9759e1fce4923260fbdacd2e2fd799730 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class WebWebDefaultController extends BaseController implements Controller {
-       /**
-        * Instance of a CommandResolver class
-        */
-       private $resolverInstance = null;
-
        /**
         * Protected constructor
         *
@@ -41,9 +36,6 @@ class WebWebDefaultController extends BaseController implements Controller {
 
                // Create unique ID number
                $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeSystemArray();
        }
 
        /**
@@ -63,16 +55,6 @@ class WebWebDefaultController extends BaseController implements Controller {
                return $controllerInstance;
        }
 
-       /**
-        * Setter for a command resolver instance
-        *
-        * @param       $resolverInstance       An instance of a command resolver class
-        * @return      void
-        */
-       public final function setResolverInstance (CommandResolver $resolverInstance) {
-               $this->resolverInstance = $resolverInstance;
-       }
-
        /**
         * Handles the given request and response
         *
@@ -82,7 +64,7 @@ class WebWebDefaultController extends BaseController implements Controller {
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
                // Get the command instance
-               $commandInstance = $this->resolverInstance->resolvCommandByRequest($requestInstance);
+               $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
 
                // Execute the command
                $commandInstance->execute($requestInstance, $responseInstance);
index ea690a9ec85d13399fadf5d64537cdb4142f8bda..a6e2ebcad6891a21cfb39e62501c74f205c2b5c9 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class WebDefaultNewsController extends BaseController implements Controller {
-       /**
-        * Instance of a CommandResolver class
-        */
-       private $resolverInstance = null;
-
        /**
         * Protected constructor
         *
@@ -41,9 +36,6 @@ class WebDefaultNewsController extends BaseController implements Controller {
 
                // Create unique ID number
                $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeSystemArray();
        }
 
        /**
@@ -63,16 +55,6 @@ class WebDefaultNewsController extends BaseController implements Controller {
                return $controllerInstance;
        }
 
-       /**
-        * Setter for a command resolver instance
-        *
-        * @param       $resolverInstance       An instance of a command resolver class
-        * @return      void
-        */
-       public final function setResolverInstance (CommandResolver $resolverInstance) {
-               $this->resolverInstance = $resolverInstance;
-       }
-
        /**
         * Handles the given request and response
         *
@@ -82,7 +64,7 @@ class WebDefaultNewsController extends BaseController implements Controller {
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
                // Get the command instance from the resolver by sending a request instance to the resolver
-               $commandInstance = $this->resolverInstance->resolvCommandByRequest($requestInstance);
+               $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
 
                // Load the news here
                $this->loadNewsByRequest($requestInstance);
diff --git a/inc/classes/main/controller/form/.htaccess b/inc/classes/main/controller/form/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/controller/form/class_WebDoFormController.php b/inc/classes/main/controller/form/class_WebDoFormController.php
new file mode 100644 (file)
index 0000000..7e2e086
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+/**
+ * A controller for handling sent forms
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class WebDoFormController extends BaseController implements Controller {
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Controller for handling forms");
+
+               // Create unique ID number
+               $this->createUniqueID();
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $resolverInstance               An instance of a resolver class
+        * @return      $controllerInstance             A prepared instance of this class
+        */
+       public final static function createWebDoFormController (CommandResolver $resolverInstance) {
+               // Create the instance
+               $controllerInstance = new WebDoFormController();
+
+               // Set resolver instance
+               $controllerInstance->setResolverInstance($resolverInstance);
+
+               // 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) {
+               // Run all pre filters
+               $this->executePreFilters($requestInstance, $responseInstance);
+
+               // Get command instance from resolver
+               $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
+
+               // Execute the command
+               $commandInstance->execute($requestInstance, $responseInstance);
+
+               // Run all post filters
+               $this->executePostFilters($requestInstance, $responseInstance);
+
+               // Do something more here
+               die("OK");
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/controller/registration/.htaccess b/inc/classes/main/controller/registration/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/inc/classes/main/controller/registration/class_DefaultRegistrationController.php b/inc/classes/main/controller/registration/class_DefaultRegistrationController.php
deleted file mode 100644 (file)
index 24d7040..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-/**
- * A default registration controller which is suitable for most applications
- * with a registration form.
- *
- * @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 DefaultRegistrationController extends BaseController implements Controller {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set part description
-               $this->setObjectDescription("Ein Standart-Anmelde-Controller");
-
-               // Create unique ID number
-               $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeSystemArray();
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $controllerInstance             A prepared instance of this class
-        */
-       public final static function createDefaultRegistrationController () {
-               // Create the instance
-               $controllerInstance = new DefaultRegistrationController();
-
-               // 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) {
-               die(__METHOD__.": Stub!");
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/filter/.htaccess b/inc/classes/main/filter/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/filter/class_ b/inc/classes/main/filter/class_
new file mode 100644 (file)
index 0000000..b79b83d
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * 
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Filter extends BaseFrameworkSystem implements Filterable {
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("A concrete filter");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public final static function create???Filter () {
+               // Get a new instance
+               $filterInstance = new ???Filter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Implement this!
+               $this->partialStub("Please implement this method.");
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/filter/class_AbstractFilterDecorator.php b/inc/classes/main/filter/class_AbstractFilterDecorator.php
new file mode 100644 (file)
index 0000000..a9a1d4a
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+/**
+ * An abstract filter decorator for decorating filters with other filters
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+abstract class AbstractFilterDecorator extends BaseFrameworkSystem implements Filterable {
+       /**
+        * The decorated filter instance
+        */
+       private $filterInstance = null;
+
+       /**
+        * Private constructor
+        *
+        * @param       $className      Name of the real class' name
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Setter for the decorated filter instance
+        *
+        * @param       $filterInstance         An instance of a filter
+        * @return      void
+        */
+       protected final function setFilterInstance (Filterable $filterInstance) {
+               $this->filterInstance = $filterInstance;
+       }
+
+       /**
+        * Getter for the decorated filter instance
+        *
+        * @return      $filterInstance         An instance of a filter
+        */
+       protected final function getFilterInstance () {
+               return $this->filterInstance;
+       }
+
+       /**
+        * Execute the inner filter
+        *
+        * @param<->$requestInstance<-->An instance of a request class
+        * @param<->$responseInstance<->An instance of a response class
+        * @return      void
+        */
+       public final function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               $this->getFilterInstance()->execute($requestInstance, $responseInstance);
+       }
+
+
+       /**
+        * Do the execution of the filter
+        *
+        * @param<->$requestInstance<-->An instance of a request class
+        * @param<->$responseInstance<->An instance of a response class
+        * @return      void
+        */
+       abstract public function doExecute (Requestable $requestInstance, Responseable $responseInstance);
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/filter/class_FilterChain.php b/inc/classes/main/filter/class_FilterChain.php
new file mode 100644 (file)
index 0000000..a335323
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+/**
+ * A filter chain for pre and post filters
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class FilterChain extends BaseFrameworkSystem {
+       /**
+        * All filters together
+        */
+       private $filters = array();
+
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $chainInstance  An instance of this class
+        */
+       public final static function createFilterChain () {
+               // Get a new instance
+               $chainInstance = new FilterChain();
+
+               // Return the prepared instance
+               return $chainInstance;
+       }
+
+       /**
+        * Add a new filter
+        *
+        * @param       $filerInstance  An instance of a filter class
+        * @return      void
+        */
+       public final function addFilter (Filterable $filterInstance) {
+               $this->filters[] = $filterInstance;
+       }
+
+       /**
+        * Process all added filters
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       public function processFilters (Requestable $requestInstance, Responseable $responseInstance) {
+               // Run all filters
+               foreach ($this->filters as $filterInstance) {
+                       // Execute this filter
+                       //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing started.<br />\n";
+                               $filterInstance->execute($requestInstance, $responseInstance);
+                       //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing ended.<br />\n";
+               }
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/filter/validator/.htaccess b/inc/classes/main/filter/validator/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php
new file mode 100644 (file)
index 0000000..efc3fec
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+/**
+ * A concrete filter for validating the username. This filter may intercept the
+ * filter chain if no username is given or if the supplied username has an
+ * invalid form. It could also intercept the filter chain if the username is
+ * already taken.
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class UserNameValidatorFilter extends BaseFrameworkSystem implements Filterable {
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("A filter for username validation");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public final static function createUserNameValidatorFilter () {
+               // Get a new instance
+               $filterInstance = new UserNameValidatorFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Implement this!
+               $this->partialStub("Please implement this method.");
+       }
+}
+
+// [EOF]
+?>
index 41ad0fd33a7c8075c7e7e0d4c44660410b03b826..0c761d8fc7f27a4bd76c6d7934ae8b1aa0ab2d60 100644 (file)
@@ -161,13 +161,11 @@ class WebFormHelper extends BaseHelper {
         * opened. The field's name will be set as id.
         *
         * @param       $fieldName                      Input field name
-        * @param       $fieldSize                      Input size
-        * @param       $fieldMaxLength         Input max length
         * @param       $fieldValue                     Input default value (default: empty)
         * @return      void
         * @throws      FormClosedException             If the form is not yet opened
         */
-       public function addInputTextField ($fieldName, $fieldSize, $fieldMaxLength, $fieldValue = "") {
+       public function addInputTextField ($fieldName, $fieldValue = "") {
                // Is the form opened?
                if ($this->formOpened === false) {
                        // Throw an exception
@@ -175,8 +173,11 @@ class WebFormHelper extends BaseHelper {
                }
 
                // Generate the content
-               $inputContent = sprintf("<input type=\"text\" class=\"textfield\" id=\"%s\" name=\"%s\" size=\"%d\" maxlength=\"%d\" value=\"%s\" />",
-                       $fieldName, $fieldName, $fieldSize, $fieldMaxLength, $fieldValue);
+               $inputContent = sprintf("<input type=\"text\" class=\"textfield\" id=\"%s\" name=\"%s\" value=\"%s\" />",
+                       $fieldName,
+                       $fieldName,
+                       $fieldValue
+               );
 
                // And add it maybe with a "li" tag
                $this->addContent($inputContent);
@@ -187,13 +188,11 @@ class WebFormHelper extends BaseHelper {
         * yet opened. The field's name will be set as id.
         *
         * @param       $fieldName                      Input field name
-        * @param       $fieldSize                      Input size
-        * @param       $fieldMaxLength         Input max length
         * @param       $fieldValue                     Input default value (default: empty)
         * @return      void
         * @throws      FormClosedException             If the form is not yet opened
         */
-       public function addInputPasswordField ($fieldName, $fieldSize, $fieldMaxLength, $fieldValue = "") {
+       public function addInputPasswordField ($fieldName, $fieldValue = "") {
                // Is the form opened?
                if ($this->formOpened === false) {
                        // Throw an exception
@@ -201,8 +200,11 @@ class WebFormHelper extends BaseHelper {
                }
 
                // Generate the content
-               $inputContent = sprintf("<input type=\"password\" class=\"password\" id=\"%s\" name=\"%s\" size=\"%d\" maxlength=\"%d\" value=\"%s\" />",
-                       $fieldName, $fieldName, $fieldSize, $fieldMaxLength, $fieldValue);
+               $inputContent = sprintf("<input type=\"password\" class=\"password\" id=\"%s\" name=\"%s\" value=\"%s\" />",
+                       $fieldName,
+                       $fieldName,
+                       $fieldValue
+               );
 
                // And add it
                $this->addContent($inputContent);
index d947d89e318df1e89495e419d8d9f3fa06088edb..91f5c3d522b625a1fbdaf6a10316fc2a4c9b7ec7 100644 (file)
@@ -94,7 +94,7 @@ class BaseResolver extends BaseFrameworkSystem {
                // Now, let us create the full name of the command class
                $class = sprintf("%s%sCommand",
                        $this->commandPrefix,
-                       ucfirst(strtolower($commandName))
+                       $this->convertToClassName($commandName)
                );
 
                // Is this class already loaded?
@@ -103,6 +103,13 @@ class BaseResolver extends BaseFrameworkSystem {
                        $isValid = true;
                }
 
+               // Debug output
+               //echo "<strong>----- ".__METHOD__." -----</strong><br />\n";
+               //print($class."<pre>");
+               //debug_print_backtrace();
+               //var_dump($isValid);
+               //print("</pre>");
+
                // Set command name
                $this->setCommandName($commandName);
 
index 2ab4e50035275e81cff71b98f26c6673a72d4dad..05bcd6509023136521c163ec8cf0310a3276549a 100644 (file)
@@ -53,23 +53,23 @@ class WebCommandResolver extends BaseResolver implements CommandResolver {
        /**
         * Creates an instance of a Web command resolver with a given default command
         *
-        * @param       $defaultCommand                         The default command we shall execute
+        * @param       $commandName                            The default command we shall execute
         * @param       $appInstance                            An instance of a manageable application helper class
         * @return      $resolverInstance                       The prepared command resolver instance
         * @throws      EmptyVariableException          Thrown if the default command is not set
         * @throws      InvalidCommandException         Thrown if the default command is invalid
         */
-       public final static function createWebCommandResolver ($defaultCommand, ManageableApplication $appInstance) {
+       public final static function createWebCommandResolver ($commandName, ManageableApplication $appInstance) {
                // Create the new instance
                $resolverInstance = new WebCommandResolver();
 
-               // Is the variable $defaultCommand set and the command is valid?
-               if (empty($defaultCommand)) {
+               // Is the variable $commandName set and the command is valid?
+               if (empty($commandName)) {
                        // Then thrown an exception here
                        throw new EmptyVariableException(array($resolverInstance, 'defaultCommand'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!$resolverInstance->isCommandValid($defaultCommand)) {
+               } elseif (!$resolverInstance->isCommandValid($commandName)) {
                        // Invalid command found
-                       throw new InvalidCommandException(array($resolverInstance, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
+                       throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
                }
 
                // Set the application instance
@@ -145,7 +145,7 @@ class WebCommandResolver extends BaseResolver implements CommandResolver {
 
                // Create command class name
                $class = sprintf("Web%sCommand",
-                       ucfirst(strtolower($commandName))
+                       $this->convertToClassName($commandName)
                );
 
                // Is this class loaded?
index 16ad0c2c40dbbbcbfa2e7a46eeb7b352cbd6a97b..06d0bcfe57cdefdf7f0ddb2b61f38c3d9323175a 100644 (file)
  */
 class WebControllerResolver extends BaseResolver implements ControllerResolver {
        /**
-        * Last successfull resolved controller
+        * Last successfull resolved controller (name)
         */
        private $lastControllerName = "";
 
+       /**
+        * Last successfull resolved controller (instance)
+        */
+       private $lastControllerInstance = null;
+
        /**
         * Protected constructor
         *
@@ -114,8 +119,8 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
                                throw new InvalidControllerInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_CONTROLLER);
                        }
 
-                       // Set last command
-                       $this->lastCommandInstance = $controllerInstance;
+                       // Set last controller
+                       $this->lastControllerInstance = $controllerInstance;
                } catch (MissingArrayElementsException $e) {
                        // Just catch it here...
                }
@@ -133,6 +138,12 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
         *                                                                              controller class is missing (bad!)
         */
        private function loadController ($commandName) {
+                // Debug message
+                //print("<strong>----- ".__METHOD__." -----</strong><pre>");
+                //debug_print_backtrace();
+                //print("</pre>");
+                //
+
                // Cache default command
                $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
 
@@ -146,11 +157,14 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
                if ($commandName != $defaultCommand) {
                        // Create controller class name
                        $class = sprintf("Web%sController",
-                               ucfirst(strtolower($commandName))
+                               $this->convertToClassName($commandName)
                        );
                } elseif ($this->getConfigInstance()->readConfig("home_with_news") == "Y") {
                        // Yes, display news in home then set default controller with news
                        $class = "WebDefaultNewsController";
+               } else {
+                       // No nes at "home" page
+                       $class = "WebDefaultController";
                }
 
                // Is this class loaded?