]> git.mxchange.org Git - mailer.git/blobdiff - inc/template-functions.php
Fix for if sql_patches is not installed or older than 0.3.6
[mailer.git] / inc / template-functions.php
index 1733c35b7ee11aba60a59a3f32e8259b806f6cae..fad3dc2df35d68961d078876cebc6f263f70b6f9 100644 (file)
@@ -234,7 +234,7 @@ function doFinalCompilation ($code, $insertComments = true) {
        $cnt = 0;
 
        // Compile all out
-       while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($cnt < 4)) {
+       while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($cnt < 5)) {
                // Init common variables
                $content = array();
                $newContent = '';
@@ -242,7 +242,7 @@ function doFinalCompilation ($code, $insertComments = true) {
                // Compile it
                //* DEBUG: */ debugOutput('<pre>'.encodeEntities($code).'</pre>');
                $eval = '$newContent = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($code))) . '";';
-               //* DEBUG: */ if ($insertComments) die('<pre>'.linenumberCode($eval).'</pre>');
+               //* DEBUG: */ if (!$insertComments) print('<pre>'.linenumberCode($eval).'</pre>');
                eval($eval);
                //* DEBUG: */ die('<pre>'.encodeEntities($newContent).'</pre>');
 
@@ -351,8 +351,6 @@ function loadTemplate ($template, $return = false, $content = array()) {
 <div class="para">
        {--TEMPLATE_CONTENT--}
        <pre>' . print_r($content, true) . '</pre>
-       {--TEMPLATE_DATA--}
-       <pre>' . print_r($DATA, true) . '</pre>
 </div>';
                } else {
                        // No file!
@@ -704,7 +702,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 're
 
                case 'year': // Year
                        // Get current year
-                       $year = date('Y', time());
+                       $year = getYear();
 
                        // Use configured min age or fixed?
                        if (isExtensionInstalledAndNewer('order', '0.2.1')) {
@@ -736,10 +734,10 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 're
                                // Calculate earliest year depending on extension version
                                if (isExtensionInstalledAndNewer('order', '0.2.1')) {
                                        // Use configured minimum age
-                                       $year = date('Y', time()) - getConfig('min_age');
+                                       $year = getYear() - getConfig('min_age');
                                } else {
                                        // Use fixed 16 years age
-                                       $year = date('Y', time()) - 16;
+                                       $year = getYear() - 16;
                                }
 
                                // Construct year selection list
@@ -856,9 +854,9 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
 
        // Do we have a leap year?
        $SWITCH = '0';
-       $TEST = date('Y', time()) / 4;
-       $M1 = date('m', time());
-       $M2 = date('m', (time() + $timestamp));
+       $TEST = getYear() / 4;
+       $M1 = getMonth();
+       $M2 = getMonth(time() + $timestamp);
 
        // If so and if current time is before 02/29 and estimated time is after 02/29 then add 86400 seconds (one day)
        if ((floor($TEST) == $TEST) && ($M1 == '02') && ($M2 > '02'))  $SWITCH = getConfig('ONE_DAY');
@@ -1452,6 +1450,9 @@ function escapeQuotes ($str, $single = false) {
                // Escape all (including null)
                $str = addslashes($str);
        } else {
+               // Remove escaping of single quotes
+               $str = str_replace("\'", "'", $str);
+
                // Escape only double-quotes but prevent double-quoting
                $str = str_replace("\\\\", "\\", str_replace('"', "\\\"", $str));
        }
@@ -1600,8 +1601,6 @@ function generateSelectionBoxFromArray ($options, $name, $optionValue, $optionCo
        // Prepare output
        $content = array(
                'selection_box' => $OUT,
-               'module'        => getModule(),
-               'what'          => getWhat()
        );
 
        // Load template and return it