]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Rewrites/fixes for broken template cache, the actual value was rendered but instead...
[mailer.git] / inc / functions.php
index 864e26f9678eda20f32524877b8129e96053070e..0a38bdf44108522f4896ade1a1f49c3f22d1dc43 100644 (file)
@@ -49,10 +49,6 @@ function outputHtml ($htmlCode, $newLine = true) {
                $GLOBALS['output'] = '';
        } // END - if
 
-       // Transfer username
-       $username = getMessage('USERNAME_UNKNOWN');
-       if (isset($GLOBALS['username'])) $username = getUsername();
-
        // Do we have HTML-Code here?
        if (!empty($htmlCode)) {
                // Yes, so we handle it as you have configured
@@ -266,9 +262,6 @@ function loadTemplate ($template, $return = false, $content = array()) {
                // Evaluate the cache
                eval(readTemplateCache($template));
        } elseif (!isset($GLOBALS['template_eval'][$template])) {
-               // Add more variables which you want to use in your template files
-               $username = getUsername();
-
                // Make all template names lowercase
                $template = strtolower($template);
 
@@ -872,6 +865,34 @@ function translateUserStatus ($status) {
        return $ret;
 }
 
+// "Translates" 'visible' and 'locked' to a CSS class
+function translateMenuVisibleLocked ($content, $prefix = '') {
+       // Translate 'visible' and keep an eye on the prefix
+       switch ($content[$prefix . 'visible']) {
+               // Should be visible
+               case 'Y': $content[$prefix . 'visible_css'] = $prefix . 'menu_visible'  ; break;
+               case 'N': $content[$prefix . 'visible_css'] = $prefix . 'menu_invisible'; break;
+               default:
+                       // Please report this
+                       debug_report_bug('Unsupported visible value detected. content=<pre>'.print_r($content, true).'</pre>');
+                       break;
+       } // END - switch
+
+       // Translate 'locked' and keep an eye on the prefix
+       switch ($content[$prefix . 'locked']) {
+               // Should be locked
+               case 'Y': $content[$prefix . 'locked_css'] = $prefix . 'menu_locked'  ; break;
+               case 'N': $content[$prefix . 'locked_css'] = $prefix . 'menu_unlocked'; break;
+               default:
+                       // Please report this
+                       debug_report_bug('Unsupported locked value detected. content=<pre>'.print_r($content, true).'</pre>');
+                       break;
+       } // END - switch
+
+       // Return the resulting array
+       return $content;
+}
+
 // Generates an URL for the dereferer
 function generateDerefererUrl ($URL) {
        // Don't de-refer our own links!
@@ -972,6 +993,9 @@ function redirectToUrl ($URL, $allowSpider = true) {
                // Clear own output buffer
                $GLOBALS['output'] = '';
 
+               // Set header
+               setHttpStatus('302 Found');
+
                // Load URL when headers are not sent
                sendHeader('Location: '.str_replace('&amp;', '&', $URL));
        } else {
@@ -1046,11 +1070,11 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true
        if ($constants === true) {
                // BEFORE 0.2.1 : Language and data constants
                // WITH 0.2.1+  : Only language constants
-               $code = str_replace('{--', "\" . getMessage('", str_replace('--}', "') . \"", $code));
+               $code = str_replace('{--', "{DQUOTE} . getMessage('", str_replace('--}', "') . {DQUOTE}", $code));
 
                // BEFORE 0.2.1 : Not used
                // WITH 0.2.1+  : Data constants
-               $code = str_replace('{!', "\" . constant('", str_replace('!}', "') . \"", $code));
+               $code = str_replace('{!', "{DQUOTE} . constant('", str_replace('!}', "') . {DQUOTE}", $code));
        } // END - if
 
        // Compile QUOT and other non-HTML codes
@@ -2395,7 +2419,7 @@ function displayParsingTime () {
        // Prepare output
        // @TODO This can be easily moved out after the merge from EL branch to this is complete
        $content = array(
-               'run_time' => translateComma($runTime),
+               'run_time' => $runTime,
                'sql_time' => translateComma(getConfig('sql_time') * 1000),
        );
 
@@ -2612,7 +2636,7 @@ function getMessageFromErrorCode ($code) {
                        if (isExtensionActive('mailid', true)) {
                                $message = getMessage('ERROR_CONFIRMING_MAIL');
                        } else {
-                               $message = getMaskedMessage('EXTENSION_PROBLEM_NOT_INSTALLED', 'mailid');
+                               $message = getMaskedMessage('EXTENSION_PROBLEM_EXTENSION_NOT_INSTALLED', 'mailid');
                        }
                        break;
 
@@ -3549,10 +3573,10 @@ function determinePageTitle () {
                $pageTitle = '[-- ' . getConfig('MAIN_TITLE') . ' - ' . getModuleTitle(getModule()) . ' --]';
        } elseif ((isInstalled()) && (!isAdminRegistered())) {
                // Installed but no admin registered
-               $pageTitle = getMessage('SETUP_OF_MXCHANGE');
+               $pageTitle = getMessage('SETUP_OF_MAILER');
        } elseif ((!isInstalled()) || (!isAdminRegistered())) {
                // Installation mode
-               $pageTitle = getMessage('INSTALLATION_OF_MXCHANGE');
+               $pageTitle = getMessage('INSTALLATION_OF_MAILER');
        } else {
                // Configuration not found!
                $pageTitle = getMessage('NO_CONFIG_FOUND_TITLE');
@@ -3587,9 +3611,6 @@ function flushTemplateCache ($template, $eval) {
                // Generate FQFN
                $FQFN = generateCacheFqfn($template);
 
-               // Replace username with a call
-               $eval = str_replace('$username', '".getUsername()."', $eval);
-
                // And flush it
                writeToFile($FQFN, $eval, true);
        } // END - if