Decorators moved, naming convention applied:
authorRoland Häder <roland@mxchange.org>
Tue, 9 Feb 2010 23:55:45 +0000 (23:55 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 9 Feb 2010 23:55:45 +0000 (23:55 +0000)
- Some generic decorators moved from hub project to this
- The naming convention requires $tplInstance to be not shorted, so
  $templateInstance is the right name
- Interface CompileableTemplate updated
- Deprecated methods removed from BaseTemplateEngine

19 files changed:
.gitattributes
inc/classes/interfaces/template/class_CompileableTemplate.php
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/decorator/.htaccess [new file with mode: 0644]
inc/classes/main/decorator/class_BaseDecorator.php [new file with mode: 0644]
inc/classes/main/decorator/template/.htaccess [new file with mode: 0644]
inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php [new file with mode: 0644]
inc/classes/main/decorator/xml/.htaccess [new file with mode: 0644]
inc/classes/main/decorator/xml/class_XmlCompactorDecorator.php [new file with mode: 0644]
inc/classes/main/mailer/class_BaseMailer.php
inc/classes/main/template/class_BaseTemplateEngine.php
inc/classes/main/template/console/class_ConsoleTemplateEngine.php
inc/classes/main/template/image/class_ImageTemplateEngine.php
inc/classes/main/template/mail/class_MailTemplateEngine.php
inc/classes/main/template/menu/class_MenuTemplateEngine.php
inc/classes/main/template/web/class_WebTemplateEngine.php
inc/config.php
setup-repos.sh
templates/README.1st [new file with mode: 0644]

index c45a449..2a7ae36 100644 (file)
@@ -321,6 +321,12 @@ inc/classes/main/debug/.htaccess -text
 inc/classes/main/debug/class_DebugConsoleOutput.php -text
 inc/classes/main/debug/class_DebugErrorLogOutput.php -text
 inc/classes/main/debug/class_DebugWebOutput.php -text
+inc/classes/main/decorator/.htaccess -text
+inc/classes/main/decorator/class_BaseDecorator.php -text
+inc/classes/main/decorator/template/.htaccess -text
+inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php -text
+inc/classes/main/decorator/xml/.htaccess -text
+inc/classes/main/decorator/xml/class_XmlCompactorDecorator.php -text
 inc/classes/main/discovery/.htaccess -text
 inc/classes/main/discovery/class_ -text
 inc/classes/main/discovery/class_BaseDiscovery.php -text
@@ -569,6 +575,7 @@ inc/selector.php -text
 /setup-repos.sh -text
 /svn-externals.txt -text
 templates/.htaccess -text
+templates/README.1st -text
 templates/_compiled/.htaccess -text
 templates/images/.htaccess -text
 templates/images/_cache/.htaccess -text
index 8667cd7..3432251 100644 (file)
@@ -51,39 +51,137 @@ interface CompileableTemplate extends FrameworkInterface {
        function loadCodeTemplate ($template);
 
        /**
-        * Load a specified email template into the engine
+        * Compile all variables by inserting their respective values
         *
-        * @param       $template       The email template we shall load which is
-        *                                              located in "emails" by default
         * @return      void
         */
-       function loadEmailTemplate ($template);
+       function compileVariables ();
+
 
        /**
-        * Compile all variables by inserting their respective values
+        * Compile all required code/web/email-templates into the current one
         *
         * @return      void
         */
-       function compileVariables ();
+       function compileTemplate ();
 
+       /**
+        * Adds a variable to current group
+        *
+        * @param       $var    Variable to set
+        * @param       $value  Value to store in variable
+        * @return      void
+        */
+       function addGroupVariable ($var, $value);
 
        /**
-        * Compile all required code/web/email-templates into the current one
+        * Removes a given variable
         *
+        * @param       $var    The variable we are looking for
         * @return      void
         */
-       function compileTemplate ();
+       function removeVariable ($var);
+
+       /**
+        * Assign a given congfiguration variable with a value
+        *
+        * @param       $var    The configuration variable we want to assign
+        * @return      void
+        */
+       function assignConfigVariable ($var);
+
+       /**
+        * Compiles configuration place-holders in all variables. This 'walks'
+        * through the variable stack 'general'. It interprets all values from that
+        * variables as configuration entries after compiling them.
+        *
+        * @return      void
+        */
+       function compileConfigInVariables ();
+
+       /**
+        * Assigns the last loaded raw template content with a given variable
+        *
+        * @param       $templateName   Name of the template we want to assign
+        * @param       $variableName   Name of the variable we want to assign
+        * @return      void
+        */
+       function assignTemplateWithVariable ($templateName, $variableName);
+
+       /**
+        * Transfers the content of this template engine to a given response instance
+        *
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       function transferToResponse (Responseable $responseInstance);
 
        /**
-        * Output the compiled template to the outside world. In case of web
-        * templates this would be vaild (X)HTML code. And in case of email
-        * templates this would store a prepared email body inside the template
-        * engine.
+        * Assigns all the application data with template variables
         *
+        * @param       $appInstance    A manageable application instance
         * @return      void
         */
-       function output ();
+       function assignApplicationData (ManageableApplication $appInstance);
+
+       /**
+        * "Compiles" a variable by replacing {?var?} with it's content
+        *
+        * @param       $rawCode                        Raw code to compile
+        * @param       $setMatchAsCode         Sets $match if readVariable() returns empty result
+        * @return      $rawCode        Compile code with inserted variable value
+        */
+       function compileRawCode ($rawCode, $setMatchAsCode=false);
+
+       /**
+        * Renames a variable in code and in stack
+        *
+        * @param       $oldName        Old name of variable
+        * @param       $newName        New name of variable
+        * @return      void
+        */
+       function renameVariable ($oldName, $newName);
+
+       /**
+        * Renders the given XML content
+        *
+        * @param       $content        Valid XML content or if not set the current loaded raw content
+        * @return      void
+        * @throws      XmlParserException      If an XML error was found
+        */
+       function renderXmlContent ($content = null);
+
+       /**
+        * Enables or disables language support
+        *
+        * @param       $languageSupport        New language support setting
+        * @return      void
+        */
+       function enableLanguageSupport ($languageSupport = true);
+
+       /**
+        * Checks wether language support is enabled
+        *
+        * @return      $languageSupport        Wether language support is enabled or disabled
+        */
+       function isLanguageSupportEnabled ();
+
+       /**
+        * Enables or disables XML compacting
+        *
+        * @param       $xmlCompacting  New XML compacting setting
+        * @return      void
+        */
+       function enableXmlCompacting ($xmlCompacting = true);
+
+       /**
+        * Checks wether XML compacting is enabled
+        *
+        * @return      $xmlCompacting  Wether XML compacting is enabled or disabled
+        */
+       function isXmlCompactingEnabled ();
 }
 
 // [EOF]
 ?>
+
index 9ef0a80..923ef28 100644 (file)
@@ -109,6 +109,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        private $compressorInstance = null;
 
        /**
+        * A Parseable instance
+        */
+       private $parserInstance = null;
+
+       /**
         * The real class name
         */
        private $realClass      = 'BaseFrameworkSystem';
@@ -1320,6 +1325,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        public final function getCompressorInstance () {
                return $this->compressorInstance;
        }
+
+       /**
+        * Setter for Parseable instanxe
+        *
+        * @param       $parserInstance An instance of an Parseable
+        * @return      void
+        */
+       public final function setParserInstance (Parseable $parserInstance) {
+               $this->parserInstance = $parserInstance;
+       }
+
+       /**
+        * Getter for Parseable instanxe
+        *
+        * @return      $parserInstance An instance of an Parseable
+        */
+       public final function getParserInstance () {
+               return $this->parserInstance;
+       }
 }
 
 // [EOF]
