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
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
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
* 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ähler");
// 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");
* 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");
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()
$this->setObjectDescription("");
// Create unique ID number
- $this->createUniqueID();
+ $this->generateUniqueId();
// Clean up a little
$this->removeNumberFormaters();
$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();
}
// 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);
));
// 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ä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ä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()
}
// 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()
));
}
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
* @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());
}
/**
// 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);
--- /dev/null
+Deny from all
--- /dev/null
+<?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);
+}
+
+//
+?>
*
*
* @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
$this->setObjectDescription("");
// Generate unique key
- $this->createUniqueID();
+ $this->generateUniqueId();
}
/**
--- /dev/null
+<?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]
+?>
*
*
* @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
$this->setObjectDescription("");
// Create unique ID number
- $this->createUniqueID();
+ $this->generateUniqueId();
// Clean up a little
$this->removeNumberFormaters();
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())) {
PATH,
$this->getConfigInstance()->readConfig('compressor_base_path')
)));
- }
+ } // END - if
// Initialize database middleware
if (is_null($this->getDatabaseInstance())) {
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) {
}
// 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;
$this->setObjectDescription("");
// Create unique ID number
- $this->createUniqueID();
+ $this->generateUniqueId();
// Clean up a little
$this->removeSystemArray();
$this->setObjectDescription("Ein spezieller Controller");
// Create unique ID number
- $this->createUniqueID();
+ $this->generateUniqueId();
// Clean up a little
$this->removeSystemArray();
$this->setObjectDescription("");
// Create unique ID number
- $this->createUniqueID();
+ $this->generateUniqueId();
// Clean up a little
$this->removeNumberFormaters();
// 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(
* 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();
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;
/**
* 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;
$this->setObjectDescription("A concrete filter");
// Create unique ID number
- $this->createUniqueID();
+ $this->generateUniqueId();
// Clean up a little
$this->removeNumberFormaters();
}
// 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;
// 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;
// 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 (
) {
// Set the null compressor handler. This should not be configureable!
$cInstance->setCompressor(ObjectFactory::createObjectByName('NullCompressor'));
- }
+ } // END - if
// Return the compressor instance
return $cInstance;
/**
* The concrete output instance
*/
- private $outputHandler = null;
+ private $outputInstance = null;
/**
* An instance of this class
parent::__construct(__CLASS__);
// Set description
- $this->setObjectDescription("Debug-Ausgabe-Handler");
+ $this->setObjectDescription("Debug-Ausgabe-Instance");
// Create an unique ID
$this->generateUniqueId();
* 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
}
/**
- * 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
return;
}
- // Use the output handler
- $this->outputHandler->outputStream($outStream);
+ // Use the output instance
+ $this->outputInstance->outputStream($outStream);
}
}
// 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);