More fixes...
authorRoland Häder <roland@mxchange.org>
Sun, 20 Apr 2008 22:01:53 +0000 (22:01 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 20 Apr 2008 22:01:53 +0000 (22:01 +0000)
13 files changed:
.gitattributes
application/selector/templates/de/code/selector_main.ctp
application/ship-simu/templates/de/code/footer.ctp [new file with mode: 0644]
application/ship-simu/templates/de/code/shipsimu_main.ctp
application/ship-simu/templates/de/html/nav_advert.tpl [new file with mode: 0644]
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/extended/class_SerializationContainer.php
inc/classes/main/template/class_TemplateEngine.php
inc/classes/middleware/debug/class_DebugMiddleware.php
index.php
templates/de/code/emergency_exit.ctp
templates/de/code/footer_msg.ctp
templates/de/code/header.ctp

index ccc214e..8b50b1b 100644 (file)
@@ -115,9 +115,11 @@ application/ship-simu/main/structures/extended/upper/class_Bridge.php -text
 application/ship-simu/starter.php -text
 application/ship-simu/templates/.htaccess -text
 application/ship-simu/templates/de/.htaccess -text
+application/ship-simu/templates/de/code/footer.ctp -text
 application/ship-simu/templates/de/code/shipsimu_main.ctp -text
 application/ship-simu/templates/de/html/.htaccess -text
 application/ship-simu/templates/de/html/home.tpl -text
+application/ship-simu/templates/de/html/nav_advert.tpl -text
 application/ship-simu/templates/de/html/selector_ship-simu.tpl -text
 db/.htaccess -text
 devel/.htaccess -text
index ff75745..77b5bf6 100644 (file)
@@ -2,7 +2,7 @@
 
 {?header:title=[WELCOME_APPLICATION_SELECTOR]?}
 
-{?navigation:nav_row=home;imprint;contact?}
+{?navigation?}
 
 <div id="main_header">
        [HEADER_APPLICATION_SELECTOR]
diff --git a/application/ship-simu/templates/de/code/footer.ctp b/application/ship-simu/templates/de/code/footer.ctp
new file mode 100644 (file)
index 0000000..aa82e68
--- /dev/null
@@ -0,0 +1,4 @@
+</div> <!-- masterbox //-->
+
+</body>
+</html>
index 7e00108..659c2bb 100644 (file)
@@ -2,20 +2,24 @@
 
 {?header:title=[WELCOME_SHIP_SIMU]?}
 
+<div id="main_header">
+[HEADER_SHIP_SIMU]
+</div>
+
 <div id="navigation">
-{?navigation:nav_row=home;imprint;contact?}
+{?navigation?}
 </div>
 
-<div id="main_header">
-       [HEADER_SHIP_SIMU]
+<div id="advert">
+{?nav_advert?}
 </div>
 
 <div id="main_content">
-       {?content?}
+{?content?}
 </div>
 
 <div id="main_footer">
-       [FOOTER_SHIP_SIMU]
+[FOOTER_SHIP_SIMU]
 </div>
 
-{?footer_msg:footer_msg=[FOOTER_SHIP_SIMU]?}
+{?footer?}
diff --git a/application/ship-simu/templates/de/html/nav_advert.tpl b/application/ship-simu/templates/de/html/nav_advert.tpl
new file mode 100644 (file)
index 0000000..22da43b
--- /dev/null
@@ -0,0 +1 @@
+<!-- Put your ads code here which shall be shown below the navigation //-->
index 6b4d816..6cc7a20 100644 (file)
@@ -920,6 +920,19 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Return the prepared instance
                return $tplEngine;
        }
+
+       /**
+        * Debugs this instance by putting out it's full content
+        *
+        * @return      void
+        */
+       public final function debugInstance () {
+               // Generate the output
+               $content = "<pre>".trim(print_r($this, true))."</pre>";
+
+               // Output it
+               ApplicationEntryPoint::app_die("<strong>Debug output:</strong>".$content);
+       }
 }
 
 // [EOF]
index 3987ad8..b07bfc9 100644 (file)
@@ -70,7 +70,7 @@ class SerializationContainer extends FrameworkArrayObject {
                                ));
 
                                // Run it
