/**
* The constructor
*
- * @param $class An array holding our informations
+ * @param $msgArray An array holding our informations
* @param $code Code number for the exception
* @return void
*/
- public function __construct (BaseFrameworkSystem $class, $code) {
+ public function __construct (array $msgArray, $code) {
// Add a message around the missing class
$message = sprintf("[%s:%d] Der Template-Typ <u>%s</u> entspricht nicht dem erwartetem Template-Typ <u>%s</u>.",
- $class[0]->__toString(),
+ $msgArray[0]->__toString(),
$this->getLine(),
- $class[1],
- $class[2]
+ $msgArray[1],
+ $msgArray[2]
);
// Call parent constructor
}
}
+ /**
+ * Finalizes the compilation of all template variables
+ *
+ * @return void
+ */
+ private function finalizeVariableCompilation () {
+ // Get the content
+ $content = $this->getRawTemplateData();
+
+ // 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
+ $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
+ $this->setRawTemplateData($content);
+ }
+
/**
* Getter for raw template data
*
// Iterate through all variables
for ($idx = $this->varStack->getIterator(); $idx->valid(); $idx->next()) {
+
// Get current variable from the stack
$currVariable = $idx->current();
// Transfer it's name/value combination to the $content array
$dummy[$currVariable['name']] = $currVariable['value'];
- }
+
+ }// END - if
+
+ // Set the new variable (don't remove the second dollar !)
$$validVar = $dummy;
// Prepare all configuration variables
unset($idx);
unset($currVariable);
+ // Finalize the compilation of template variables
+ $this->finalizeVariableCompilation();
+
// Prepare the eval() command for comiling the template
$eval = sprintf("\$this->setCompiledData(\"%s\");",
addslashes($this->getRawTemplateData())
if ($this->getTemplateType() != $this->getConfigInstance()->readConfig("code_template_type")) {
// Abort here
throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->readConfig("code_template_type")), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED);
- }
+ } // END - if
// Get the raw data.
$rawData = $this->getRawTemplateData();
//
// The main analysis
$this->analyzeTemplate($templateMatches);
- $this->debugInstance();
// Compile raw template data
$this->compileRawTemplateData($templateMatches);
// Are some raw templates found and loaded?
if (count($this->rawTemplates) > 0) {
+
// Insert all raw templates
$this->insertRawTemplates();
- }
+
+ // Remove the raw template content as well
+ $this->setRawTemplateData("");
+
+ } // END - if
} // END - if($templateMatches ...
}