]> git.mxchange.org Git - mailer.git/blobdiff - inc/template-functions.php
Extension ext-earning introduced (unfinished), renamings:
[mailer.git] / inc / template-functions.php
index 73e88c6ce05cef02ac10234a892621d043043ae8..19d2459be3dd3ef66c99f8b0c25dda9ad6e99ec6 100644 (file)
@@ -182,13 +182,13 @@ function compileFinalOutput () {
        // Compress it?
        /**
         * @TODO On some pages this is buggy
-       if (!empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos('gzip', $_SERVER['HTTP_ACCEPT_ENCODING']) !== null)) {
+       if (!empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (isInStringIgnoreCase('gzip', $_SERVER['HTTP_ACCEPT_ENCODING']))) {
                // Compress it for HTTP gzip
                $GLOBALS['output'] = gzencode($GLOBALS['output'], 9);
 
                // Add header
                sendHeader('Content-Encoding: gzip');
-       } elseif (!empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos('deflate', $_SERVER['HTTP_ACCEPT_ENCODING']) !== null)) {
+       } elseif (!empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (isInStringIgnoreCase('deflate', $_SERVER['HTTP_ACCEPT_ENCODING']))) {
                // Compress it for HTTP deflate
                $GLOBALS['output'] = gzcompress($GLOBALS['output'], 9);
 
@@ -213,7 +213,7 @@ function doFinalCompilation ($code, $insertComments = true, $enableCodes = true)
        $count = 0;
 
        // Compile all out
-       while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($count < 7)) {
+       while (((isInString('{--', $code)) || (isInString('{DQUOTE}', $code)) || (isInString('{?', $code)) || (isInString('{%', $code) !== false)) && ($count < 7)) {
                // Init common variables
                $content = array();
                $newContent = '';
@@ -314,7 +314,7 @@ function loadTemplate ($template, $return = false, $content = array(), $compileC
 
                        // Do we have to compile the code?
                        $ret = '';
-                       if ((strpos($GLOBALS['tpl_content'][$template], '$') !== false) || (strpos($GLOBALS['tpl_content'][$template], '{--') !== false) || (strpos($GLOBALS['tpl_content'][$template], '{?') !== false) || (strpos($GLOBALS['tpl_content'][$template], '{%') !== false)) {
+                       if ((isInString('$', $GLOBALS['tpl_content'][$template])) || (isInString('{--', $GLOBALS['tpl_content'][$template])) || (isInString('{?', $GLOBALS['tpl_content'][$template])) || (isInString('{%', $GLOBALS['tpl_content'][$template]))) {
                                // Normal HTML output?
                                if (isHtmlOutputMode()) {
                                        // Add surrounding HTML comments to help finding bugs faster
@@ -433,9 +433,6 @@ function detectExtraTemplatePath ($template) {
 
 // Loads an email template and compiles it
 function loadEmailTemplate ($template, $content = array(), $userid = NULL, $loadUserData = true) {
-       // @TODO $DATA is deprecated and should be avoided and replaced with $content
-       global $DATA;
-
        // Make sure all template names are lowercase!
        $template = strtolower($template);
 
@@ -516,8 +513,6 @@ function loadEmailTemplate ($template, $content = array(), $userid = NULL, $load
 <div class="para">
        {--TEMPLATE_CONTENT--}:
        <pre>' . print_r($content, true) . '</pre>
-       {--TEMPLATE_DATA--}:
-       <pre>' . print_r($DATA, true) . '</pre>
 </div>';
 
                // Debug mode not active? Then remove the HTML tags
@@ -541,7 +536,6 @@ function loadEmailTemplate ($template, $content = array(), $userid = NULL, $load
 
        // Remove content and data
        unset($content);
-       unset($DATA);
 
        // Return content
        return $newContent;
@@ -598,7 +592,7 @@ function compileCode ($code, $simple = false, $constants = true, $full = true, $
        return $code;
 }
 
-// Compiles the code (use compileCode() only for HTML because of the comments)
+// Compiles the code
 // @TODO $simple/$constants are deprecated
 function compileRawCode ($code, $simple = false, $constants = true, $full = true, $compileCode = true) {
        // Is the code a string or shall we not compile?
@@ -625,8 +619,7 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true
        $code = str_replace($secChars['to'], $secChars['from'], $code);
 
        // Find $content[bla][blub] entries
-       // @TODO Do only use $content and deprecate $DATA in templates
-       preg_match_all('/\$(content|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches);
+       preg_match_all('/\$content((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches);
 
        // Are some matches found?
        if ((count($matches) > 0) && (count($matches[0]) > 0)) {
@@ -657,12 +650,12 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true
                        } // END - if
 
                        // Take all string elements
-                       if ((is_string($matches[4][$key])) && (!isset($matchesFound[$match])) && (!isset($matchesFound[$key.'_' . $matches[4][$key]]))) {
+                       if ((is_string($matches[3][$key])) && (!isset($matchesFound[$match])) && (!isset($matchesFound[$key.'_' . $matches[3][$key]]))) {
                                // Replace it in the code
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',match=' . $match);
                                $newMatch = str_replace('[', "['", str_replace(']', "']", $match));
                                $code = str_replace($match, '".' . $newMatch . '."', $code);
-                               $matchesFound[$key . '_' . $matches[4][$key]] = 1;
+                               $matchesFound[$key . '_' . $matches[3][$key]] = 1;
                                $matchesFound[$match] = true;
                        } elseif (!isset($matchesFound[$match])) {
                                // Not yet replaced!
@@ -1236,7 +1229,9 @@ function debug_report_bug ($F, $L, $message = '', $sendEmail = true) {
 // Compile characters which are allowed in URLs
 function compileUriCode ($code, $simple = true) {
        // Compile constants
-       if ($simple === false) $code = str_replace('{--', '".', str_replace('--}', '."', $code));
+       if ($simple === false) {
+               $code = str_replace('{--', '".', str_replace('--}', '."', $code));
+       } // END - if
 
        // Compile QUOT and other non-HTML codes
        $code = str_replace('{DOT}', '.',
@@ -1257,17 +1252,18 @@ function compileUriCode ($code, $simple = true) {
 
 // Handle message codes from URL
 function handleCodeMessage () {
-       if (isGetRequestParameterSet('code')) {
+       // Is 'code' set?
+       if (isGetRequestElementSet('code')) {
                // Default extension is 'unknown'
                $ext = 'unknown';
 
                // Is extension given?
-               if (isGetRequestParameterSet('ext')) {
-                       $ext = getRequestParameter('ext');
+               if (isGetRequestElementSet('ext')) {
+                       $ext = getRequestElement('ext');
                } // END - if
 
                // Convert the 'code' parameter from URL to a human-readable message
-               $message = getMessageFromErrorCode(getRequestParameter('code'));
+               $message = getMessageFromErrorCode(getRequestElement('code'));
 
                // Load message template
                loadTemplate('message', false, $message);
@@ -1546,7 +1542,7 @@ function sendModeMails ($mod, $modes) {
                $hash = encodeHashForCookie(getUserData('password'));
 
                // Does the hash match or should we change it?
-               if (($hash == getSession('u_hash')) || (postRequestParameter('pass1') == postRequestParameter('pass2'))) {
+               if (($hash == getSession('u_hash')) || (postRequestElement('pass1') == postRequestElement('pass2'))) {
                        // Load the data
                        $content = getUserDataArray();
 
@@ -1561,7 +1557,7 @@ function sendModeMails ($mod, $modes) {
                                                switch ($mode) {
                                                        case 'normal': break; // Do not add any special lines
                                                        case 'email': // Email was changed!
-                                                               $content['message'] = '{--MEMBER_CHANGED_EMAIL--}' . ': ' . postRequestParameter('old_email') . "\n";
+                                                               $content['message'] = '{--MEMBER_CHANGED_EMAIL--}' . ': ' . postRequestElement('old_email') . "\n";
                                                                break;
 
                                                        case 'password': // Password was changed
@@ -1577,7 +1573,7 @@ function sendModeMails ($mod, $modes) {
 
                                        if (isExtensionActive('country')) {
                                                // Replace code with description
-                                               $content['country'] = generateCountryInfo(postRequestParameter('country_code'));
+                                               $content['country'] = generateCountryInfo(postRequestElement('country_code'));
                                        } // END - if
 
                                        // Merge content with data from POST