application/ship-simu/main/drives/class_BaseDrive.php -text
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_ShipSimuNewsFactory.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/main/extended/class_SerializationContainer.php -text
inc/classes/main/factories/.htaccess -text
inc/classes/main/factories/class_BaseFactory.php -text
+inc/classes/main/factories/objects/.htaccess -text
+inc/classes/main/factories/objects/class_ObjectFactory.php -text
inc/classes/main/factories/web/.htaccess -text
inc/classes/main/factories/web/class_NewsFactory.php -text
inc/classes/main/io/.htaccess -text
-
+<?php
+/**
+ *
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class extends BaseFrameworkSystem {
/**
- * Limits this object with an ObjectLimits instance
+ * Private constructor
+ *
+ * @return void
*/
- public function limitObject (ObjectLimits $limitInstance) {
- die("limitObject() reached! Stub!");
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
}
+}
+
+// [EOF]
+?>
// Existiert die Klasse ueberhaupt?
if (!class_exists($shipType)) {
// Klasse nicht gefunden
- throw new ClassNotFoundException ($shipType, 0);
+ throw new ClassNotFoundException ($shipType, self::EXCEPTION_CLASS_NOT_FOUND);
}
// Schiff-Instanz temporaer erzeugen und in den Bauvertrag einfuegen
$this->getShipInstance()->getShipName()
));
}
- } catch(ClassNotFoundException $e) {
+ } catch (ClassNotFoundException $e) {
// Throw it again...
throw new ClassNotFoundException($e->getMessage(), $e->getCode());
}
// Is the class there?
if (!class_exists($shipType)) {
// Throw exception
- throw new ClassNotFoundException($shipType, 0);
+ throw new ClassNotFoundException($shipType, self::EXCEPTION_CLASS_NOT_FOUND);
}
// Create dummy ship
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A class for the special news object factory
+ *
+ * @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 ShipSimuNewsFactory extends BaseFrameworkSystem {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("News-Objektefabrik für Ship-Simu");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $factoryInstance An instance of this class
+ */
+ public final static function createShipSimuNewsFactory () {
+ // Get a new instance
+ $factoryInstance = new ShipSimuNewsFactory();
+
+ // Return the prepared instance
+ return $factoryInstance;
+ }
+}
+
+// [EOF]
+?>
eval($eval);
} else {
// Nicht vorhanden, dann Ausnahme werfen!
- throw new ClassNotFoundException($partClass, 0);
+ throw new ClassNotFoundException($partClass, self::EXCEPTION_CLASS_NOT_FOUND);
}
// Das Einbauen versuchen...
/**
* The constructor
*
- * @param $message Message from the exception
+ * @param $class Class' name we have no class found for
* @param $code Code number for the exception
* @return void
*/
- public function __construct (BaseFrameworkSystem $class, $code) {
+ public function __construct ($class, $code) {
// Add a message around the missing class
$message = sprintf("Die interne Script-Klasse <u>%s</u> konnte nicht gefunden werden!", $class);
const EXCEPTION_INVALID_CONTROLLER = 0x032;
const EXCEPTION_HEADERS_ALREADY_SENT = 0x033;
const EXCEPTION_DEFAUL_CONTROLLER_GONE = 0x034;
+ const EXCEPTION_CLASS_NOT_FOUND = 0x035;
/**
* In the super constructor these system classes shall be ignored or else
*/
class WebHomeCommand extends BaseCommand implements Commandable {
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
private $resolverInstance = null;
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
private $resolverInstance = null;
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
*/
class DefaultRegistrationController extends BaseController implements Controller {
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
*/
class BaseFactory extends BaseFrameworkSystem {
/**
- * Private constructor
+ * An instance of the real factory class
+ */
+ private $realFactoryInstance = null;
+
+ /**
+ * Protected constructor
*
* @param $class Name of the real class (not BaseFactory)
* @return void
// Call parent constructor
parent::__construct($class);
+ // Create unique ID number
+ $this->createUniqueID();
+
// Clean up a little
$this->removeNumberFormaters();
$this->removeSystemArray();
}
+
+ /**
+ * Setter for the *real* factory instance
+ *
+ * @param $realFactoryInstance An instance of the real factory class
+ * @return void
+ */
+ public final function setRealFactoryInstance (BaseFrameworkSystem $realFactoryInstance) {
+ $this->realFactoryInstance = $realFactoryInstance;
+ }
+
+ /**
+ * Getter for the *real* factory instance
+ *
+ * @return $realFactoryInstance An instance of the real factory class
+ */
+ protected final function getRealFactoryInstance () {
+ return $this->realFactoryInstance;
+ }
}
// [EOF]
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An general object factory
+ *
+ * @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 ObjectFactory extends BaseFactory {
+ /**
+ * Protected constructor
+ *
+ * @param $class Name of the real class (not BaseFactory)
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set object description
+ $this->setObjectDescription("Objekte-Fabrik");
+ }
+
+ /**
+ * Creates a new object given by the name or throws an exception if
+ * 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
+ * @throws ClassNotFoundException If the requested class was not found
+ * @throws EmptyVariableException If a variable is empty unexpectly
+ */
+ public final static function createObjectByName ($className) {
+ // First get an instance of this factory
+ $factoryInstance = new ObjectFactory();
+
+ // Is the class name valid and is the class there?
+ if (empty($className)) {
+ // Throw an exception here
+ throw new EmptyVariableException(array($factoryInstance, 'className'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif (!class_exists($className)) {
+ // Then throw an exception
+ throw new ClassNotFoundException($className, self::EXCEPTION_CLASS_NOT_FOUND);
+ }
+
+ // Then Prepare the eval() command
+ $eval = sprintf("\$objectInstance = %s::create%s();",
+ $className,
+ $className
+ );
+
+ // Run the command
+ eval($eval);
+
+ // Return the prepared instance
+ return $objectInstance;
+ }
+}
+
+// [EOF]
+?>
*/
class NewsFactory extends BaseFactory {
/**
- * Private constructor
+ * Instance of a request class
+ */
+ private $requestInstance = null;
+
+ /**
+ * Protected constructor
*
* @return void
*/
// Set part description
$this->setObjectDescription("News-Fabrik für Webseiten");
-
- // Create unique ID number
- $this->createUniqueID();
}
/**
// Generate the new instance
$factoryInstance = new NewsFactory();
- // Get the element name
+ // Get the element name from configuration
$element = FrameworkConfiguration::getInstance()->readConfig("app_selector_get");
// Analyze the request, first get the Uni* application name (short one from URL)
- $appVariable = $requestInstance->getRequestElement($element);
+ $appName = $requestInstance->getRequestElement($element);
+
+ // Initialize some variables
+ $className = "";
+ $className2 = $appName;
+
+ // Then construct the class name
+ foreach (array("_", "-") as $exp) {
+ $array = explode($exp, $className2);
+ foreach ($array as $el) {
+ $className .= ucfirst(strtolower($el));
+ }
- // Add more code here...
+ // Copy it back and clear the class name
+ $className2 = $className;
+ $className = "";
+ }
+
+ // After all is done, copy it back and add this class' name
+ $className = $className2 . $factoryInstance->__toString();
+
+ // Once we have that name, try to load initialize it
+ $realFactoryInstance = ObjectFactory::createObjectByName($className);
+
+ // And assign it with the factory
+ $factoryInstance->setRealFactoryInstance($realFactoryInstance);
+
+ // Remember the request we have used for later usage
+ $factoryInstance->setRequestInstance($requestInstance);
// Return the prepared factory instance
return $factoryInstance;
}
+
+ /**
+ * Setter for the request instance
+ *
+ * @param $requestInstance An instance of a request object
+ * @return void
+ */
+ public final function setRequestInstance (Requestable $requestInstance) {
+ $this->requestInstance = $requestInstance;
+ }
+
+ /**
+ * Creates a new object instance and returns it
+ *
+ * @return $newsInstance An instance of a news object
+ */
+ public function createNewsObject () {
+ // Ask the real factory class for doing this
+ $newsInstance = $this->getRealFactoryInstance()->createNewObject($this->requestInstance);
+
+ // And return it
+ return $newsInstance;
+ }
}
// [EOF]
private $commandPrefix = "";
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
private $lastCommandInstance = "";
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
private $lastControllerName = "";
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/