Moved regex to variable.
[core.git] / inc / classes / main / template / class_BaseTemplateEngine.php
index 4948b28f7890ba1723f05a36649e5a82706ad1c8..e7592c008d7b2631f988a7cc12763a7db1189273 100644 (file)
@@ -106,6 +106,11 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         */
        private $regExpCodeTags = '/\{\?([a-z_]+)(:("[^"]+"|[^?}]+)+)?\?\}/';
 
+       /**
+        * A regular expression to find template comments like <!-- Comment here //-->
+        */
+       private $regExpComments = '/<!--[\w\W]*?(\/\/){0,1}-->/';
+
        /**
         * Loaded helpers
         */
@@ -724,7 +729,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                // 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",
+                       $fqfn = sprintf('%s%s%s%s/%s/%s%s',
                                $this->getConfigInstance()->getConfigEntry('base_path'),
                                $this->getTemplateBasePath(),
                                $this->getGenericBasePath(),
@@ -735,7 +740,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                        );
                } else {
                        // Construct the FQFN for the template without language
-                       $fqfn = sprintf("%s%s%s%s/%s%s",
+                       $fqfn = sprintf('%s%s%s%s/%s%s',
                                $this->getConfigInstance()->getConfigEntry('base_path'),
                                $this->getTemplateBasePath(),
                                $this->getGenericBasePath(),
@@ -1256,7 +1261,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                        $this->finalizeVariableCompilation();
 
                        // Prepare the eval() command for comiling the template
-                       $eval = sprintf("\$result = \"%s\";",
+                       $eval = sprintf('$result = "%s";',
                                addslashes($this->getRawTemplateData())
                        );
 
@@ -1276,14 +1281,14 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                                $evalRight = substr($evalRight, (strpos($evalRight, $this->codeEnd) + 2));
 
                                // And put all together
-                               $eval = sprintf("%s<%%php %s %%>%s", $evalLeft, $evalMiddle, $evalRight);
+                               $eval = sprintf('%s<%%php %s %%>%s', $evalLeft, $evalMiddle, $evalRight);
                        } // END - while
 
                        // Prepare PHP code for eval() command
                        $eval = str_replace(
-                               "<%php", "\";",
+                               '<%php', '";',
                                str_replace(
-                                       "%>",
+                                       '%>',
                                        "\n\$result .= \"",
                                        $eval
                                )
@@ -1295,7 +1300,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                        // Goes something wrong?
                        if ((!isset($result)) || (empty($result))) {
                                // Output eval command
-                               self::createDebugInstance(__CLASS__)->debugOutput(sprintf("Failed eval() code: <pre>%s</pre>", $this->markupCode($eval, TRUE)), TRUE);
+                               self::createDebugInstance(__CLASS__)->debugOutput(sprintf('Failed eval() code: <pre>%s</pre>', $this->markupCode($eval, TRUE)), TRUE);
 
                                // Output backtrace here
                                $this->debugBackTrace();
@@ -1592,7 +1597,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                $compactedContent = str_replace(chr(9), '', str_replace(chr(10), '', str_replace(chr(13), '', $uncompactedContent)));
 
                // Then regex all comments like <!-- //--> away
-               preg_match_all('/<!--[\w\W]*?(\/\/){0,1}-->/', $compactedContent, $matches);
+               preg_match_all($this->regExpComments, $compactedContent, $matches);
 
                // Do we have entries?
                if (isset($matches[0][0])) {