From: Roland Haeder Date: Sun, 16 Aug 2015 09:12:58 +0000 (+0200) Subject: First initial import for a web interface, this will later allow to browse and X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=06b93d16462a541848b8944bcfe17b70a2831c46;p=hub.git First initial import for a web interface, this will later allow to browse and search within the hub network. Signed-off-by: Roland Haeder --- diff --git a/application/hub/class_ApplicationHelper.php b/application/hub/class_ApplicationHelper.php index a44051c98..ad4d8626a 100644 --- a/application/hub/class_ApplicationHelper.php +++ b/application/hub/class_ApplicationHelper.php @@ -194,6 +194,15 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica $requestInstance->setRequestElement('command', $commandName); } // END - if + // Is the responseType 'html' ? + if ($responseType == 'html') { + // The language system is needed for this + $languageInstance = ObjectFactory::createObjectByConfiguredName('language_system_class'); + + // And set it here + $this->setLanguageInstance($languageInstance); + } // END - if + // Get a controller resolver $resolverClass = self::convertToClassName($this->getAppShortName() . '_' . $responseType . '_controller_resolver'); $resolverInstance = ObjectFactory::createObjectByName($resolverClass, array($commandName, $this)); @@ -204,12 +213,15 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica // Launch the hub main routine here $this->getControllerInstance()->handleRequest($requestInstance, $responseInstance); - // -------------------------- Shutdown phase -------------------------- - // Shutting down the hub by saying "good bye" to all connected peers - // and other hubs, flushing all queues and caches. - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: Shutdown in progress, main loop exited.'); - $this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance); - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: Shutdown completed. (This is the last line.)'); + // Only for console requests as this is the actual daemon + if ($responseType == 'console') { + // -------------------------- Shutdown phase -------------------------- + // Shutting down the hub by saying "good bye" to all connected peers + // and other hubs, flushing all queues and caches. + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: Shutdown in progress, main loop exited.'); + $this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance); + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: Shutdown completed. (This is the last line.)'); + } // END - if } /** diff --git a/application/hub/config.php b/application/hub/config.php index b4c67a00e..c71f66f93 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -357,9 +357,6 @@ $cfg->setConfigEntry('node_dht_bootstrap_template_type', 'xml/dht_bootstrap'); // CFG: DHT-PUBLISH-TEMPLATE-TYPE $cfg->setConfigEntry('node_dht_publish_template_type', 'xml/dht_publish'); -// CFG: CODE-TEMPLATE-TYPE -$cfg->setConfigEntry('code_template_type', 'xml'); - // CFG: RAW-TEMPLATE-EXTENSION (to speed-up things) $cfg->setConfigEntry('raw_template_extension', '.xml'); @@ -1487,19 +1484,6 @@ $cfg->setConfigEntry('crawler_csv_file_path', 'data/url_lists'); // CFG: CRAWLER-URL-LIST-COLUMN-SEPARATOR $cfg->setConfigEntry('crawler_url_list_column_separator', ','); -/////////////////////////////////////////////////////////////////////////////// -// HTTP Configuration -/////////////////////////////////////////////////////////////////////////////// - -// CFG: DEFAULT-WEB-COMMAND -$cfg->setConfigEntry('default_web_command', 'home'); - -// CFG: WEB-CMD-HOME-RESOLVER-CLASS -$cfg->setConfigEntry('web_cmd_home_resolver_class', 'WebCommandResolver'); - -// CFG: NEWS-HOME-LIMIT -$cfg->setConfigEntry('news_home_limit', 10); - /////////////////////////////////////////////////////////////////////////////// // Apt-Proxy Configuration /////////////////////////////////////////////////////////////////////////////// @@ -1543,5 +1527,27 @@ $cfg->setConfigEntry('task_apt_proxy_listener_interval_delay', 10); // CFG: TASK-APT-PROXY-LISTENER-MAX-RUNS $cfg->setConfigEntry('task_apt_proxy_listener_max_runs', 0); +/////////////////////////////////////////////////////////////////////////////// +// HTML interface // +/////////////////////////////////////////////////////////////////////////////// + +// CFG: DEFAULT-HUB-HTML-COMMAND +$cfg->setConfigEntry('default_hub_html_command', 'index'); + +// CFG: DEFAULT-HTML-CONTROLLER +$cfg->setConfigEntry('default_html_controller', 'index'); + +// CFG: HTML-CMD-INDEX-RESOLVER-CLASS +$cfg->setConfigEntry('html_cmd_index_resolver_class', 'HubHtmlCommandResolver'); + +// CFG: NEWS-READER-INDEX-CLASS +$cfg->setConfigEntry('news_reader_index_class', 'DefaultNewsReader'); + +// CFG: NEWS-INDEX-LIMIT +$cfg->setConfigEntry('news_index_limit', 10); + +// CFG: HUB-INDEX-MENU-CLASS +$cfg->setConfigEntry('hub_index_menu_class', 'HubIndexMenu'); + // [EOF] ?> diff --git a/application/hub/language/.htaccess b/application/hub/language/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/language/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/commands/html/.htaccess b/application/hub/main/commands/html/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/commands/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/commands/html/class_HubHtmlIndexCommand.php b/application/hub/main/commands/html/class_HubHtmlIndexCommand.php new file mode 100644 index 000000000..e56eeb890 --- /dev/null +++ b/application/hub/main/commands/html/class_HubHtmlIndexCommand.php @@ -0,0 +1,91 @@ + + * @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 HubHtmlIndexCommand 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 createHubHtmlIndexCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HubHtmlIndexCommand(); + + // 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 + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // This command doesn't handle any POST requests, so only handle get request + if ($requestInstance->isPostRequestMethod()) { + // Don't handle this here + $response->sendRequestMethodNotAllowed(); + + // Bail out + exit(); + } // END - if + + /* + * This is a generic HTML request, this means that a regular page with + * header, menu, content and footer shall be send to the client. + */ + $this->sendGenericGetResponse($requestInstance, $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/hub/main/menu/.htaccess b/application/hub/main/menu/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/menu/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/menu/class_Hub b/application/hub/main/menu/class_Hub new file mode 100644 index 000000000..e518971c6 --- /dev/null +++ b/application/hub/main/menu/class_Hub @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub 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 . + */ +class Hub???Menu 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 final static function createHub???Menu () { + // Get a new instance + $menuInstance = new Hub???Menu(); + + // Return the prepared instance + return $menuInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/menu/class_HubIndexMenu.php b/application/hub/main/menu/class_HubIndexMenu.php new file mode 100644 index 000000000..2b004eb1b --- /dev/null +++ b/application/hub/main/menu/class_HubIndexMenu.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 2007 - 2008 Roland Haeder, 2009 - Hub 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 HubIndexMenu 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 createHubIndexMenu () { + // Get a new instance + $menuInstance = new HubIndexMenu(); + + // Return the prepared instance + return $menuInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/resolver/command/html/.htaccess b/application/hub/main/resolver/command/html/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/resolver/command/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/resolver/command/html/class_HubHtmlCommandResolver.php b/application/hub/main/resolver/command/html/class_HubHtmlCommandResolver.php new file mode 100644 index 000000000..95841f395 --- /dev/null +++ b/application/hub/main/resolver/command/html/class_HubHtmlCommandResolver.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub 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 HubHtmlCommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "HubHtml" + $this->setClassPrefix('hub_html'); + } + + /** + * Creates an instance of a HubHtml command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidCommandException Thrown if default command is invalid + */ + public static final function createHubHtmlCommandResolver ($commandName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new HubHtmlCommandResolver(); + + // 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) === FALSE) { + // Invalid command found + throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Return the prepared instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/resolver/controller/html/class_HubHtmlControllerResolver.php b/application/hub/main/resolver/controller/html/class_HubHtmlControllerResolver.php index 738aa3a2c..1376a827e 100644 --- a/application/hub/main/resolver/controller/html/class_HubHtmlControllerResolver.php +++ b/application/hub/main/resolver/controller/html/class_HubHtmlControllerResolver.php @@ -31,8 +31,8 @@ class HubHtmlControllerResolver extends BaseControllerResolver implements Contro // Call parent constructor parent::__construct(__CLASS__); - // Set prefix to 'Web' - $this->setClassPrefix('Web'); + // Set prefix to 'Html' + $this->setClassPrefix('Html'); } /** diff --git a/application/hub/templates/de/.htaccess b/application/hub/templates/de/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/templates/de/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/templates/de/code/.htaccess b/application/hub/templates/de/code/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/templates/de/code/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/templates/de/code/footer.ctp b/application/hub/templates/de/code/footer.ctp new file mode 100644 index 000000000..aa82e6817 --- /dev/null +++ b/application/hub/templates/de/code/footer.ctp @@ -0,0 +1,4 @@ + + + + diff --git a/application/hub/templates/de/code/header.ctp b/application/hub/templates/de/code/header.ctp new file mode 100644 index 000000000..6f2518ff5 --- /dev/null +++ b/application/hub/templates/de/code/header.ctp @@ -0,0 +1,21 @@ + + + + + {?app_full_name?} - {?title?} + + + + + + + + + + + + {?header_extras_hook?} + + + +
diff --git a/application/hub/templates/de/code/index.ctp b/application/hub/templates/de/code/index.ctp new file mode 100644 index 000000000..9bf9da7e4 --- /dev/null +++ b/application/hub/templates/de/code/index.ctp @@ -0,0 +1,11 @@ +
+ Willkommen zum {?app_full_name?} +
+ +
+ {?hub_news?} +
+ +
+ Hier kommt noch vieles dazu. +
diff --git a/application/hub/templates/de/code/menu_block.ctp b/application/hub/templates/de/code/menu_block.ctp new file mode 100644 index 000000000..454ccf1d2 --- /dev/null +++ b/application/hub/templates/de/code/menu_block.ctp @@ -0,0 +1,11 @@ +
+ {?title_text?} +
+ +
    +{?block_content?} +
