More usage of FileNotFoundException
[core.git] / inc / classes / main / template / class_BaseTemplateEngine.php
index 11e3acc63fe8a13d11576371e5969b52a91bd45b..69b86079624860a2281e19fa35cebf38780e06b1 100644 (file)
@@ -505,7 +505,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         * @param               $templateBasePath               The relative base path for all templates
         * @return      void
         */
-       public final function setTemplateBasePath ($templateBasePath) {
+       protected final function setTemplateBasePath ($templateBasePath) {
                // And set it
                $this->templateBasePath = (string) $templateBasePath;
        }
@@ -537,7 +537,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         *                                                      templates
         * @return      void
         */
-       public final function setRawTemplateExtension ($templateExtension) {
+       protected final function setRawTemplateExtension ($templateExtension) {
                // And set it
                $this->templateExtension = (string) $templateExtension;
        }
@@ -549,7 +549,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         *                                                      templates
         * @return      void
         */
-       public final function setCodeTemplateExtension ($codeExtension) {
+       protected final function setCodeTemplateExtension ($codeExtension) {
                // And set it
                $this->codeExtension = (string) $codeExtension;
        }
@@ -583,7 +583,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         *                                                              templates
         * @return      void
         */
-       public final function setCompileOutputPath ($compileOutputPath) {
+       protected final function setCompileOutputPath ($compileOutputPath) {
                // And set it
                $this->compileOutputPath = (string) $compileOutputPath;
        }
@@ -647,7 +647,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        }
 
        /**
-        * Getter for compiled templates
+        * Getter for compiled templates, must be public for e.g. Mailer classes.
         *
         * @return      $compiledData   Compiled template data
         */
@@ -662,7 +662,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         * @param       $template       The template we shall load
         * @param       $extOther       An other extension to use
         * @return      void
-        * @throws      FileIoException If the template was not found
+        * @throws      FileNotFoundException   If the template was not found
         */
        protected function loadTemplate ($template, $extOther = '') {
                // Get extension for the template if empty
@@ -702,9 +702,9 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                try {
                        // Load the raw template data
                        $this->loadRawTemplateData($fqfn);
-               } catch (FileIoException $e) {
+               } catch (FileNotFoundException $e) {
                        // If we shall load a code-template we need to switch the file extension
-                       if (($this->getTemplateType() != $this->getConfigInstance()->getConfigEntry('web_template_type')) && (empty($extOther))) {
+                       if (($this->getTemplateType() != $this->getConfigInstance()->getConfigEntry('html_template_type')) && (empty($extOther))) {
                                // Switch over to the code-template extension and try it again
                                $ext = $this->getCodeTemplateExtension();
 
@@ -712,7 +712,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                                $this->loadTemplate($template, $ext);
                        } else {
                                // Throw it again
-                               throw new FileIoException($fqfn, self::EXCEPTION_FILE_NOT_FOUND);
+                               throw new FileNotFoundException($fqfn, self::EXCEPTION_FILE_NOT_FOUND);
                        }
                }
 
@@ -830,13 +830,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                                //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:template=' . $template);
 
                                // Template not found, but maybe variable assigned?
-                               if ($this->getVariableIndex($template, 'config') !== FALSE) {
-                                       // Use that content here
-                                       $this->loadedRawData[$template] = $this->readVariable($template, 'config');
-
-                                       // Recursive protection:
-                                       array_push($this->loadedTemplates, $template);
-                               } elseif ($this->getVariableIndex($template) !== FALSE) {
+                               if ($this->getVariableIndex($template) !== FALSE) {
                                        // Use that content here
                                        $this->loadedRawData[$template] = $this->readVariable($template);
 
@@ -852,7 +846,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                                                // Remember this template for recursion detection
                                                // RECURSIVE PROTECTION!
                                                array_push($this->loadedTemplates, $template);
-                                       } catch (FileIoException $e) {
+                                       } catch (FileNotFoundException $e) {
                                                // Even this is not done... :/
                                                array_push($this->rawTemplates, $template);
                                        }
@@ -940,7 +934,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                        foreach ($this->rawTemplates as $key => $template) {
                                try {
                                        // Load the template
-                                       $this->loadWebTemplate($template);
+                                       $this->loadHtmlTemplate($template);
 
                                        // Remember it's contents
                                        $this->rawTemplates[$template] = $this->getRawTemplateData();
@@ -951,7 +945,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                                        // Remember this template for recursion detection
                                        // RECURSIVE PROTECTION!
                                        array_push($this->loadedTemplates, $template);
-                               } catch (FileIoException $e) {
+                               } catch (FileNotFoundException $e) {
                                        // This template was never found. We silently ignore it
                                        unset($this->rawTemplates[$key]);
                                }
@@ -1092,15 +1086,15 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        }
 
        /**
-        * Load a specified web template into the engine
+        * Load a specified HTML template into the engine
         *
         * @param       $template       The web template we shall load which is located in
         *                                              'html' by default
         * @return      void
         */
-       public function loadWebTemplate ($template) {
+       public function loadHtmlTemplate ($template) {
                // Set template type
-               $this->setTemplateType($this->getConfigInstance()->getConfigEntry('web_template_type'));
+               $this->setTemplateType($this->getConfigInstance()->getConfigEntry('html_template_type'));
 
                // Load the special template
                $this->loadTemplate($template);
@@ -1188,24 +1182,24 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
 
                // Sweet and simple...
                //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: variableName=' . $variableName . ',getConfigEntry()=' . $this->getConfigInstance()->getConfigEntry($variableName));
-               $this->setVariable('config', $variableName, $this->getConfigInstance()->getConfigEntry($variableName));
+               $this->assignVariable($variableName, $this->getConfigInstance()->getConfigEntry($variableName));
        }
 
        /**
-        * Injects an array of config variables into the stack of currently loaded
-        * template. This method should only be used in very rare circumstances,
-        * e.g. when you have to copy a whole set of variables into the template
-        * engine. Before you use this method, please make sure you have considered
-        * all other possiblities.
+        * Assigns a lot variables into the stack of currently loaded template.
+        * This method should only be used in very rare circumstances, e.g. when
+        * you have to copy a whole set of variables into the template engine.
+        * Before you use this method, please make sure you have considered all
+        * other possiblities.
         *
-        * @param       $variables      An array with variables to be injected
+        * @param       $variables      An array with variables to be assigned
         * @return      void
         */
-       public function injectConfigVariables (array $variables) {
+       public function assignMultipleVariables (array $variables) {
                // "Inject" all
                foreach ($variables as $name => $value) {
                        // Set variable with name for 'config' group
-                       $this->setVariable('config', $name, $value);
+                       $this->assignVariable($name, $value);
                } // END - foreach
        }
 
@@ -1244,6 +1238,21 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                $this->loadTemplate($template);
        }
 
+       /**
+        * Load a specified email template into the engine
+        *
+        * @param       $template       The email template we shall load which is
+        *                                              located in 'emails' by default
+        * @return      void
+        */
+       public function loadEmailTemplate ($template) {
+               // Set template type
+               $this->setTemplateType($this->getConfigInstance()->getConfigEntry('email_template_type'));
+
+               // Load the special template
+               $this->loadTemplate($template);
+       }
+
        /**
         * Compiles configuration place-holders in all variables. This 'walks'
         * through the variable group 'general'. It interprets all values from that
@@ -1277,7 +1286,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                                $this->assignConfigVariable($value);
                        } else {
                                // Re-assign the value directly
-                               $this->setVariable('config', $currVariable['name'], $value);
+                               $this->assignVariable($currVariable['name'], $value);
                        }
                } // END - foreach
        }
@@ -1550,7 +1559,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                // Get a XmlParser instance
                $parserInstance = ObjectFactory::createObjectByConfiguredName('xml_parser_class', array($this));
 
-               // Check if we have XML compacting enabled
+               // Check if XML compacting is enabled
                if ($this->isXmlCompactingEnabled()) {
                        // Yes, so get a decorator class for transparent compacting
                        $parserInstance = ObjectFactory::createObjectByConfiguredName('deco_compacting_xml_parser_class', array($parserInstance));