From e45df7cacaa7d889402ce51ead090e455696d546 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 5 May 2008 20:07:21 +0000 Subject: [PATCH] Template inserts fixes --- .../selector/templates/de/code/selector_main.ctp | 2 +- .../ship-simu/templates/de/code/shipsimu_main.ctp | 2 +- .../main/commands/local/class_LocalHomeCommand.php | 10 +++++++--- inc/classes/main/template/class_TemplateEngine.php | 9 ++++++--- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/application/selector/templates/de/code/selector_main.ctp b/application/selector/templates/de/code/selector_main.ctp index 77b5bf6..4779a57 100644 --- a/application/selector/templates/de/code/selector_main.ctp +++ b/application/selector/templates/de/code/selector_main.ctp @@ -1,6 +1,6 @@ -{?header:title=[WELCOME_APPLICATION_SELECTOR]?} +{?header?} {?navigation?} diff --git a/application/ship-simu/templates/de/code/shipsimu_main.ctp b/application/ship-simu/templates/de/code/shipsimu_main.ctp index 659c2bb..1841149 100644 --- a/application/ship-simu/templates/de/code/shipsimu_main.ctp +++ b/application/ship-simu/templates/de/code/shipsimu_main.ctp @@ -1,6 +1,6 @@ -{?header:title=[WELCOME_SHIP_SIMU]?} +{?header?}
[HEADER_SHIP_SIMU] diff --git a/inc/classes/main/commands/local/class_LocalHomeCommand.php b/inc/classes/main/commands/local/class_LocalHomeCommand.php index 033e1af..78d6799 100644 --- a/inc/classes/main/commands/local/class_LocalHomeCommand.php +++ b/inc/classes/main/commands/local/class_LocalHomeCommand.php @@ -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"; diff --git a/inc/classes/main/template/class_TemplateEngine.php b/inc/classes/main/template/class_TemplateEngine.php index c9e05ab..e11b84d 100644 --- a/inc/classes/main/template/class_TemplateEngine.php +++ b/inc/classes/main/template/class_TemplateEngine.php @@ -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=
".htmlentities($currEntry['value'])."
\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']."=
".htmlentities($currVariable['value'])."
\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); } /** -- 2.39.2