From: Roland Häder Date: Sun, 20 Apr 2008 22:01:53 +0000 (+0000) Subject: More fixes... X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=commitdiff_plain;h=30d74f6c90bb37a58e10c8a789cd2b185f26a1fb More fixes... --- diff --git a/.gitattributes b/.gitattributes index ccc214e..8b50b1b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/application/selector/templates/de/code/selector_main.ctp b/application/selector/templates/de/code/selector_main.ctp index ff75745..77b5bf6 100644 --- a/application/selector/templates/de/code/selector_main.ctp +++ b/application/selector/templates/de/code/selector_main.ctp @@ -2,7 +2,7 @@ {?header:title=[WELCOME_APPLICATION_SELECTOR]?} -{?navigation:nav_row=home;imprint;contact?} +{?navigation?}
[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 index 0000000..aa82e68 --- /dev/null +++ b/application/ship-simu/templates/de/code/footer.ctp @@ -0,0 +1,4 @@ +
+ + + diff --git a/application/ship-simu/templates/de/code/shipsimu_main.ctp b/application/ship-simu/templates/de/code/shipsimu_main.ctp index 7e00108..659c2bb 100644 --- a/application/ship-simu/templates/de/code/shipsimu_main.ctp +++ b/application/ship-simu/templates/de/code/shipsimu_main.ctp @@ -2,20 +2,24 @@ {?header:title=[WELCOME_SHIP_SIMU]?} +
+[HEADER_SHIP_SIMU] +
+ -
- [HEADER_SHIP_SIMU] +
- {?content?} +{?content?}
-{?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 index 0000000..22da43b --- /dev/null +++ b/application/ship-simu/templates/de/html/nav_advert.tpl @@ -0,0 +1 @@ + diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 6b4d816..6cc7a20 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -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 = "
".trim(print_r($this, true))."
"; + + // Output it + ApplicationEntryPoint::app_die("Debug output:".$content); + } } // [EOF] diff --git a/inc/classes/main/extended/class_SerializationContainer.php b/inc/classes/main/extended/class_SerializationContainer.php index 3987ad8..b07bfc9 100644 --- a/inc/classes/main/extended/class_SerializationContainer.php +++ b/inc/classes/main/extended/class_SerializationContainer.php @@ -70,7 +70,7 @@ class SerializationContainer extends FrameworkArrayObject { )); // Run it - @eval($eval); + eval($eval); // Add this item to the container list $containerInstance->append(array( diff --git a/inc/classes/main/template/class_TemplateEngine.php b/inc/classes/main/template/class_TemplateEngine.php index 980f56c..16fbd3c 100644 --- a/inc/classes/main/template/class_TemplateEngine.php +++ b/inc/classes/main/template/class_TemplateEngine.php @@ -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!"); @@ -864,6 +864,19 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate } // END - if (count($this->loadedRawData) ... } + /** + * 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 * @@ -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 %s 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 %s 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 %s 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 diff --git a/inc/classes/middleware/debug/class_DebugMiddleware.php b/inc/classes/middleware/debug/class_DebugMiddleware.php index 37d4ed9..f46dbb5 100644 --- a/inc/classes/middleware/debug/class_DebugMiddleware.php +++ b/inc/classes/middleware/debug/class_DebugMiddleware.php @@ -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"))) { diff --git a/index.php b/index.php index d0a0f08..9cabcb0 100644 --- a/index.php +++ b/index.php @@ -8,10 +8,10 @@ * But good little boys and girls would always initialize their variables... ;-) * * @author Roland Haeder - * @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 . + * along with this program. If not, see . */ 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 .= "".basename($trace['file']).":".$trace['line'].", ".$trace['function']."(".count($trace['args']).")
"; + } + + // 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: %s", + die(sprintf("[Main:] Emergency exit reached: %s", $message )); } diff --git a/templates/de/code/emergency_exit.ctp b/templates/de/code/emergency_exit.ctp index f747430..4cd1cf9 100644 --- a/templates/de/code/emergency_exit.ctp +++ b/templates/de/code/emergency_exit.ctp @@ -4,15 +4,15 @@ {?navigation:nav_row=home;imprint;contact?} -
+
$content[message]
-
-
+
+
Backtrace:
-
+
$content[backtrace]
diff --git a/templates/de/code/footer_msg.ctp b/templates/de/code/footer_msg.ctp index 309a0fd..c67ed0c 100644 --- a/templates/de/code/footer_msg.ctp +++ b/templates/de/code/footer_msg.ctp @@ -1,4 +1,4 @@ -