Template inserts fixes
authorRoland Häder <roland@mxchange.org>
Mon, 5 May 2008 20:07:21 +0000 (20:07 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 5 May 2008 20:07:21 +0000 (20:07 +0000)
application/selector/templates/de/code/selector_main.ctp
application/ship-simu/templates/de/code/shipsimu_main.ctp
inc/classes/main/commands/local/class_LocalHomeCommand.php
inc/classes/main/template/class_TemplateEngine.php

index 77b5bf6f361e32f5eac79472f35abe15eb260a90..4779a57de40b42b4e4db41ea7a9219ae7b97afe3 100644 (file)
@@ -1,6 +1,6 @@
 <!-- A compileable template for the application selector //-->
 
-{?header:title=[WELCOME_APPLICATION_SELECTOR]?}
+{?header?}
 
 {?navigation?}
 
index 659c2bb43755f39bb54d8f7f1b77f7da2fdf488a..1841149942ae55f43915e2ebf58d6b1bcfe5ba6f 100644 (file)
@@ -1,6 +1,6 @@
 <!-- The compileable main template for the ship simulator //-->
 
-{?header:title=[WELCOME_SHIP_SIMU]?}
+{?header?}
 
 <div id="main_header">
 [HEADER_SHIP_SIMU]
index 033e1afc290ec5a738ccb8f6e34e81fd46886bdd..78d679943bb61ccecb39a32e56cb4d0312dbeadb 100644 (file)
@@ -78,6 +78,13 @@ class LocalHomeCommand extends BaseCommand implements Commandable {
                // Load the master template
                $masterTemplate = $appInstance->getMasterTemplate();
 
+               // Load header template
+               $templateInstance->loadCodeTemplate("header");
+
+               // Compile and assign it with a variable
+               $templateInstance->compileTemplate();
+               $templateInstance->assignTemplateWithVariable("header", "header");
+
                // Load the home template
                $templateInstance->loadWebTemplate("home");
 
@@ -87,9 +94,6 @@ class LocalHomeCommand extends BaseCommand implements Commandable {
                // Load the master template
                $templateInstance->loadCodeTemplate($masterTemplate);
 
-               // Compile it...
-               $templateInstance->compileTemplate();
-
                // Set title
                $title = ucfirst($requestInstance->getRequestElement($this->getConfigInstance()->readConfig("command_parameter")));
                if (empty($title)) $title = "Home";
index c9e05ab6029ebbb758b3ad20a5e3a963ca005733..e11b84d553c537104e487e13ade529ef7e0d28e6 100644 (file)
@@ -875,15 +875,14 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
 
                // Walk through all variables
                for ($idx = $this->varStack->getIterator(); $idx->valid(); $idx->next()) {
-
                        // Get current entry
                        $currEntry = $idx->current();
 
                        // Replace all [$var] or {?$var?} with the content
+                       //* DEBUG: */ echo "name=".$currEntry['name'].", value=<pre>".htmlentities($currEntry['value'])."</pre>\n";
                        $content = str_replace("\$content[".$currEntry['name']."]", $currEntry['value'], $content);
                        $content = str_replace("[".$currEntry['name']."]", $currEntry['value'], $content);
                        $content = str_replace("{?".$currEntry['name']."?}", $currEntry['value'], $content);
-
                } // END - for
 
                // Set the content back
@@ -968,6 +967,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        $currVariable = $idx->current();
 
                        // Transfer it's name/value combination to the $content array
+                       //* DEBUG: */ echo $currVariable['name']."=<pre>".htmlentities($currVariable['value'])."</pre>\n";
                        $dummy[$currVariable['name']] = $currVariable['value'];
 
                }// END - if
@@ -986,7 +986,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                $this->finalizeVariableCompilation();
 
                // Prepare the eval() command for comiling the template
-               $eval = sprintf("\$this->setCompiledData(\"%s\");",
+               $eval = sprintf("\$result = \"%s\";",
                        addslashes($this->getRawTemplateData())
                );
 
@@ -998,6 +998,9 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
 
                // Run the constructed command. This will "compile" all variables in
                eval($eval);
+
+               // Set the new content
+               $this->setCompiledData($result);
        }
 
        /**