Admin menu has now a JavaScript "effect":
[mailer.git] / inc / template-functions.php
index 78e58e0790efc9f741a0479e5edc5be55e0ee847..e13e09a291b367c6623711527c98867f4762d2a9 100644 (file)
@@ -325,7 +325,7 @@ 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 //-->';
 
@@ -573,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
@@ -1419,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)
@@ -1793,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
 //-----------------------------------------------------------------------------