*
* @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
*
/**
* Setter for controller name
*
- * @param $controllerName Last validated controller name
+ * @param $controllerName Last validated controller name
* @return void
*/
protected final function setControllerName ($controllerName) {
*
* @return $controllerName Last validated controller name
*/
- protected final function getControllerName () {
+ public final function getControllerName () {
return $this->controllerName;
}
/**
* Checks wether the given controller is valid
*
- * @param $controllerName The default controller we shall execute
- * @return $isValid Wether the given controller is valid
+ * @param $controllerName The default controller we shall execute
+ * @return $isValid Wether the given controller is valid
* @throws EmptyVariableException Thrown if the given controller is not set
+ * @throws DefaultControllerException If the default controller was not found
*/
public function isControllerValid ($controllerName) {
// By default nothing shall be valid
} // END - if
// Now, let us create the full name of the controller class
- $className = sprintf("%s%sController",
+ $this->setClassName(sprintf("%s%sController",
$this->controllerPrefix,
$this->convertToClassName($controllerName)
- );
+ ));
// Try it hard to get an controller
while (!$isValid) {
// Is this class already loaded?
- if (class_exists($className)) {
+ if (class_exists($this->getClassName())) {
// This class does exist. :-)
$isValid = true;
- } elseif (($className != "WebDefaultController") && ($className != "WebDefaultNewsController")) {
+ } 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
- $className = "WebDefaultNewsController";
+ $this->setClassName($this->controllerPrefix.'DefaultNewsController');
} else {
- // No news at "home" page or non-news page
- $className = "WebDefaultController";
+ // No news at home page or non-news page
+ $this->setClassName($this->controllerPrefix.'DefaultController');
}
} else {
// All is tried, give it up here
- throw new DefaultControllerException($this, self::EXCEPTION_DEFAUL_CONTROLLER_GONE);
+ throw new DefaultControllerException($this, self::EXCEPTION_DEFAULT_CONTROLLER_GONE);
}
} // END - while
// Debug output
- //* DEBUG: */ $this->debugBacktrace();
+ //* DEBUG: */ $this->debugBackTrace();
// Return the result
return $isValid;