]> git.mxchange.org Git - mailer.git/blobdiff - inc/template-functions.php
Refback and referal points hopefully fixed:
[mailer.git] / inc / template-functions.php
index 29e3e092db01218a48b7830291dd3de344f83786..6e2e4730660d0f0e803575ab0fc29e97f4435cb1 100644 (file)
@@ -217,9 +217,6 @@ function doFinalCompilation ($code, $insertComments = true, $enableCodes = true)
        // Init counter
        $count = 0;
 
-       // Compile the raw code
-       $code = compileRawCode($code);
-
        // Compile all out
        while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($count < 7)) {
                // Init common variables
@@ -243,10 +240,22 @@ function doFinalCompilation ($code, $insertComments = true, $enableCodes = true)
                // Use it again
                $code = $newContent;
 
+               // Compile the final code if insertComments is true
+               if ($insertComments == true) {
+                       // ... because SQL queries shall keep OPEN_CONFIG and such in
+                       $code = compileRawCode($code);
+               } // END - if
+
                // Count round
                $count++;
        } // END - while
 
+       // Add debugging data in HTML code, if mode is enabled
+       if ((isDebugModeEnabled()) && ($insertComments === true)) {
+               // Add loop count
+               $code .= '<!-- Total compilation loop=' . $count . ' //-->';
+       } // END - if
+
        // Return the compiled code
        return $code;
 }
@@ -428,7 +437,7 @@ function detectExtraTemplatePath ($template) {
 }
 
 // Loads an email template and compiles it
-function loadEmailTemplate ($template, $content = array(), $userid = '0', $loadUserData = true) {
+function loadEmailTemplate ($template, $content = array(), $userid = NULL, $loadUserData = true) {
        // @TODO $DATA is deprecated and should be avoided and replaced with $content
        global $DATA;
 
@@ -659,12 +668,15 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true
                                $newMatch = str_replace('[', "['", str_replace(']', "']", $match));
                                $code = str_replace($match, '".' . $newMatch . '."', $code);
                                $matchesFound[$key . '_' . $matches[4][$key]] = 1;
-                               $matchesFound[$match] = 1;
+                               $matchesFound[$match] = true;
                        } elseif (!isset($matchesFound[$match])) {
                                // Not yet replaced!
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'match=' . $match);
                                $code = str_replace($match, '".' . $match . '."', $code);
                                $matchesFound[$match] = 1;
+                       } else {
+                               // Everthing else should be a least logged
+                               logDebugMessage(__FUNCTION__, __LINE__, 'match=' . $match . ',key=' . $key);
                        }
                } // END - foreach
        } // END - if
@@ -1119,9 +1131,6 @@ function generateEmailLink ($email, $table = 'admins') {
                $EMAIL = generateSponsorEmailLink($email);
        }
 
-       // Shall I close the link when there is no admin?
-       if ((!isAdmin()) && ($EMAIL == $email)) $EMAIL = '#'; // Closed!
-
        // Return email link
        return $EMAIL;
 }