]> git.mxchange.org Git - mailer.git/blobdiff - inc/template-functions.php
Admin menu has now a JavaScript "effect":
[mailer.git] / inc / template-functions.php
index 62fecd0386f86a5c54187892e77648dfd6a00e7a..e13e09a291b367c6623711527c98867f4762d2a9 100644 (file)
@@ -110,23 +110,32 @@ function outputHtml ($htmlCode, $newLine = true) {
                                        outputRawCode($htmlCode);
 
                                        // That's why you don't need any \n at the end of your HTML code... :-)
-                                       if ($newLine === true) print("\n");
+                                       if ($newLine === true) {
+                                               print("\n");
+                                       } // END - if
                                } else {
                                        // Render mode for old or lame servers...
                                        $GLOBALS['output'] .= $htmlCode;
 
                                        // That's why you don't need any \n at the end of your HTML code... :-)
-                                       if ($newLine === true) $GLOBALS['output'] .= "\n";
+                                       if ($newLine === true) {
+                                               $GLOBALS['output'] .= "\n";
+                                       } // END - if
                                }
                                break;
 
                        case 'direct':
                                // If we are switching from render to direct output rendered code
-                               if ((!empty($GLOBALS['output'])) && (getPhpCaching() != 'on')) { outputRawCode($GLOBALS['output']); $GLOBALS['output'] = ''; }
+                               if ((!empty($GLOBALS['output'])) && (getPhpCaching() != 'on')) {
+                                       outputRawCode($GLOBALS['output']);
+                                       $GLOBALS['output'] = '';
+                               } // END - if
 
                                // The same as above... ^
                                outputRawCode($htmlCode);
-                               if ($newLine === true) print("\n");
+                               if ($newLine === true) {
+                                       print("\n");
+                               } // END - if
                                break;
 
                        default:
