Now by default with news due to deprecation of 'page_with_news'
[core.git] / inc / classes / main / resolver / controller / web / class_WebControllerResolver.php
index 5378006..a941f53 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, 2009 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -25,7 +25,7 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
        /**
         * Last successfull resolved controller (name)
         */
-       private $lastControllerName = "";
+       private $lastControllerName = '';
 
        /**
         * Last successfull resolved controller (instance)
@@ -87,7 +87,7 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
         */
        public function resolveController () {
                // Init variables
-               $controllerName = "";
+               $controllerName = '';
                $controllerInstance = null;
 
                // Get the command name 
@@ -127,21 +127,19 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
                $controllerInstance = null;
 
                // Default controller
-               $this->setClassName('WebDefaultController');
+               $this->setClassName('WebDefaultNewsController');
 
                // Generate the class name
                //* DEBUG: */ echo __METHOD__.": Controller=".$controllerName;
                if ($controllerName != $defaultController) {
                        // Create controller class name
-                       $this->setClassName(sprintf("Web%sController",
-                               $this->convertToClassName($controllerName)
-                       ));
-               } elseif ($this->getConfigInstance()->readConfig('page_with_news') == $this->getApplicationInstance()->getRequestInstance()->getRequestElement('page')) {
-                       // Yes, display news in home then set default controller with news
-                       $this->setClassName('WebDefaultNewsController');
+                       $className = 'Web' . $this->convertToClassName($controllerName) . 'Controller';
+
+                       // ... and set it
+                       $this->setClassName($className);
                } else {
                        // No news at home page or non-news page
-                       $this->setClassName('WebDefaultController');
+                       $this->setClassName('WebDefaultNewsController');
                }
                //* DEBUG: */ echo ", controller=".$this->getClassName()."<br />\n";
 
@@ -152,7 +150,7 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
                } // END - if
 
                // Set default resolver config name
-               $resolverConfigEntry = "";
+               $resolverConfigEntry = '';
 
                // Try to read a config entry for our resolver including controller name... ;-)
                try {
@@ -163,15 +161,22 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
                        $resolverClass = $this->getConfigInstance()->readConfig($resolverConfigEntry);
                } catch (ConfigEntryNotFoundException $e) {
                        // Use default resolver entry
-                       $resolverConfigEntry = "web_cmd_resolver_class";
+                       // @TODO Maybe we need to log this?
+                       $resolverConfigEntry = 'web_cmd_resolver_class';
                }
 
                // Initiate the resolver and controller
-               $resolverInstance = ObjectFactory::createObjectByConfiguredName($resolverConfigEntry, array($controllerName, $this->getApplicationInstance()));
-               $controllerInstance = ObjectFactory::createObjectByName($this->getClassName(), array($resolverInstance));
-
-               // Remove resolver (we don't need it anymore)
-               unset($resolverInstance);
+               $resolverInstance = ObjectFactory::createObjectByConfiguredName(
+                       $resolverConfigEntry,
+                       array(
+                               $controllerName,
+                               $this->getApplicationInstance()
+                       )
+               );
+               $controllerInstance = ObjectFactory::createObjectByName(
+                       $this->getClassName(),
+                       array($resolverInstance)
+               );
 
                // Return the result
                return $controllerInstance;