]> git.mxchange.org Git - mailer.git/blobdiff - inc/template-functions.php
MINOR: Small code improvements
[mailer.git] / inc / template-functions.php
index aa8678f37648f0cf0fae5db9122b2ad0646ffc92..9e9a252d1840d44918ce901742311291dc057a3e 100644 (file)
@@ -235,26 +235,26 @@ function doFinalCompilation ($code, $insertComments = TRUE, $enableCodes = TRUE)
        enableTemplateHtml($insertComments);
 
        // Init counter
-       $count = 0;
+       $totalCompilations = 0;
 
        // Compile all out
-       while (((isInString('{--', $code)) || (isInString('{DQUOTE}', $code)) || (isInString('{?', $code)) || (isInString('{%', $code) !== FALSE)) && ($count < 7)) {
+       while (((isInString('{--', $code)) || (isInString('{DQUOTE}', $code)) || (isInString('{?', $code)) || (isInString('{%', $code) !== FALSE)) && ($totalCompilations < 7)) {
                // Init common variables
                $content = array();
                $newContent = '';
 
                // Compile it
-               //* DEBUG: */ debugOutput('<pre>'.linenumberCode($code).'</pre>');
+               //* DEBUG: */ debugOutput('<pre>'.lineNumberCode($code).'</pre>');
                $eval = '$newContent = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($code), $enableCodes)) . '";';
-               //* DEBUG: */ if (!$insertComments) print('EVAL=<pre>'.linenumberCode($eval).'</pre>');
+               //* DEBUG: */ if (!$insertComments) print('EVAL=<pre>'.lineNumberCode($eval).'</pre>');
                eval($eval);
-               //* DEBUG: */ if (!$insertComments) print('NEW=<pre>'.linenumberCode($newContent).'</pre>');
+               //* DEBUG: */ if (!$insertComments) print('NEW=<pre>'.lineNumberCode($newContent).'</pre>');
                //* DEBUG: */ die('<pre>'.encodeEntities($newContent).'</pre>');
 
                // Was that eval okay?
                if (empty($newContent)) {
                        // Something went wrong!
-                       reportBug(__FUNCTION__, __LINE__, 'Evaluation error:<pre>' . linenumberCode($eval) . '</pre>', FALSE);
+                       reportBug(__FUNCTION__, __LINE__, 'Evaluation error:<pre>' . lineNumberCode($eval) . '</pre>', FALSE);
                } // END - if
 
                // Use it again
@@ -267,14 +267,14 @@ function doFinalCompilation ($code, $insertComments = TRUE, $enableCodes = TRUE)
                } // END - if
 
                // Count round
-               $count++;
+               $totalCompilations++;
        } // END - while
 
        // Add debugging data in HTML code, if mode is enabled
        if ((isDebugModeEnabled()) && ($insertComments === TRUE) && (isHtmlOutputMode())) {
                // Add loop count
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isDebugModeEnabled()=' . intval(isDebugModeEnabled()) . ',insertComments=' . intval($insertComments) . ',isHtmlOutputMode()=' . intval(isHtmlOutputMode()));
-               $code .= '<!-- Total compilation loop=' . $count . ' //-->';
+               $code .= '<!-- Total compilation loop=' . $totalCompilations . ' //-->';
        } // END - if
 
        // Return the compiled code
