]> git.mxchange.org Git - shipsimu.git/commitdiff
eval() commands replace by improved object factory, user login class stub added
authorRoland Häder <roland@mxchange.org>
Mon, 9 Jun 2008 18:14:14 +0000 (18:14 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 9 Jun 2008 18:14:14 +0000 (18:14 +0000)
28 files changed:
.gitattributes
application/selector/init.php
application/ship-simu/config.php
application/ship-simu/init.php
application/ship-simu/loader.php
application/ship-simu/main/class_
application/ship-simu/main/class_WorksContract.php
application/ship-simu/main/login/.htaccess [new file with mode: 0644]
application/ship-simu/main/login/class_ShipSimuUserLogin.php [new file with mode: 0644]
application/ship-simu/main/registration/class_ShipSimuRegistration.php
application/ship-simu/main/ships/class_BaseShip.php
inc/classes/interfaces/login/.htaccess [new file with mode: 0644]
inc/classes/interfaces/login/class_LoginableUser.php [new file with mode: 0644]
inc/classes/main/actions/class_
inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php [new file with mode: 0644]
inc/classes/main/class_
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/commands/class_
inc/classes/main/controller/class_
inc/classes/main/database/class_
inc/classes/main/extended/class_SerializationContainer.php
inc/classes/main/factories/objects/class_ObjectFactory.php
inc/classes/main/filter/class_
inc/classes/main/resolver/web/class_WebCommandResolver.php
inc/classes/main/resolver/web/class_WebControllerResolver.php
inc/classes/middleware/compressor/class_CompressorChannel.php
inc/classes/middleware/debug/class_DebugMiddleware.php
inc/config.php

index 64cbe6fae15fda70da1a42d9d850070a7c3fbe59..4435563c5dab3a6a54cae75dc1c65921b959a583 100644 (file)
@@ -82,6 +82,8 @@ application/ship-simu/main/drives/motor/.htaccess -text
 application/ship-simu/main/drives/motor/class_Motor.php -text
 application/ship-simu/main/factories/.htaccess -text
 application/ship-simu/main/factories/class_ShipSimuWebNewsFactory.php -text
+application/ship-simu/main/login/.htaccess -text
+application/ship-simu/main/login/class_ShipSimuUserLogin.php -text
 application/ship-simu/main/parts/.htaccess -text
 application/ship-simu/main/parts/class_BaseShipPart.php -text
 application/ship-simu/main/parts/maschineroom/.htaccess -text
@@ -260,6 +262,8 @@ inc/classes/interfaces/io/output/.htaccess -text
 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/login/.htaccess -text
+inc/classes/interfaces/login/class_LoginableUser.php -text
 inc/classes/interfaces/registration/.htaccess -text
 inc/classes/interfaces/registration/class_UserRegister.php -text
 inc/classes/interfaces/registry/.htaccess -text
@@ -282,6 +286,7 @@ inc/classes/main/actions/.htaccess -text
 inc/classes/main/actions/class_ -text
 inc/classes/main/actions/class_BaseAction.php -text
 inc/classes/main/actions/post_registration/.htaccess -text
+inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php -text
 inc/classes/main/cache/.htaccess -text
 inc/classes/main/cache/class_MemoryCache.php -text
 inc/classes/main/class_ -text
index 6a02f976ea3745f1ce80624da46a94423be1dc5c..ed31055300d03a539260f0a8b13dc75616429a5d 100644 (file)
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-//
-//
-// Get an instance of the initializer
-$eval = sprintf("\$app = %s::getInstance();",
+
+// Generate call-back function
+$callback = sprintf("%s::getInstance",
        FrameworkConfiguration::getInstance()->readConfig('app_helper_class')
 );
-eval($eval);
+
+// Get an instance of the helper
+$app = call_user_func_array($callback, array());
 
 // Set application name and version
 $app->setAppName("Applikationsausw&auml;hler");
index 1b3b1a2254565527c494ee8abd2a6f5f2a815424..2d5cd1f45ee3ea2aba4cb46adedbb618ec10b3fa 100644 (file)
@@ -73,6 +73,9 @@ $cfg->setConfigEntry('command_parameter', "page");
 // CFG: USER-REGISTRATION
 $cfg->setConfigEntry('user_registration', "ShipSimuRegistration");
 
+// CFG: LOGIN-USER
+$cfg->setConfigEntry('login_user', "ShipSimuUserLogin");
+
 // CFG: USER-STATUS-REGISTER
 $cfg->setConfigEntry('user_status_register', "UNCONFIRMED");
 
index ffc577c22f0f5a0b546e55d7192c1f7e607738d8..431e4420d37ef526e2f2966178ca76d1b2a25da0 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-// Get an instance of the helper
-$eval = sprintf("\$app = %s::getInstance();",
+// Generate call-back function
+$callback = sprintf("%s::getInstance",
        FrameworkConfiguration::getInstance()->readConfig('app_helper_class')
 );
-eval($eval);
+
+// Get an instance of the helper
+$app = call_user_func_array($callback, array());
 
 // Set application name and version
 $app->setAppName("Ship-Simu Schiffsimulator");
index 35ecc298e4edf41828120a0f3ad11faa9ac97f39..240c01aec9344f478869b108de57018de6281ec1 100644 (file)
@@ -34,25 +34,25 @@ foreach ($lowerClasses as $class) {
        try {
                ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/%s", FrameworkConfiguration::getInstance()->readConfig('application_path'), $application, $class));
        } catch (PathIsNoDirectoryException $e) {
-               ApplicationEntryPoint::app_die(sprintf("[Main:%s] Kann Applikationsklassen im Pfad <strong>%s</strong> nicht laden. Grund: <strong>%s</strong>",
+               ApplicationEntryPoint::app_die(sprintf("[Main:%s] Cannot find application classes in path <u>%s</u> for this reason: <u>%s</u>",
                        $application,
                        $class,
                        $e->getMessage()
                ));
        } catch (PathIsEmptyException $e) {
-               ApplicationEntryPoint::app_die(sprintf("[Main:%s] Kann Applikationsklassen im Pfad <strong>%s</strong> nicht laden. Grund: <strong>%s</strong>",
+               ApplicationEntryPoint::app_die(sprintf("[Main:%s] Cannot find application classes in path <u>%s</u> for this reason: <u>%s</u>",
                        $application,
                        $class,
                        $e->getMessage()
                ));
        } catch (PathReadProtectedException $e) {
-               ApplicationEntryPoint::app_die(sprintf("[Main:%s] Kann Applikationsklassen im Pfad <strong>%s</strong> nicht laden. Grund: <strong>%s</strong>",
+               ApplicationEntryPoint::app_die(sprintf("[Main:%s] Cannot find application classes in path <u>%s</u> for this reason: <u>%s</u>",
                        $application,
                        $class,
                        $e->getMessage()
                ));
        } catch (DirPointerNotOpenedException $e) {
-               ApplicationEntryPoint::app_die(sprintf("[Main:%s] Kann Applikationsklassen im Pfad <strong>%s</strong> nicht laden. Grund: <strong>%s</strong>",
+               ApplicationEntryPoint::app_die(sprintf("[Main:%s] Cannot find application classes in path <u>%s</u> for this reason: <u>%s</u>",
                        $application,
                        $class,
                        $e->getMessage()
index d8eb3efc4b68b6d10fe8b76a65da8681e08498f5..762357225d8dd4fc18390e6eaa5b5a9dc791e633 100644 (file)
@@ -35,7 +35,7 @@ class  extends BaseFrameworkSystem {
                $this->setObjectDescription("");
 
                // Create unique ID number
-               $this->createUniqueID();
+               $this->generateUniqueId();
 
                // Clean up a little
                $this->removeNumberFormaters();
index d1cf574b85bc5af4df68b03623365c3da0d89a89..ebed5120a6bd20422328f0dc9b01431bc08602b0 100644 (file)
@@ -61,18 +61,6 @@ class WorksContract extends BaseFrameworkSystem implements SignableContract {
                $shipType = (string) $shipType;
                $shipName = (string) $shipName;
 
-               // Is the other one a contract partner?
-               if (is_null($partnerInstance)) {
-                       // Opps! Empty partner instance?
-                       throw new NullPointerException($partnerInstance, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($partnerInstance)) {
-                       // Not an object! ;-(
-                       throw new NoObjectException($partnerInstance, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($partnerInstance, 'isContractPartner')) {
-                       // Does not have the required feature (method)
-                       throw new MissingMethodException(array($partnerInstance, 'isContractPartner'), self::EXCEPTION_MISSING_METHOD);
-               }
-
                // Get new instance
                $contractInstance = new WorksContract();
 
@@ -95,21 +83,11 @@ class WorksContract extends BaseFrameworkSystem implements SignableContract {
                }
 
                // Schiff-Instanz temporaer erzeugen und in den Bauvertrag einfuegen
-               $eval = sprintf("\$contractInstance->setShipInstance(%s::create%s(\"%s\"));",
-                       $shipType,
-                       $shipType,
-                       $shipName
-               );
-
-               // Debug message
-               if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) $contractInstance->getDebugInstance()->output(sprintf("[%s:%d] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
-                       __CLASS__,
-                       __LINE__,
-                       htmlentities($eval)
-               ));
+               $shipInstance = ObjectFactory::createObjectByName($shipType, array($shipName));
+               $contractInstance->setShipInstance($shipInstance);
 
-               // Execute constructed command
-               @eval($eval);
+               // Remove the ship instance
+               unset($shipInstance);
 
                // Set itself as contract partner
                $contractInstance->setContractPartner($partnerInstance);
@@ -172,71 +150,28 @@ class WorksContract extends BaseFrameworkSystem implements SignableContract {
                ));
 
                // Initialize the instance (shall not be done within dynamic part)
-               $instance = null;
-
-               // Prepare the big command for everthing
-               $eval = "try {
-       \$instance = ".$shipPart."::create".$shipPart."(";
-               foreach ($dataArray as $pIdx => $parts) {
-                       if (is_string($parts)) {
-                               // String einbauen
-                               $eval .= "\"".$parts."\", ";
-                       } elseif (is_array($parts)) {
-                               // Ist ein weiteres Array!
-                               $eval .= "array(";
-                               foreach ($parts as $idx2 => $sub) {
-                                       $eval .= "'".$idx2."' => ";
-                                       if (is_string($sub)) {
-                                               // Ist erneut ein String
-                                               $eval .= "\"".$sub."\"";
-                                       } elseif (is_array($sub)) {
-                                               // Wird nicht mehr unterstuetzt!
-                                               ApplicationEntryPoint::app_die("No more arrays!");
-                                       } else {
-                                               // Direkt anhaengen
-                                               $eval .= $sub;
-                                       }
-                                       $eval .= ", ";
-                               }
-
-                               // Letztes Komma entfernen
-                               $eval = substr($eval, 0, -2);
-                               $eval .= "), ";
-                       } else {
-                               // Etwas anderes direkt!
-                               $eval .= $parts.", ";
-                       }
-               }
+               $partInstance = null;
 
-               // Letztes Komma abhaengen
-               $eval = substr($eval, 0, -2);
-               $eval .= ");
-} catch (DimNotFoundInArrayException \$e) {
-       \$this->getDebugInstance()->output(sprintf(\"[main:] Die <strong>%s</strong> konnte nicht vervollst&auml;ndigt werden. Grund: <strong>%s</strong><br />\\n\",
-               \$this->getShipInstance()->getShipName(),
-               \$e->getMessage()
-       ));
-       \$instance = null;
-}";
-
-               // Debug message
-               if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[Ship:] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
-                       htmlentities($eval)
-               ));
-
-               // Code ausfuhren
-               @eval($eval);
-
-               // Try to add the ship part to the contract
+               // Try to get an instance for this ship part
                try {
+                       $partInstance = ObjectFactory::createObjectByName($shipPart, $dataArray);
+               } catch (DimNotFoundInArrayException $e) {
+                       $this->getDebugInstance()->output(sprintf("[main:] Die <strong>%s</strong> konnte nicht vervollst&auml;ndigt werden. Grund: <strong>%s</strong><br />",
+                               $this->getShipInstance()->getShipName(),
+                               $e->getMessage()
+                       ));
+
+                       // Debug message
                        if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Versuche ein Schiffsteil in den Bauvertrag aufzunehmen.<br />\n",
                                __CLASS__,
                                __LINE__
                        ));
-                       if (!$instance instanceof ConstructableShipPart) {
+
+                       // Is this ship part constructable?
+                       if (!$partInstance instanceof ConstructableShipPart) {
                                // Ship part not constructable!
                                throw new ShipPartNotConstructableException(array($shipPart), self::EXCEPTION_NOT_CONSTRUCTABLE);
-                       } elseif (!$this->getShipInstance()->createShipPart($instance, $parentPart)) {
+                       } elseif (!$this->getShipInstance()->createShipPart($partInstance, $parentPart)) {
                                // Schiff konnte nicht gebaut werden!
                                throw new ShipNotConstructedException(sprintf("Das Schiff <strong>%s</strong> konnte wegen eines Fehlers nicht gebaut werden. Siehe obere Meldungen.",
                                        $this->getShipInstance()->getShipName()
@@ -248,24 +183,24 @@ class WorksContract extends BaseFrameworkSystem implements SignableContract {
                }
 
                // Get price for this item
-               $price = $this->getMerchantInstance()->getPriceFromList($instance);
+               $price = $this->getMerchantInstance()->getPriceFromList($partInstance);
 
                // Final debug message
                if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%s</strong> kostet <strong>%s</strong>.<br />\n",
                        __CLASS__,
                        __LINE__,
-                       $instance->getObjectDescription(),
+                       $partInstance->getObjectDescription(),
                        $this->getMerchantInstance()->formatCurrency($price)
                ));
 
                // Add price
-               $instance->setPrice($price);
+               $partInstance->setPrice($price);
 
                // Final debug message
                if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] <strong>%s</strong> wurde in den Bauvertrag aufgenommen.<br />\n",
                        __CLASS__,
                        __LINE__,
-                       $instance->getObjectDescription()
+                       $partInstance->getObjectDescription()
                ));
        }
 
diff --git a/application/ship-simu/main/login/.htaccess b/application/ship-simu/main/login/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/ship-simu/main/login/class_ShipSimuUserLogin.php b/application/ship-simu/main/login/class_ShipSimuUserLogin.php
new file mode 100644 (file)
index 0000000..2ffc777
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * A special login class for Ship-Simu
+ *
+ * @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 ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Login for Ship-Simu");
+
+               // Create unique ID number
+               $this->generateUniqueId();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Creates an instance of this login class
+        *
+        * @return      $loginInstance  An instance of this login class
+        */
+       public final static function createShipSimuUserLogin () {
+               // Get a new instance
+               $loginInstance = new ShipSimuUserLogin();
+
+               // Return the instance
+               return $loginInstance;
+       }
+
+       /**
+        * Logins the user with the given request containing the credential. The
+        * result of the login can be thrown by exception or, if prefered stored
+        * in a boolean attribute which is then readable by a matching getter.
+        *
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return      void
+        */
+       public function doLogin (Requestable $requestInstance) {
+               $this->partialStub();
+       }
+}
+
+// [EOF]
+?>
index 01235f7e60558402c0fc87fdcdabb3d5f96730b8..0a8563cd10c5754e8cb3536e65264e0a0e898e73 100644 (file)
@@ -142,7 +142,11 @@ class ShipSimuRegistration extends BaseRegistration {
         * @return      void
         */
        public function doPostAction () {
-               $this->partialStub();
+               // Get an action instance from our factory
+               $actionInstance = ObjectFactory::createObjectByConfiguredName('post_registration_action');
+
+               // Execute the action
+               $actionInstance->execute($this->getRequestInstance(), $this->getResponseInstance());
        }
 
        /**
index 77426cc5d0c66ee2436ff955eee48f005d546745..7ccfaff7cd2e0d8f6b4589f071ad3cf1e0252f23 100644 (file)
@@ -71,20 +71,8 @@ class BaseShip extends BaseSimulator {
 
                // Ist die gewuenschte Klasse vorhanden?
                if (class_exists($partClass)) {
-                       // Befehl zusammenbauen
-                       $eval = sprintf("\$partInstance = %s::create%s();",
-                               $partClass, $partClass
-                       );
-
-                       // Debug-Meldung ausgeben
-                       if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
-                               __CLASS__,
-                               __LINE__,
-                               htmlentities($eval)
-                       ));
-
-                       // ... und ausfuehren
-                       eval($eval);
+                       // Get an instance back from our object factory
+                       $partInstance = ObjectFactory::createObjectByName($partClass);
                } else {
                        // Nicht vorhanden, dann Ausnahme werfen!
                        throw new ClassNotFoundException($partClass, self::EXCEPTION_CLASS_NOT_FOUND);
diff --git a/inc/classes/interfaces/login/.htaccess b/inc/classes/interfaces/login/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/login/class_LoginableUser.php b/inc/classes/interfaces/login/class_LoginableUser.php
new file mode 100644 (file)
index 0000000..c7abf2d
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+/**
+ * An interface for user login 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 LoginableUser extends FrameworkInterface {
+       /**
+        * Logins the user with the given request containing the credential. The
+        * result of the login can be thrown by exception or, if prefered stored
+        * in a boolean attribute which is then readable by a matching getter.
+        *
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return      void
+        */
+       function doLogin (Requestable $requestInstance);
+}
+
+//
+?>
index 797b770ad676ca5e99c96a6c9d24887c0015a954..93d4fc52178bc575a3d7bea2eb8948605171e472 100644 (file)
@@ -3,10 +3,10 @@
  * 
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.3.0
+ * @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.mxchange.org
+ * @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
@@ -35,7 +35,7 @@ class ???Action extends BaseAction implements Commandable {
                $this->setObjectDescription("");
 
                // Generate unique key
-               $this->createUniqueID();
+               $this->generateUniqueId();
        }
 
        /**
diff --git a/inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php b/inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php
new file mode 100644 (file)
index 0000000..aae33eb
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+/**
+ * A post registration action to login after the registration is done
+ *
+ * @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 LoginAfterRegistrationAction extends BaseAction implements Commandable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set description
+               $this->setObjectDescription("Post registration action for logging in");
+
+               // Generate unique key
+               $this->generateUniqueId();
+       }
+
+       /**
+        * Creates an instance of this action
+        *
+        * @return      $actionInstance         An instance of this action class
+        */
+       public final static function createLoginAfterRegistrationAction () {
+               // Get a new instance
+               $actionInstance = new LoginAfterRegistrationAction();
+
+               // Return the instance
+               return $actionInstance;
+       }
+
+       /**
+        * 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
+        * @return      void
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get a login class from factory
+               $loginInstance = ObjectFactory::createObjectByConfiguredName('login_user');
+
+               // Login the user by the request instance
+               $loginInstance->doLogin($requestInstance);
+
+               // Was the login fine? Then redirect here
+               if ($loginInstance->ifLoginWasSuccessfull()) {
+                       // Try to redirect here
+                       try {
+                               $responseInstance->redirectConfiguredUrl('app_login');
+                       } catch (FrameworkException $e) {
+                               // Something went wrong here!
+                               $responseInstance->addFatalMessage($e->getMessage());
+                       }
+               } else {
+                       // Attach error message to the response
+                       $responseInstance->addFatalMessage('failed_login_after_registration');
+               }
+       }
+}
+
+// [EOF]
+?>
index 07d96db97ffc36d819e7ba60b2d41e66204b4a59..6a6ff22da58f8fee40d2a4fa4a236f7f30ed61dc 100644 (file)
@@ -3,10 +3,10 @@
  * 
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.3.0
+ * @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.mxchange.org
+ * @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
@@ -35,7 +35,7 @@ class  extends BaseFrameworkSystem {
                $this->setObjectDescription("");
 
                // Create unique ID number
-               $this->createUniqueID();
+               $this->generateUniqueId();
 
                // Clean up a little
                $this->removeNumberFormaters();
index f61deb85c47df5f02c5e04f8bc78c8f8004994bc..7fc55e2c15eca048a3671490fdac1b2be611ffd9 100644 (file)
@@ -293,26 +293,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        if (is_null($this->getDebugInstance())) {
                                // Set the debug output system if it is not debug class ;)
                                $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig('debug_engine')));
-                       }
+                       } // END - if
 
                        // Initialize web instance
-                       if (is_null($this->getWebOutputInstance())) {
-                               // Generate the eval() command
-                               $eval = sprintf("\$this->setWebOutputInstance(%s::create%s(\"%s\"));",
-                                       $this->getConfigInstance()->readConfig('web_engine'),
-                                       $this->getConfigInstance()->readConfig('web_engine'),
-                                       $this->getConfigInstance()->readConfig('web_content_type')
-                               );
-
-                               // Debug message
-                               if (defined('DEBUG_EVAL')) $this->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command: <pre><em>%s</em></pre><br />\n",
-                                       $this->__toString(),
-                                       htmlentities($eval)
-                               ));
+                       if ((is_null($this->getWebOutputInstance())) && ($this->__toString() != "ObjectFactory")) {
+                               // Call our object factory
+                               $outputInstance = ObjectFactory::createObjectByConfiguredName('web_engine', array($this->getConfigInstance()->readConfig('web_content_type')));
 
-                               // Run the command
-                               eval($eval);
-                       }
+                               // And set the instance
+                               $this->setWebOutputInstance($outputInstance);
+                       } // END - if
 
                        // Initialize compressor channel
                        if (is_null($this->getCompressorChannel())) {
@@ -321,7 +311,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                                        PATH,
                                        $this->getConfigInstance()->readConfig('compressor_base_path')
                                )));
-                       }
+                       } // END - if
 
                        // Initialize database middleware
                        if (is_null($this->getDatabaseInstance())) {
@@ -330,16 +320,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                                if (is_object($db)) {
                                        // Set the database middleware
                                        $this->setDatabaseInstance($db);
-                               }
-                       }
-               }
+                               } // END - if
+                       } // END - if
+               } // END - if
        }
 
        /**
         * Setter for language instance
         *
-        * @param       $configInstance The configuration instance which shall
-        *                                                      be FrameworkConfiguration
+        * @param       $configInstance         The configuration instance which shall
+        *                                                              be FrameworkConfiguration
         * @return      void
         */
        public final function setConfigInstance (FrameworkConfiguration $configInstance) {
@@ -858,36 +848,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                }
 
                // Initialize the template engine
-               $tplEngine = null;
-               $eval = sprintf("\$tplEngine = %s::create%s(
-       \"%s\",
-       \$appInstance->getLanguageInstance(),
-       \$appInstance->getFileIoInstance()
-);",
-                       $this->getConfigInstance()->readConfig('tpl_engine'),
-                       $this->getConfigInstance()->readConfig('tpl_engine'),
-                       $fqfn
-               );
-
-               // Debug message
-               if ((!is_null($this->getDebugInstance())) && (defined('DEBUG_EVAL'))) {
-                       $this->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command: <pre><em>%s</em></pre><br />\n",
-                               $this->__toString(),
-                               htmlentities($eval)
-                       ));
-               }
-
-               // Run the command
-               eval($eval);
-
-               // Is it a valid instance?
-               if (is_null($tplEngine)) {
-                       // No class returned
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!$tplEngine instanceof CompileableTemplate) {
-                       // Not an object! ;-(
-                       throw new UnsupportedTemplateEngineException($tplEngine, self::EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED);
-               }
+               $tplEngine = ObjectFactory::createObjectByConfiguredName('tpl_engine', array($fqfn, $appInstance->getLanguageInstance(), $appInstance->getFileIoInstance()));
 
                // Return the prepared instance
                return $tplEngine;
index cbb5b60fe4557016d101fa0853e91b5ec4d6ccca..628cd0f8eb59cd66aa6b278a8393b48317675fcd 100644 (file)
@@ -35,7 +35,7 @@ class ???Command extends BaseCommand implements Commandable {
                $this->setObjectDescription("");
 
                // Create unique ID number
-               $this->createUniqueID();
+               $this->generateUniqueId();
 
                // Clean up a little
                $this->removeSystemArray();
index 0f9c56cf599c21a0108536056657d86009476079..46459d5d8a374b08a709b32a7cdd085216df77f5 100644 (file)
@@ -35,7 +35,7 @@ class Controller extends BaseController implements Controller {
                $this->setObjectDescription("Ein spezieller Controller");
 
                // Create unique ID number
-               $this->createUniqueID();
+               $this->generateUniqueId();
 
                // Clean up a little
                $this->removeSystemArray();
index 657fbd0a4295337bdca8f976d6bdc8e915402cb6..6c338fdd99968564dcc52ce231adfd780aaf37b1 100644 (file)
@@ -36,7 +36,7 @@ class  extends BaseDatabaseFrontend {
                $this->setObjectDescription("");
 
                // Create unique ID number
-               $this->createUniqueID();
+               $this->generateUniqueId();
 
                // Clean up a little
                $this->removeNumberFormaters();
index 54a4acb13c7d56f308d57d274df4e171ae5e5235..6d5c15de54fd078d2bf1014929174a0fc5ae1a97 100644 (file)
@@ -55,19 +55,8 @@ class SerializationContainer extends FrameworkArrayObject {
 
                        // Is the required method available?
                        if (method_exists($object, sprintf("get%s", $curr))) {
-                               // Generate a command for getting it
-                               $eval = sprintf("\$value = \$object->get%s();",
-                                       $curr
-                               );
-
-                               // Debug eval command
-                               if (defined('DEBUG_EVAL')) $limitInstance->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command: <pre><em>%s</em></pre><br />\n",
-                                       $this->__toString(),
-                                       htmlentities($eval)
-                               ));
-
-                               // Run it
-                               eval($eval);
+                               // Generate call-back function
+                               $value = call_user_func_array(array($object, sprintf("get%s", $curr)));
 
                                // Add this item to the container list
                                $containerInstance->append(array(
index 19d0e3d8aa5049504700b312b76eecc5951cca85..8fe592bf86ea61e560a2ff7771201494e8ae405b 100644 (file)
@@ -43,12 +43,13 @@ class ObjectFactory extends BaseFactory {
         * the class was not found. No parameters for the object are currently
         * supported.
         *
-        * @param       $className                              Name of the class we shall construct
-        * @return      $objectInstance                 An instance of the requested object
+        * @param       $className                      Name of the class we shall construct
+        * @param       $args                           Arguments in an indexed array
+        * @return      $objectInstance         An instance of the requested object
         * @throws      ClassNotFoundException  If the requested class was not found
         * @throws      EmptyVariableException  If a variable is empty unexpectly
         */
-       public final static function createObjectByName ($className) {
+       public final static function createObjectByName ($className, array $args=array()) {
                // First get an instance of this factory
                $factoryInstance = new ObjectFactory();
 
@@ -61,14 +62,14 @@ class ObjectFactory extends BaseFactory {
                        throw new ClassNotFoundException(array($factoryInstance, $className), self::EXCEPTION_CLASS_NOT_FOUND);
                }
 
-               // Then Prepare the eval() command
-               $eval = sprintf("\$objectInstance = %s::create%s();",
+               // Then Prepare the call-back function
+               $callback = sprintf("%s::create%s",
                        $className,
                        $className
                );
 
-               // Run the command
-               eval($eval);
+               // Run the user function
+               $objectInstance = call_user_func_array($callback, $args);
 
                // Return the prepared instance
                return $objectInstance;
@@ -77,15 +78,16 @@ class ObjectFactory extends BaseFactory {
        /**
         * Creates an object by it's configured name
         *
-        * @param       $configEnttry                   Configuration entry to read
-        * @return      $objectInstance                 An instance of the requested object
+        * @param       $configEnttry           Configuration entry to read
+        * @param       $args                           Arguments in an indexed array
+        * @return      $objectInstance         An instance of the requested object
         */
-       public final static function createObjectByConfiguredName ($configEntry) {
+       public final static function createObjectByConfiguredName ($configEntry, array $args=array()) {
                // Read the configuration entry
                $className = FrameworkConfiguration::getInstance()->readConfig($configEntry);
 
                // Send this to the other factory...
-               $objectInstance = self::createObjectByName($className);
+               $objectInstance = self::createObjectByName($className, $args);
 
                // Return the instance
                return $objectInstance;
index a1feab9084816ea59e402130841281233142cb70..674159909e18911f57b57f8bfb8b661b0c332575 100644 (file)
@@ -35,7 +35,7 @@ class ???Filter extends BaseFrameworkSystem implements Filterable {
                $this->setObjectDescription("A concrete filter");
 
                // Create unique ID number
-               $this->createUniqueID();
+               $this->generateUniqueId();
 
                // Clean up a little
                $this->removeNumberFormaters();
index bcc6dbb203ace1600677c87302893dcc220002fc..fa52125d68a944b13b6a37e3fac32c6b9fabea51 100644 (file)
@@ -184,19 +184,7 @@ class WebCommandResolver extends BaseResolver implements CommandResolver {
                }
 
                // Initiate the command
-               $eval = sprintf("\$commandInstance = %s::create%s(\$this);",
-                       $className,
-                       $className
-               );
-
-               // Run the command
-               eval($eval);
-
-               // Is the instance valid?
-               if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
-                       // Something is wrong
-                       $commandInstance = null;
-               }
+               $commandInstance = ObjectFactory::createObjectByName($className, array($this));
 
                // Return the result
                return $commandInstance;
index 7da1934bb8d467f50e73352ff287b26f0d7b38f1..b5f66e85314c923e1e952b8b0bb76ea75b4f52b7 100644 (file)
@@ -173,22 +173,14 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
                                // Still not found?
                                throw new DefaultControllerException($this, self::EXCEPTION_DEFAUL_CONTROLLER_GONE);
                        }
-               }
-
-               // Initiate the controller
-               $eval = sprintf("\$controllerInstance = %s::create%s(WebCommandResolver::createWebCommandResolver(\$commandName, \$this->getApplicationInstance()));",
-                       $class,
-                       $class
-               );
+               } // END - if
 
-               // Run the command
-               eval($eval);
+               // Initiate the resolver and controller
+               $resolverInstance = ObjectFactory::createObjectByConfiguredName('web_cmd_resolver', array($commandName, $this->getApplicationInstance()));
+               $controllerInstance = ObjectFactory::createObjectByName($class, array($resolverInstance));
 
-               // Is the instance valid?
-               if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
-                       // Something is wrong
-                       $controllerInstance = null;
-               }
+               // Remove resolver
+               unset($resolverInstance);
 
                // Return the result
                return $controllerInstance;
index 51ea53e2def0ee2cdc14d9b8e7691e4fb0b537c7..1a999852e3a8c839fdcef325a43d4d269bf035c8 100644 (file)
@@ -73,35 +73,20 @@ class CompressorChannel extends BaseMiddleware {
                                        // must keep on class in one file.
                                        $class = substr($dir, 6, -4);
 
-                                       // Create eval command
-                                       $eval = sprintf("\$tempInstance = %s::create%s();",
-                                               $class,
-                                               $class
-                                       );
-
-                                       // Debug message
-                                       if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) $cInstance->getDebugInstance()->output(sprintf("[%s:] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
-                                               $cInstance->__toString(),
-                                               htmlentities($eval)
-                                       ));
-
-                                       // Run it. This will create an instance to the current class
-                                       eval($eval);
-
-                                       // Is the instance valid? We have the stream handler here
-                                       if ((!is_null($tempInstance)) && (method_exists($tempInstance, 'compressStream')) && (method_exists($tempInstance, 'decompressStream'))) {
-                                               // Okay, this handler is valid
-                                               $cInstance->setCompressor($tempInstance);
-
-                                               // No more searches required because we have found a valid compressor stream
-                                               break;
-                                       }
-                               }
-                       }
+                                       // Get an instance from our object factory
+                                       $tempInstance = ObjectFactory::createObjectByName($class);
+
+                                       // Set the compressor
+                                       $cInstance->setCompressor($tempInstance);
+
+                                       // No more searches required because we have found a valid compressor stream
+                                       break;
+                               } // END - if
+                       } // END - while
 
                        // Close the directory
                        $dirPointer->closeDirectory();
-               }
+               } // END - if
 
                // Check again if there is a compressor
                if (
@@ -112,7 +97,7 @@ class CompressorChannel extends BaseMiddleware {
                ) {
                        // Set the null compressor handler. This should not be configureable!
                        $cInstance->setCompressor(ObjectFactory::createObjectByName('NullCompressor'));
-               }
+               } // END - if
 
                // Return the compressor instance
                return $cInstance;
index bbd96b579b72b53b730dba270ac4bc0f42a8bd4a..5c1e050d2854a092432d5d9742097a03ec331818 100644 (file)
@@ -27,7 +27,7 @@ class DebugMiddleware extends BaseMiddleware {
        /**
         * The concrete output instance
         */
-       private $outputHandler = null;
+       private $outputInstance = null;
 
        /**
         * An instance of this class
@@ -44,7 +44,7 @@ class DebugMiddleware extends BaseMiddleware {
                parent::__construct(__CLASS__);
 
                // Set description
-               $this->setObjectDescription("Debug-Ausgabe-Handler");
+               $this->setObjectDescription("Debug-Ausgabe-Instance");
 
                // Create an unique ID
                $this->generateUniqueId();
@@ -58,36 +58,24 @@ class DebugMiddleware extends BaseMiddleware {
         * If no output is given this class is currently being used for back-fall.
         * This fall-back mechanism will become deprecated very soon.
         *
-        * @param               $debuggerClass       The class name which we shall use for
+        * @param       $debuggerClass  The class name which we shall use for
         *                                                      registering the *real* debug output
-        * @return      $debugInstance          An instance of this middleware class
+        * @return      $debugInstance  An instance of this middleware class
         */
        public final static function createDebugMiddleware ($debuggerClass) {
                // Create an instance if this middleware
                $debugInstance = new DebugMiddleware();
 
-               // Is there a valid output handler provided?
-               if ((!is_null($debuggerClass)) && (is_object($debuggerClass)) && (method_exists($debuggerClass, 'outputStream'))) {
-                       // Use the given output system
-                       $debugInstance->setOutputHandler($debuggerClass);
+               // Is there a valid output instance provided?
+               if ((!is_null($debuggerClass)) && (is_object($debuggerClass)) && ($debuggerClass instanceof OutputStreamer)) {
+                       // Use the given output instance
+                       $debugInstance->setOutputInstance($debuggerClass);
                } elseif ((!is_null($debuggerClass)) && (is_string($debuggerClass)) && (class_exists($debuggerClass))) {
                        // A name for a debug output class has been provided so we try to get it
-                       $eval = sprintf("\$debuggerClass = %s::create%s();",
-                               $debuggerClass,
-                               $debuggerClass
-                       );
+                       $debuggerInstance = ObjectFactory::createObjectByName($debuggerClass);
 
-                       // Run the constructed name
-                       @eval($eval);
-
-                       // Was this successfull?
-                       if ((is_object($debuggerClass)) && (method_exists($debuggerClass, "outputStream"))) {
-                               // Set this as output class
-                               $debugInstance->setOutputHandler($debuggerClass);
-                       } else {
-                               // No object or method is missing use fall-back
-                               throw new MissingMethodException(array($debuggerClass, 'outputStream'), self::EXCEPTION_MISSING_METHOD);
-                       }
+                       // Set this as output class
+                       $debugInstance->setOutputInstance($debuggerInstance);
                }
 
                // Return instance
@@ -104,32 +92,33 @@ class DebugMiddleware extends BaseMiddleware {
        }
 
        /**
-        * Setter for output handler
+        * Setter for output instance
         *
+        * @param       $outputInstance The debug output instance
         * @return      void
         */
-       public final function setOutputHandler ($outputHandler) {
-               $this->outputHandler = $outputHandler;
+       public final function setOutputInstance (OutputStreamer $outputInstance) {
+               $this->outputInstance = $outputInstance;
        }
 
        /**
         * This method shall send debug output which can be HTML code for the
         * browser or debug lines for a log file, etc. to the registered debug
-        * output handler.
+        * output instance.
         *
         * @return      void
         */
        public final function output ($outStream) {
-               // Check if the output handler is valid
-               if (is_null($this->outputHandler)) {
-                       // Debug output handler was not set
+               // Check if the output instance is valid
+               if (is_null($this->outputInstance)) {
+                       // Debug output instance was not set
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($this->outputHandler)) {
-                       // The debug output handler is not an object
-                       throw new NoObjectException($this->ouputHandler, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($this->outputHandler, 'outputStream')) {
+               } elseif (!is_object($this->outputInstance)) {
+                       // The debug output instance is not an object
+                       throw new NoObjectException($this->ouputInstance, self::EXCEPTION_IS_NO_OBJECT);
+               } elseif (!method_exists($this->outputInstance, 'outputStream')) {
                        // The required method outputStream() is missing
-                       throw new MissingMethodException(array($this->outputHandler, 'outputStream'), self::EXCEPTION_MISSING_METHOD);
+                       throw new MissingMethodException(array($this->outputInstance, 'outputStream'), self::EXCEPTION_MISSING_METHOD);
                }
 
                // Is the output stream set
@@ -138,8 +127,8 @@ class DebugMiddleware extends BaseMiddleware {
                        return;
                }
 
-               // Use the output handler
-               $this->outputHandler->outputStream($outStream);
+               // Use the output instance
+               $this->outputInstance->outputStream($outStream);
        }
 }
 
index dc48fe6acce4840bfb3166925dd30756a5d35c88..142093ba2955c64cb7a193a8736b871fa9268e1a 100644 (file)
@@ -189,6 +189,9 @@ $cfg->setConfigEntry('rng_class', "RandomNumberGenerator");
 // CFG: USER-DB-WRAPPER
 $cfg->setConfigEntry('user_db_wrapper', "UserDatabaseWrapper");
 
+// CFG: WEB-CMD-RESOLVER
+$cfg->setConfigEntry('web_cmd_resolver', "WebCommandResolver");
+
 // CFG: MATH-PRIME
 $cfg->setConfigEntry('math_prime', 591623);