]> git.mxchange.org Git - mailer.git/blobdiff - inc/template-functions.php
Continued:
[mailer.git] / inc / template-functions.php
index a59a577af2786b2361170ace4cb6b787f43fcdb2..3f9be64120d0f51792cb888ea666c47d55be6261 100644 (file)
@@ -78,16 +78,16 @@ function initTemplateColorSwitch ($template) {
        $GLOBALS['color_switch'][$template] = 2;
 }
 
-// "Getter" for color switch code
-function getColorSwitchCode ($template) {
+// "Renders" color switch code
+function renderColorSwitchCode ($template) {
        // Prepare the code
-       $code = "{DQUOTE} . doTemplateColorSwitch('" . $template . "', FALSE, FALSE) . {DQUOTE}";
+       $code = sprintf("{DQUOTE} . doTemplateColorSwitch('%s', FALSE, FALSE) . {DQUOTE}", $template);
 
        // And return it
        return $code;
 }
 
-// Output HTML code directly or 'render' it. You addionally switch the new-line character off
+// Output HTML code directly or 'render' it. You can addionally switch the new-line character off
 function outputHtml ($htmlCode = NULL, $newLine = TRUE) {
        // Init output
        if (!isset($GLOBALS['__output'])) {
@@ -351,7 +351,7 @@ function loadTemplate ($template, $return = FALSE, $content = [], $compileCode =
 
                                        // Prepare eval() command
                                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!');
-                                       $GLOBALS['template_eval']['html'][$template] = '$templateContent = "' . getColorSwitchCode($template) . compileCode(escapeQuotes($code), TRUE, $compileCode) . '";';
+                                       $GLOBALS['template_eval']['html'][$template] = '$templateContent = "' . renderColorSwitchCode($template) . compileCode(escapeQuotes($code), TRUE, $compileCode) . '";';
                                } elseif (substr($template, 0, 3) == 'js_') {
                                        // JavaScripts don't like entities, dollar signs and timings
                                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!');
@@ -369,7 +369,7 @@ function loadTemplate ($template, $return = FALSE, $content = [], $compileCode =
                                // Add surrounding HTML comments to help finding bugs faster
                                $templateContent = '<!-- Template ' . $template . ' - Start //-->' . $GLOBALS['template_content']['html'][$template] . '<!-- Template ' . $template . ' - End //-->';
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!');
-                               $GLOBALS['template_eval']['html'][$template] = '$templateContent = "' . getColorSwitchCode($template) . compileRawCode(escapeQuotes($templateContent), TRUE, $compileCode) . '";';
+                               $GLOBALS['template_eval']['html'][$template] = '$templateContent = "' . renderColorSwitchCode($template) . compileRawCode(escapeQuotes($templateContent), TRUE, $compileCode) . '";';
                        } elseif (isAjaxOutputMode()) {
                                // AJAX (JSON content)
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!');
@@ -536,13 +536,16 @@ function loadEmailTemplate ($template, $content = [], $userid = NULL, $loadUserD
                        $GLOBALS['template_eval']['email'][$template] = '$templateContent = decodeEntities("' . compileRawCode(escapeQuotes($GLOBALS['template_content']['email'][$template])) . '");';
                } elseif (!empty($template)) {
                        // Template file not found
-                       $templateContent = '<div class="para">
-       {--TEMPLATE_404--}: ' . $template . '
+                       $templateContent = sprintf('<div class="para">
+       {--TEMPLATE_404--}: %s
 </div>
 <div class="para">
        {--TEMPLATE_CONTENT--}:
-       <pre>' . print_r($content, TRUE) . '</pre>
-</div>';
+       <pre>%s</pre>
+</div>',
+                               $template,
+                               print_r($content, TRUE)
+                       );
 
                        // Don't cache this, as there is no template to cache
                        $GLOBALS['template_eval']['email'][$template] = '404';
@@ -2031,24 +2034,24 @@ function returnErrorMessage ($message) {
        return loadTemplate('admin_settings_unsaved', TRUE, $message);
 }
 
-// Generates a selection box for (maybe) given gender
-function generateGenderSelectionBox ($selectedGender = '', $fieldName = 'gender') {
+// Generates a selection box for (maybe) given sex
+function generateSexSelectionBox ($selectedSex = '', $fieldName = 'sex') {
        // Start the HTML code
        $out  = '<select name="' . $fieldName . '" size="1" class="form_select">';
 
        // Add options
        $out .= generateOptions(
                '/ARRAY/',
-               array(
+               [
                        'M',
                        'F',
                        'C'
-               ), array(
-                       '{--GENDER_M--}',
-                       '{--GENDER_F--}',
-                       '{--GENDER_C--}'
-               ),
-               $selectedGender
+               ], [
+                       '{--SEX_M--}',
+                       '{--SEX_F--}',
+                       '{--SEX_C--}'
+               ],
+               $selectedSex
        );
 
        // Finish HTML code