From 9315156949e696cb41366e12e840765269ac6284 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 14 Apr 2008 19:27:41 +0000 Subject: [PATCH] Fix for double inserting of template code --- .../ship-simu/templates/de/html/home.tpl | 4 +++- .../main/template/class_TemplateEngine.php | 21 +++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/application/ship-simu/templates/de/html/home.tpl b/application/ship-simu/templates/de/html/home.tpl index a7f8e71..6845ef1 100644 --- a/application/ship-simu/templates/de/html/home.tpl +++ b/application/ship-simu/templates/de/html/home.tpl @@ -3,5 +3,7 @@ Willkommen zum Schiffsimulator "Ship-Simu"! - Hier muss noch ein einleitender Text für die Eingangsseite hin (Home!) +
+ {?ship_simu_news?} +
diff --git a/inc/classes/main/template/class_TemplateEngine.php b/inc/classes/main/template/class_TemplateEngine.php index 5f13b6f..20984c2 100644 --- a/inc/classes/main/template/class_TemplateEngine.php +++ b/inc/classes/main/template/class_TemplateEngine.php @@ -739,13 +739,13 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate */ private function insertAllTemplates (array $templateMatches) { // Run through all loaded codes - foreach ($this->loadedRawData as $template => $code) { + foreach ($this->loadedRawData as $template=>$code) { // Search for the template $foundIndex = array_search($template, $templateMatches[1]); // Lookup the matching template replacement - if (isset($templateMatches[0][$foundIndex])) { + if (($foundIndex !== false) && (isset($templateMatches[0][$foundIndex]))) { // Get the current raw template $rawData = $this->getRawTemplateData(); @@ -755,8 +755,10 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate // Set the new raw data $this->setRawTemplateData($rawData); - } - } + + } // END - if + + } // END - foreach } /** @@ -829,13 +831,20 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate if (count($this->loadedRawData) > 0) { // Then compile all! - foreach ($this->loadedRawData as $template => $code) { + foreach ($this->loadedRawData as $template=>$code) { + + // Is this template already compiled? + if (in_array($template, $this->compiledTemplates)) { + // Then skip it + continue; + } // Search for the template $foundIndex = array_search($template, $templateMatches[1]); // Lookup the matching variable data - if (isset($templateMatches[3][$foundIndex])) { + if (($foundIndex !== false) && (isset($templateMatches[3][$foundIndex]))) { + // Split it up with another reg. exp. into variable=value pairs preg_match_all($this->regExpVarValue, $templateMatches[3][$foundIndex], $varMatches); -- 2.30.2