Dev mode deactivated
[shipsimu.git] / index.php
index 75926e2c40eedfb0c75b96aaabff9bb4278d1f2c..658d70ade8c82ceeeec99f9df1041907a4a23fa4 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,4 +1,7 @@
 <?php
+// Developer mode active? Comment out if no dev!
+//define('DEVELOPER', true);
+
 //xdebug_start_trace();
 /**
  * The main class with the entry point to the whole application. This class
@@ -34,8 +37,8 @@ class ApplicationEntryPoint {
         * @return      void
         */
        private static $instances = array (
-               'cfg',  // The configuration system
-               'loader',       // The class loader system
+               'cfg',    // The configuration system
+               'loader', // The class loader system
                'debug',  // Debug output
                'db',     // Database layer
                'io',     // Base I/O system (local file [or network])
@@ -67,7 +70,7 @@ class ApplicationEntryPoint {
                }
 
                // Get some instances
-               $tpl = FrameworkConfiguration::getInstance()->readConfig("tpl_engine");
+               $tpl = FrameworkConfiguration::getInstance()->readConfig('tpl_engine');
                $lang = LanguageSystem::getInstance();
                $io = FileIoHandler::getInstance();
 
@@ -75,27 +78,22 @@ class ApplicationEntryPoint {
                if ((class_exists($tpl)) && (is_object($lang)) && (is_object($io))) {
                        // Use the template engine for putting out (nicer look) the message
                        try {
-                               $eval = sprintf("\$tplEngine = %s::create%s(\"%s%s\", \$lang, \$io);",
-                                       FrameworkConfiguration::getInstance()->readConfig("tpl_engine"),
-                                       FrameworkConfiguration::getInstance()->readConfig("tpl_engine"),
-                                       PATH,
-                                       FrameworkConfiguration::getInstance()->readConfig("tpl_base_path")
-                               );
-                               eval($eval);
+                               // Get the template instance from our object factory
+                               $tplEngine = ObjectFactory::createObjectByConfiguredName('tpl_engine', array(FrameworkConfiguration::getInstance()->readConfig('tpl_base_path'), $lang, $io));
                        } catch (BasePathIsEmptyException $e) {
-                               die(sprintf("[Main:] Die Template-Engine konnte nicht initialisieren. Grund: <strong>%s</strong>",
+                               die(sprintf("[Main:] Could not initialize template engine for this reason: <strong>%s</strong>",
                                        $e->getMessage()
                                ));
                        } catch (InvalidBasePathStringException $e) {
-                               die(sprintf("[Main:] Die Template-Engine konnte nicht initialisieren. Grund: <strong>%s</strong>",
+                               die(sprintf("[Main:] Could not initialize template engine for this reason: <strong>%s</strong>",
                                        $e->getMessage()
                                ));
                        } catch (BasePathIsNoDirectoryException $e) {
-                               die(sprintf("[Main:] Die Template-Engine konnte nicht initialisieren. Grund: <strong>%s</strong>",
+                               die(sprintf("[Main:] Could not initialize template engine for this reason: <strong>%s</strong>",
                                        $e->getMessage()
                                ));
                        } catch (BasePathReadProtectedException $e) {
-                               die(sprintf("[Main:] Die Template-Engine konnte nicht initialisieren. Grund: <strong>%s</strong>",
+                               die(sprintf("[Main:] Could not initialize template engine for this reason: <strong>%s</strong>",
                                        $e->getMessage()
                                ));
                        }
@@ -111,11 +109,12 @@ class ApplicationEntryPoint {
                        }
 
                        // Assign variables
-                       $tplEngine->assignVariable("message", $message);
-                       $tplEngine->assignVariable("backtrace", $backtrace);
+                       $tplEngine->assignVariable('message', $message);
+                       $tplEngine->assignVariable('backtrace', $backtrace);
+                       $tplEngine->assignVariable('total_objects', ObjectFactory::getTotal());
 
                        // Load the template
-                       $tplEngine->loadCodeTemplate("emergency_exit");
+                       $tplEngine->loadCodeTemplate('emergency_exit');
 
                        // Compile the template
                        $tplEngine->compileTemplate();
@@ -149,16 +148,16 @@ class ApplicationEntryPoint {
                global $_SERVER;
 
                // Load config file
-               require(dirname(__FILE__) . "/inc/config.php");
+               require(dirname(__FILE__) . '/inc/config.php');
 
                // Load all include files
-               require(PATH . "inc/includes.php");
+               require(PATH . 'inc/includes.php');
 
                // Load all framework classes
-               require(PATH . "inc/classes.php");
+               require(PATH . 'inc/classes.php');
 
                // Include the application selector
-               require(PATH . "inc/selector.php");
+               require(PATH . 'inc/selector.php');
 
        } // END - main()