+ +
+ {?footer_text?} +
diff --git a/application/hub/templates/de/code/menu_entry.ctp b/application/hub/templates/de/code/menu_entry.ctp new file mode 100644 index 000000000..e30bd8c85 --- /dev/null +++ b/application/hub/templates/de/code/menu_entry.ctp @@ -0,0 +1,3 @@ +
  • + {?anchor_text?} +
  • diff --git a/application/hub/templates/de/code/node_main.ctp b/application/hub/templates/de/code/node_main.ctp new file mode 100644 index 000000000..c3cd3b7b7 --- /dev/null +++ b/application/hub/templates/de/code/node_main.ctp @@ -0,0 +1,29 @@ +{?header?} + +
    +
    + {?hub_header?} +
    + + + + + +
    + {?language_selector?} +
    + +
    + {?main_content?} +
    + + +
    + +{?footer?} diff --git a/application/hub/templates/de/menu/.htaccess b/application/hub/templates/de/menu/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/templates/de/menu/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/templates/de/menu/generic_menu_entries.xml b/application/hub/templates/de/menu/generic_menu_entries.xml new file mode 100644 index 000000000..43b4a6dc4 --- /dev/null +++ b/application/hub/templates/de/menu/generic_menu_entries.xml @@ -0,0 +1,54 @@ + + + + + + + + <title-id><![CDATA[index_menu_title]]></title-id> + <title-class><![CDATA[menu_title]]></title-class> + <title-text><![CDATA[Home:]]></title-text> + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core b/core index 23aa45d4a..993f346ec 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 23aa45d4a6205e26184190ca446316d06a9b4648 +Subproject commit 993f346ece437f25fbdba2643f3011cbc1860611