@@ -316,14 +325,14 @@ function loadTemplate ($template, $return = false, $content = array(), $compileC
                        $ret = '';
                        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()) {
+                               if ((isHtmlOutputMode()) && (substr($template, 0, 3) != 'js_')) {
                                        // Add surrounding HTML comments to help finding bugs faster
                                        $ret = '<!-- Template ' . $template . ' - Start //-->' . $GLOBALS['tpl_content'][$template] . '<!-- Template ' . $template . ' - End //-->';
 
                                        // Prepare eval() command
                                        $GLOBALS['template_eval'][$template] = '$ret = "' . getColorSwitchCode($template) . compileCode(escapeQuotes($ret), false, true, true, $compileCode) . '";';
                                } elseif (substr($template, 0, 3) == 'js_') {
-                                       // JavaScripts don't like entities and timings
+                                       // JavaScripts don't like entities, dollar signs and timings
                                        $GLOBALS['template_eval'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($GLOBALS['tpl_content'][$template]), false, true, true, $compileCode) . '");';
                                } else {
                                        // Prepare eval() command, other output doesn't like entities, maybe
@@ -340,7 +349,7 @@ function loadTemplate ($template, $return = false, $content = array(), $compileC
                } elseif ((isAdmin()) || ((isInstalling()) && (!isInstalled()))) {
                        // Only admins shall see this warning or when installation mode is active
                        $ret = '<div class="para">
-       <span class="notice">{--TEMPLATE_404--}</span>
+       <span class="bad">{--TEMPLATE_404--}</span>
 </div>
 <div class="para">
        (' . $template . ')
@@ -564,7 +573,7 @@ function getMenuCssClasses ($data) {
 
 // Generate XHTML code for the CAPTCHA
 function generateCaptchaCode ($code, $type, $type, $userid) {
-       return '<img border="0" alt="Code ' . $code . '" src="{%url=mailid_top.php?userid=' . $userid . '&amp;' . $type . '=' . $type . '&amp;mode=img&amp;code=' . $code . '%}" />';
+       return '<img border="0" alt="Code ' . $code . '" src="{%url=mailid_top.php?userid=' . $userid . '&amp;' . $type . '=' . $type . '&amp;do=img&amp;code=' . $code . '%}" />';
 }
 
 // Compiles the given HTML/mail code
@@ -1410,20 +1419,20 @@ function determinePageTitle () {
                } // END - if
 
                // Add title from what file
-               $mode = '';
+               $menuMode = '';
                if (getModule() == 'login') {
-                       $mode = 'member';
+                       $menuMode = 'member';
                } elseif (getModule() == 'index') {
-                       $mode = 'guest';
+                       $menuMode = 'guest';
                } elseif (getModule() == 'admin') {
-                       $mode = 'admin';
+                       $menuMode = 'admin';
                } elseif (getModule() == 'sponsor') {
-                       $mode = 'sponsor';
+                       $menuMode = 'sponsor';
                }
 
                // Add middle part (always in admin area!)
-               if ((!empty($mode)) && ((isWhatTitleEnabled()) || ($mode == 'admin'))) {
-                       $pageTitle .= ' {%config,trim=title_middle%} ' . getTitleFromMenu($mode, getWhat());
+               if ((!empty($menuMode)) && ((isWhatTitleEnabled()) || ($menuMode == 'admin'))) {
+                       $pageTitle .= ' {%config,trim=title_middle%} ' . getTitleFromMenu($menuMode, getWhat());
                } // END - if
 
                // Add title decorations? (right)
@@ -1603,16 +1612,16 @@ function sendModeMails ($mod, $modes) {
 
                                default: // Unsupported module!
                                        logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unsupported module %s detected.", $mod));
-                                       $content['message'] = '<span class="notice">{--UNKNOWN_MODULE--}</span>';
+                                       $content['message'] = '<span class="bad">{--UNKNOWN_MODULE--}</span>';
                                        break;
                        } // END - switch
                } else {
                        // Passwords mismatch
-                       $content['message'] = '<span class="notice">{--MEMBER_PASSWORD_ERROR--}</span>';
+                       $content['message'] = '<span class="bad">{--MEMBER_PASSWORD_ERROR--}</span>';
                }
        } else {
                // Could not load profile
-               $content['message'] = '<span class="notice">{--MEMBER_CANNOT_LOAD_PROFILE--}</span>';
+               $content['message'] = '<span class="bad">{--MEMBER_CANNOT_LOAD_PROFILE--}</span>';
        }
 
        // Send email to user if required
@@ -1638,7 +1647,7 @@ function sendModeMails ($mod, $modes) {
 }
 
 // Generates a 'selection box' from given array
-function generateSelectionBoxFromArray ($options, $name, $optionValue, $optionContent = '', $extraName = '') {
+function generateSelectionBoxFromArray ($options, $name, $optionValue, $optionContent = '', $extraName = '', $templateName = '') {
        // Start the output
        $OUT = '<select name="' . $name . '" size="1" class="form_select">
 <option value="X" disabled="disabled">{--PLEASE_SELECT--}</option>';
@@ -1647,8 +1656,14 @@ function generateSelectionBoxFromArray ($options, $name, $optionValue, $optionCo
        foreach ($options as $option) {
                // Add the <option> entry from ...
                if (empty($optionContent)) {
-                       // ... template
-                       $OUT .= loadTemplate('select_' . $name . $extraName . '_option', true, $option);
+                       // Is a template name given?
+                       if (empty($templateName)) {
+                               // ... $name template
+                               $OUT .= loadTemplate('select_' . $name . $extraName . '_option', true, $option);
+                       } else {
+                               // ... $templateName template
+                               $OUT .= loadTemplate('select_' . $templateName . $extraName . '_option', true, $option);
+                       }
                } else {
                        // ... direct HTML code
                        $OUT .= '<option value="' . $option[$optionValue] . '">' . $option[$optionContent] . '</option>';
@@ -1664,7 +1679,13 @@ function generateSelectionBoxFromArray ($options, $name, $optionValue, $optionCo
        );
 
        // Load template and return it
-       return loadTemplate('select_' . $name . $extraName . '_box', true, $content);
+       if (empty($templateName)) {
+               // Use name from $name + $extraName
+               return loadTemplate('select_' . $name . $extraName . '_box', true, $content);
+       } else {
+               // Use name from $templateName + $extraName
+               return loadTemplate('select_' . $templateName . $extraName . '_box', true, $content);
+       }
 }
 
 // Prepares the header for HTML output
@@ -1709,8 +1730,8 @@ function generateMetaDescriptionCode () {
                $GLOBALS['page_header'] .= '<meta name="description" content="' . $DESCR . '" />';
        } // END - if
 
-       // Initialize referal system
-       initReferalSystem();
+       // Initialize referral system
+       initReferralSystem();
 }
 
 // Generates an FQFN for template cache from the given template name
@@ -1772,6 +1793,43 @@ function generateGenderSelectionBox ($selectedGender = '') {
        return $out;
 }
 
+// Function to add style tag (wether display:none/block)
+function addStyleMenuContent ($menuMode, $mainAction, $action) {
+       // Do we have foo_menu_javascript enabled?
+       if (getConfig($menuMode . '_menu_javascript') == 'N') {
+               // Silently abort here, not enabled
+               return '';
+       } // END - if
+
+       // Is action=mainAction?
+       if ($action == $mainAction) {
+               // Add "menu open" style
+               return ' style="display:block"';
+       } else {
+               return ' style="display:none"';
+       }
+}
+
+// Function to add onclick attribute
+function addJavaScriptMenuContent ($menuMode, $mainAction, $action, $what) {
+       // Do we have foo_menu_javascript enabled?
+       if (getConfig($menuMode . '_menu_javascript') == 'N') {
+               // Silently abort here, not enabled
+               return '';
+       } // END - if
+
+       // Prepare content
+       $content = array(
+               'menu_mode'   => $menuMode,
+               'main_action' => $mainAction,
+               'action'      => $action,
+               'what'        => $what
+       );
+
+       // Return template
+       return loadTemplate('js_' . $menuMode . '_menu_onclick', true, $content);
+}
+
 //-----------------------------------------------------------------------------
 //                     Template helper functions for EL code
 //-----------------------------------------------------------------------------
@@ -1798,7 +1856,7 @@ function doTemplateColorSwitch ($template, $clear = false, $return = true) {
 // Helper function for extension registration link
 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>';
+       $OUT = '<div style="cursor:help" title="{%message,ADMIN_EXTENSION_IS_NON_PRODUCTIVE_LINK_TITLE=' . $ext_name . '%}">{--ADMIN_EXTENSION_IS_NON_PRODUCTIVE_LINK--}</div>';
 
        // Is the given extension non-productive?
        if (isExtensionProductive($ext_name)) {
@@ -1825,7 +1883,7 @@ function doTemplateAdminMemberMailLinks ($template, $clear, $mailId) {
 // Helper function to create a selection box for YES/NO configuration entries
 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>';
+       $OUT = '<div class="bad" style="cursor:help" title="{%message,ADMIN_CONFIG_ENTRY_MISSING=' . $configEntry . '%}">!' . $configEntry . '!</div>';
 
        // Generate the HTML code
        if (isConfigEntrySet($configEntry)) {