From: Roland Haeder Date: Tue, 24 Mar 2015 00:36:44 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4e55bcf00e54f69328f8de3a1aaee1067dabf2c1;p=city.git Continued: - 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 --- diff --git a/application/city/class_ApplicationHelper.php b/application/city/class_ApplicationHelper.php index c655ea2..ca061e4 100644 --- a/application/city/class_ApplicationHelper.php +++ b/application/city/class_ApplicationHelper.php @@ -195,7 +195,13 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica // 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 -------------------------- diff --git a/application/city/config.php b/application/city/config.php index af7d9ed..a221c83 100644 --- a/application/city/config.php +++ b/application/city/config.php @@ -25,10 +25,10 @@ $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'); @@ -39,8 +39,17 @@ $cfg->setConfigEntry('news_process_filter', 'NewsProcessFilter'); // 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] ?> diff --git a/application/city/main/commands/html/class_CityHtmlHomeCommand.php b/application/city/main/commands/html/class_CityHtmlHomeCommand.php new file mode 100644 index 0000000..1e80dbf --- /dev/null +++ b/application/city/main/commands/html/class_CityHtmlHomeCommand.php @@ -0,0 +1,133 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/main/commands/html/class_CityHtmlMainCommand.php b/application/city/main/commands/html/class_CityHtmlMainCommand.php deleted file mode 100644 index 826144d..0000000 --- a/application/city/main/commands/html/class_CityHtmlMainCommand.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @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 . - */ -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] -?> diff --git a/application/city/main/menu/.htaccess b/application/city/main/menu/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/menu/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/menu/class_CityHomeMenu.php b/application/city/main/menu/class_CityHomeMenu.php new file mode 100644 index 0000000..b80e67f --- /dev/null +++ b/application/city/main/menu/class_CityHomeMenu.php @@ -0,0 +1,50 @@ + + * @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 . + */ +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] +?> diff --git a/application/city/starter.php b/application/city/starter.php index d9dd2d8..b157f5c 100644 --- a/application/city/starter.php +++ b/application/city/starter.php @@ -33,18 +33,18 @@ $app = call_user_func_array( // Some sanity checks if ((empty($app)) || (is_null($app))) { // Something went wrong! - ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s could not be launched because the helper class %s is not loaded.", + ApplicationEntryPoint::app_exit(sprintf('[Main:] The application %s could not be launched because the helper class %s is not loaded.', $application, FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class') )); } elseif (!is_object($app)) { // No object! - ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s could not be launched because 'app' is not an object.", + ApplicationEntryPoint::app_exit(sprintf('[Main:] The application %s 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 %s could not be launched because the method %s is missing.", + ApplicationEntryPoint::app_exit(sprintf('[Main:] The application %s could not be launched because the method %s is missing.', $application, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method') )); diff --git a/application/city/templates/de/.htaccess b/application/city/templates/de/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/templates/de/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/templates/de/code/.htaccess b/application/city/templates/de/code/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/templates/de/code/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/templates/de/code/city_main.ctp b/application/city/templates/de/code/city_main.ctp new file mode 100644 index 0000000..142c1dc --- /dev/null +++ b/application/city/templates/de/code/city_main.ctp @@ -0,0 +1,3 @@ +
+ Bla bla ... +
diff --git a/application/city/templates/de/code/footer.ctp b/application/city/templates/de/code/footer.ctp new file mode 100644 index 0000000..aa82e68 --- /dev/null +++ b/application/city/templates/de/code/footer.ctp @@ -0,0 +1,4 @@ + + + + diff --git a/application/city/templates/de/code/header.ctp b/application/city/templates/de/code/header.ctp new file mode 100644 index 0000000..ed67731 --- /dev/null +++ b/application/city/templates/de/code/header.ctp @@ -0,0 +1,21 @@ + + + + + {?app_full_name?} - {?title?} + + + + + + + + + + + + {?header_extras_hook?} + + + +
diff --git a/application/city/templates/de/code/home.ctp b/application/city/templates/de/code/home.ctp new file mode 100644 index 0000000..72fd839 --- /dev/null +++ b/application/city/templates/de/code/home.ctp @@ -0,0 +1,7 @@ +
+ Willkommen zum {?app_full_name?} +
+ +
+ {?city_news?} +
diff --git a/application/city/templates/de/menu/.htaccess b/application/city/templates/de/menu/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/templates/de/menu/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/templates/de/menu/base_menu.xml b/application/city/templates/de/menu/base_menu.xml new file mode 100644 index 0000000..568cf5b --- /dev/null +++ b/application/city/templates/de/menu/base_menu.xml @@ -0,0 +1,52 @@ + + + + + + + + <title-id>{?menu_title_id?}</title-id> + <title-class>{!menu_title_class?}</title-class> + <title-text>{?menu_title?}</title-text> + + + + + {?entry_id?} + + {?anchor_id?} + {?anchor_text?} + {?anchor_title?} + {?anchor_href?} + + + + + {!footer_id?} + {?footer_design_class?} + {?menu_footer?} + + + + diff --git a/application/city/templates/de/menu/generic_menu_entries.xml b/application/city/templates/de/menu/generic_menu_entries.xml new file mode 100644 index 0000000..67190e3 --- /dev/null +++ b/application/city/templates/de/menu/generic_menu_entries.xml @@ -0,0 +1,113 @@ + + + + + + + + <title-id><![CDATA[home_menu_title]]></title-id> + <title-class><![CDATA[menu_title]]></title-class> + <title-text><![CDATA[Home:]]></title-text> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <title-id><![CDATA[law_menu_title]]></title-id> + <title-class><![CDATA[menu_title]]></title-class> + <title-text><![CDATA[Rechtliches:]]></title-text> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core b/core index c22c08a..19e333c 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit c22c08adbf7134688c55e78546510348b24ceb8f +Subproject commit 19e333c1363fa81bed69403baa8e0125fa318884