]> git.mxchange.org Git - mailer.git/blobdiff - inc/template-functions.php
First batch of removal of the headers needed for revision-functions.php
[mailer.git] / inc / template-functions.php
index 139759e5b0016c80bfe55cbcaaafbb557bb184fc..cc04cdeb79295e04e23299d09355ec1017ca5c49 100644 (file)
@@ -305,7 +305,7 @@ function loadTemplate ($template, $return = FALSE, $content = array(), $compileC
        }
 
        // Init returned content
-       $ret = '';
+       $templateContent = '';
 
        // Set current template
        $GLOBALS['current_template'] = $template;
@@ -859,7 +859,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = NULL, $class = 'f
 
                case 'ho': // Hours
                        for ($idx = 0; $idx <= 23; $idx++) {
-                               $padded = padLeftZero($idx);
+                               $padded = padLeftZero($idx, 2);
                                $OUT .= '<option value="' . $padded . '"';
                                if ($default == $padded) $OUT .= ' selected="selected"';
                                $OUT .= '>' . $padded . '</option>';
@@ -869,7 +869,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = NULL, $class = 'f
                case 'mi': // Minutes
                case 'se': // Seconds
                        for ($idx = 0; $idx <= 59; $idx+=5) {
-                               $padded = padLeftZero($idx);
+                               $padded = padLeftZero($idx, 2);
                                $OUT .= '<option value="' . $padded . '"';
                                if ($default == $padded) $OUT .= ' selected="selected"';
                                $OUT .= '>' . $padded . '</option>';
@@ -1497,8 +1497,8 @@ function generateExtensionInactiveNotInstalledMessage ($ext_name) {
                        break;
 
                default: // Should not happen!
-                       logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid state of extension %s detected.", $ext_name));
-                       $message = sprintf("Invalid state of extension %s detected.", $ext_name);
+                       logDebugMessage(__FUNCTION__, __LINE__, sprintf('Invalid state of extension %s detected.', $ext_name));
+                       $message = sprintf('Invalid state of extension %s detected.', $ext_name);
                        break;
        } // END - switch
 
@@ -1931,10 +1931,12 @@ function generateCacheFqfn ($prefix, $template) {
        if (!isset($GLOBALS['template_cache_fqfn'][$prefix][$template])) {
                // Generate the FQFN
                $GLOBALS['template_cache_fqfn'][$prefix][$template] = sprintf(
-                       '%s_compiled/%s/%s.tpl.cache',
+                       '%s%s_compiled/%s/%s%s',
+                       getPath(),
                        getCachePath(),
                        $prefix,
-                       $template
+                       $template,
+                       getCacheExtension()
                );
        } // END - if
 
@@ -1982,15 +1984,27 @@ function translateTimeUnit ($unit) {
 }
 
 // Displays given message in admin_settings_saved template
-function displayMessage ($message, $return = FALSE) {
+function displayMessage ($message) {
+       // Call inner function
+       outputHtml(returnMessage($message));
+}
+
+// Returns given message in admin_settings_saved template
+function returnMessage ($message) {
+       // Load the template
+       return loadTemplate('admin_settings_saved', TRUE, $message);
+}
+
+// Displays given error message in admin_settings_unsaved template
+function displayErrorMessage ($message) {
        // Load the template
-       return loadTemplate('admin_settings_saved', $return, $message);
+       outputHtml(returnErrorMessage($message));
 }
 
-// Displays given error message in admin_settings_saved template
-function displayErrorMessage ($message, $return = FALSE) {
+// Displays given error message in admin_settings_unsaved template
+function returnErrorMessage ($message) {
        // Load the template
-       return loadTemplate('admin_settings_unsaved', $return, $message);
+       return loadTemplate('admin_settings_unsaved', TRUE, $message);
 }
 
 // Generates a selection box for (maybe) given gender
@@ -2387,6 +2401,21 @@ function doTemplateMetaFavIcon ($templateName, $clear = FALSE) {
        return $out;
 }
 
+// Helper function to display referral id or hide it depending on settings
+function doTemplateDisplayReferralIdContent ($template, $clear = FALSE) {
+       // Ddisplay the refid or make it editable?
+       if (isDisplayRefidEnabled()) {
+               // Load "hide" form template
+               $out = loadTemplate('guest_register_refid_hide', TRUE);
+       } else {
+               // Load template to enter it
+               $out = loadTemplate('guest_register_refid', TRUE);
+       }
+
+       // Return code
+       return $out;
+}
+
 // "Getter" for template base path
 function getTemplateBasePath ($part) {
        // Is there cache?
@@ -2399,5 +2428,44 @@ function getTemplateBasePath ($part) {
        return $GLOBALS[__FUNCTION__][$part];
 }
 
+// Removes comments with @DEPRECATED
+function removeDeprecatedComment ($output) {
+       // Explode it into pieces ... ;)
+       $lines = explode(chr(10), $output);
+
+       // Walk through all
+       $return = '';
+       foreach ($lines as $line) {
+               // Is there a @DEPRECATED?
+               if (isInString('@DEPRECATED', $line)) {
+                       // Ignore this line
+                       continue;
+               } // END - if
+
+               // Add it
+               $return .= $line . chr(13);
+       } // END - foreach
+
+       // Returned cleaned content
+       return $return;
+}
+
+// Generates a selection box suitable for e.g. birthdays: day, month and year
+function generateDayMonthYearSelectionBox ($day, $month, $year) {
+       // This depends on selected language
+       switch (getLanguage()) {
+               case 'de': // German date format
+                       $content = addSelectionBox('da', $day) . addSelectionBox('mo', $month) . addSelectionBox('ye', $year);
+                       break;
+
+               default: // Default is the US date format... :)
+                       $content = addSelectionBox('mo', $month) . addSelectionBox('da', $day) . addSelectionBox('ye', $year);
+                       break;
+       } // END - switch
+
+       // Return content
+       return $content;
+}
+
 // [EOF]
 ?>