Launcher scripts updated
authorRoland Häder <roland@mxchange.org>
Wed, 19 Nov 2008 22:40:48 +0000 (22:40 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 19 Nov 2008 22:40:48 +0000 (22:40 +0000)
.gitattributes
application/mxchange/data.php [new file with mode: 0644]
application/mxchange/debug.php
application/mxchange/exceptions.php
application/mxchange/init.php
application/mxchange/loader.php
application/mxchange/starter.php

index 6288da63c88bea7369eac20cf9407babd90692ba..8dbf3f29797a9e8c41631ee1ec51c0ee14e5841a 100644 (file)
@@ -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 (file)
index 0000000..7d88a17
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Application data
+ *
+ * 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 <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+
+// 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]
+?>
index 8046ad48d3caa134fff9c35686b4ca14225bdafb..f5da828ae95e14a248d7ebbd9afa39305e088b7a 100644 (file)
@@ -1,12 +1,12 @@
 <?php
 /**
- * Initialize some debug constants here
+ * Some debugging stuff for this application
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @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
  * 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
+// 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]
 ?>
index 7cbec418e490d15a11ebe428eeb331e951bf2d47..fd41c37727663bfd3d5e82c4f31870119eaa3f99 100644 (file)
@@ -1,13 +1,12 @@
 <?php
 /**
- * Sets an application's own exception handle, by default the default one from
- * PHP will be used (as you have setupped in php.ini)
+ * The exception handler for this application
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @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
  * 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
+// Our own exception handler
+function __exceptionHandler (FrameworkException $e) {
+       // Call the app_die() method
+       ApplicationEntryPoint::app_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> (<span class=\"app_short_name\">%s</span>) has terminated due to a thrown exception: <span class=\"exception_name\">%s</span> <span class=\"exception_number\">[%s]</span>: <span class=\"debug_exception\">%s</span> Backtrace: <div class=\"debug_backtrace\">%s</div>",
+               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: <span class=\"debug_file\">%s</span>, Line: <span class=\"debug_line\">%s</span>, Code: <span class=\"debug_code\">%s</span>, Message: <span class=\"debug_message\">%s</span>",
+               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 = "<em>Unknown</em>";
+
+       // Create message
+       $message = sprintf("File: <span class=\"debug_file\">%s</span>, Line: <span class=\"debug_line\">%s</span>, Code: <span class=\"debug_code\">%s</span>",
+               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]
 ?>
index eb2152432ed54d71fa5a97e180bd0e5571de70f3..39c5bed007acfcb599fb0edf378e27f513a2df07 100644 (file)
@@ -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 <webmaster@ship-simu.org>
  * @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
  * 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-// 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]
 ?>
index 795c4c806c12722d4c52935d2e48f0adfcac56d9..12b388beb3ebde03f5376cd38b94236ca87b49fc 100644 (file)
@@ -1,12 +1,12 @@
 <?php
 /**
- * The application's class loader
+ * A specialized class loader for this class
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @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
  * 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
 // 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]
 ?>
index 28fe0636013b9398cd34adeae0117a6a90cdcd9a..b128839499518afe66965769f58138ac40ecb844 100644 (file)
@@ -1,12 +1,12 @@
 <?php
 /**
- * Launches the application
+ * The application launcher
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @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 <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
 // 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 <strong>%s</strong> kann nicht gestartet werden, da die Hilfsklasse <strong>%s</strong> nicht geladen ist!",
+       ApplicationEntryPoint::app_die(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::getInstance()->readConfig("app_helper_class")
+               FrameworkConfiguration::getInstance()->readConfig('app_helper_class')
        ));
 } elseif (!is_object($app)) {
        // No object!
-       ApplicationEntryPoint::app_die(sprintf("[Main:] Die Applikation <strong>%s</strong> kann nicht gestartet werden, da die &#39;app&#39; kein Objekt ist!",
+       ApplicationEntryPoint::app_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because &#39;app&#39; 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 <strong>%s</strong> kann nicht gestartet werden, da die Methode <strong>%s</strong> fehlt!",
+       ApplicationEntryPoint::app_die(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::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 <strong>%s</strong> kann nicht gestartet werden. Grund: <u>%s</u>",
-               $application,
-               $e->getMessage()
-       ));
-}
+// Call user function
+call_user_func_array(array($app, FrameworkConfiguration::getInstance()->readConfig('entry_method')), array());
 
 // [EOF]
 ?>