Now DefaultNewsController is the default controller
[core.git] / inc / classes / main / resolver / controller / class_BaseControllerResolver.php
index f324ec6d3a2bf4105f9d10c6af9929c51d51f29c..23e449ac913386c2b6092539f41cdfc2d39004b5 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007 - 2009 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,12 +25,12 @@ class BaseControllerResolver extends BaseResolver {
        /**
         * Prefix for local, remote or other resolver
         */
-       private $controllerPrefix = "";
+       private $controllerPrefix = '';
 
        /**
         * Validated controller name
         */
-       private $controllerName = "";
+       private $controllerName = '';
 
        /**
         * Protected constructor
@@ -90,11 +90,11 @@ class BaseControllerResolver extends BaseResolver {
                        throw new EmptyVariableException(array($this, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } // END - if
 
+               // Create class name
+               $className = $this->controllerPrefix . $this->convertToClassName($controllerName) . 'Controller';
+
                // Now, let us create the full name of the controller class
-               $this->setClassName(sprintf("%s%sController",
-                       $this->controllerPrefix,
-                       $this->convertToClassName($controllerName)
-               ));
+               $this->setClassName($className);
 
                // Try it hard to get an controller
                while ($isValid === false) {
@@ -102,15 +102,9 @@ class BaseControllerResolver extends BaseResolver {
                        if (class_exists($this->getClassName())) {
                                // This class does exist. :-)
                                $isValid = true;
-                       } elseif (($this->getClassName() != $this->controllerPrefix.'DefaultController') && ($this->getClassName() != $this->controllerPrefix.'DefaultNewsController')) {
-                               // Do we have news?
-                               if ($this->getConfigInstance()->readConfig('page_with_news') == $this->getApplicationInstance()->getRequestInstance()->getRequestElement('page')) {
-                                       // Yes, display news in home then set default controller with news
-                                       $this->setClassName($this->controllerPrefix . 'DefaultNewsController');
-                               } else {
-                                       // No news at home page or non-news page
-                                       $this->setClassName($this->controllerPrefix . 'DefaultController');
-                               }
+                       } elseif ($this->getClassName() != $this->controllerPrefix.'DefaultNewsController') {
+                               // Set default controller
+                               $this->setClassName($this->controllerPrefix . 'DefaultNewsController');
                        } else {
                                // All is tried, give it up here
                                throw new DefaultControllerException($this, self::EXCEPTION_DEFAULT_CONTROLLER_GONE);