3 * The main class with the entry point to the whole application. This class
4 * "emulates" Java(tm)'s entry point call. Additionally it covers local
5 * variables from outside access to prevent possible attacks on uninitialized
8 * But good little boys and girls would always initialize their variables... ;-)
10 class ApplicationEntryPoint {
12 * The instances we want to remove after all is done
16 private static $instances = array (
17 'cfg', // The configuration system
18 'loader', // The class loader system
19 'debug', // Debug output
20 'db', // Database layer
21 'io', // Base I/O system (local file [or network])
22 'engine', // Template engine ( for ApplicationEntryPoint::app_die() )
23 'lang', // Language sub-system
24 'app', // The ApplicationHelper instance
28 * The application's emergency exit
30 * @param $message The optional message we shall output on exit
33 public static function app_die ($message = "") {
35 if (empty($message)) {
36 // No message provided
37 $message = "No message provided!";
41 $tpl = FrameworkConfiguration::getInstance()->readConfig("tpl_engine");
42 $lang = LanguageSystem::getInstance();
43 $io = FileIOHandler::getInstance();
45 // Is the template engine loaded?
46 if ((class_exists($tpl)) && (is_object($lang)) && (is_object($io))) {
47 // Use the template engine for putting out (nicer look) the message
49 $eval = sprintf("$tplEngine = %s::create%s(\"%s%s\", LanguageSystem::getInstance(), FileIOHandler::getInstance());",
50 FrameworkConfiguration::getInstance()->readConfig("tpl_engine"),
51 FrameworkConfiguration::getInstance()->readConfig("tpl_engine"),
53 FrameworkConfiguration::getInstance()->readConfig("tpl_base_path")
56 } catch (BasePathIsEmptyException $e) {
57 die(sprintf("[Main:] Die Template-Engine konnte nicht initialisieren. Grund: <strong>%s</strong>",
60 } catch (InvalidBasePathStringException $e) {
61 die(sprintf("[Main:] Die Template-Engine konnte nicht initialisieren. Grund: <strong>%s</strong>",
64 } catch (BasePathIsNoDirectoryException $e) {
65 die(sprintf("[Main:] Die Template-Engine konnte nicht initialisieren. Grund: <strong>%s</strong>",
68 } catch (BasePathReadProtectedException $e) {
69 die(sprintf("[Main:] Die Template-Engine konnte nicht initialisieren. Grund: <strong>%s</strong>",
75 $tplEngine->assignVariable("message", $message);
78 $tplEngine->loadCodeTemplate("emergency_exit");
80 // Compile the template
81 $tplEngine->compileTemplate();
83 // Compile all variables
84 $tplEngine->compileVariables();
92 // Output message and die
93 die(sprintf("[Main:] Emergency exit reached: <strong>%s</strong>",
100 * The application's main entry point. This class isolates some local
101 * variables which shall not become visible to outside because of security
102 * concerns. We are doing this here to "emulate" the well-known entry
107 public static function main () {
108 // Some non-global common arrays we need...
112 require(dirname(__FILE__) . "/inc/config.php");
114 // Load all include files
115 require(PATH . "inc/includes.php");
117 // Load all framework classes
118 require(PATH . "inc/classes.php");
120 // Include the application selector
121 require(PATH . "inc/selector.php");
127 // Do not remove the following line:
128 ApplicationEntryPoint::main();