inc/classes/interfaces/io/output/class_OutputStreamer.php -text
inc/classes/interfaces/language/.htaccess -text
inc/classes/interfaces/language/class_ManageableLanguage.php -text
+inc/classes/interfaces/registry/.htaccess -text
+inc/classes/interfaces/registry/class_Register.php -text
+inc/classes/interfaces/registry/class_Registerable.php -text
inc/classes/interfaces/request/.htaccess -text
inc/classes/interfaces/request/class_Requestable.php -text
inc/classes/interfaces/resolver/.htaccess -text
$controllerInstance = $resolverInstance->getControllerInstance();
// @TODO Add some more pre/post filters to the controller
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_validator'));
$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_validator'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_validator'));
// Return the prepared instance
return $commandInstance;
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for registries
+ *
+ * @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 Register extends FrameworkInterface {
+ /**
+ * Checks wether an instance key was found
+ *
+ * @param $instanceKey The key holding an instance in the registry
+ * @return $exists Wether the key exists in the registry
+ */
+ function instanceExists ($instanceKey);
+}
+
+//
+?>
--- /dev/null
+<?php
+/**
+ * A class for registerable classes
+ *
+ * @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 Registerable extends FrameworkInterface {
+}
+
+//
+?>
} elseif (is_string($arg)) {
// String
$argsString .= "\"".$arg."\"(string)";
+ } elseif (is_null($arg)) {
+ // Null
+ $argsString .= "(null)";
} else {
// Unknown type (please report!)
$argsString .= $arg."(unknown!)";
* Formats computer generated price values into human-understandable formats
* with thousand and decimal seperators.
*
- * @param $value The in computer format value for a price
- * @param $currency The currency symbol (use HTML-valid characters!)
- * @param $decNum Number of decimals after commata
- * @return $price The for the current language formated price string
+ * @param $value The in computer format value for a price
+ * @param $currency The currency symbol (use HTML-valid characters!)
+ * @param $decNum Number of decimals after commata
+ * @return $price The for the current language formated price string
* @throws MissingDecimalsThousandsSeperatorException If decimals or
* thousands seperator
* is missing
// Default is already taken
$alreadyTaken = true;
+ // Initialize instance
+ $userInstance = null;
+
// Get a registry instance
$registry = Registry::getInstance();
// Is the user already there?
- if ($registry->keyExists('userInstance')) {
+ if ($registry->instanceExists('user')) {
// Use the instance for checking for the email
- $userInstance = $registry->getInstance('userInstance');
+ $userInstance = $registry->getInstance('user');
$userInstance->setEmailAddress($email);
} else {
// If this instance is created then the username *does* exist
- $userInstance = User::createUserByEmail($userName);
+ $userInstance = User::createUserByEmail($email);
// Remember this user instance in our registry for later usage
- $registry->addInstance('userInstance', $userInstance);
+ $registry->addInstance('user', $userInstance);
}
// Does the email exist?
// Default is already taken
$alreadyTaken = true;
+ // Initialize instance
+ $userInstance = null;
+
// Get a registry instance
$registry = Registry::getInstance();
$userInstance = $registry->getInstance('user');
} else {
// If this instance is created then the username *does* exist
- $userInstance = User::createUserByUsername($userName);
-
- // Remember this user instance in our registry for later usage
- $registry->addInstance('user', $userInstance);
+ try {
+ $userInstance = User::createUserByUsername($userName);
+
+ // Remember this user instance in our registry for later usage
+ $registry->addInstance('user', $userInstance);
+ } catch (UsernameMissingException $e) {
+ // User was not found
+ }
}
// Does the username exist?
- if (!$userInstance->ifUsernameExists()) {
+ if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) {
// This username is still available
$alreadyTaken = false;
}
* 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 Registry extends BaseFrameworkSystem {
+class Registry extends BaseFrameworkSystem implements Register {
/**
* Instance of this class
*/
private static $selfInstance = null;
+ /**
+ * Instance registry
+ */
+ private $instanceRegistry = array();
+
/**
* Protected constructor
*
// Return the instance
return self::$selfInstance;
}
+
+ /**
+ * Checks wether an instance key was found
+ *
+ * @param $instanceKey The key holding an instance in the registry
+ * @return $exists Wether the key exists in the registry
+ */
+ public function instanceExists ($instanceKey) {
+ // Does this key exists?
+ $exists = (isset($this->instanceRegistry[$instanceKey]));
+
+ // Return the result
+ return $exists;
+ }
+
+ /**
+ * Adds/overwrites a new instance to the registry at the given key
+ *
+ * @param $instanceKey The key to identify the instance
+ * @param $objectInstance An instance we shall store
+ * @return void
+ */
+ public function addInstance ($instanceKey, Registerable $objectInstance) {
+ $this->instanceRegistry[$instanceKey] = $objectInstance;
+ }
}
// [EOF]
* 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 User extends BaseFrameworkSystem implements ManageableUser {
+class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
/**
- * Username
+ * Username of current user
*/
- private $username = "";
+ private $userName = "";
+
+ /**
+ * Email of current user
+ */
+ private $email = "";
// Exceptions
const EXCEPTION_USERNAME_NOT_FOUND = 0xd00;
* factory method will check if the username is already taken and if not
* so it will throw an exception.
*
- * @param $username Username we need a class instance for
+ * @param $userName Username we need a class instance for
* @return $userInstance An instance of this user class
* @throws UsernameMissingException If the username does not exist
*/
return $userInstance;
}
+ /**
+ * Creates an instance of this user class by a provided email address. This
+ * factory method will not check if the email address is there.
+ *
+ * @param $email Email address of the user
+ * @return $userInstance An instance of this user class
+ */
+ public final static function createUserByEmail ($email) {
+ // Get a new instance
+ $userInstance = new User();
+
+ // Set the username
+ $userInstance->setEmail($email);
+
+ // Return the instance
+ return $userInstance;
+ }
+
/**
* Setter for username
*
* @return void
*/
protected final function setUsername ($userName) {
- $this->userNane = $userName;
+ $this->UserName = $userName;
+ }
+
+ /**
+ * Setter for email
+ *
+ * @param $email The email to set
+ * @return void
+ */
+ protected final function setEmail ($email) {
+ $this->userName = $email;
}
/**
* @return $userName The username to get
*/
public final function getUsername () {
- return $this->userNane;
+ return $this->userName;
+ }
+
+ /**
+ * Getter for email
+ *
+ * @return $email The email to get
+ */
+ public final function getEmail () {
+ return $this->email;
}
/**