* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplication {
/**
*/
private $shortName = "";
+ /**
+ * The name of the master template
+ */
+ private $masterTemplate = "shipsimu_main";
+
/**
* An instance of this class
*/
private static $thisInstance = null;
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
- $this->setPartDescr("Application-Helper");
+ $this->setObjectDescription("Application-Helper");
// Create an unique ID
$this->createUniqueID();
/**
* Getter for the version number
*
- * @return $appVersion The application's version number
+ * @return $appVersion The application's version number
*/
public final function getAppVersion () {
return $this->appVersion;
/**
* Setter for the version number
*
- * @param $appVersion The application's version number
+ * @param $appVersion The application's version number
* @return void
*/
public final function setAppVersion ($appVersion) {
/**
* Setter for human-readable name
*
- * @param $appName The application's human-readable name
+ * @param $appName The application's human-readable name
* @return void
*/
public final function setAppName ($appName) {
/**
* Setter for short uni*-like name
*
- * @param $shortName The application's short uni*-like name
+ * @param $shortName The application's short uni*-like name
* @return void
*/
public final function setAppShortName ($shortName) {
$this->shortName = $shortName;
}
+ /**
+ * Getter for master template name
+ *
+ * @return $masterTemplate Name of the master template
+ */
+ public final function getMasterTemplate () {
+ return $this->masterTemplate;
+ }
+
/**
* Launches the ship-simulator game
*
* @return void
*/
public final function entryPoint () {
- // Handle the request
+ // Create a new request object
+ $requestInstance = HttpRequest::createHttpRequest();
+
+ // ... and a new response object
+ $responseInstance = HttpResponse::createHttpResponse($this);
- // Prepare the template engine
- $tplEngine = $this->prepareTemplateEngine($this);
+ // Get command parameter
+ $commandPara = $this->getConfigInstance()->readConfig("command_parameter");
- // Load the main template
- $tplEngine->loadCodeTemplate("shipsimu_main");
+ // Get the parameter from the request
+ $commandName = $requestInstance->getRequestElement($commandPara);
+
+ // If it is null then get default command
+ if (is_null($commandName)) {
+ $commandName = $this->getConfigInstance()->readConfig("default_command");
+ }
- // Raise an error here
- trigger_error(__METHOD__.": Unfinished work!");
+ // Get a resolver
+ $resolverInstance = WebControllerResolver::createWebControllerResolver($commandName, $this);
+
+ // Get a new controller instance as well
+ $controllerInstance = $resolverInstance->resolveDefaultController();
+
+ // Handle the request
+ $controllerInstance->handleRequest($requestInstance, $responseInstance);
}
}