]> git.mxchange.org Git - shipsimu.git/commitdiff
More renamed
authorRoland Häder <roland@mxchange.org>
Wed, 7 May 2008 14:57:06 +0000 (14:57 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 7 May 2008 14:57:06 +0000 (14:57 +0000)
.gitattributes
inc/classes/main/resolver/local/.htaccess [deleted file]
inc/classes/main/resolver/local/class_LocalCommandResolver.php [deleted file]
inc/classes/main/resolver/local/class_LocalControllerResolver.php [deleted file]
inc/classes/main/resolver/web/.htaccess [new file with mode: 0644]
inc/classes/main/resolver/web/class_WebCommandResolver.php [new file with mode: 0644]
inc/classes/main/resolver/web/class_WebControllerResolver.php [new file with mode: 0644]

index f0c126ec22e0e84a8e181c758db2e46e5beecb6d..6b382e1f6eaeba7c70adb914c0e0334acd68f4b1 100644 (file)
@@ -285,9 +285,9 @@ inc/classes/main/request/.htaccess -text
 inc/classes/main/request/class_HttpRequest.php -text
 inc/classes/main/resolver/.htaccess -text
 inc/classes/main/resolver/class_BaseResolver.php -text
-inc/classes/main/resolver/local/.htaccess -text
-inc/classes/main/resolver/local/class_LocalCommandResolver.php -text
-inc/classes/main/resolver/local/class_LocalControllerResolver.php -text
+inc/classes/main/resolver/web/.htaccess -text
+inc/classes/main/resolver/web/class_WebCommandResolver.php -text
+inc/classes/main/resolver/web/class_WebControllerResolver.php -text
 inc/classes/main/response/.htaccess -text
 inc/classes/main/response/class_HttpResponse.php -text
 inc/classes/main/template/.htaccess -text
diff --git a/inc/classes/main/resolver/local/.htaccess b/inc/classes/main/resolver/local/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/inc/classes/main/resolver/local/class_LocalCommandResolver.php b/inc/classes/main/resolver/local/class_LocalCommandResolver.php
deleted file mode 100644 (file)
index 87e0d69..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-<?php
-/**
- * A command resolver for local (non-hubbed) commands
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @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
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class LocalCommandResolver extends BaseResolver implements CommandResolver {
-       /**
-        * Last successfull resolved command
-        */
-       private $lastCommandInstance = "";
-
-       /**
-        * Private constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set part description
-               $this->setObjectDescription("Lokaler Kommandoaufl&ouml;ser");
-
-               // Create unique ID number
-               $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
-
-               // Set prefix to "Local"
-               $this->setCommandPrefix("Local");
-       }
-
-       /**
-        * Creates an instance of a local command resolver with a given default command
-        *
-        * @param       $defaultCommand                         The default command we shall execute
-        * @param       $appInstance                            An instance of a manageable application helper class
-        * @return      $resolverInstance                       The prepared command resolver instance
-        * @throws      EmptyVariableException          Thrown if the default command is not set
-        * @throws      InvalidCommandException         Thrown if the default command is invalid
-        */
-       public final static function createLocalCommandResolver ($defaultCommand, ManageableApplication $appInstance) {
-               // Create the new instance
-               $resolverInstance = new LocalCommandResolver();
-
-               // Is the variable $defaultCommand set and the command is valid?
-               if (empty($defaultCommand)) {
-                       // Then thrown an exception here
-                       throw new EmptyVariableException(array($resolverInstance, 'defaultCommand'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!$resolverInstance->isCommandValid($defaultCommand)) {
-                       // Invalid command found
-                       throw new InvalidCommandException(array($resolverInstance, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
-               }
-
-               // Set the application instance
-               $resolverInstance->setApplicationInstance($appInstance);
-
-               // Return the prepared instance
-               return $resolverInstance;
-       }
-
-       /**
-        * Returns an command instance for a given request class or null if
-        * MissingArrayElementsException was thrown
-        *
-        * @param       $requestInstance        An instance of a request class
-        * @return      $commandInstance        An instance of the resolved command
-        * @throws      InvalidCommandException                         Thrown if $commandName is
-        *                                                                                              invalid
-        * @throws      InvalidCommandInstanceException         Thrown if $commandInstance
-        *                                                                                              is an invalid instance
-        */
-       public function resolvCommandByRequest (Requestable $requestInstance) {
-               // Init variables
-               $commandName = "";
-               $commandInstance = null;
-
-               // Test if the required parameter is set
-               try {
-                       // This goes fine so let's resolv the command
-                       $commandName = $requestInstance->getRequestElement($this->getConfigInstance()->readConfig("command_parameter"));
-
-                       // Is the command empty? Then fall back to default command
-                       if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig("default_command");
-
-                       // Check if the command is valid
-                       if (!$this->isCommandValid($commandName)) {
-                               // This command is invalid!
-                               throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
-                       }
-
-                       // Get the command
-                       $commandInstance = $this->loadCommand($commandName);
-
-                       // And validate it
-                       if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
-                               // This command has an invalid instance!
-                               throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
-                       }
-
-                       // Set last command
-                       $this->lastCommandInstance = $commandInstance;
-               } catch (MissingArrayElementsException $e) {
-                       // Just catch it here...
-               }
-
-               // Return the resolved command instance
-               return $commandInstance;
-       }
-
-       /**
-        * "Loads" a given command and instances it if not yet cached
-        *
-        * @param       $commandName                            A command name we shall look for
-        * @return      $commandInstance                        A loaded command instance
-        * @throws      InvalidCommandException         Thrown if even the default
-        *                                                                              command class is missing (bad!)
-        */
-       private function loadCommand ($commandName) {
-               // Cache default command
-               $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
-
-               // Init command instance
-               $commandInstance = null;
-
-               // Create command class name
-               $class = sprintf("Local%sCommand",
-                       ucfirst(strtolower($commandName))
-               );
-
-               // Is this class loaded?
-               if (!class_exists($class)) {
-                       // Class not found, so try the default one or throw exception
-                       if ($commandName != $defaultCommand) {
-                               // Try the default command
-                               return $this->loadCommand($defaultCommand);
-                       } else {
-                               // Still not found?
-                               throw new InvalidCommandException(array($this, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
-                       }
-               }
-
-               // Initiate the command
-               $eval = sprintf("\$commandInstance = %s::create%s(\$this);",
-                       $class,
-                       $class
-               );
-
-               // Run the command
-               eval($eval);
-
-               // Is the instance valid?
-               if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
-                       // Something is wrong
-                       $commandInstance = null;
-               }
-
-               // Return the result
-               return $commandInstance;
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/resolver/local/class_LocalControllerResolver.php b/inc/classes/main/resolver/local/class_LocalControllerResolver.php
deleted file mode 100644 (file)
index 9c94209..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-<?php
-/**
- * A resolver for resolving controllers locally
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @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
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class LocalControllerResolver extends BaseResolver implements ControllerResolver {
-       /**
-        * Last successfull resolved controller
-        */
-       private $lastControllerName = "";
-
-       /**
-        * Private constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set part description
-               $this->setObjectDescription("");
-
-               // Create unique ID number
-               $this->createUniqueID();
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
-
-               // Set prefix to "Local"
-               $this->setCommandPrefix("Local");
-       }
-
-       /**
-        * Creates an instance of a resolver class with a given command
-        *
-        * @param       $commandName                            The default command we shall execute
-        * @param       $appInstance                            An instance of a manageable application helper class
-        * @return      $resolverInstance                       The prepared command resolver instance
-        * @throws      EmptyVariableException          Thrown if the default command is not set
-        * @throws      InvalidCommandException         Thrown if the default command is invalid
-        */
-       public final static function createLocalControllerResolver ($commandName, ManageableApplication $appInstance) {
-               // Create the new instance
-               $resolverInstance = new LocalControllerResolver();
-
-               // Is the variable $commandName set and the command is valid?
-               if (empty($commandName)) {
-                       // Then thrown an exception here
-                       throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!$resolverInstance->isCommandValid($commandName)) {
-                       // Invalid command found
-                       throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
-               }
-
-               // Set the application instance
-               $resolverInstance->setApplicationInstance($appInstance);
-
-               // Return the prepared instance
-               return $resolverInstance;
-       }
-
-       /**
-        * Resolves the default controller of the given command
-        *
-        * @return      $controllerInstance             A controller instance for the default
-        *                                                                      command
-        * @throws      InvalidCommandException                         Thrown if $commandName is
-        *                                                                                              invalid
-        * @throws      InvalidControllerInstanceException      Thrown if $commandInstance
-        *                                                                                              is invalid
-        */
-       public function resolveDefaultController () {
-               // Init variables
-               $commandName = "";
-               $controllerInstance = null;
-
-               // Try to resolv the command
-               try {
-                       // Get the command name 
-                       $commandName = $this->getCommandName();
-
-                       // Check if the command is valid
-                       if (!$this->isCommandValid($commandName)) {
-                               // This command is invalid!
-                               throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
-                       }
-
-                       // Get the command
-                       $controllerInstance = $this->loadController($commandName);
-
-                       // And validate it
-                       if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
-                               // This command has an invalid instance!
-                               throw new InvalidControllerInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_CONTROLLER);
-                       }
-
-                       // Set last command
-                       $this->lastCommandInstance = $controllerInstance;
-               } catch (MissingArrayElementsException $e) {
-                       // Just catch it here...
-               }
-
-               // Return the maybe resolved instance
-               return $controllerInstance;
-       }
-
-       /**
-        * "Loads" a given controller and instances it if not yet cached
-        *
-        * @param       $commandName                    A controller name we shall look for
-        * @return      $controllerInstance             A loaded controller instance
-        * @throws      DefaultControllerException      Thrown if even the default
-        *                                                                              controller class is missing (bad!)
-        */
-       private function loadController ($commandName) {
-               // Cache default command
-               $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
-
-               // Init controller instance
-               $controllerInstance = null;
-
-               // Default controller
-               $class = "LocalDefaultController";
-
-               // Generate the class name
-               if ($commandName != $defaultCommand) {
-                       // Create controller class name
-                       $class = sprintf("Local%sController",
-                               ucfirst(strtolower($commandName))
-                       );
-               } elseif ($this->getConfigInstance()->readConfig("home_with_news") == "Y") {
-                       // Yes, display news in home then set default controller with news
-                       $class = "LocalDefaultNewsController";
-               }
-
-               // Is this class loaded?
-               if (!class_exists($class)) {
-                       // Class not found, so try the default one or throw exception
-                       if ($commandName != $defaultCommand) {
-                               // Try the default controller
-                               return $this->loadController($defaultCommand);
-                       } else {
-                               // Still not found?
-                               throw new DefaultControllerException($this, self::EXCEPTION_DEFAUL_CONTROLLER_GONE);
-                       }
-               }
-
-               // Initiate the controller
-               $eval = sprintf("\$controllerInstance = %s::create%s(LocalCommandResolver::createLocalCommandResolver(\$commandName, \$this->getApplicationInstance()));",
-                       $class,
-                       $class
-               );
-
-               // Run the command
-               eval($eval);
-
-               // Is the instance valid?
-               if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
-                       // Something is wrong
-                       $controllerInstance = null;
-               }
-
-               // Return the result
-               return $controllerInstance;
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/resolver/web/.htaccess b/inc/classes/main/resolver/web/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/resolver/web/class_WebCommandResolver.php b/inc/classes/main/resolver/web/class_WebCommandResolver.php
new file mode 100644 (file)
index 0000000..30b31b5
--- /dev/null
@@ -0,0 +1,184 @@
+<?php
+/**
+ * A command resolver for local (non-hubbed) commands
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @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
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class WebCommandResolver extends BaseResolver implements CommandResolver {
+       /**
+        * Last successfull resolved command
+        */
+       private $lastCommandInstance = "";
+
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Lokaler Kommandoaufl&ouml;ser");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+
+               // Set prefix to "Web"
+               $this->setCommandPrefix("Web");
+       }
+
+       /**
+        * Creates an instance of a Web command resolver with a given default command
+        *
+        * @param       $defaultCommand                         The default command we shall execute
+        * @param       $appInstance                            An instance of a manageable application helper class
+        * @return      $resolverInstance                       The prepared command resolver instance
+        * @throws      EmptyVariableException          Thrown if the default command is not set
+        * @throws      InvalidCommandException         Thrown if the default command is invalid
+        */
+       public final static function createWebCommandResolver ($defaultCommand, ManageableApplication $appInstance) {
+               // Create the new instance
+               $resolverInstance = new WebCommandResolver();
+
+               // Is the variable $defaultCommand set and the command is valid?
+               if (empty($defaultCommand)) {
+                       // Then thrown an exception here
+                       throw new EmptyVariableException(array($resolverInstance, 'defaultCommand'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               } elseif (!$resolverInstance->isCommandValid($defaultCommand)) {
+                       // Invalid command found
+                       throw new InvalidCommandException(array($resolverInstance, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
+               }
+
+               // Set the application instance
+               $resolverInstance->setApplicationInstance($appInstance);
+
+               // Return the prepared instance
+               return $resolverInstance;
+       }
+
+       /**
+        * Returns an command instance for a given request class or null if
+        * MissingArrayElementsException was thrown
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @return      $commandInstance        An instance of the resolved command
+        * @throws      InvalidCommandException                         Thrown if $commandName is
+        *                                                                                              invalid
+        * @throws      InvalidCommandInstanceException         Thrown if $commandInstance
+        *                                                                                              is an invalid instance
+        */
+       public function resolvCommandByRequest (Requestable $requestInstance) {
+               // Init variables
+               $commandName = "";
+               $commandInstance = null;
+
+               // Test if the required parameter is set
+               try {
+                       // This goes fine so let's resolv the command
+                       $commandName = $requestInstance->getRequestElement($this->getConfigInstance()->readConfig("command_parameter"));
+
+                       // Is the command empty? Then fall back to default command
+                       if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig("default_command");
+
+                       // Check if the command is valid
+                       if (!$this->isCommandValid($commandName)) {
+                               // This command is invalid!
+                               throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+                       }
+
+                       // Get the command
+                       $commandInstance = $this->loadCommand($commandName);
+
+                       // And validate it
+                       if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
+                               // This command has an invalid instance!
+                               throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+                       }
+
+                       // Set last command
+                       $this->lastCommandInstance = $commandInstance;
+               } catch (MissingArrayElementsException $e) {
+                       // Just catch it here...
+               }
+
+               // Return the resolved command instance
+               return $commandInstance;
+       }
+
+       /**
+        * "Loads" a given command and instances it if not yet cached
+        *
+        * @param       $commandName                            A command name we shall look for
+        * @return      $commandInstance                        A loaded command instance
+        * @throws      InvalidCommandException         Thrown if even the default
+        *                                                                              command class is missing (bad!)
+        */
+       private function loadCommand ($commandName) {
+               // Cache default command
+               $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
+
+               // Init command instance
+               $commandInstance = null;
+
+               // Create command class name
+               $class = sprintf("Web%sCommand",
+                       ucfirst(strtolower($commandName))
+               );
+
+               // Is this class loaded?
+               if (!class_exists($class)) {
+                       // Class not found, so try the default one or throw exception
+                       if ($commandName != $defaultCommand) {
+                               // Try the default command
+                               return $this->loadCommand($defaultCommand);
+                       } else {
+                               // Still not found?
+                               throw new InvalidCommandException(array($this, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
+                       }
+               }
+
+               // Initiate the command
+               $eval = sprintf("\$commandInstance = %s::create%s(\$this);",
+                       $class,
+                       $class
+               );
+
+               // Run the command
+               eval($eval);
+
+               // Is the instance valid?
+               if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
+                       // Something is wrong
+                       $commandInstance = null;
+               }
+
+               // Return the result
+               return $commandInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/resolver/web/class_WebControllerResolver.php b/inc/classes/main/resolver/web/class_WebControllerResolver.php
new file mode 100644 (file)
index 0000000..c3bebd5
--- /dev/null
@@ -0,0 +1,189 @@
+<?php
+/**
+ * A resolver for resolving controllers locally
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @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
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class WebControllerResolver extends BaseResolver implements ControllerResolver {
+       /**
+        * Last successfull resolved controller
+        */
+       private $lastControllerName = "";
+
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("");
+
+               // Create unique ID number
+               $this->createUniqueID();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+
+               // Set prefix to "Web"
+               $this->setCommandPrefix("Web");
+       }
+
+       /**
+        * Creates an instance of a resolver class with a given command
+        *
+        * @param       $commandName                            The default command we shall execute
+        * @param       $appInstance                            An instance of a manageable application helper class
+        * @return      $resolverInstance                       The prepared command resolver instance
+        * @throws      EmptyVariableException          Thrown if the default command is not set
+        * @throws      InvalidCommandException         Thrown if the default command is invalid
+        */
+       public final static function createWebControllerResolver ($commandName, ManageableApplication $appInstance) {
+               // Create the new instance
+               $resolverInstance = new WebControllerResolver();
+
+               // Is the variable $commandName set and the command is valid?
+               if (empty($commandName)) {
+                       // Then thrown an exception here
+                       throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               } elseif (!$resolverInstance->isCommandValid($commandName)) {
+                       // Invalid command found
+                       throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
+               }
+
+               // Set the application instance
+               $resolverInstance->setApplicationInstance($appInstance);
+
+               // Return the prepared instance
+               return $resolverInstance;
+       }
+
+       /**
+        * Resolves the default controller of the given command
+        *
+        * @return      $controllerInstance             A controller instance for the default
+        *                                                                      command
+        * @throws      InvalidCommandException                         Thrown if $commandName is
+        *                                                                                              invalid
+        * @throws      InvalidControllerInstanceException      Thrown if $commandInstance
+        *                                                                                              is invalid
+        */
+       public function resolveDefaultController () {
+               // Init variables
+               $commandName = "";
+               $controllerInstance = null;
+
+               // Try to resolv the command
+               try {
+                       // Get the command name 
+                       $commandName = $this->getCommandName();
+
+                       // Check if the command is valid
+                       if (!$this->isCommandValid($commandName)) {
+                               // This command is invalid!
+                               throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+                       }
+
+                       // Get the command
+                       $controllerInstance = $this->loadController($commandName);
+
+                       // And validate it
+                       if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
+                               // This command has an invalid instance!
+                               throw new InvalidControllerInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_CONTROLLER);
+                       }
+
+                       // Set last command
+                       $this->lastCommandInstance = $controllerInstance;
+               } catch (MissingArrayElementsException $e) {
+                       // Just catch it here...
+               }
+
+               // Return the maybe resolved instance
+               return $controllerInstance;
+       }
+
+       /**
+        * "Loads" a given controller and instances it if not yet cached
+        *
+        * @param       $commandName                    A controller name we shall look for
+        * @return      $controllerInstance             A loaded controller instance
+        * @throws      DefaultControllerException      Thrown if even the default
+        *                                                                              controller class is missing (bad!)
+        */
+       private function loadController ($commandName) {
+               // Cache default command
+               $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
+
+               // Init controller instance
+               $controllerInstance = null;
+
+               // Default controller
+               $class = "WebDefaultController";
+
+               // Generate the class name
+               if ($commandName != $defaultCommand) {
+                       // Create controller class name
+                       $class = sprintf("Web%sController",
+                               ucfirst(strtolower($commandName))
+                       );
+               } elseif ($this->getConfigInstance()->readConfig("home_with_news") == "Y") {
+                       // Yes, display news in home then set default controller with news
+                       $class = "WebDefaultNewsController";
+               }
+
+               // Is this class loaded?
+               if (!class_exists($class)) {
+                       // Class not found, so try the default one or throw exception
+                       if ($commandName != $defaultCommand) {
+                               // Try the default controller
+                               return $this->loadController($defaultCommand);
+                       } else {
+                               // Still not found?
+                               throw new DefaultControllerException($this, self::EXCEPTION_DEFAUL_CONTROLLER_GONE);
+                       }
+               }
+
+               // Initiate the controller
+               $eval = sprintf("\$controllerInstance = %s::create%s(WebCommandResolver::createWebCommandResolver(\$commandName, \$this->getApplicationInstance()));",
+                       $class,
+                       $class
+               );
+
+               // Run the command
+               eval($eval);
+
+               // Is the instance valid?
+               if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
+                       // Something is wrong
+                       $controllerInstance = null;
+               }
+
+               // Return the result
+               return $controllerInstance;
+       }
+}
+
+// [EOF]
+?>