From: Roland Häder Date: Fri, 3 Oct 2008 01:00:31 +0000 (+0000) Subject: Application init phase rewritten, data.php now sets app data X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=commitdiff_plain;h=21a25cc77b1108c7e33d4ce55b1a85970b355de2 Application init phase rewritten, data.php now sets app data --- diff --git a/.gitattributes b/.gitattributes index 616fec2..e57ab49 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,6 +4,7 @@ application/.htaccess -text application/blog/.htaccess -text application/blog/class_ApplicationHelper.php -text application/blog/config.php -text +application/blog/data.php -text application/blog/debug.php -text application/blog/exceptions.php -text application/blog/exceptions/.htaccess -text @@ -47,6 +48,7 @@ application/selector/.htaccess -text application/selector/class_ApplicationHelper.php -text application/selector/class_ApplicationSelector.php -text application/selector/config.php -text +application/selector/data.php -text application/selector/debug.php -text application/selector/exceptions.php -text application/selector/init.php -text @@ -60,6 +62,7 @@ application/selector/templates/de/code/selector_main.ctp -text application/ship-simu/.htaccess -text application/ship-simu/class_ApplicationHelper.php -text application/ship-simu/config.php -text +application/ship-simu/data.php -text application/ship-simu/debug.php -text application/ship-simu/exceptions.php -text application/ship-simu/exceptions/.htaccess -text @@ -236,6 +239,7 @@ application/ship-simu/templates/images/de/image/code_captcha.itp -text application/shoutbox/.htaccess -text application/shoutbox/class_ApplicationHelper.php -text application/shoutbox/config.php -text +application/shoutbox/data.php -text application/shoutbox/debug.php -text application/shoutbox/exceptions.php -text application/shoutbox/exceptions/.htaccess -text @@ -278,6 +282,7 @@ application/shoutbox/templates/images/de/image/code_captcha.itp -text application/todo/.htaccess -text application/todo/class_ApplicationHelper.php -text application/todo/config.php -text +application/todo/data.php -text application/todo/debug.php -text application/todo/exceptions.php -text application/todo/exceptions/.htaccess -text diff --git a/application/blog/data.php b/application/blog/data.php new file mode 100644 index 0000000..e89cd58 --- /dev/null +++ b/application/blog/data.php @@ -0,0 +1,51 @@ +isClass("ApplicationSelector"))) { return; } + * + * isset() is required to prevent a warning and is_object() is highly required + * when the application itself is requested in URL (hint: index.php?app=your_app) + * + * @author Roland Haeder + * @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 . + */ + +// Get config instance +$cfg = FrameworkConfiguration::getInstance(); + +// Get an instance of the helper +$app = call_user_func_array( + array($cfg->readConfig('app_helper_class'), "getInstance"), + array() +); + +// Set application name and version +$app->setAppName("Nameless Blogging Software"); +$app->setAppVersion("0.0.0"); +$app->setAppShortName("blog"); + +// [EOF] +?> diff --git a/application/blog/init.php b/application/blog/init.php index fa7aee2..39c5bed 100644 --- a/application/blog/init.php +++ b/application/blog/init.php @@ -49,23 +49,5 @@ require($cfg->readConfig('base_path') . 'inc/language.php'); // the inc/database.php script require($cfg->readConfig('base_path') . 'inc/database.php'); -// Generate call-back function -$callback = sprintf("%s::getInstance", - FrameworkConfiguration::getInstance()->readConfig('app_helper_class') -); - -// Get an instance of the helper -$app = call_user_func_array($callback, array()); - -// Set application name and version -$app->setAppName("Nameless Blogging Software"); -$app->setAppVersion("0.0.0"); -$app->setAppShortName("blog"); - -// Set instances -$app->setFileIoInstance($io); -$app->setLanguageInstance($lang); -$app->setDatabaseInstance($db); - // [EOF] ?> diff --git a/application/selector/class_ApplicationSelector.php b/application/selector/class_ApplicationSelector.php index 0d366b7..f52b50a 100644 --- a/application/selector/class_ApplicationSelector.php +++ b/application/selector/class_ApplicationSelector.php @@ -109,18 +109,18 @@ class ApplicationSelector extends BaseFrameworkSystem { } /** - * Load the init.php script of an application and append the application + * Load the data.php script of an application and append the application * instance to $foundApps * - * @param $initScript The FQFN of init.php + * @param $appData The FQFN of data.php * @param $appName The application's Uni* name * @return void */ - private function loadInitScript ($initScript, $appName) { + private function loadApplicationData ($appData, $appName) { // Is it a file and readable? - if ((is_file($initScript)) && (is_readable($initScript))) { + if ((is_file($appData)) && (is_readable($appData))) { // Then include it - include ($initScript); + include ($appData); // Add the current instance to the list $this->foundApps->append($app); @@ -206,15 +206,13 @@ class ApplicationSelector extends BaseFrameworkSystem { // Is this a readable directory? (files will be ignored silently) if ((is_dir($fqfn)) && (is_readable($fqfn))) { - // Then get the init.php script for analyzing - $initScript = sprintf("%s/init.php", $fqfn); + // Then get the data.php script for analyzing + $appData = sprintf("%s/data.php", $fqfn); - // Load the application's init.php script and append the + // Load the application's data.php script and append the // application to the ArrayObject - $this->loadInitScript($initScript, $appName); - - } // END - if ((is_dir(... - + $this->loadApplicationData($appData, $appName); + } // END - if } // END - while // Close directory pointer diff --git a/application/selector/data.php b/application/selector/data.php new file mode 100644 index 0000000..29d47ef --- /dev/null +++ b/application/selector/data.php @@ -0,0 +1,43 @@ + + * @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 . + */ + +// Get config instance +$cfg = FrameworkConfiguration::getInstance(); + +// Get an instance of the helper +$app = call_user_func_array( + array($cfg->readConfig('app_helper_class'), "getInstance"), + array() +); + +// Set application name and version +$app->setAppName("Applikationsauswähler"); +$app->setAppVersion("0.1a"); +$app->setAppShortName($cfg->readConfig('selector_name')); + +// [EOF] +?> diff --git a/application/selector/init.php b/application/selector/init.php index 71893f0..3b9e2db 100644 --- a/application/selector/init.php +++ b/application/selector/init.php @@ -37,22 +37,5 @@ require($cfg->readConfig('base_path') . 'inc/file_io.php'); // Include the language sub-system require($cfg->readConfig('base_path') . 'inc/language.php'); -// Generate call-back function -$callback = sprintf("%s::getInstance", - FrameworkConfiguration::getInstance()->readConfig('app_helper_class') -); - -// Get an instance of the helper -$app = call_user_func_array($callback, array()); - -// Set application name and version -$app->setAppName("Applikationsauswähler"); -$app->setAppVersion("0.1a"); -$app->setAppShortName(FrameworkConfiguration::getInstance()->readConfig('selector_name')); - -// Set instances -$app->setFileIoInstance($io); -$app->setLanguageInstance($lang); - // [EOF] ?> diff --git a/application/ship-simu/data.php b/application/ship-simu/data.php new file mode 100644 index 0000000..0ec07a0 --- /dev/null +++ b/application/ship-simu/data.php @@ -0,0 +1,51 @@ +isClass("ApplicationSelector"))) { return; } + * + * isset() is required to prevent a warning and is_object() is highly required + * when the application itself is requested in URL (hint: index.php?app=your_app) + * + * @author Roland Haeder + * @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 . + */ + +// Get config instance +$cfg = FrameworkConfiguration::getInstance(); + +// Get an instance of the helper +$app = call_user_func_array( + array($cfg->readConfig('app_helper_class'), "getInstance"), + array() +); + +// Set application name and version +$app->setAppName("Ship-Simu Schiffsimulator"); +$app->setAppVersion("0.0.0"); +$app->setAppShortName("ship-simu"); + +// [EOF] +?> diff --git a/application/ship-simu/init.php b/application/ship-simu/init.php index 7b65cae..39c5bed 100644 --- a/application/ship-simu/init.php +++ b/application/ship-simu/init.php @@ -49,23 +49,5 @@ require($cfg->readConfig('base_path') . 'inc/language.php'); // the inc/database.php script require($cfg->readConfig('base_path') . 'inc/database.php'); -// Generate call-back function -$callback = sprintf("%s::getInstance", - FrameworkConfiguration::getInstance()->readConfig('app_helper_class') -); - -// Get an instance of the helper -$app = call_user_func_array($callback, array()); - -// Set application name and version -$app->setAppName("Ship-Simu Schiffsimulator"); -$app->setAppVersion("0.0.0"); -$app->setAppShortName("ship-simu"); - -// Set instances -$app->setFileIoInstance($io); -$app->setLanguageInstance($lang); -$app->setDatabaseInstance($db); - // [EOF] ?> diff --git a/application/shoutbox/data.php b/application/shoutbox/data.php new file mode 100644 index 0000000..d97c702 --- /dev/null +++ b/application/shoutbox/data.php @@ -0,0 +1,51 @@ +isClass("ApplicationSelector"))) { return; } + * + * isset() is required to prevent a warning and is_object() is highly required + * when the application itself is requested in URL (hint: index.php?app=your_app) + * + * @author Roland Haeder + * @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 . + */ + +// Get config instance +$cfg = FrameworkConfiguration::getInstance(); + +// Get an instance of the helper +$app = call_user_func_array( + array($cfg->readConfig('app_helper_class'), "getInstance"), + array() +); + +// Set application name and version +$app->setAppName("Nameless Blogging Software"); +$app->setAppVersion("0.0.0"); +$app->setAppShortName("shoutbox"); + +// [EOF] +?> diff --git a/application/shoutbox/init.php b/application/shoutbox/init.php index 117b295..39c5bed 100644 --- a/application/shoutbox/init.php +++ b/application/shoutbox/init.php @@ -49,23 +49,5 @@ require($cfg->readConfig('base_path') . 'inc/language.php'); // the inc/database.php script require($cfg->readConfig('base_path') . 'inc/database.php'); -// Generate call-back function -$callback = sprintf("%s::getInstance", - FrameworkConfiguration::getInstance()->readConfig('app_helper_class') -); - -// Get an instance of the helper -$app = call_user_func_array($callback, array()); - -// Set application name and version -$app->setAppName("Nameless Blogging Software"); -$app->setAppVersion("0.0.0"); -$app->setAppShortName("shoutbox"); - -// Set instances -$app->setFileIoInstance($io); -$app->setLanguageInstance($lang); -$app->setDatabaseInstance($db); - // [EOF] ?> diff --git a/application/todo/data.php b/application/todo/data.php new file mode 100644 index 0000000..df4b3bf --- /dev/null +++ b/application/todo/data.php @@ -0,0 +1,51 @@ +isClass("ApplicationSelector"))) { return; } + * + * isset() is required to prevent a warning and is_object() is highly required + * when the application itself is requested in URL (hint: index.php?app=your_app) + * + * @author Roland Haeder + * @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 . + */ + +// Get config instance +$cfg = FrameworkConfiguration::getInstance(); + +// Get an instance of the helper +$app = call_user_func_array( + array($cfg->readConfig('app_helper_class'), "getInstance"), + array() +); + +// Set application name and version +$app->setAppName("OpenToDo"); +$app->setAppVersion("0.0.0"); +$app->setAppShortName("todo"); + +// [EOF] +?> diff --git a/application/todo/init.php b/application/todo/init.php index c8d19e3..39c5bed 100644 --- a/application/todo/init.php +++ b/application/todo/init.php @@ -49,23 +49,5 @@ require($cfg->readConfig('base_path') . 'inc/language.php'); // the inc/database.php script require($cfg->readConfig('base_path') . 'inc/database.php'); -// Generate call-back function -$callback = sprintf("%s::getInstance", - FrameworkConfiguration::getInstance()->readConfig('app_helper_class') -); - -// Get an instance of the helper -$app = call_user_func_array($callback, array()); - -// Set application name and version -$app->setAppName("OpenToDo"); -$app->setAppVersion("0.0.0"); -$app->setAppShortName("todo"); - -// Set instances -$app->setFileIoInstance($io); -$app->setLanguageInstance($lang); -$app->setDatabaseInstance($db); - // [EOF] ?> diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 38e689b..006a6b4 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -269,6 +269,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { private final function initInstance () { // Is this a system class? if (!in_array($this->__toString(), $this->systemClasses)) { + // Set configuration instance + $this->setConfigInstance(FrameworkConfiguration::getInstance()); + // Add application helper to our class $this->systemclasses[] = $this->getConfigInstance()->readConfig('app_helper_class'); diff --git a/inc/classes/main/factories/objects/class_ObjectFactory.php b/inc/classes/main/factories/objects/class_ObjectFactory.php index 06c73d8..0848e79 100644 --- a/inc/classes/main/factories/objects/class_ObjectFactory.php +++ b/inc/classes/main/factories/objects/class_ObjectFactory.php @@ -64,14 +64,13 @@ class ObjectFactory extends BaseFactory { throw new ClassNotFoundException(array($factoryInstance, $className), self::EXCEPTION_CLASS_NOT_FOUND); } - // Then Prepare the call-back function - $callback = sprintf("%s::create%s", - $className, + // Create method name + $methodName = sprintf("create%s", $className ); // Run the user function - $objectInstance = call_user_func_array($callback, $args); + $objectInstance = call_user_func_array(array($className, $methodName), $args); // Count generated objects up self::$total++; diff --git a/inc/database.php b/inc/database.php index f274f6c..52d7506 100644 --- a/inc/database.php +++ b/inc/database.php @@ -77,6 +77,9 @@ try { )); } +// Is the app variable there and valid? +if (is_object($app)) $app->setDatabaseInstance($db); + // Datenbankobjekt debuggen if (defined('DEBUG_DATABASE_OBJ')) { DebugMiddleware::getInstance()->output(sprintf("The database sub-system does now look like this:
diff --git a/inc/file_io.php b/inc/file_io.php index 0a5ec9b..c141fea 100644 --- a/inc/file_io.php +++ b/inc/file_io.php @@ -27,5 +27,8 @@ // Get the instance $io = ObjectFactory::createObjectByConfiguredName('file_io_class'); +// Is the app variable there and valid? +if (is_object($app)) $app->setFileIoInstance($io); + // [EOF] ?> diff --git a/inc/language.php b/inc/language.php index 6db17c0..b9250e5 100644 --- a/inc/language.php +++ b/inc/language.php @@ -43,5 +43,8 @@ try { )); } +// Is the app variable there and valid? +if (is_object($app)) $app->setLanguageInstance($lang); + // [EOF] ?> diff --git a/inc/selector.php b/inc/selector.php index 819485e..d20cbcb 100644 --- a/inc/selector.php +++ b/inc/selector.php @@ -29,6 +29,7 @@ $cfg = FrameworkConfiguration::getInstance(); $configAppIncludes = array( sprintf("class_%s", $cfg->readConfig('app_helper_class')), // The ApplicationHelper class "config", // The application's own configuration + "data", // Application data "init", // The application initializer "loader", // The application's class loader "debug", // Some debugging stuff