]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/template/class_TemplateEngine.php
Fake class names added, insertDataSet() stub added, dataset criteria added
[shipsimu.git] / inc / classes / main / template / class_TemplateEngine.php
index ee01937a364d75ebae00264c73138131e83a4b19..09abcca891c76e1fba4964a86be2418d1e91bef5 100644 (file)
@@ -3,7 +3,7 @@
  * 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
@@ -123,7 +123,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                parent::__construct(__CLASS__);
 
                // Set part description
-               $this->setObjectDescription("Template-Engine");
+               $this->setObjectDescription("Web template engine");
 
                // Create unique ID number
                $this->createUniqueID();
@@ -180,11 +180,11 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                $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;
@@ -290,7 +290,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         * @return      void
         */
        public final function initVariableStack () {
-               $this->varStack = new FrameworkArrayObject();
+               $this->varStack = new FrameworkArrayObject("FakedVariableStack");
        }
 
        /**
@@ -518,7 +518,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                $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();
                }
@@ -642,24 +642,24 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        // 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;
                                        }
@@ -905,7 +905,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         */
        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);
@@ -920,7 +920,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         */
        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);
@@ -935,7 +935,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         */
        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);
@@ -948,7 +948,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         */
        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
@@ -1047,9 +1047,9 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         */
        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.