Fix for double inserting of template code
authorRoland Häder <roland@mxchange.org>
Mon, 14 Apr 2008 19:27:41 +0000 (19:27 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 14 Apr 2008 19:27:41 +0000 (19:27 +0000)
application/ship-simu/templates/de/html/home.tpl
inc/classes/main/template/class_TemplateEngine.php

index a7f8e71..6845ef1 100644 (file)
@@ -3,5 +3,7 @@
                Willkommen zum Schiffsimulator &quot;Ship-Simu&quot;!
        </div>
 
                Willkommen zum Schiffsimulator &quot;Ship-Simu&quot;!
        </div>
 
-       Hier muss noch ein einleitender Text f&uuml;r die Eingangsseite hin (Home!)
+       <div class="news_frame">
+               {?ship_simu_news?}
+       </div>
 </div>
 </div>
index 5f13b6f..20984c2 100644 (file)
@@ -739,13 +739,13 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         */
        private function insertAllTemplates (array $templateMatches) {
                // Run through all loaded codes
         */
        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
 
                        // 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();
 
                                // 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);
 
                                // 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!
                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
 
                                // 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);
 
                                        // Split it up with another reg. exp. into variable=value pairs
                                        preg_match_all($this->regExpVarValue, $templateMatches[3][$foundIndex], $varMatches);