From: Roland Häder Date: Wed, 19 Nov 2008 22:40:48 +0000 (+0000) Subject: Launcher scripts updated X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7940f3ad709afe4ba58012aa835c82cecc9328cc;p=mailer.git Launcher scripts updated --- diff --git a/.gitattributes b/.gitattributes index 6288da63c8..8dbf3f2979 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,6 +4,7 @@ application/.htaccess -text application/mxchange/.htaccess -text application/mxchange/class_ApplicationHelper.php -text application/mxchange/config.php -text +application/mxchange/data.php -text application/mxchange/debug.php -text application/mxchange/exceptions.php -text application/mxchange/exceptions/.htaccess -text diff --git a/application/mxchange/data.php b/application/mxchange/data.php new file mode 100644 index 0000000000..7d88a17e57 --- /dev/null +++ b/application/mxchange/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("MXChange Mail-Exchange"); +$app->setAppVersion("0.3.0"); +$app->setAppShortName("mxchange"); + +// [EOF] +?> diff --git a/application/mxchange/debug.php b/application/mxchange/debug.php index 8046ad48d3..f5da828ae9 100644 --- a/application/mxchange/debug.php +++ b/application/mxchange/debug.php @@ -1,12 +1,12 @@ * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @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 + * @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 @@ -19,8 +19,43 @@ * 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 . + * along with this program. If not, see . */ +// Reederei-Objekt debuggen +//define('DEBUG_COMPANY_OBJ', true); +// Hafen-Objekt debuggen +//define('DEBUG_HARBOR_OBJ', true); +// Schiff-Objekt debuggen +//define('DEBUG_SHIP_OBJ', true); +// Auftrag-Objekt debuggen +//define('DEBUG_CONTRACT_OBJ', true); +// Haendler-Objekt debuggen +//define('DEBUG_MERCHANT_OBJ', true); +// Personal-Objekt debuggen +//define('DEBUG_PERSONELL_OBJ', true); +// Personal debuggen +//define('DEBUG_PERSONELL', true); +// Reederei debuggen +//define('DEBUG_COMPANY', true); +// Mitarbeiter debuggen +//define('DEBUG_COMPANY_EMPLOYEE', true); +// Hafen debuggen +//define('DEBUG_HARBOR', true); +// Werft debuggen +//define('DEBUG_SHIPYARD', true); +// Schiff debuggen +//define('DEBUG_SHIP', true); +// Schiffstruktur debuggen +//define('DEBUG_STRUCTURE', true); +// Kabinen debuggen +//define('DEBUG_CABIN', true); +// Decks debuggen +//define('DEBUG_DECK', true); +// Bauauftraege debuggen +//define('DEBUG_CONTRACT', true); +// Haendler debuggen +//define('DEBUG_MERCHANT', true); + // [EOF] ?> diff --git a/application/mxchange/exceptions.php b/application/mxchange/exceptions.php index 7cbec418e4..fd41c37727 100644 --- a/application/mxchange/exceptions.php +++ b/application/mxchange/exceptions.php @@ -1,13 +1,12 @@ * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @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 + * @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 @@ -20,11 +19,67 @@ * 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 . + * along with this program. If not, see . */ +// Our own exception handler +function __exceptionHandler (FrameworkException $e) { + // Call the app_die() method + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has terminated due to a thrown exception: %s [%s]: %s Backtrace:
%s
", + ApplicationHelper::getInstance()->getAppName(), + ApplicationHelper::getInstance()->getAppShortName(), + $e->__toString(), + $e->getHexCode(), + $e->getMessage(), + $e->getPrintableBackTrace() + ), + $e->getHexCode(), + $e->getExtraData() + ); +} // END - function + // Set the new handler -//set_exception_handler('selector_exception_handler'); +set_exception_handler('__exceptionHandler'); + +// Error handler +function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) { + // Construct the message + $message = sprintf("File: %s, Line: %s, Code: %s, Message: %s", + basename($errfile), + $errline, + $errno, + $errstr + ); + + // Throw an exception here + throw new FatalErrorException($message, BaseFrameworkSystem::EXCEPTION_FATAL_ERROR); +} // END - function + +// Set error handler +set_error_handler('__errorHandler'); + +// Assertion handler +function __assertHandler ($file, $line, $code) { + // Empty code? + if ($code === "") $code = "Unknown"; + + // Create message + $message = sprintf("File: %s, Line: %s, Code: %s", + basename($file), + $line, + $code + ); + + // Throw an exception here + throw new AssertionException($message, BaseFrameworkSystem::EXCEPTION_ASSERTION_FAILED); +} // END - function + +// Init assert handling +assert_options(ASSERT_ACTIVE, 1); +assert_options(ASSERT_WARNING, 0); +assert_options(ASSERT_BAIL, 0); +assert_options(ASSERT_QUIET_EVAL, 0); +assert_options(ASSERT_CALLBACK, '__assertHandler'); // [EOF] ?> diff --git a/application/mxchange/init.php b/application/mxchange/init.php index eb2152432e..39c5bed007 100644 --- a/application/mxchange/init.php +++ b/application/mxchange/init.php @@ -2,11 +2,22 @@ /** * Application initializer * + * Please remember that this include file is being loaded *before* the class + * loader is loading classes from "exceptions", "interfaces" and "main"! + * + * You can prevent adding this application to the selector by uncommenting the + * following line: + * + * if ((isset($this)) && (is_object($this)) && ($this->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 + * @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 + * @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 @@ -19,41 +30,24 @@ * 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 . + * along with this program. If not, see . */ -// Get a new configuration instance -$cfg = FrameworkConfiguration::createFrameworkConfiguration(); +// Get config instance +$cfg = FrameworkConfiguration::getInstance(); // Initialize output system -require($cfg->readConfig('base_path') . "inc/output.php"); +require($cfg->readConfig('base_path') . 'inc/output.php'); // Initialize file i/o system -require($cfg->readConfig('base_path') . "inc/file_io.php"); +require($cfg->readConfig('base_path') . 'inc/file_io.php'); // Include the language sub-system -require($cfg->readConfig('base_path') . "inc/language.php"); - -// Get the database layer as well -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("MXChange Mailtausch-Skript"); -$app->setAppVersion("0.3.0"); -$app->setAppShortName(FrameworkConfiguration::getInstance()->readConfig("selector_name")); +require($cfg->readConfig('base_path') . 'inc/language.php'); -// Set instances -$app->setFileIoInstance($io); -$app->setLanguageInstance($lang); -$app->setDatabaseInstance($db); +// This application needs a database connection then we have to simply include +// the inc/database.php script +require($cfg->readConfig('base_path') . 'inc/database.php'); // [EOF] ?> diff --git a/application/mxchange/loader.php b/application/mxchange/loader.php index 795c4c806c..12b388beb3 100644 --- a/application/mxchange/loader.php +++ b/application/mxchange/loader.php @@ -1,12 +1,12 @@ * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @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 + * @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 @@ -19,18 +19,21 @@ * 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 . + * along with this program. If not, see . */ // Get config instance $cfg = FrameworkConfiguration::getInstance(); -// Load all classes -ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/", $cfg->readConfig("application_path"), $cfg->readConfig("app_name"))); +// Load all classes for the application +foreach ($lowerClasses as $className) { + // Load the application classes + ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/%s", $cfg->readConfig('application_path'), $cfg->readConfig('app_name'), $className)); +} // END - if // Clean up the global namespace unset($lowerClasses); -unset($class); +unset($className); // [EOF] ?> diff --git a/application/mxchange/starter.php b/application/mxchange/starter.php index 28fe063601..b128839499 100644 --- a/application/mxchange/starter.php +++ b/application/mxchange/starter.php @@ -1,12 +1,12 @@ * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @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 + * @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 @@ -19,7 +19,7 @@ * 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 . + * along with this program. If not, see . */ // Is there an application helper instance? We need the method main() for @@ -29,32 +29,25 @@ $app = call_user_func_array(array(FrameworkConfiguration::getInstance()->readCon // Some sanity checks if ((empty($app)) || (is_null($app))) { // Something went wrong! - ApplicationEntryPoint::app_die(sprintf("[Main:] Die Applikation %s kann nicht gestartet werden, da die Hilfsklasse %s nicht geladen ist!", + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s could not be launched because the helper class %s is not loaded.", $application, - FrameworkConfiguration::getInstance()->readConfig("app_helper_class") + FrameworkConfiguration::getInstance()->readConfig('app_helper_class') )); } elseif (!is_object($app)) { // No object! - ApplicationEntryPoint::app_die(sprintf("[Main:] Die Applikation %s kann nicht gestartet werden, da die 'app' kein Objekt ist!", + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s could not be launched because 'app' is not an object.", $application )); -} elseif (!method_exists($app, FrameworkConfiguration::getInstance()->readConfig("entry_method"))) { +} elseif (!method_exists($app, FrameworkConfiguration::getInstance()->readConfig('entry_method'))) { // Method not found! - ApplicationEntryPoint::app_die(sprintf("[Main:] Die Applikation %s kann nicht gestartet werden, da die Methode %s fehlt!", + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s could not be launched because the method %s is missing.", $application, - FrameworkConfiguration::getInstance()->readConfig("entry_method") + FrameworkConfiguration::getInstance()->readConfig('entry_method') )); } -// Call the entry point method -try { - call_user_func_array(array($app, FrameworkConfiguration::getInstance()->readConfig('entry_method')), array()); -} catch (FrameworkException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] Die Applikation %s kann nicht gestartet werden. Grund: %s", - $application, - $e->getMessage() - )); -} +// Call user function +call_user_func_array(array($app, FrameworkConfiguration::getInstance()->readConfig('entry_method')), array()); // [EOF] ?>