- Added a lot templates from shipsimu project (as they both are browser-based games)
- Renamed class (again)
- Other improvements
- Updated 'core' to latest revision
Signed-off-by: Roland Haeder <roland@mxchange.org>
// Get a controller instance as well
$this->setControllerInstance($resolverInstance->resolveController());
- // Launch the test suite here
+ // Initialize language system
+ $languageInstance = ObjectFactory::createObjectByConfiguredName('language_system_class');
+
+ // And set it here
+ $this->setLanguageInstance($languageInstance);
+
+ // Launch the game here
$this->getControllerInstance()->handleRequest($requestInstance, $responseInstance);
// -------------------------- Shutdown phase --------------------------
$cfg = FrameworkConfiguration::getSelfInstance();
// CFG: DEFAULT-HTML-COMMAND
-$cfg->setConfigEntry('default_html_command', 'main');
+$cfg->setConfigEntry('default_html_command', 'home');
-// CFG: HTML-CMD-MAIN-RESOLVER-CLASS
-$cfg->setConfigEntry('html_cmd_main_resolver_class', 'CityHtmlCommandResolver');
+// CFG: HTML-CMD-HOME-RESOLVER-CLASS
+$cfg->setConfigEntry('html_cmd_home_resolver_class', 'CityHtmlCommandResolver');
// CFG: NEWS-DOWNLOAD-FILTER
$cfg->setConfigEntry('news_download_filter', 'NewsDownloadFilter');
// CFG: NEWS-READER-CLASS
$cfg->setConfigEntry('news_reader_class', 'ConsoleNewsReader');
-// CFG: NEWS-MAIN-LIMIT
-$cfg->setConfigEntry('news_main_limit', 10);
+// CFG: NEWS-HOME-LIMIT
+$cfg->setConfigEntry('news_home_limit', 10);
+
+// CFG: CITY-HOME-MENU-CLASS
+$cfg->setConfigEntry('city_home_menu_class', 'CityHomeMenu');
+
+// CFG: MENU-TEMPLATE-CLASS
+$cfg->setConfigEntry('menu_template_class', 'MenuTemplateEngine');
+
+// CFG: MENU-TEMPLATE-EXTENSION
+$cfg->setConfigEntry('menu_template_extension', '.xml');
// [EOF]
?>
--- /dev/null
+<?php
+/**
+ * A command for the 'main' routine
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHtmlHomeCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $commandInstance An instance a prepared command class
+ */
+ public static final function createCityHtmlHomeCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new CityHtmlHomeCommand();
+
+ // Set the application instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * Executes the given command with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @todo ~10% done?
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get the application instance
+ $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
+
+ // Prepare a template instance
+ $templateInstance = $this->prepareTemplateInstance($applicationInstance);
+
+ // Transfer application data
+ $templateInstance->assignApplicationData($applicationInstance);
+
+ // Load the master template
+ $masterTemplate = $applicationInstance->buildMasterTemplateName();
+
+ // Load header template
+ $templateInstance->loadCodeTemplate('header');
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('header', 'header');
+
+ // Load footer template
+ $templateInstance->loadCodeTemplate('footer');
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable('footer', 'footer');
+
+ // Load the home template
+ $templateInstance->loadCodeTemplate('home');
+
+ // Assign the home template with the master template as a content ... ;)
+ $templateInstance->assignTemplateWithVariable('city_home', 'content');
+
+ // Load the master template
+ $templateInstance->loadCodeTemplate($masterTemplate);
+
+ // Set title
+ $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_city_home_title'));
+
+ // Construct the menu in every command. We could do this in BaseCommand class. But this means
+ // *every* command has a navigation system and that is want we don't want.
+ $menuInstance = ObjectFactory::createObjectByConfiguredName('city_home_menu_class', array($applicationInstance));
+
+ // Render the menu
+ $menuInstance->renderMenu();
+
+ // Transfer it to the template engine instance
+ $menuInstance->transferContentToTemplateEngine($templateInstance);
+
+ // ... and all variables. This should be merged together in a pattern
+ // to make things easier. A cache mechanism should be added between
+ // these two calls to cache compiled templates.
+ $templateInstance->compileVariables();
+
+ // Get the content back from the template engine and put it in response class
+ $templateInstance->transferToResponse($responseInstance);
+ }
+
+ /**
+ * Adds extra filters to the given controller instance
+ *
+ * @param $controllerInstance A controller instance
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @return void
+ * @todo 0% done
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Add pre filters
+ //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_php_requirements_filter'));
+ }
+}
+
+// [EOF]
+?>
+++ /dev/null
-<?php
-/**
- * A command for the 'main' routine
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 CityHtmlMainCommand extends BaseCommand implements Commandable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $commandInstance An instance a prepared command class
- */
- public static final function createCityHtmlMainCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new CityHtmlMainCommand();
-
- // Set the application instance
- $commandInstance->setResolverInstance($resolverInstance);
-
- // Return the prepared instance
- return $commandInstance;
- }
-
- /**
- * Executes the given command with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @todo ~10% done?
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get a registry and the application instance from it
- $applicationInstance = Registry::getRegistry()->getInstance('app');
- }
-
- /**
- * Adds extra filters to the given controller instance
- *
- * @param $controllerInstance A controller instance
- * @param $requestInstance An instance of a class with an Requestable interface
- * @return void
- * @todo 0% done
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Add pre filters
- //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_php_requirements_filter'));
- }
-}
-
-// [EOF]
-?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A menu class for City
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 CityHomeMenu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public static final function createCityHomeMenu () {
+ // Get a new instance
+ $menuInstance = new CityHomeMenu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
// Some sanity checks
if ((empty($app)) || (is_null($app))) {
// Something went wrong!
- ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because the helper class <span class=\"class_name\">%s</span> is not loaded.",
+ ApplicationEntryPoint::app_exit(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the helper class <span class="class_name">%s</span> is not loaded.',
$application,
FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class')
));
} elseif (!is_object($app)) {
// No object!
- ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because 'app' is not an object.",
+ ApplicationEntryPoint::app_exit(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because 'app' is not an object.',
$application
));
} elseif (!method_exists($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method'))) {
// Method not found!
- ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because the method <span class=\"method_name\">%s</span> is missing.",
+ ApplicationEntryPoint::app_exit(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the method <span class="method_name">%s</span> is missing.',
$application,
FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method')
));
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<div id="content_main">
+ Bla bla ...
+</div>
--- /dev/null
+</div> <!-- masterbox //-->
+
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
+<head>
+ <title>
+ {?app_full_name?} - {?title?}
+ </title>
+
+ <meta name="author" content="$config[meta_author]" />
+ <meta name="publisher" content="$config[meta_publisher]" />
+ <meta name="keywords" content="$config[meta_keywords]" />
+ <meta name="robots" content="index,follow" />
+ <meta name="description" content="$config[meta_description]" />
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="content-style-type" content="text/css" />
+ <meta http-equiv="content-script-type" content="text/javascript" />
+ <meta http-equiv="language" content="de" />
+ {?header_extras_hook?}
+</head>
+
+<body>
+<div id="masterbox">
--- /dev/null
+<div id="content_header">
+ Willkommen zum <span class="app_name">{?app_full_name?}</span>
+</div>
+
+<div id="news_frame">
+ {?city_news?}
+</div>
--- /dev/null
+Deny from all
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+A general menu XML file. We should later on convert this into a DTD.
+
+@author Roland Haeder <webmaster@ship-simu.org>
+@version 0.0.0
+@copyright Copyright (c) 2015 City Developer Team
+@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/>
+//-->
+<menu>
+ <block-list block-count="{?block_count?}">
+ <block>
+ <block-header>
+ <title>
+ <title-id>{?menu_title_id?}</title-id>
+ <title-class>{!menu_title_class?}</title-class>
+ <title-text>{?menu_title?}</title-text>
+ </title>
+ </block-header>
+ <entry-list entry-count="{?entry_count?}">
+ <entry>
+ <entry-id>{?entry_id?}</entry-id>
+ <anchor>
+ <anchor-id>{?anchor_id?}</anchor-id>
+ <anchor-text>{?anchor_text?}</anchor-text>
+ <anchor-title>{?anchor_title?}</anchor-title>
+ <anchor-href>{?anchor_href?}</anchor-href>
+ </anchor>
+ </entry>
+ </entry-list>
+ <block-footer>
+ <footer-id>{!footer_id?}</footer>
+ <footer-class>{?footer_design_class?}</footer-class>
+ <footer-text>{?menu_footer?}</footer-text>
+ </block-footer>
+ </block>
+ </block-list>
+</menu>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+Generic menu entries. You should leave this template for smooth upgrades.
+
+@author Roland Haeder <webmaster@ship-simu.org>
+@version 0.0.0
+@copyright Copyright (c) 2015 City Developer Team
+@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/>
+//-->
+<menu>
+ <block-list block-count="{?block_count?}">
+ <block>
+ <block-header>
+ <title>
+ <title-id><![CDATA[home_menu_title]]></title-id>
+ <title-class><![CDATA[menu_title]]></title-class>
+ <title-text><![CDATA[Home:]]></title-text>
+ </title>
+ </block-header>
+ <entry-list entry-count="{?entry_count?}">
+ <entry>
+ <entry-id><![CDATA[home_entry]]></entry-id>
+ <anchor>
+ <anchor-id><![CDATA[menu_home]]></anchor-id>
+ <anchor-text><![CDATA[Home]]></anchor-text>
+ <anchor-title><![CDATA[Zur Startseite]]></anchor-title>
+ <anchor-href><![CDATA[index.php?app={?app_short_name?}]]></anchor-href>
+ </anchor>
+ </entry>
+ <entry>
+ <entry-id><![CDATA[login_entry]]></entry-id>
+ <anchor>
+ <anchor-id><![CDATA[menu_login]]></anchor-id>
+ <anchor-text><![CDATA[Einloggen]]></anchor-text>
+ <anchor-title><![CDATA[Zum Spiel {?app_name?} einloggen]]></anchor-title>
+ <anchor-href><![CDATA[index.php?app={?app_short_name?}&page=login]]></anchor-href>
+ </anchor>
+ </entry>
+ <entry>
+ <entry-id><![CDATA[register_entry]]></entry-id>
+ <anchor>
+ <anchor-id><![CDATA[menu_register]]></anchor-id>
+ <anchor-text><![CDATA[Anmeldung]]></anchor-text>
+ <anchor-title><![CDATA[Zur Anmeldeseite]]></anchor-title>
+ <anchor-href><![CDATA[index.php?app={?app_short_name?}&page=register]]></anchor-href>
+ </anchor>
+ </entry>
+ <entry>
+ <entry-id><![CDATA[pillory_entry]]></entry-id>
+ <anchor>
+ <anchor-id><![CDATA[menu_pillory]]></anchor-id>
+ <anchor-text><![CDATA[Pranger]]></anchor-text>
+ <anchor-title><![CDATA[Zum Pranger]]></anchor-title>
+ <anchor-href><![CDATA[index.php?app={?app_short_name?}&page=pillory]]></anchor-href>
+ </anchor>
+ </entry>
+ </entry-list>
+ <block-footer>
+ <footer-id><![CDATA[home_menu_footer]]></footer-id>
+ <footer-class><![CDATA[menu_footer]]></footer-class>
+ <footer-text><![CDATA[Leer]]></footer-text>
+ </block-footer>
+ </block>
+ <block>
+ <block-header>
+ <title>
+ <title-id><![CDATA[law_menu_title]]></title-id>
+ <title-class><![CDATA[menu_title]]></title-class>
+ <title-text><![CDATA[Rechtliches:]]></title-text>
+ </title>
+ </block-header>
+ <entry-list entry-count="{?entry_count?}">
+ <entry>
+ <entry-id><![CDATA[imprint_entry]]></entry-id>
+ <anchor>
+ <anchor-id><![CDATA[menu_imprint]]></anchor-id>
+ <anchor-text><![CDATA[Impressum]]></anchor-text>
+ <anchor-title><![CDATA[Impressum]]></anchor-title>
+ <anchor-href><![CDATA[index.php?app={?app_short_name?}&page=imprint]]></anchor-href>
+ </anchor>
+ </entry>
+ <entry>
+ <entry-id><![CDATA[terms_entry]]></entry-id>
+ <anchor>
+ <anchor-id><![CDATA[menu_terms]]></anchor-id>
+ <anchor-text><![CDATA[ANBs]]></anchor-text>
+ <anchor-title><![CDATA[Allgemeine Nutzungsbedingungen]]></anchor-title>
+ <anchor-href><![CDATA[index.php?app={?app_short_name?}&page=terms]]></anchor-href>
+ </anchor>
+ </entry>
+ </entry-list>
+ <block-footer>
+ <footer-id><![CDATA[law_menu_footer]]></footer-id>
+ <footer-class><![CDATA[menu_footer]]></footer-class>
+ <footer-text><![CDATA[Leer]]></footer-text>
+ </block-footer>
+ </block>
+ </block-list>
+</menu>
-Subproject commit c22c08adbf7134688c55e78546510348b24ceb8f
+Subproject commit 19e333c1363fa81bed69403baa8e0125fa318884