diff --git a/inc/classes/main/decorator/.htaccess b/inc/classes/main/decorator/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/decorator/class_BaseDecorator.php b/inc/classes/main/decorator/class_BaseDecorator.php
new file mode 100644 (file)
index 0000000..c837229
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * A general Decorator
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseDecorator extends BaseHubSystem {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/decorator/template/.htaccess b/inc/classes/main/decorator/template/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php b/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php
new file mode 100644 (file)
index 0000000..90126f8
--- /dev/null
@@ -0,0 +1,395 @@
+<?php
+/**
+ * A decorator for XML template engines which rewrites the XML for compacting
+ * it.
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableTemplate {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of the class TemplateEngine and prepares it for usage
+        *
+        * @param       $innerTemplateInstance  A CompileableTemplate instance
+        * @return      $templateInstance       An instance of TemplateEngine
+        */
+       public final static function createXmlRewriterTemplateDecorator (CompileableTemplate $innerTemplateInstance) {
+               // Get a new instance
+               $templateInstance = new XmlRewriterTemplateDecorator();
+
+               // Set the inner template engine
+               $templateInstance->setTemplateInstance($innerTemplateInstance);
+
+               // Return the prepared instance
+               return $templateInstance;
+       }
+
+       /**
+        * Settter for variable group
+        *
+        * @param       $groupName      Name of variable group
+        * @param       $add            Wether add this group
+        * @return      void
+        */
+       public function setVariableGroup ($groupName, $add = true) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->setVariableGroup($groupName, $add);
+       }
+
+       /**
+        * Adds a variable to current group
+        *
+        * @param       $var    Variable to set
+        * @param       $value  Value to store in variable
+        * @return      void
+        */
+       public function addGroupVariable ($var, $value) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->addGroupVariable($var, $value);
+       }
+
+       /**
+        * Setter for base path
+        *
+        * @param       $templateBasePath       The relative base path for all templates
+        * @return      void
+        */
+       public final function setTemplateBasePath ($templateBasePath) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->setTemplateBasePath($templateBasePath);
+       }
+
+       /**
+        * Getter for base path
+        *
+        * @return      $templateBasePath       The relative base path for all templates
+        */
+       public final function getTemplateBasePath () {
+               // Call the inner class' method
+               return $this->getTemplateInstance()->getTemplateBasePath();
+       }
+
+       /**
+        * Getter for generic base path
+        *
+        * @return      $templateBasePath       The relative base path for all templates
+        */
+       public final function getGenericBasePath () {
+               // Call the inner class' method
+               return $this->getTemplateInstance()->getGenericBasePath();
+       }
+
+       /**
+        * Setter for template extension
+        *
+        * @param       $templateExtension      The file extension for all uncompiled templates
+        * @return      void
+        */
+       public final function setRawTemplateExtension ($templateExtension) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->setRawTemplateExtension($templateExtension);
+       }
+
+       /**
+        * Setter for code template extension
+        *
+        * @param       $codeExtension  The file extension for all uncompiled templates
+        * @return      void
+        */
+       public final function setCodeTemplateExtension ($codeExtension) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->setCodeTemplateExtension($codeExtension);
+       }
+
+       /**
+        * Getter for template extension
+        *
+        * @return      $templateExtension      The file extension for all uncompiled templates
+        */
+       public final function getRawTemplateExtension () {
+               // Call the inner class' method
+               return $this->getTemplateInstance()->getRawTemplateExtension();
+       }
+
+       /**
+        * Getter for code-template extension
+        *
+        * @return      $codeExtension  The file extension for all code templates
+        */
+       public final function getCodeTemplateExtension () {
+               // Call the inner class' method
+               return $this->getTemplateInstance()->getCodeTemplateExtension();
+       }
+
+       /**
+        * Setter for path of compiled templates
+        *
+        * @param       $compileOutputPath      The local base path for all compiled templates
+        * @return      void
+        */
+       public final function setCompileOutputPath ($compileOutputPath) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->setCompileOutputPath($compileOutputPath);
+       }
+
+       /**
+        * Getter for template type
+        *
+        * @return      $templateType   The current template's type
+        */
+       public final function getTemplateType () {
+               // Call the inner class' method
+               return $this->getTemplateInstance()->getTemplateType();
+       }
+
+       /**
+        * Assign (add) a given variable with a value
+        *
+        * @param       $var    The variable we are looking for
+        * @param       $value  The value we want to store in the variable
+        * @return      void
+        * @throws      EmptyVariableException  If the variable name is left empty
+        */
+       public final function assignVariable ($var, $value) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->assignVariable($var, $value);
+       }
+
+       /**
+        * Removes a given variable
+        *
+        * @param       $var    The variable we are looking for
+        * @return      void
+        */
+       public final function removeVariable ($var) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->removeVariable($var);
+       }
+
+       /**
+        * Getter for compiled templates
+        *
+        * @return      $compiledData   Compiled template data
+        */
+       public final function getCompiledData () {
+               // Call the inner class' method
+               return $this->getTemplateInstance()->getCompiledData();
+       }
+
+       /**
+        * Load a specified web 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) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->loadWebTemplate($template);
+       }
+
+       /**
+        * Assign a given congfiguration variable with a value
+        *
+        * @param       $var    The configuration variable we want to assign
+        * @return      void
+        */
+       public function assignConfigVariable ($var) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->assignConfigVariable($var);
+       }
+
+       /**
+        * Load a specified code template into the engine
+        *
+        * @param       $template       The code template we shall load which is
+        *                                              located in 'code' by default
+        * @return      void
+        */
+       public function loadCodeTemplate ($template) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->loadCodeTemplate($template);
+       }
+
+       /**
+        * Compiles configuration place-holders in all variables. This 'walks'
+        * through the variable stack 'general'. It interprets all values from that
+        * variables as configuration entries after compiling them.
+        *
+        * @return      void
+        */
+       public final function compileConfigInVariables () {
+               // Call the inner class' method
+               $this->getTemplateInstance()->compileConfigInVariables();
+       }
+
+       /**
+        * Compile all variables by inserting their respective values
+        *
+        * @return      void
+        */
+       public final function compileVariables () {
+               // Call the inner class' method
+               $this->getTemplateInstance()->compileVariables();
+       }
+
+       /**
+        * Compile all required templates into the current loaded one
+        *
+        * @return      void
+        */
+       public function compileTemplate () {
+               // Call the inner class' method
+               $this->getTemplateInstance()->compileTemplate();
+       }
+
+       /**
+        * Assigns the last loaded raw template content with a given variable
+        *
+        * @param       $templateName   Name of the template we want to assign
+        * @param       $variableName   Name of the variable we want to assign
+        * @return      void
+        */
+       public function assignTemplateWithVariable ($templateName, $variableName) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->assignTemplateWithVariable($templateName, $variableName);
+       }
+
+       /**
+        * Transfers the content of this template engine to a given response instance
+        *
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       public function transferToResponse (Responseable $responseInstance) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->transportToResponse($responseInstance);
+       }
+
+       /**
+        * Assigns all the application data with template variables
+        *
+        * @param       $appInstance    A manageable application instance
+        * @return      void
+        */
+       public function assignApplicationData (ManageableApplication $appInstance) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->assignApplicationData($appInstance);
+       }
+
+       /**
+        * "Compiles" a variable by replacing {?var?} with it's content
+        *
+        * @param       $rawCode                        Raw code to compile
+        * @param       $setMatchAsCode         Sets $match if readVariable() returns empty result
+        * @return      $rawCode        Compile code with inserted variable value
+        */
+       public function compileRawCode ($rawCode, $setMatchAsCode=false) {
+               return $this->getTemplateInstance()->compileRawCode($rawCode, $setMatchAsCode);
+       }
+
+       /**
+        * Getter for variable group array
+        *
+        * @return      $vargroups      All variable groups
+        */
+       public final function getVariableGroups () {
+               // Call the inner class' method
+               return $this->getTemplateInstance()->getVariableGroups();
+       }
+
+       /**
+        * Renames a variable in code and in stack
+        *
+        * @param       $oldName        Old name of variable
+        * @param       $newName        New name of variable
+        * @return      void
+        */
+       public function renameVariable ($oldName, $newName) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->renameVariable($oldName, $newName);
+       }
+
+       /**
+        * Renders the given XML content
+        *
+        * @param       $content        Valid XML content or if not set the current loaded raw content
+        * @return      void
+        * @throws      XmlParserException      If an XML error was found
+        */
+       public function renderXmlContent ($content = null) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->renderXmlContent($content);
+       }
+
+       /**
+        * Enables or disables language support
+        *
+        * @param       $languageSupport        New language support setting
+        * @return      void
+        */
+       public final function enableLanguageSupport ($languageSupport = true) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->enableLanguageSupport($languageSupport);
+       }
+
+       /**
+        * Checks wether language support is enabled
+        *
+        * @return      $languageSupport        Wether language support is enabled or disabled
+        */
+       public final function isLanguageSupportEnabled () {
+               // Call the inner class' method
+               return $this->getTemplateInstance()->isLanguageSupportEnabled();
+       }
+
+       /**
+        * Enables or disables XML compacting
+        *
+        * @param       $xmlCompacting  New XML compacting setting
+        * @return      void
+        */
+       public final function enableXmlCompacting ($xmlCompacting = true) {
+               // Call the inner class' method
+               $this->getTemplateInstance()->enableXmlCompacting($xmlCompacting);
+       }
+
+       /**
+        * Checks wether XML compacting is enabled
+        *
+        * @return      $xmlCompacting  Wether XML compacting is enabled or disabled
+        */
+       public final function isXmlCompactingEnabled () {
+               // Call the inner class' method
+               return $this->getTemplateInstance()->isXmlCompactingEnabled();
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/decorator/xml/.htaccess b/inc/classes/main/decorator/xml/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/decorator/xml/class_XmlCompactorDecorator.php b/inc/classes/main/decorator/xml/class_XmlCompactorDecorator.php
new file mode 100644 (file)
index 0000000..0e191c9
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * A XML compacting decorator class for XML parsers
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class XmlCompactorDecorator extends BaseDecorator implements Parseable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of the class Parser and prepares it for usage
+        *
+        * @param       $innerParserInstance    A Parseable instance
+        * @return      $parserInstance         An instance of this parser
+        */
+       public final static function createXmlCompactorDecorator (Parseable $innerParserInstance) {
+               // Get a new instance
+               $parserInstance = new XmlCompactorDecorator();
+
+               // Get a new decorator instance for the template engine
+               $templateInstance = ObjectFactory::createObjectByConfiguredName('deco_xml_rewriter_template_class', array($innerParserInstance->getTemplateInstance()));
+
+               // Re-set the parser's template instance to the decorator instance
+               $innerParserInstance->setTemplateInstance($templateInstance);
+
+               // Set the inner parser instance
+               $parserInstance->setParserInstance($innerParserInstance);
+
+               // Return the prepared instance
+               return $parserInstance;
+       }
+
+       /**
+        * Parses the given XML content
+        *
+        * @param       $content        Valid XML content
+        * @return      void
+        * @throws      XmlCompactorDecoratorException  If an XML error was found
+        */
+       public function parseXmlContent ($content) {
+               // Parse the content
+               $this->getParserInstance()->parseXmlContent($content);
+       }
+}
+
+// [EOF]
+?>
index 76ab283..5d2b045 100644 (file)
@@ -57,7 +57,9 @@ class BaseMailer extends BaseFrameworkSystem {
                $templatePrefix = $this->getConfigInstance()->getConfigEntry('email_tpl_' . $templateName);
 
                // Load this email template
-               $this->getTemplateInstance()->loadEmailTemplate($templatePrefix . '_' . $templateName);
+               // @TODO This needs testing/fixes because the deprecated method
+               // loadEmailTemplate() has been removed from interface CompileableTemplate.
+               $this->getTemplateInstance()->loadCodeTemplate($templatePrefix . '_' . $templateName);
        }
 
        /**
index 2256fab..d04e154 100644 (file)
@@ -136,6 +136,11 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         */
        private $languageSupport = true;
 
