]> git.mxchange.org Git - shipsimu.git/commitdiff
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 a7f8e71adc90291543edcd8a0e66ee7757b77439..6845ef1ab7f73e67c5432804d89023544a6dfd3f 100644 (file)
@@ -3,5 +3,7 @@
                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>
index 5f13b6f0611431797112038b13602a13de975037..20984c2fe181ddb40b6f309525060fc04aaec9b2 100644 (file)
@@ -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);