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
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
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
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
// ... 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();
$helper->addFormGroup("login", "Bitte gebe hier gewünschten Nickname und dein Zugangspasswort ein.");
$helper->addFormSubGroup("username", "Dein Nickname wird erst nach Absenden des Formulares geprüft. Spä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äter bauen wir hier noch einen automatischen Test ein, der dir sofort die Passwortstä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ätigung) ein, damit wir dir deinen Freischaltlink zusenden kö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()) {
if (!$helper->ifRegisterRequiresEmailVerification()) {
$helper->addFormSubGroup("email", "Die Angabe deiner Email-Adresse ist nur dann nötig, wenn du auch Email-Benachrichtigungen (<span id=\"add_note\">*1</span>) haben mö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ä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()) {
*/
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
--- /dev/null
+Deny from all
--- /dev/null
+<?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);
+}
+
+//
+?>
/**
* 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();
$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;
}
}
--- /dev/null
+<?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]
+?>
* 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
*
// 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);
}
}
* 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
*
// Create unique ID number
$this->createUniqueID();
-
- // Clean up a little
- $this->removeSystemArray();
}
/**
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
*
*/
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);
* 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
*
// Create unique ID number
$this->createUniqueID();
-
- // Clean up a little
- $this->removeSystemArray();
}
/**
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
*
*/
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);
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?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]
-?>
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
* 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
}
// 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);
* 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
}
// 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);
// 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?
$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);
/**
* 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
// Create command class name
$class = sprintf("Web%sCommand",
- ucfirst(strtolower($commandName))
+ $this->convertToClassName($commandName)
);
// Is this class loaded?
*/
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
*
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...
}
* 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");
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?