]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/template/class_BaseTemplateEngine.php
Refactured code for deprecated includes file_io and language:
[core.git] / inc / classes / main / template / class_BaseTemplateEngine.php
index b64477c4f10b41704cfbe582ba49b11ef1cfbfde..2b9406b0f055efe0948579aae92ef378b696d306 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.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 - 2011 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -156,6 +156,12 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        protected function __construct ($className) {
                // Call parent constructor
                parent::__construct($className);
+
+               // Init file I/O instance
+               $ioInstance = ObjectFactory::createObjectByConfiguredName('file_io_class');
+
+               // Set it
+               $this->setFileIoInstance($ioInstance);
        }
 
        /**
@@ -1245,8 +1251,11 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         *                                                                                      count has been found
         */
        public function compileTemplate () {
+               // Get code type to make things shorter
+               $codeType = $this->getConfigInstance()->getConfigEntry('code_template_type');
+
                // We will only work with template type "code" from configuration
-               if ($this->getTemplateType() != $this->getConfigInstance()->getConfigEntry('code_template_type')) {
+               if (substr($this->getTemplateType(), 0, strlen($codeType)) != $codeType) {
                        // Abort here
                        throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->getConfigEntry('code_template_type')), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED);
                } // END - if
@@ -1496,27 +1505,27 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        /**
         * Removes all commentd, tabs and new-line characters to compact the content
         *
-        * @param       $content        The uncompacted content
-        * @return      $content        The compacted content
+        * @param       $uncompactedContent             The uncompacted content
+        * @return      $compactedContent               The compacted content
         */
-       public function compactContent ($content) {
+       public function compactContent ($uncompactedContent) {
                // First, remove all tab/new-line/revert characters
-               $content = str_replace("\t", '', str_replace("\n", '', str_replace("\r", '', $content)));
+               $compactedContent = str_replace("\t", '', str_replace("\n", '', str_replace("\r", '', $uncompactedContent)));
 
                // Then regex all comments like <!-- //--> away
-               preg_match_all('/<!--[\w\W]*?(\/\/){0,1}-->/', $content, $matches);
+               preg_match_all('/<!--[\w\W]*?(\/\/){0,1}-->/', $compactedContent, $matches);
 
                // Do we have entries?
                if (isset($matches[0][0])) {
                        // Remove all
                        foreach ($matches[0] as $match) {
                                // Remove the match
-                               $content = str_replace($match, '', $content);
+                               $compactedContent = str_replace($match, '', $compactedContent);
                        } // END - foreach
                } // END - if
 
                // Return compacted content
-               return $content;
+               return $compactedContent;
        }
 }