* The own template engine for loading caching and sending out the web pages
* and emails.
*
- * @author Roland Haeder <webmaster@mxchange.org>
+ * @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
* @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("Template-Engine");
+ $this->setObjectDescription("Web template engine");
// Create unique ID number
$this->createUniqueID();
$tplInstance->setFileIoInstance($ioInstance);
// Set template extensions
- $tplInstance->setRawTemplateExtension($cfgInstance->readConfig("raw_template_extension"));
- $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig("code_template_extension"));
+ $tplInstance->setRawTemplateExtension($cfgInstance->readConfig('raw_template_extension'));
+ $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig('code_template_extension'));
// Absolute output path for compiled templates
- $tplInstance->setCompileOutputPath(PATH . $cfgInstance->readConfig("compile_output_path"));
+ $tplInstance->setCompileOutputPath(PATH . $cfgInstance->readConfig('compile_output_path'));
// Return the prepared instance
return $tplInstance;
* @return void
*/
public final function initVariableStack () {
- $this->varStack = new FrameworkArrayObject();
+ $this->varStack = new FrameworkArrayObject("FakedVariableStack");
}
/**
$ext = $this->getRawTemplateExtension();
// If we shall load a code-template we need to switch the file extension
- if ($this->getTemplateType() == $this->getConfigInstance()->readConfig("code_template_type")) {
+ if ($this->getTemplateType() == $this->getConfigInstance()->readConfig('code_template_type')) {
// Switch over to the code-template extension
$ext = $this->getCodeTemplateExtension();
}
// RECURSIVE PROTECTION! BE CAREFUL HERE!
if ((!isset($this->loadedRawData[$template])) && (!in_array($template, $this->loadedTemplates))) {
- // Then try to search for code-templates first
- try {
- // Load the code template and remember it's contents
- $this->loadCodeTemplate($template);
- $this->loadedRawData[$template] = $this->getRawTemplateData();
+ // Template not found, but maybe variable assigned?
+ if ($this->isVariableAlreadySet($template) !== false) {
+ // Use that content here
+ $this->loadedRawData[$template] = $this->readVariable($template);
- // Remember this template for recursion detection
- // RECURSIVE PROTECTION!
+ // Recursive protection:
$this->loadedTemplates[] = $template;
- } catch (FilePointerNotOpenedException $e) {
- // Template not found, but maybe variable assigned?
- if ($this->isVariableAlreadySet($template) !== false) {
- // Use that content here
- $this->loadedRawData[$template] = $this->readVariable($template);
-
- // Recursive protection:
+ } else {
+ // Then try to search for code-templates
+ try {
+ // Load the code template and remember it's contents
+ $this->loadCodeTemplate($template);
+ $this->loadedRawData[$template] = $this->getRawTemplateData();
+
+ // Remember this template for recursion detection
+ // RECURSIVE PROTECTION!
$this->loadedTemplates[] = $template;
- } else {
+ } catch (FilePointerNotOpenedException $e) {
// Even this is not done... :/
$this->rawTemplates[] = $template;
}
*/
public final function loadWebTemplate ($template) {
// Set template type
- $this->setTemplateType($this->getConfigInstance()->readConfig("web_template_type"));
+ $this->setTemplateType($this->getConfigInstance()->readConfig('web_template_type'));
// Load the special template
$this->loadTemplate($template);
*/
public final function loadEmailTemplate ($template) {
// Set template type
- $this->setTemplateType($this->getConfigInstance()->readConfig("email_template_type"));
+ $this->setTemplateType($this->getConfigInstance()->readConfig('email_template_type'));
// Load the special template
$this->loadTemplate($template);
*/
public final function loadCodeTemplate ($template) {
// Set template type
- $this->setTemplateType($this->getConfigInstance()->readConfig("code_template_type"));
+ $this->setTemplateType($this->getConfigInstance()->readConfig('code_template_type'));
// Load the special template
$this->loadTemplate($template);
*/
public final function compileVariables () {
// Initialize the $content array
- $validVar = $this->getConfigInstance()->readConfig("tpl_valid_var");
+ $validVar = $this->getConfigInstance()->readConfig('tpl_valid_var');
$dummy = array();
// Iterate through all variables
*/
public final function compileTemplate () {
// We will only work with template type "code" from configuration
- if ($this->getTemplateType() != $this->getConfigInstance()->readConfig("code_template_type")) {
+ 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);
+ 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.