]> git.mxchange.org Git - mailer.git/blobdiff - inc/template-functions.php
Wrapper getBonusRanks() more used
[mailer.git] / inc / template-functions.php
index 16cc8cbf6fb71492ac7b59a80000f683a15f9259..73e88c6ce05cef02ac10234a892621d043043ae8 100644 (file)
@@ -70,13 +70,8 @@ function debugOutput ($message) {
 
 // "Fixes" an empty string into three dashes (use for templates)
 function fixEmptyContentToDashes ($str) {
-       // Trim the string
-       $str = trim($str);
-
-       // Is the string empty?
-       if (empty($str)) {
-               $str = '---';
-       } // END - if
+       // Call inner function
+       $str = fixNullEmptyToDashes($str, 3);
 
        // Return string
        return $str;
@@ -854,15 +849,11 @@ function generateImageOrCode ($img_code, $headerSent = true) {
 }
 
 // Create selection box or array of splitted timestamp
-function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = 'center', $return_array=false) {
+function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = 'center', $asArray = false) {
        // Do not continue if ONE_DAY is absend
        if (!isConfigEntrySet('ONE_DAY')) {
-               // And return the timestamp itself or empty array
-               if ($return_array === true) {
-                       return array();
-               } else {
-                       return $timestamp;
-               }
+               // Abort here
+               debug_report_bug(__FUNCTION__, __LINE__, 'Configuration entry ONE_DAY is absend. timestamp=' . $timestamp . ',prefix=' . $prefix . ',align=' . $align . ',asArray=' . intval($asArray));
        } // END - if
 
        // Calculate 2-seconds timestamp
@@ -911,7 +902,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
        //
        // Now we convert them in seconds...
        //
-       if ($return_array) {
+       if ($asArray === true) {
                // Just put all data in an array for later use
                $OUT = array(
                        'YEARS'   => $Y,
@@ -1396,42 +1387,54 @@ function linenumberCode ($code)    {
 
 // Determines the right page title
 function determinePageTitle () {
+       // Init page title
+       $pageTitle = '';
+
        // Config and database connection valid?
        if ((isConfigLocalLoaded()) && (isConfigurationLoaded()) && (SQL_IS_LINK_UP()) && (isExtensionInstalledAndNewer('sql_patches', '0.1.6'))) {
-               // Init title
-               $TITLE = '';
-
                // Title decoration enabled?
-               if ((isTitleDecorationEnabled()) && (getConfig('title_left') != '')) $TITLE .= trim(getConfig('title_left')) . ' ';
+               if ((isTitleDecorationEnabled()) && (getConfig('title_left') != '')) {
+                       $pageTitle .= '{%config,trim=title_left%} ';
+               } // END - if
 
                // Do we have some extra title?
                if (isExtraTitleSet()) {
-                       // Then prepent it
-                       $TITLE .= getExtraTitle() . ' by ';
+                       // Then prepend it
+                       $pageTitle .= '{%pipe,getExtraTitle%} by ';
                } // END - if
 
                // Add main title
-               $TITLE .= getMainTitle();
+               $pageTitle .= '{?MAIN_TITLE?}';
 
                // Add title of module? (middle decoration will also be added!)
                if ((isModuleTitleEnabled()) || ((!isWhatSet()) && (!isActionSet())) || (getModule() == 'admin')) {
-                       $TITLE .= ' ' . trim(getConfig('title_middle')) . ' {DQUOTE} . getModuleTitle(getModule()) . {DQUOTE}';
+                       $pageTitle .= ' {%config,trim=title_middle%} {DQUOTE} . getModuleTitle(getModule()) . {DQUOTE}';
                } // END - if
 
                // Add title from what file
                $mode = '';
-               if (getModule() == 'login') $mode = 'member';
-               elseif (getModule() == 'index') $mode = 'guest';
-               if ((!empty($mode)) && (isWhatTitleEnabled())) $TITLE .= ' ' . trim(getConfig('title_middle')) . ' ' . getTitleFromMenu($mode, getWhat());
+               if (getModule() == 'login') {
+                       $mode = 'member';
+               } elseif (getModule() == 'index') {
+                       $mode = 'guest';
+               } elseif (getModule() == 'admin') {
+                       $mode = 'admin';
+               } elseif (getModule() == 'sponsor') {
+                       $mode = 'sponsor';
+               }
 
-               // Add title decorations? (right)
-               if ((isTitleDecorationEnabled()) && (getConfig('title_right') != '')) $TITLE .= ' ' . trim(getConfig('title_right'));
+               // Add middle part (always in admin area!)
+               if ((!empty($mode)) && ((isWhatTitleEnabled()) || ($mode == 'admin'))) {
+                       $pageTitle .= ' {%config,trim=title_middle%} ' . getTitleFromMenu($mode, getWhat());
+               } // END - if
 
-               // Remember title in constant for the template
-               $pageTitle = $TITLE;
+               // Add title decorations? (right)
+               if ((isTitleDecorationEnabled()) && (getConfig('title_right') != '')) {
+                       $pageTitle .= ' {%config,trim=title_right%}';
+               } // END - if
        } elseif ((isInstalled()) && (isAdminRegistered())) {
                // Installed, admin registered but no ext-sql_patches
-               $pageTitle = '[-- ' . getMainTitle() . ' - ' . getModuleTitle(getModule()) . ' --]';
+               $pageTitle = '[-- {?MAIN_TITLE?} - {%pipe,getModule,getModuleTitle%} --]';
        } elseif ((isInstalled()) && (!isAdminRegistered())) {
                // Installed but no admin registered
                $pageTitle = '{--INSTALLER_OF_MAILER_NO_ADMIN--}';
@@ -1772,7 +1775,7 @@ function generateGenderSelectionBox ($selectedGender = '') {
 }
 
 //-----------------------------------------------------------------------------
-//                      Template helper functions for EL
+//                     Template helper functions for EL code
 //-----------------------------------------------------------------------------
 
 // Color-switch helper function
@@ -1795,7 +1798,7 @@ function doTemplateColorSwitch ($template, $clear = false, $return = true) {
 }
 
 // Helper function for extension registration link
-function doTemplateExtensionRegistrationLink ($template, $dummy, $ext_name) {
+function doTemplateExtensionRegistrationLink ($template, $clear, $ext_name) {
        // Default is all non-productive
        $OUT = '<em style="cursor:help" class="notice" title="{%message,ADMIN_EXTENSION_IS_NON_PRODUCTIVE_LINK_TITLE=' . $ext_name . '%}">{--ADMIN_EXTENSION_IS_NON_PRODUCTIVE_LINK--}</em>';
 
@@ -1810,22 +1813,50 @@ function doTemplateExtensionRegistrationLink ($template, $dummy, $ext_name) {
 }
 
 // Helper function to create bonus mail admin links
-function doTemplateAdminBonusMailLinks ($template, $dummy, $bonusId) {
+function doTemplateAdminBonusMailLinks ($template, $clear, $bonusId) {
        // Call the inner function
        return generateAdminMailLinks('bid', $bonusId);
 }
 
 // Helper function to create member mail admin links
-function doTemplateAdminMemberMailLinks ($template, $dummy, $mailId) {
+function doTemplateAdminMemberMailLinks ($template, $clear, $mailId) {
        // Call the inner function
        return generateAdminMailLinks('mid', $mailId);
 }
 
 // Helper function to create a selection box for YES/NO configuration entries
-function doTemplateConfigurationYesNoSelectionBox ($template, $dummy, $configEntry) {
+function doTemplateConfigurationYesNoSelectionBox ($template, $clear, $configEntry) {
+       // Default is a "missing entry" warning
+       $OUT = '<em style="cursor:help" class="notice" title="{%message,ADMIN_CONFIG_ENTRY_MISSING=' . $configEntry . '%}">!' . $configEntry . '!</em>';
+
        // Generate the HTML code
-       $OUT = '<select name="' . $configEntry . '" class="form_select" size="1">
+       if (isConfigEntrySet($configEntry)) {
+               // Configuration entry is found
+               $OUT = '<select name="' . $configEntry . '" class="form_select" size="1">
 {%config,generateYesNoOptionList=' . $configEntry . '%}
+</select>';
+       } // END - if
+
+       // Return it
+       return $OUT;
+}
+
+// Helper function to create a selection box for YES/NO form fields
+function doTemplateYesNoSelectionBox ($template, $clear, $formField) {
+       // Generate the HTML code
+       $OUT = '<select name="' . $formField . '" class="form_select" size="1">
+{%pipe,generateYesNoOptionList%}
+</select>';
+
+       // Return it
+       return $OUT;
+}
+
+// Helper function to create a selection box for YES/NO form fields, by NO is default
+function doTemplateNoYesSelectionBox ($template, $clear, $formField) {
+       // Generate the HTML code
+       $OUT = '<select name="' . $formField . '" class="form_select" size="1">
+{%pipe,generateYesNoOptionList=N%}
 </select>';
 
        // Return it