@@ -616,7 +616,7 @@ function getMenuCssClasses ($data) {
 
 // Generate XHTML code for the CAPTCHA
 function generateCaptchaCode ($code, $type, $urlId, $userid) {
-       return '<img border="0" alt="Code ' . $code . '" src="{%url=mailid_top.php?userid=' . $userid . '&amp;' . $type . '=' . $urlId . '&amp;do=img&amp;code=' . $code . '%}" />';
+       return '<img border="0" alt="Code ' . $code . '" src="{%url=mailid.php?userid=' . $userid . '&amp;' . $type . '=' . $urlId . '&amp;do=img&amp;code=' . $code . '%}" />';
 }
 
 // Compiles the given HTML/mail code
@@ -829,6 +829,14 @@ function addSelectionBox ($type, $default, $prefix = '', $id = NULL, $class = 'f
                        } // END - for
                        break;
 
+               case 'mn': // Months, numeric
+                       for ($idx = 0; $idx <= 12; $idx++) {
+                               $OUT .= '<option value="' . $idx . '"';
+                               if ($default == $idx) $OUT .= ' selected="selected"';
+                               $OUT .= '>{%pipe,padLeftZero=' . $idx . '%}</option>';
+                       } // END - for
+                       break;
+
                case 'we': // Weeks
                        for ($idx = 0; $idx <= 4; $idx++) {
                                $OUT .= '  <option value="' . $idx . '"';
@@ -838,15 +846,15 @@ function addSelectionBox ($type, $default, $prefix = '', $id = NULL, $class = 'f
                        break;
 
                case 'da': // Days
-                       for ($idx = 0; $idx < 32; $idx++) {
+                       for ($idx = 0; $idx <= 31; $idx++) {
                                $OUT .= '<option value="' . $idx . '"';
                                if ($default == $idx) $OUT .= ' selected="selected"';
-                               $OUT .= '>' .padLeftZero($idx) . '</option>';
+                               $OUT .= '>{%pipe,padLeftZero=' . $idx . '%}</option>';
                        } // END - for
                        break;
 
                case 'ho': // Hours
-                       for ($idx = 0; $idx < 24; $idx++) {
+                       for ($idx = 0; $idx <= 23; $idx++) {
                                if (strlen($idx) == 1) $idx = 0 . $idx;
                                $OUT .= '<option value="' . $idx . '"';
                                if ($default == $idx) $OUT .= ' selected="selected"';
@@ -856,7 +864,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = NULL, $class = 'f
 
                case 'mi': // Minutes
                case 'se': // Seconds
-                       for ($idx = 0; $idx < 60; $idx+=5) {
+                       for ($idx = 0; $idx <= 59; $idx+=5) {
                                if (strlen($idx) == 1) $idx = 0 . $idx;
                                $OUT .= '<option value="' . $idx . '"';
                                if ($default == $idx) $OUT .= ' selected="selected"';
@@ -1009,7 +1017,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
                        // Time unit -> field name
                        'unit_field' => array(
                                'Y' => 'ye',
-                               'M' => 'mo',
+                               'M' => 'mn',
                                'W' => 'we',
                                'D' => 'da',
                                'h' => 'ho',
@@ -1233,6 +1241,12 @@ function displayParsingTime () {
 
        // Load the template
        $GLOBALS['__page_footer'] .= loadTemplate('show_timings', TRUE, $content);
+
+       // Is debug enabled?
+       if (isDebugModeEnabled()) {
+               // Log loading of total includes
+               //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Loaded includes: ' . count($GLOBALS['inc_loaded']) . ', readable files: ' . count($GLOBALS['file_readable']));
+       } // END - if
 }
 
 /**
@@ -1471,7 +1485,7 @@ function generateExtensionInactiveNotInstalledMessage ($ext_name) {
 }
 
 // Print code with line numbers
-function linenumberCode ($code)    {
+function lineNumberCode ($code)    {
        // By default copy the code
        $codeE = $code;
 
@@ -1948,6 +1962,12 @@ function displayMessage ($message, $return = FALSE) {
        return loadTemplate('admin_settings_saved', $return, $message);
 }
 
+// Displays given error message in admin_settings_saved template
+function displayErrorMessage ($message, $return = FALSE) {
+       // Load the template
+       return loadTemplate('admin_settings_unsaved', $return, $message);
+}
+
 // Generates a selection box for (maybe) given gender
 function generateGenderSelectionBox ($selectedGender = '', $fieldName = 'gender') {
        // Start the HTML code
@@ -2075,13 +2095,13 @@ function doTemplateExtensionRegistrationLink ($templateName, $clear, $ext_name)
 // Helper function to create bonus mail admin links
 function doTemplateAdminBonusMailLinks ($templateName, $clear, $bonusId) {
        // Call the inner function
-       return generateAdminMailLinks('bid', $bonusId);
+       return generateAdminMailLinks('bonus', $bonusId);
 }
 
 // Helper function to create member mail admin links
 function doTemplateAdminMemberMailLinks ($templateName, $clear, $mailId) {
        // Call the inner function
-       return generateAdminMailLinks('mid', $mailId);
+       return generateAdminMailLinks('normal', $mailId);
 }
 
 // Helper function to create a selection box for YES/NO configuration entries
@@ -2272,7 +2292,7 @@ function anonymizeSensitiveData ($data) {
                if (isAdmin()) {
                        // Is admin, has always priority
                        $data = '[<a href="{%pipe,generateFrametesterUrl=' . $data . '%}" target="_blank">{--ADMIN_TEST_URL--}</a>]';
-               } elseif (isUrlBlacklisted($data)) {
+               } elseif ((isExtensionActive('blacklist')) && (isUrlBlacklisted($data))) {
                        // Yes, so replace it with text
                        $data = '<em>{--URL_IS_BLACKLISTED--}</em>';
                } else {