[BUGFIX] Warning in list module
[Packages/TYPO3.CMS.git] / typo3 / class.alt_menu_functions.inc
old mode 100755 (executable)
new mode 100644 (file)
index 6201856..f426ec7
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  * Basically it traverses the module structure and generates output based on that.
  *
  * $Id$
- * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
+ * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
  * XHTML compliant content
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
@@ -66,7 +66,7 @@
 /**
  * Class with menu functions
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -96,13 +96,14 @@ class alt_menu_functions {
 
                        // By default module sections are collapsable, only if they are explicitly turned off via TSconfig, they are not:
                $tmpArr = $BE_USER->getTSConfig('options.moduleMenuCollapsable');
-               $collapsable = ($tmpArr['value'] ? 0 : 1);
+               $collapsable = (isset($tmpArr['value']) && $tmpArr['value']==0) ? 0 : 1;
                unset($tmpArr);
 
                        // Initialize vars:
                $final='';
                $menuCode='';
                $descrCode='';
+               $collection=array();
                $menuCode_sub='';
                $selectItems=array();
                $mIcons=array();
@@ -112,11 +113,6 @@ class alt_menu_functions {
                $selectItems[] = '<option value="">[ '.$LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.selMenu_modules',1).' ]</option>';
                $mC=0;
 
-                       // Remove the 'doc' module?
-               if ($BE_USER->getTSConfigVal('options.disableDocModuleInAB'))   {
-                       unset($theModules['doc']);
-               }
-
                        // Get collapsed configuration
                if ($collapsable == 1) {
                        $config = is_array ($BE_USER->uc['moduleData']['alt_menu.php']) ? $BE_USER->uc['moduleData']['alt_menu.php'] : array();
@@ -146,8 +142,7 @@ class alt_menu_functions {
                }
 
                        // Traverse array with modules
-               reset($theModules);
-               while(list($moduleName,$moduleInfo)=each($theModules))  {
+               foreach ($theModules as $moduleName => $moduleInfo) {
                        $mC++;
 
                        $prefix = $this->getNavFramePrefix($moduleInfo);
@@ -177,12 +172,19 @@ class alt_menu_functions {
                        $moduleKey = $moduleName.'_tab';
                        $moduleCSSId = 'ID_'.t3lib_div::md5int($moduleName);
 
+                       $collection[$moduleKey] = array(
+                               'moduleName' => $moduleName,
+                               'title' => $LANG->moduleLabels['tabs'][$moduleKey],
+                               'onclick' => 'top.goToModule(\''.$moduleName.'\');',
+                       );
+
                                // Creating image icon
                        $image = @getimagesize($this->mIconFile($LANG->moduleLabels['tabs_images'][$moduleKey],$backPath));
                        $imageCode='';
                        $descr3_title = $LANG->moduleLabels['tabs'][$moduleKey].' ';
                        if ($image)     {
                                $Ifilename = $this->mIconFilename($LANG->moduleLabels['tabs_images'][$moduleKey],$backPath);
+                               $collection[$moduleKey]['icon'] = array($Ifilename, $image[3]);
                                $imageCode = '<img src="'.$Ifilename.'" '.$image[3].' alt="" />';
                                $descr3_imageCode = '<img src="'.$Ifilename.'" '.$image[3].' title="'.htmlspecialchars($descr3_title).'" alt="" />';
                        } else {
@@ -204,13 +206,13 @@ class alt_menu_functions {
                        }
 
                        $selectItems[] = '<option value="top.goToModule(\''.$moduleName.'\');">'.htmlspecialchars($LANG->moduleLabels['tabs'][$moduleKey]).'</option>';
-                       $label='&nbsp;<b>'.$label.'</b>&nbsp;';
+                       $label='&nbsp;<strong>'.$label.'</strong>&nbsp;';
 
 
                                // make menu collapsable
                        if($collapsable == 1 && is_array($moduleInfo['sub'])) {
                                $collapseJS = 'onclick="window.location.href=\'alt_menu.php?collapsedOverride['.$moduleName.']='.($config[$moduleName] ? '0' : '1').'\'"';
-                               $collapseIcon = '<span class="c-iconCollapse"><img'.t3lib_iconWorks::skinImg($backPath,'gfx/ol/'.($config[$moduleName] ? 'plusbullet.gif':'minusbullet.gif'),'width="18" height="16"').' title="" alt="" /></span>';
+                               $collapseIcon = t3lib_iconWorks::getSpriteIcon('actions-view-table-' . ($config[$moduleName] ? 'expand' : 'collapse'), array('class' => 'c-iconCollapse'));
                        } else {
                                $collapseJS = $collapseIcon = '';
                        }
@@ -223,7 +225,7 @@ class alt_menu_functions {
 
                                // Code for "About modules"
                        $descrCode.='
-                                               <tr class="c-mainitem bgColor4">
+                                               <tr class="c-mainitem">
                                                        <td colspan="3">'.$imageCode.$label.'</td>
                                                </tr>';
 
@@ -236,9 +238,9 @@ class alt_menu_functions {
                                // Traversing submodules
                        $subCode='';
                        if (is_array($moduleInfo['sub']))       {
-                               reset($moduleInfo['sub']);
+                               $collection[$moduleKey]['subitems'] = array();
                                $c=0;
-                               while(list($subName,$subInfo)=each($moduleInfo['sub'])) {
+                               foreach ($moduleInfo['sub'] as $subName => $subInfo) {
                                        if ($c==0)              {
                                                $subCode.='
                                                                <tr class="c-first">
@@ -256,12 +258,19 @@ class alt_menu_functions {
                                        $subKey = $moduleName.'_'.$subName.'_tab';
                                        $moduleCSSId = 'ID_'.t3lib_div::md5int($moduleName.'_'.$subName);
 
+                                       $collection[$moduleKey]['subitems'][$subKey] = array(
+                                               'moduleName' => $moduleName.'_'.$subName,
+                                               'title' => $LANG->moduleLabels['tabs'][$subKey],
+                                               'onclick' => 'top.goToModule(\''.$moduleName.'_'.$subName.'\');',
+                                       );
+
                                                // Creating image icon
                                        $image = @getimagesize($this->mIconFile($LANG->moduleLabels['tabs_images'][$subKey],$backPath));
                                        $imageCode='';
                                        $descr3_title = $LANG->moduleLabels['tabs'][$subKey].': '.$LANG->moduleLabels['labels'][$subKey.'label'];
                                        if ($image)     {
                                                $Ifilename = $this->mIconFilename($LANG->moduleLabels['tabs_images'][$subKey],$backPath);
+                                               $collection[$moduleKey]['subitems'][$subKey]['icon'] = array($Ifilename, $image[3]);
                                                $imageCode = '<img src="'.$Ifilename.'" '.$image[3].' title="'.htmlspecialchars($LANG->moduleLabels['labels'][$subKey.'label']).'" alt="" />';
                                                $descr3_imageCode = '<img src="'.$Ifilename.'" '.$image[3].' title="'.htmlspecialchars($descr3_title).'" alt="" />';
                                        } else {
@@ -277,7 +286,7 @@ class alt_menu_functions {
 
                                                // Setting additional JavaScript if frameset script:
                                        $addJS = '';
-                                       if ($moduleInfo['navFrameScript'])      {$addJS="+'&id='+top.rawurlencode(top.fsMod.recentIds['".$moduleName."'])";}
+                                       if ($moduleInfo['navFrameScript'])      {$addJS = "+'&id='+top.rawurlencodeAndRemoveSiteUrl(top.fsMod.recentIds['" . $moduleName . "'])";}
 
                                                // If there is a script to link to (and linking is not disabled.
                                        if ($link && !$dontLink)        {
@@ -344,11 +353,24 @@ class alt_menu_functions {
                                                        </tr>';
 
                                                // For "About modules":
+                                       $moduleLabel = htmlspecialchars($LANG->moduleLabels['labels'][$subKey.'label']);
+                                       $moduleLabelHtml = !empty($moduleLabel) ? '<strong>' . $moduleLabel . '</strong><br />' : '';
+                                       $moduleDescription = $LANG->moduleLabels['labels'][$subKey.'descr'];
+
                                        $descrCode.='
                                                        <tr class="c-subitem-row">
                                                                <td align="center">'.$imageCode.'</td>
-                                                               <td>'.$flabel.'&nbsp;&nbsp;</td>
-                                                               <td><strong>'.htmlspecialchars($LANG->moduleLabels['labels'][$subKey.'label']).'</strong><br />'.$LANG->moduleLabels['labels'][$subKey.'descr'].'</td>
+                                                               <td>'.$flabel.'&nbsp;&nbsp;</td>';
+
+                                       if (!empty($moduleLabel) || !empty($moduleDescription)) {
+                                               $descrCode .= '
+                                                               <td class="module-description">' . $moduleLabelHtml . $moduleDescription . '</td>';
+                                       } else {
+                                               $descrCode .= '
+                                                               <td>&nbsp;</td>';
+                                       }
+
+                                       $descrCode .= '
                                                        </tr>';
 
                                                // Possibly adding a divider line
@@ -367,20 +389,21 @@ class alt_menu_functions {
                                }
                        }
 
-                               // Add spacers after each main section:
-                       $subCode.='
-                                       <tr class="c-endrow">
-                                               <td colspan="3"></td>
-                                       </tr>';
-                       $descrCode.='
-                                       <tr class="c-endrow">
-                                               <td colspan="3"></td>
-                                       </tr>';
+                       if (!empty($subCode)) {
+                                       // Add spacers after each main section:
+                               $subCode .= '
+                                               <tr class="c-endrow">
+                                                       <td colspan="3"></td>
+                                               </tr>';
+                               $descrCode .= '
+                                               <tr class="c-endrow">
+                                                       <td colspan="3"></td>
+                                               </tr>';
 
-                               // Add sub-code:
-                       $menuCode.=$subCode;
+                                       // Add sub-code:
+                               $menuCode .= $subCode;
+                       }
                }
-
                        // $descr==0:   Ordinary vertical menu
                if ($menuCode)  {
                        if($collapsable == 1 || $config['expandAll'] == 1) {
@@ -459,6 +482,11 @@ class alt_menu_functions {
                        $final = chr(10).implode(chr(10),$mJScmds).chr(10);
                }
 
+                       // Output for TOPMENU BAR drop downs (but basically this is an array with which you can do many interesting things...)
+               if ($descr==5)  {
+                       $final = $collection;
+               }
+
                        // Return result:
                return $final;
        }
@@ -569,8 +597,13 @@ class alt_menu_functions {
                if ($TYPO3_CONF_VARS['EXT']['extCache'])        {
                        $title = $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_allTypo3Conf');
                        $functions[]=array(
+                               'id' => 'temp_CACHED',
                                'title' => $title,
-                               'href' => $backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')).'&cacheCmd=temp_CACHED',
+                               'href' => $backPath .
+                                               'tce_db.php?vC=' . $BE_USER->veriCode() .
+                                               '&redirect=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')) .
+                                               '&cacheCmd=temp_CACHED' .
+                                               t3lib_BEfunc::getUrlToken('tceAction'),
                                'icon' => '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_cache_files_in_typo3c.gif','width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
                        );
                }
@@ -578,8 +611,12 @@ class alt_menu_functions {
                        // Clear all page cache
                $title = $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all');
                $functions[]=array(
+                       'id' => 'all',
                        'title' => $title,
-                       'href' => $backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')).'&cacheCmd=all',
+                       'href' => $backPath . 'tce_db.php?vC=' . $BE_USER->veriCode() .
+                                       '&redirect=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')) .
+                                       '&cacheCmd=all' .
+                                       t3lib_BEfunc::getUrlToken('tceAction'),
                        'icon' => '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_all_cache.gif','width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
                );
 
@@ -598,10 +635,41 @@ class alt_menu_functions {
                        return $link.'?';
                } else return $link;
        }
+
+       /**
+        * Generates some JavaScript code for the frame.
+        *
+        * @return      string  goToModule javascript function
+        */
+       function generateMenuJScode($loadedModules, $menuType = 4)      {
+               global $TBE_TEMPLATE;
+
+               $goToModuleSwitch = $this->topMenu($loadedModules, 0, '', $menuType);
+
+               $jsCode = '
+       /**
+        * Function used to switch switch module.
+        */
+       var currentModuleLoaded = "";
+       function goToModule(modName,cMR_flag,addGetVars)        {       //
+               var additionalGetVariables = "";
+               if (addGetVars) additionalGetVariables = addGetVars;
+
+               var cMR = 0;
+               if (cMR_flag)   cMR = 1;
+
+               currentModuleLoaded = modName;
+
+               switch(modName) {'.$goToModuleSwitch.'
+               }
+       }';
+
+               return $jsCode;
+       }
 }
 
 
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc'])     {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc']);
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc']);
 }
-?>
\ No newline at end of file
+?>