+       /**
+        * XML compacting is disabled by default
+        */
+       private $xmlCompacting = false;
+
        // Exception codes for the template engine
        const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED   = 0x110;
        const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x111;
@@ -156,17 +161,21 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         * Search for a variable in the stack
         *
         * @param       $var    The variable we are looking for
+        * @param       $stack  Optional variable stack to look in
         * @return      $idx    FALSE means not found, >=0 means found on a specific index
         */
-       private function isVariableAlreadySet ($var) {
+       private function isVariableAlreadySet ($var, $stack = null) {
                // First everything is not found
                $found = false;
 
+               // If the stack is null, use the current group
+               if (is_null($stack)) $stack = $this->currGroup;
+
                // Is the group there?
-               if (isset($this->varStack[$this->currGroup])) {
+               if ($this->isVarStackSet($stack)) {
                        // Now search for it
-                       foreach ($this->varStack[$this->currGroup] as $idx => $currEntry) {
-                               //* DEBUG: */ echo __METHOD__.":currGroup={$this->currGroup},idx={$idx},currEntry={$currEntry['name']},var={$var}<br />\n";
+                       foreach ($this->getVarStack($stack) as $idx => $currEntry) {
+                               //* DEBUG: */ echo __METHOD__.":currGroup={$stack},idx={$idx},currEntry={$currEntry['name']},var={$var}<br />\n";
                                // Is the entry found?
                                if ($currEntry['name'] == $var) {
                                        // Found!
@@ -182,26 +191,54 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        }
 
        /**
+        * Checks wether the given variable stack is set
+        *
+        * @param       $stack  Variable stack to check
+        * @return      $isSet  Wether the given variable stack is set
+        */
+       protected final function isVarStackSet ($stack) {
+               // Check it
+               $isSet = isset($this->varStack[$stack]);
+
+               // Return result
+               return $isSet;
+       }
+
+       /**
+        * Getter for given variable stack
+        *
+        * @param       $stack          Variable stack to check
+        * @return      $varStack       Found variable stack
+        */
+       public final function getVarStack ($stack) {
+               return $this->varStack[$stack];
+       }
+
+       /**
         * Return a content of a variable or null if not found
         *
         * @param       $var            The variable we are looking for
+        * @param       $stack          Optional variable stack to look in
         * @return      $content        Content of the variable or null if not found
         */
-       protected function readVariable ($var) {
+       protected function readVariable ($var, $stack = null) {
                // First everything is not found
                $content = null;
 
+               // If the stack is null, use the current group
+               if (is_null($stack)) $stack = $this->currGroup;
+
                // Get variable index
-               $found = $this->isVariableAlreadySet($var);
+               $found = $this->isVariableAlreadySet($var, $stack);
 
                // Is the variable found?
                if ($found !== false) {
                        // Read it
-                       $content = $this->varStack[$this->currGroup][$found]['value'];
+                       $content = $this->getVariableValue($stack, $found);
                } // END - if
 
                // Return the current position
-               //* DEBUG: */ echo __METHOD__.": group=".$this->currGroup.",var=".$var.", content[".gettype($content)."]=".$content."<br />\n";
+               //* DEBUG: */ echo __METHOD__.": group=".$stack.",var=".$var.", content[".gettype($content)."]=".$content."<br />\n";
                return $content;
        }
 
@@ -230,9 +267,9 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                $result = array();
 
                // Is the group there?
-               if (isset($this->varStack[$this->currGroup])) {
+               if ($this->isVarStackSet($this->currGroup)) {
                        // Then use it
-                       $result = $this->varStack[$this->currGroup];
+                       $result = $this->getVarStack($this->currGroup);
                } // END - if
 
                // Return result
@@ -244,7 +281,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         *
         * @param       $groupName      Name of variable group
         * @param       $add            Wether add this group
-        * @retur4n     void
+        * @retur     void
         */
        public function setVariableGroup ($groupName, $add = true) {
                // Set group name
@@ -278,7 +315,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                );
 
                // Add it to the stack
-               $this->varStack[$this->currGroup] = $currVars;
+               $this->setVarStack($this->currGroup, $currVars);
        }
 
        /**
@@ -295,7 +332,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                // Is the variable set?
                if ($idx !== false) {
                        // Then modify it
-                       $this->varStack[$this->currGroup][$idx]['value'] = $value;
+                       $this->setVariableValue($this->currGroup, $idx, $value);
                } // END - if
        }
 
@@ -486,7 +523,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        protected final function setRawTemplateData ($rawTemplateData) {
                // And store it in this class
                //* DEBUG: */ echo __METHOD__.':'.$this->getUniqueId().': '.strlen($rawTemplateData).' Bytes set.<br />\n';
-               //* DEBUG: */ echo $this->currGroup.' variables: '.count($this->varStack[$this->currGroup]).', groups='.count($this->varStack).'<br />\n';
+               //* DEBUG: */ echo $this->currGroup.' variables: '.count($this->getVarStack($this->currGroup)).', groups='.count($this->varStack).'<br />\n';
                $this->rawTemplateData = (string) $rawTemplateData;
        }
 
@@ -690,9 +727,9 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
 
                                        // Recursive protection:
                                        $this->loadedTemplates[] = $template;
-                               } elseif (isset($this->varStack['config'][$template])) {
+                               } elseif ($this->isVariableAlreadySet($template, 'config')) {
                                        // Use that content here
-                                       $this->loadedRawData[$template] = $this->varStack['config'][$template];
+                                       $this->loadedRawData[$template] = $this->readVariable($template, 'config');
 
                                        // Recursive protection:
                                        $this->loadedTemplates[] = $template;
@@ -908,18 +945,25 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                $content = $this->getRawTemplateData();
                //* DEBUG: */ echo __METHOD__.': content before='.strlen($content).' ('.md5($content).')<br />\n';
 
+               // Do we have the stack?
+               if (!$this->isVarStackSet('general')) {
+                       // Abort here silently
+                       // @TODO This silent abort should be logged, maybe.
+                       return;
+               } // END - if
+
                // Walk through all variables
-               foreach ($this->varStack['general'] as $currEntry) {
+               foreach ($this->getVarStack('general') as $currEntry) {
                        //* DEBUG: */ echo __METHOD__.': name='.$currEntry['name'].', value=<pre>'.htmlentities($currEntry['value']).'</pre>\n';
                        // Replace all [$var] or {?$var?} with the content
                        // @TODO Old behaviour, will become obsolete!
-                       $content = str_replace("\$content[".$currEntry['name'].']', $currEntry['value'], $content);
+                       $content = str_replace('$content[' . $currEntry['name'] . ']', $currEntry['value'], $content);
 
                        // @TODO Yet another old way
-                       $content = str_replace('['.$currEntry['name'].']', $currEntry['value'], $content);
+                       $content = str_replace('[' . $currEntry['name'] . ']', $currEntry['value'], $content);
 
                        // The new behaviour
-                       $content = str_replace('{?'.$currEntry['name'].'?}', $currEntry['value'], $content);
+                       $content = str_replace('{?' . $currEntry['name'] . '?}', $currEntry['value'], $content);
                } // END - for
 
                //* DEBUG: */ echo __METHOD__.': content after='.strlen($content).' ('.md5($content).')<br />\n';
@@ -952,24 +996,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        public function assignConfigVariable ($var) {
                // Sweet and simple...
                //* DEBUG: */ echo __METHOD__.':var={$var}<br />\n';
-               $this->varStack['config'][$var] = $this->getConfigInstance()->getConfigEntry($var);
-       }
-
-       /**
-        * 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
-        * @deprecated
-        * @see         See loadCodeTemplate()
-        */
-       public function loadEmailTemplate ($template) {
-               // Set template type
-               $this->setTemplateType($this->getConfigInstance()->getConfigEntry('email_template_type'));
-
-               // Load the special template
-               $this->loadTemplate($template);
+               $this->setVariable('config', $var, $this->getConfigInstance()->getConfigEntry($var));
        }
 
        /**
@@ -995,13 +1022,20 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         * @return      void
         */
        public final function compileConfigInVariables () {
+               // Do we have the stack?
+               if (!$this->isVarStackSet('general')) {
+                       // Abort here silently
+                       // @TODO This silent abort should be logged, maybe.
+                       return;
+               } // END - if
+
                // Iterate through all general variables
-               foreach ($this->varStack['general'] as $idx=>$currVariable) {
+               foreach ($this->getVarStack('general') as $idx=>$currVariable) {
                        // Compile the value
                        $value = $this->compileRawCode($this->readVariable($currVariable['name']), true);
 
                        // Remove it from stack
-                       unset($this->varStack['general'][$idx]);
+                       $this->removeVariable($idx, 'general');
 
                        // Re-assign the variable
                        $this->assignConfigVariable($value);
@@ -1020,7 +1054,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                $dummy = array();
 
                // Iterate through all general variables
-               foreach ($this->varStack['general'] as $currVariable) {
+               foreach ($this->getVarStack('general') as $currVariable) {
                        // Transfer it's name/value combination to the $content array
                        //* DEBUG: */ echo $currVariable['name'].'=<pre>'.htmlentities($currVariable['value']).'</pre>\n';
                        $dummy[$currVariable['name']] = $currVariable['value'];
@@ -1031,8 +1065,8 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
 
                // Prepare all configuration variables
                $config = null;
-               if (isset($this->varStack['config'])) {
-                       $config = $this->varStack['config'];
+               if ($this->isVarStackSet('config')) {
+                       $config = $this->getVarStack('config');
                } // END - if
 
                // Remove some variables
@@ -1159,35 +1193,6 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        }
 
        /**
-        * A old deprecated method
-        *
-        * @return      void
-        * @deprecated
-        * @see         BaseTemplateEngine::transferToResponse
-        */
-       public function output () {
-               // Check which type of template we have
-               switch ($this->getTemplateType()) {
-                       case 'html': // Raw HTML templates can be send to the output buffer
-                               // Quick-N-Dirty:
-                               $this->getWebOutputInstance()->output($this->getCompiledData());
-                               break;
-
-                       default: // Unknown type found
-                               // Construct message
-                               $msg = sprintf("[%s-&gt;%s] Unknown/unsupported template type <span class=\"data\">%s</span> detected.",
-                                       $this->__toString(),
-                                       __FUNCTION__,
-                                       $this->getTemplateType()
-                               );
-
-                               // Write the problem to the world...
-                               $this->debugOutput($msg);
-                               break;
-               } // END - switch
-       }
-
-       /**
         * Loads a given view helper (by name)
         *
         * @param       $helperName             The helper's name
@@ -1342,6 +1347,12 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                // Get a XmlParser instance
                $parserInstance = ObjectFactory::createObjectByConfiguredName('xml_parser_class', array($this));
 
+               // Check if we have XML compacting enabled
+               if ($this->isXmlCompactingEnabled()) {
+                       // Yes, so get a decorator class for transparent compacting
+                       $parserInstance = ObjectFactory::createObjectByConfiguredName('deco_compacting_xml_parser_class', array($parserInstance));
+               } // END - if
+
                // Parse the XML document
                $parserInstance->parseXmlContent($content);
        }
@@ -1364,6 +1375,25 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        public final function isLanguageSupportEnabled () {
                return $this->languageSupport;
        }
+
+       /**
+        * Enables or disables XML compacting
+        *
+        * @param       $xmlCompacting  New XML compacting setting
+        * @return      void
+        */
+       public final function enableXmlCompacting ($xmlCompacting = true) {
+               $this->xmlCompacting = (bool) $xmlCompacting;
+       }
+
+       /**
+        * Checks wether XML compacting is enabled
+        *
+        * @return      $xmlCompacting  Wether XML compacting is enabled or disabled
+        */
+       public final function isXmlCompactingEnabled () {
+               return $this->xmlCompacting;
+       }
 }
 
 // [EOF]
index ce4230f..1de871e 100644 (file)
@@ -7,6 +7,7 @@
  * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
+ * @todo               This template engine does not make use of setTemplateType()
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -36,7 +37,7 @@ class ConsoleTemplateEngine extends BaseTemplateEngine implements CompileableTem
         * Creates an instance of the class TemplateEngine and prepares it for usage
         *
         * @param       $appInstance    A manageable application
-        * @return      $tplInstance    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
@@ -46,49 +47,49 @@ class ConsoleTemplateEngine extends BaseTemplateEngine implements CompileableTem
         */
        public final static function createConsoleTemplateEngine (ManageableApplication $appInstance) {
                // Get a new instance
-               $tplInstance = new ConsoleTemplateEngine();
+               $templateInstance = new ConsoleTemplateEngine();
 
                // Get language and file I/O instances from application
                $langInstance = $appInstance->getLanguageInstance();
                $ioInstance = $appInstance->getFileIoInstance();
 
                // Determine base path
-               $templateBasePath = $tplInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
+               $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
 
                // Is the base path valid?
                if (empty($templateBasePath)) {
                        // Base path is empty
-                       throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+                       throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } elseif (!is_string($templateBasePath)) {
                        // Is not a string
-                       throw new InvalidBasePathStringException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
+                       throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
                } elseif (!is_dir($templateBasePath)) {
                        // Is not a path
-                       throw new BasePathIsNoDirectoryException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
+                       throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
                } elseif (!is_readable($templateBasePath)) {
                        // Is not readable
-                       throw new BasePathReadProtectedException(array($tplInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
+                       throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
                }
 
                // Get configuration instance
                $configInstance = FrameworkConfiguration::getInstance();
 
                // Set the base path
-               $tplInstance->setTemplateBasePath($templateBasePath);
+               $templateInstance->setTemplateBasePath($templateBasePath);
 
                // Set the language and IO instances
-               $tplInstance->setLanguageInstance($langInstance);
-               $tplInstance->setFileIoInstance($ioInstance);
+               $templateInstance->setLanguageInstance($langInstance);
+               $templateInstance->setFileIoInstance($ioInstance);
 
                // Set template extensions
-               $tplInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
-               $tplInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
+               $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
+               $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
 
                // Absolute output path for compiled templates
-               $tplInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
+               $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
 
                // Return the prepared instance
-               return $tplInstance;
+               return $templateInstance;
        }
 }
 
index 908e426..dad6ab4 100644 (file)
@@ -70,7 +70,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
         * Creates an instance of the class TemplateEngine and prepares it for usage
         *
         * @param       $appInstance    A manageable application
-        * @return      $tplInstance    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
index 1d39894..cfbd7b5 100644 (file)
@@ -7,6 +7,7 @@
  * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
+ * @todo               This template engine does not make use of setTemplateType()
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +26,9 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
        /**
         * Main nodes in the XML tree
         */
-       private $mainNodes = array("mail-data");
+       private $mainNodes = array(
+               'mail-data'
+       );
 
        /**
         * Sub nodes in the XML tree
@@ -61,7 +64,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      $tplInstance    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
@@ -71,49 +74,49 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         */
        public final static function createMailTemplateEngine (ManageableApplication $appInstance) {
                // Get a new instance
-               $tplInstance = new MailTemplateEngine();
+               $templateInstance = new MailTemplateEngine();
 
                // Get language and file I/O instances from application
                $langInstance = $appInstance->getLanguageInstance();
                $ioInstance = $appInstance->getFileIoInstance();
 
                // Determine base path
-               $templateBasePath = $tplInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
+               $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
 
                // Is the base path valid?
                if (empty($templateBasePath)) {
                        // Base path is empty
-                       throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+                       throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } elseif (!is_string($templateBasePath)) {
                        // Is not a string
-                       throw new InvalidBasePathStringException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
+                       throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
                } elseif (!is_dir($templateBasePath)) {
                        // Is not a path
-                       throw new BasePathIsNoDirectoryException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
+                       throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
                } elseif (!is_readable($templateBasePath)) {
                        // Is not readable
-                       throw new BasePathReadProtectedException(array($tplInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
+                       throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
                }
 
                // Get configuration instance
                $configInstance = FrameworkConfiguration::getInstance();
 
                // Set the base path
-               $tplInstance->setTemplateBasePath($templateBasePath);
+               $templateInstance->setTemplateBasePath($templateBasePath);
 
                // Set the language and IO instances
-               $tplInstance->setLanguageInstance($langInstance);
-               $tplInstance->setFileIoInstance($ioInstance);
+               $templateInstance->setLanguageInstance($langInstance);
+               $templateInstance->setFileIoInstance($ioInstance);
 
                // Set template extensions
-               $tplInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
-               $tplInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
+               $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
+               $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
 
                // Absolute output path for compiled templates
-               $tplInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
+               $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
 
                // Return the prepared instance
-               return $tplInstance;
+               return $templateInstance;
        }
 
        /**
index 93382f9..3591bf1 100644 (file)
@@ -87,7 +87,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         *
         * @param       $appInstance    A manageable application
         * @param       $menuInstance   A RenderableMenu instance
-        * @return      $tplInstance    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
@@ -97,58 +97,58 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         */
        public final static function createMenuTemplateEngine (ManageableApplication $appInstance, RenderableMenu $menuInstance) {
                // Get a new instance
-               $tplInstance = new MenuTemplateEngine();
+               $templateInstance = new MenuTemplateEngine();
 
                // Get language and file I/O instances from application
                $langInstance = $appInstance->getLanguageInstance();
                $ioInstance = $appInstance->getFileIoInstance();
 
                // Determine base path
-               $templateBasePath = $tplInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
+               $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
 
                // Is the base path valid?
                if (empty($templateBasePath)) {
                        // Base path is empty
-                       throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+                       throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } elseif (!is_string($templateBasePath)) {
                        // Is not a string
-                       throw new InvalidBasePathStringException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
+                       throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
                } elseif (!is_dir($templateBasePath)) {
                        // Is not a path
-                       throw new BasePathIsNoDirectoryException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
+                       throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
                } elseif (!is_readable($templateBasePath)) {
                        // Is not readable
-                       throw new BasePathReadProtectedException(array($tplInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
+                       throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
                }
 
                // Get configuration instance
                $configInstance = FrameworkConfiguration::getInstance();
 
                // Set the base path
-               $tplInstance->setTemplateBasePath($templateBasePath);
+               $templateInstance->setTemplateBasePath($templateBasePath);
 
                // Set the language and IO instances
-               $tplInstance->setLanguageInstance($langInstance);
-               $tplInstance->setFileIoInstance($ioInstance);
+               $templateInstance->setLanguageInstance($langInstance);
+               $templateInstance->setFileIoInstance($ioInstance);
 
                // Set template extensions
-               $tplInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
-               $tplInstance->setCodeTemplateExtension($configInstance->getConfigEntry('menu_template_extension'));
+               $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
+               $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('menu_template_extension'));
 
                // Absolute output path for compiled templates
-               $tplInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
+               $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
 
                // Set the menu instance
-               $tplInstance->setMenuInstance($menuInstance);
+               $templateInstance->setMenuInstance($menuInstance);
 
                // Init a variable stacker
                $stackerInstance = ObjectFactory::createObjectByConfiguredName('menu_stacker_class');
 
                // Set it
-               $tplInstance->setStackerInstance($stackerInstance);
+               $templateInstance->setStackerInstance($stackerInstance);
 
                // Return the prepared instance
-               return $tplInstance;
+               return $templateInstance;
        }
 
        /**
index aee5afa..e4a3e79 100644 (file)
@@ -37,7 +37,7 @@ class WebTemplateEngine extends BaseTemplateEngine implements CompileableTemplat
         * Creates an instance of the class TemplateEngine and prepares it for usage
         *
         * @param       $appInstance    A manageable application
-        * @return      $tplInstance    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
@@ -47,49 +47,49 @@ class WebTemplateEngine extends BaseTemplateEngine implements CompileableTemplat
         */
        public final static function createWebTemplateEngine (ManageableApplication $appInstance) {
                // Get a new instance
-               $tplInstance = new WebTemplateEngine();
+               $templateInstance = new WebTemplateEngine();
 
                // Get language and file I/O instances from application
                $langInstance = $appInstance->getLanguageInstance();
                $ioInstance = $appInstance->getFileIoInstance();
 
                // Determine base path
-               $templateBasePath = $tplInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
+               $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
 
                // Is the base path valid?
                if (empty($templateBasePath)) {
                        // Base path is empty
-                       throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+                       throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } elseif (!is_string($templateBasePath)) {
                        // Is not a string
-                       throw new InvalidBasePathStringException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
+                       throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
                } elseif (!is_dir($templateBasePath)) {
                        // Is not a path
-                       throw new BasePathIsNoDirectoryException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
+                       throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
                } elseif (!is_readable($templateBasePath)) {
                        // Is not readable
-                       throw new BasePathReadProtectedException(array($tplInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
+                       throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
                }
 
                // Get configuration instance
                $configInstance = FrameworkConfiguration::getInstance();
 
                // Set the base path
-               $tplInstance->setTemplateBasePath($templateBasePath);
+               $templateInstance->setTemplateBasePath($templateBasePath);
 
                // Set the language and IO instances
-               $tplInstance->setLanguageInstance($langInstance);
-               $tplInstance->setFileIoInstance($ioInstance);
+               $templateInstance->setLanguageInstance($langInstance);
+               $templateInstance->setFileIoInstance($ioInstance);
 
                // Set template extensions
-               $tplInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
-               $tplInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
+               $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
+               $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
 
                // Absolute output path for compiled templates
-               $tplInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
+               $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
 
                // Return the prepared instance
-               return $tplInstance;
+               return $templateInstance;
        }
 }
 
index e023b96..a3acc62 100644 (file)
@@ -92,6 +92,9 @@ $cfg->setConfigEntry('compile_output_path', 'templates/_compiled/');
 // CFG: TEMPLATE-CLASS
 $cfg->setConfigEntry('web_template_class', 'WebTemplateEngine');
 
+// CFG: DECO-XML-REWRITER-TEMPLATE-CLASS
+$cfg->setConfigEntry('deco_xml_rewriter_template_class', 'XmlRewriterTemplateDecorator');
+
 // CFG: DEBUG-CLASS
 $cfg->setConfigEntry('debug_class', 'DebugWebOutput');
 
@@ -251,6 +254,9 @@ $cfg->setConfigEntry('mailer_class', 'DebugMailer');
 // CFG: XML-PARSER-CLASS
 $cfg->setConfigEntry('xml_parser_class', 'XmlParser');
 
+// CFG: DECO-COMPACTING-XML-PARSER-CLASS
+$cfg->setConfigEntry('deco_compacting_xml_parser_class', 'XmlCompactorDecorator');
+
 // CFG: MATH-PRIME
 $cfg->setConfigEntry('math_prime', 591623);
 
index bd7820a..b3d9164 100755 (executable)
@@ -1,36 +1,40 @@
 #!/bin/sh
-# A little helper script of mine to setup a new development check-out directory
+# A little helper script of mine to setup a new development check-out directory.
+# This script should be called where you want to create the repository and 'core'
+# must be in the same directory. This script is public domain, if it blows up
+# your washing maschine or your refrigerator stops working, this script is maybe
+# not responsible for this, ask your trusted electrican. Use it on your own risk.
 
-if test "$1" == ""; then
-       echo "Usage: $0 <repos> Setup given repository locally."
+if test "${1}" == ""; then
+       echo "Usage: ${0} <repos> Setup given repository locally."
        exit
-elif test -e "$1/.svn/"; then
-       echo "$0: Repository $1 is possibly setup! Aborting..."
+elif test -e "${1}/.svn/"; then
+       echo "${0}: Repository ${1} is possibly setup! Aborting..."
        exit
 fi
 
-echo "$0: Checking out $1 ..."
-svn co svn+ssh://www.mxchange.org/var/www/svn-repos/$1/ || exit 255
-cd $1
-echo "$0: Creating base directories ..."
+echo "${0}: Checking out ${1} ..."
+svn co "svn+ssh://www.mxchange.org/var/www/svn-repos/${1}/" || exit 255
+cd "${1}"
+echo "${0}: Creating base directories ..."
 svn mkdir branches tags trunk || exit 255
 cd trunk
-echo "$0: Updating skeleton ..."
+echo "${0}: Updating skeleton ..."
 svn up ../../skel/ || exit 255
-echo "$0: Importing skeleton repository ..."
+echo "${0}: Importing skeleton repository ..."
 svn export --force ../../skel/trunk/ . || exit 255
 svn add * || exit 255
-if test "$1" != "admin"; then
-       echo "$0: Adding directory application/$1 ..."
-       svn mkdir application/$1 || exit 255
+if test "${1}" != "admin"; then
+       echo "${0}: Adding directory application/${1} ..."
+       svn mkdir application/${1} || exit 255
 else
-       echo "$0: --- Not creating directory application/$1. ---"
+       echo "${0}: --- Not creating directory application/${1}. ---"
 fi
-echo "$0: Linking to external 'core' repository ..."
+echo "${0}: Linking to external 'core' repository ..."
 svn propset svn:externals -F ../../core/trunk/svn-externals.txt . || exit 255
-if (test "$1" != "admin" && test "$1" != "install"); then
+if (test "${1}" != "admin" && test "${1}" != "install"); then
        cd application/
-       if test "$1" != "qa"; then
+       if test "${1}" != "qa"; then
                svn propset svn:externals -F ../../../core/trunk/application-external.txt . || exit 255
        else
                svn propset svn:externals "admin http://www.ship-simu.org/repos/admin/trunk/application/admin/ 
@@ -38,14 +42,14 @@ install http://www.ship-simu.org/repos/install/trunk/application/install/" . ||
        fi
        cd .. # trunk
 else
-       echo "$0: --- Not setting admin external source. ---"
+       echo "${0}: --- Not setting admin external source. ---"
 fi
 cd .. # root
-echo "$0: Running commit ..."
+echo "${0}: Running commit ..."
 svn commit -m "Initial import with linked core from skeleton" || exit 255
-echo "$0: Updating ..."
+echo "${0}: Updating ..."
 svn up
-echo "$0: Exporting repositiory ..."
-svn export --force trunk/ /var/www/htdocs/$1
+echo "${0}: Exporting repositiory ..."
+svn export --force trunk/ /var/www/htdocs/${1}
 cd .. # start
-echo "$0: All done."
+echo "${0}: All done."
diff --git a/templates/README.1st b/templates/README.1st
new file mode 100644 (file)
index 0000000..9fde7f8
--- /dev/null
@@ -0,0 +1,7 @@
+This directory is generic and therefor only for template caches. If you need
+templates for your application, please DO NOT put them in here. Instead create
+a directory named "templates" in your application's directory.
+
+@TODO This README needs some extending and should be then moved to docs/
+directory.
+