Code merged from ship-simu repository
[mailer.git] / inc / classes / main / factories / web / class_WebNewsFactory.php
index d7307ec37279af64146de0f4867c6879fcea606b..1dace4e9592cabd166f2636b95e1e96a40325cc6 100644 (file)
@@ -45,8 +45,29 @@ class WebNewsFactory extends BaseFactory {
         * @return      $factoryInstance        An instance of a WebNewsFactory class
         */
        public final static function createFactoryByRequest (Requestable $requestInstance) {
+               // Set default news reader class
+               $configEntry = "news_reader_class";
+
+               // Get "page"
+               $page = $requestInstance->getRequestElement('page');
+
+               // Is "page" used?
+               if (!empty($page)) {
+                       // Then add it
+                       $configEntry = sprintf("news_reader_%s_class", $page);
+
+                       // Get "action"
+                       $action = $requestInstance->getRequestElement('action');
+
+                       // Is it also there?
+                       if (!empty($action)) {
+                               // Then use both for config entry
+                               $configEntry = sprintf("news_reader_%s_%s_class", $page, $action);
+                       } // END - if
+               } // END - if
+
                // Get the news reader class name from config
-               $className = $requestInstance->getConfigInstance()->readConfig('news_reader_class');
+               $className = $requestInstance->getConfigInstance()->readConfig($configEntry);
 
                // Once we have that name, try to load initialize it
                $newsInstance = ObjectFactory::createObjectByName($className, array($requestInstance));