CSS classes formed to ids and command LocalHome finished
[shipsimu.git] / inc / classes / main / template / class_TemplateEngine.php
index 5f13b6f0611431797112038b13602a13de975037..980f56c9426b1e6eab6b451a96240bf46f41f59c 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);
 
@@ -1097,6 +1106,17 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                // Purge raw content
                $this->setRawTemplateData("");
        }
+
+       /**
+        * Transfers the content of this template engine to a given response instance
+        *
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       public function transferToResponse (Responseable $responseInstance) {
+               // Get the content and set it in the response class
+               $responseInstance->writeToBody($this->getCompiledData());
+       }
 }
 
 // [EOF]