]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/template/mail/class_MailTemplateEngine.php
startElement(), finishElement() and characterHandler() must be public as they
[core.git] / inc / classes / main / template / mail / class_MailTemplateEngine.php
index 99072276eefb33f9dd3fd33ed3b6bad31f2cc118..7c66d76e0706d3522e026563fbbfb3f19f6935d9 100644 (file)
@@ -2,11 +2,11 @@
 /**
  * The own template engine for loading caching and sending out images
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.org
  * @todo               This template engine does not make use of setTemplateType()
  *
  * This program is free software: you can redistribute it and/or modify
@@ -43,7 +43,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
        /**
         * Mailer instance
         */
-       private $mailerInstance = null;
+       private $mailerInstance = NULL;
 
        /**
         * Current main node
@@ -63,8 +63,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
        /**
         * Creates an instance of the class TemplateEngine and prepares it for usage
         *
-        * @param       $appInstance    A manageable application
-        * @return      $templateInstance       An instance of TemplateEngine
+        * @return      $templateInstance               An instance of TemplateEngine
         * @throws      BasePathIsEmptyException                If the provided $templateBasePath is empty
         * @throws      InvalidBasePathStringException  If $templateBasePath is no string
         * @throws      BasePathIsNoDirectoryException  If $templateBasePath is no
@@ -72,16 +71,15 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @throws      BasePathReadProtectedException  If $templateBasePath is
         *                                                                                      read-protected
         */
-       public final static function createMailTemplateEngine (ManageableApplication $appInstance) {
+       public static final function createMailTemplateEngine () {
                // Get a new instance
                $templateInstance = new MailTemplateEngine();
 
-               // Get language and file I/O instances from application
-               $langInstance = $appInstance->getLanguageInstance();
-               $ioInstance = $appInstance->getFileIoInstance();
+               // Get the application instance from registry
+               $applicationInstance = Registry::getRegistry()->getInstance('app');
 
                // Determine base path
-               $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
+               $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/';
 
                // Is the base path valid?
                if (empty($templateBasePath)) {
@@ -98,22 +96,15 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                        throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
                }
 
-               // Get configuration instance
-               $configInstance = FrameworkConfiguration::getInstance();
-
                // Set the base path
                $templateInstance->setTemplateBasePath($templateBasePath);
 
-               // Set the language and IO instances
-               $templateInstance->setLanguageInstance($langInstance);
-               $templateInstance->setFileIoInstance($ioInstance);
-
                // Set template extensions
-               $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
-               $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
+               $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension'));
+               $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension'));
 
                // Absolute output path for compiled templates
-               $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
+               $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path'));
 
                // Return the prepared instance
                return $templateInstance;
@@ -155,7 +146,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         * @throws      InvalidXmlNodeException         If an unknown/invalid XML node name was found
         */
-       protected function startElement ($resource, $element, array $attributes) {
+       public function startElement ($resource, $element, array $attributes) {
                // Initial method name which will never be called...
                $methodName = 'initEmail';
 
@@ -188,7 +179,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         * @throws      XmlNodeMismatchException        If current main node mismatches the closing one
         */
-       protected function endElement ($resource, $nodeName) {
+       public function finishElement ($resource, $nodeName) {
                // Make all lower-case
                $nodeName = strtolower($nodeName);
 
@@ -216,14 +207,14 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @param       $characters             Characters to handle
         * @return      void
         */
-       protected function characterHandler ($resource, $characters) {
+       public function characterHandler ($resource, $characters) {
                // Trim all spaces away
                $characters = trim($characters);
 
                // Is this string empty?
                if (empty($characters)) {
                        // Then skip it silently
-                       return false;
+                       return;
                } // END - if
 
                // Add the message now
@@ -276,12 +267,10 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
        /**
         * Setter for subject line property
         *
-        * @param       $subjectLine    Subject line to set in email
         * @return      void
         */
-       private function setEmailPropertySubjectLine ($subjectLine) {
-               // Set the template variable
-               $this->assignVariable('subject', $subjectLine);
+       private function setEmailPropertySubjectLine () {
+               // Empty for now
        }
 
        /**
@@ -330,7 +319,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
        public function getMailCacheFqfn () {
                // Initialize FQFN
                $fqfn = '';
-               $this->debugBackTrace();
+               $this->debugBackTrace('Unfinished area!');
 
                // Return it
                return $fqfn;