Language support can now be disabled (e.g. good for hub announcement descriptor)
authorRoland Häder <roland@mxchange.org>
Tue, 22 Dec 2009 08:21:53 +0000 (08:21 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 22 Dec 2009 08:21:53 +0000 (08:21 +0000)
inc/classes/main/template/class_BaseTemplateEngine.php

index c8924f7..4f9b1e8 100644 (file)
@@ -131,6 +131,11 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         */
        private $codeEnd = '?>';
 
+       /**
+        * Language support is enabled by default
+        */
+       private $languageSupport = true;
+
        // Exception codes for the template engine
        const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED   = 0x110;
        const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x111;
@@ -535,16 +540,30 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                        $ext = (string) $extOther;
                }
 
-               // Construct the FQFN for the template by honoring the current language
-               $fqfn = sprintf("%s%s%s%s/%s/%s%s",
-                       $this->getConfigInstance()->getConfigEntry('base_path'),
-                       $this->getTemplateBasePath(),
-                       $this->getGenericBasePath(),
-                       $this->getLanguageInstance()->getLanguageCode(),
-                       $this->getTemplateType(),
-                       (string) $template,
-                       $ext
-               );
+               // Is language support enabled?
+               if ($this->isLanguageSupportEnabled()) {
+                       // Construct the FQFN for the template by honoring the current language
+                       $fqfn = sprintf("%s%s%s%s/%s/%s%s",
+                               $this->getConfigInstance()->getConfigEntry('base_path'),
+                               $this->getTemplateBasePath(),
+                               $this->getGenericBasePath(),
+                               $this->getLanguageInstance()->getLanguageCode(),
+                               $this->getTemplateType(),
+                               (string) $template,
+                               $ext
+                       );
+               } else {
+                       // Construct the FQFN for the template without language
+                       $fqfn = sprintf("%s%s%s%s/%s%s",
+                               $this->getConfigInstance()->getConfigEntry('base_path'),
+                               $this->getTemplateBasePath(),
+                               $this->getGenericBasePath(),
+                               $this->getTemplateType(),
+                               (string) $template,
+                               $ext
+                       );
+               }
+               die($fqfn);
 
                // First try this
                try {
@@ -1298,6 +1317,25 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                // Parse the XML document
                $parserInstance->parseXmlContent($content);
        }
+
+       /**
+        * Enables or disables language support
+        *
+        * @param       $languageSupport        New language support setting
+        * @return      void
+        */
+       public final function enableLanguageSupport ($languageSupport = true) {
+               $this->languageSupport = (bool) $languageSupport;
+       }
+
+       /**
+        * Checks wether language support is enabled
+        *
+        * @return      $languageSupport        Wether language support is enabled or disabled
+        */
+       public final function isLanguageSupportEnabled () {
+               return $this->languageSupport;
+       }
 }
 
 // [EOF]