-                               @eval($eval);
+                               eval($eval);
 
                                // Add this item to the container list
                                $containerInstance->append(array(
index 980f56c..16fbd3c 100644 (file)
@@ -254,8 +254,8 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
        private function addVariable ($var, $value) {
                // Add it to the stack
                $this->varStack->append(array(
-                       'name'  => $var,
-                       'value' => $value
+                       'name'  => trim($var),
+                       'value' => trim($value)
                ));
        }
 
@@ -812,7 +812,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        if ((substr($varMatches[2][$key], 0, 1) == "\"") && (substr($varMatches[2][$key], -1, 1) == "\"")) {
                                // Free string detected! Which we can assign directly
                                $this->assignVariable($var, $varMatches[3][$key]);
-                       } else {
+                       } elseif (!empty($varMatches[2][$key])) {
                                // Non-string found so we need some deeper analysis...
                                // @TODO Unfinished work or don't die here.
                                die("Deeper analysis not yet implemented!");
@@ -865,6 +865,19 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
        }
 
        /**
+        * Inserts all raw templates into their respective variables
+        *
+        * @return      void
+        */
+       private function insertRawTemplates () {
+               // Load all templates
+               foreach ($this->rawTemplates as $template=>$content) {
+                       // Set the template as a variable with the content
+                       $this->assignVariable($template, $content);
+               }
+       }
+
+       /**
         * Getter for raw template data
         *
         * @return      $rawTemplateData        The raw data from the template
@@ -983,9 +996,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->readConfig("code_template_type")), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED);
                }
 
-               // Get the raw data. Thanks to Flobee(R) for given me a hint using the
-               // modifier "m" in regular expressions. I had implemented a regex here
-               // like this: (\n|\r)
+               // Get the raw data.
                $rawData = $this->getRawTemplateData();
 
                // Remove double spaces and trim leading/trailing spaces
@@ -1003,6 +1014,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        //
                        // The main analysis
                        $this->analyzeTemplate($templateMatches);
+                       $this->debugInstance();
 
                        // Compile raw template data
                        $this->compileRawTemplateData($templateMatches);
@@ -1012,8 +1024,10 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
 
                        // Are some raw templates found and loaded?
                        if (count($this->rawTemplates) > 0) {
-                               die("NOT YET IMPLEMENTED");
+                               // Insert all raw templates
+                               $this->insertRawTemplates();
                        }
+
                } // END - if($templateMatches ...
        }
 
@@ -1033,20 +1047,20 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        break;
 
                default: // Unknown type found
+                       // Construct message
+                       $msg = sprintf("[%s:] Unknown/unsupported template type <strong>%s</strong> detected.",
+                               $this->__toString(),
+                               $this->getTemplateType()
+                       );
+
                        if ((is_object($this->getDebugInstance())) && (method_exists($this->getDebugInstance(), 'output'))) {
                                // Use debug output handler
-                               $this->getDebugInstance()->output(sprintf("[%s:] Unbekannter Template-Typ <strong>%s</strong> erkannt.",
-                                       $this->__toString(),
-                                       $this->getTemplateType()
-                               ));
+                               $this->getDebugInstance()->output($msg);
                                die();
                        } else {
                                // Put directly out
                                // DO NOT REWRITE THIS TO app_die() !!!
-                               die(sprintf("[%s:] Unbekannter Template-Typ <strong>%s</strong> erkannt.",
-                                       $this->__toString(),
-                                       $this->getTemplateType()
-                               ));
+                               die($msg);
                        }
                        break;
                }
@@ -1082,7 +1096,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        );
 
                        // Run the code
-                       @eval($eval);
+                       eval($eval);
                }
 
                // Return the requested instance
index 37d4ed9..f46dbb5 100644 (file)
@@ -78,7 +78,7 @@ class DebugMiddleware extends BaseMiddleware {
                        );
 
                        // Run the constructed name
-                       @eval($eval);
+                       eval($eval);
 
                        // Was this successfull?
                        if ((is_object($debuggerClass)) && (method_exists($debuggerClass, "outputStream"))) {
index d0a0f08..9cabcb0 100644 (file)
--- a/index.php
+++ b/index.php
@@ -8,10 +8,10 @@
  * But good little boys and girls would always initialize their variables... ;-)
  *
  * @author             Roland Haeder <webmaster@mxchange.org>
- * @version            0.3.0
+ * @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.mxchange.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
@@ -24,7 +24,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/>.
  */
 class ApplicationEntryPoint {
        /**
@@ -50,6 +50,15 @@ class ApplicationEntryPoint {
         * @return      void
         */
        public static function app_die ($message = "") {
+               // Is this method already called?
+               if (defined('EMERGENCY_EXIT_CALLED')) {
+                       // Then output the text directly
+                       die($message);
+               }
+
+               // This method shall not be called twice
+               define('EMERGENCY_EXIT_CALLED', true);
+
                // Is a message set?
                if (empty($message)) {
                        // No message provided
@@ -90,8 +99,19 @@ class ApplicationEntryPoint {
                                ));
                        }
 
-                       // Assign message
+                       // Backtrace holen und aufbereiten
+                       $backtraceArray = debug_backtrace();
+                       $backtrace = "";
+                       foreach ($backtraceArray as $key=>$trace) {
+                               if (!isset($trace['file'])) $trace['file'] = __FILE__;
+                               if (!isset($trace['line'])) $trace['line'] = 5;
+                               if (!isset($trace['args'])) $trace['args'] = array();
+                               $backtrace .= "<span class=\"backtrace_file\">".basename($trace['file'])."</span>:".$trace['line'].", <span class=\"backtrace_function\">".$trace['function']."(".count($trace['args']).")</span><br />";
+                       }
+
+                       // Assign variables
                        $tplEngine->assignVariable("message", $message);
+                       $tplEngine->assignVariable("backtrace", $backtrace);
 
                        // Load the template
                        $tplEngine->loadCodeTemplate("emergency_exit");
@@ -109,7 +129,7 @@ class ApplicationEntryPoint {
                        exit();
                } else {
                        // Output message and die
-                       die(sprintf("[Main:] Emergency exit reached: <strong>%s</strong>",
+                       die(sprintf("[Main:] Emergency exit reached: <span class=\"emergency_span\">%s</span>",
                                $message
                        ));
                }
index f747430..4cd1cf9 100644 (file)
@@ -4,15 +4,15 @@
 
 {?navigation:nav_row=home;imprint;contact?}
 
-       <div class="emergency_exit message_box">
+       <div id="emergency_exit message_box">
                $content[message]
        </div>
 
-       <div class="emergency_exit backtrace_box">
-               <div class="backtrace_header">
+       <div id="emergency_exit backtrace_box">
+               <div id="backtrace_header">
                        Backtrace:
                </div>
-               <div class="backtrace_content">
+               <div id="backtrace_content">
                        $content[backtrace]
                </div>
        </div>
index 309a0fd..c67ed0c 100644 (file)
@@ -1,4 +1,4 @@
-       <div class="footer_message message_box">
+       <div id="footer_message message_box">
                $content[footer_msg]
        </div>
 
index 1faab5b..2b2457d 100644 (file)
@@ -17,4 +17,4 @@
 </head>
 
 <body>
-<div class="masterbox">
+<div id="masterbox">