]> git.mxchange.org Git - mailer.git/blobdiff - inc/classes/main/factories/web/class_WebNewsFactory.php
Code syncronized with shipsimu code base
[mailer.git] / inc / classes / main / factories / web / class_WebNewsFactory.php
index 946f96b406f50866916d41553bd67b2c3b13175e..d7307ec37279af64146de0f4867c6879fcea606b 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @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
  *
@@ -35,12 +35,6 @@ class WebNewsFactory extends BaseFactory {
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
-
-               // Set part description
-               $this->setObjectDescription("Factory for webpages with news");
-
-               // Create unique ID number
-               $this->createUniqueID();
        }
 
        /**
@@ -51,67 +45,16 @@ class WebNewsFactory extends BaseFactory {
         * @return      $factoryInstance        An instance of a WebNewsFactory class
         */
        public final static function createFactoryByRequest (Requestable $requestInstance) {
-               // Generate the new instance
-               $factoryInstance = new WebNewsFactory();
-
-               // 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)
-               $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));
-                       }
-
-                       // 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();
+               // Get the news reader class name from config
+               $className = $requestInstance->getConfigInstance()->readConfig('news_reader_class');
 
                // Once we have that name, try to load initialize it
-               $realFactoryInstance = ObjectFactory::createObjectByName($className);
-
-               // And assign it with the factory
-               $factoryInstance->setRealFactoryInstance($realFactoryInstance);
+               $newsInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
 
-               // Remember the request we have used for later usage
-               $factoryInstance->setRequestInstance($requestInstance);
+               // Initialize the reader
+               $newsInstance->initializeReader();
 
                // 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;
        }
 }