680812c7891876762c7b1e76b1ab68e2710bef12
[Packages/TYPO3.CMS.git] / typo3 / class.alt_menu_functions.inc
1 <?php
2 /***************************************************************
3 *  Copyright notice
4 *
5 *  (c) 1999-2009 Kasper Skårhøj (kasperYYYY@typo3.com)
6 *  All rights reserved
7 *
8 *  This script is part of the TYPO3 project. The TYPO3 project is
9 *  free software; you can redistribute it and/or modify
10 *  it under the terms of the GNU General Public License as published by
11 *  the Free Software Foundation; either version 2 of the License, or
12 *  (at your option) any later version.
13 *
14 *  The GNU General Public License can be found at
15 *  http://www.gnu.org/copyleft/gpl.html.
16 *  A copy is found in the textfile GPL.txt and important notices to the license
17 *  from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 *  This script is distributed in the hope that it will be useful,
21 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 *  GNU General Public License for more details.
24 *
25 *  This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28  * Class for generation of the module menu.
29  * Will make the vertical, horizontal, selectorbox based menus AND the "about modules" display.
30  * Basically it traverses the module structure and generates output based on that.
31  *
32  * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
33  * XHTML compliant content
34  *
35  * @author      Kasper Skårhøj <kasperYYYY@typo3.com>
36  */
37 /**
38  * [CLASS/FUNCTION INDEX of SCRIPT]
39  *
40  *
41  *
42  *   73: class alt_menu_functions
43  *   94:     function topMenu($theModules,$dontLink=0,$backPath='',$descr=0)
44  *  473:     function getNavFramePrefix($moduleInfo, $subModuleInfo=array())
45  *  504:     function mIconFile($Ifilename,$backPath)
46  *  519:     function mIconFilename($Ifilename,$backPath)
47  *  531:     function topButtons()
48  *  544:     function adminButtons()
49  *  563:     function adminFunctions($backPath)
50  *  596:     function wrapLinkWithAB($link)
51  *
52  * TOTAL FUNCTIONS: 8
53  * (This index is automatically created/updated by the extension "extdeveval")
54  *
55  */
56
57
58
59
60
61
62
63
64
65 /**
66  * Class with menu functions
67  *
68  * @author      Kasper Skårhøj <kasperYYYY@typo3.com>
69  * @package TYPO3
70  * @subpackage core
71  */
72 class alt_menu_functions {
73
74                 // Internal
75         var $fsMod = array();
76
77         /**
78          * Creates the menu of modules.
79          *
80          * $descr determines the type of menu made:
81          *              0 = Ordinary vertical menu
82          *              1 = Descriptions for 'About modules' display
83          *              2 = selector-box menu
84          *              3 = topmenu - horizontal line of icons!
85          *              4 = part of JavaScript switch contruct for alt_main.php frameset.
86          *
87          * @param       array           $theModules is the output from load_modules class ($this->loadModules->modules)
88          * @param       boolean         $dontLink == TRUE will prevent the output from being linked with A-tags (used in the 'beuser' extension)
89          * @param       string          $backPath must be the 'backPath' to PATH_typo3 from where the menu is displayed.
90          * @param       integer         $descr determines the type of menu made (see above)
91          * @return      string          The menu HTML
92          */
93         function topMenu($theModules,$dontLink=0,$backPath='',$descr=0) {
94
95                         // By default module sections are collapsable, only if they are explicitly turned off via TSconfig, they are not:
96                 $tmpArr = $GLOBALS['BE_USER']->getTSConfig('options.moduleMenuCollapsable');
97                 $collapsable = (isset($tmpArr['value']) && $tmpArr['value']==0) ? 0 : 1;
98                 unset($tmpArr);
99
100                         // Initialize vars:
101                 $final='';
102                 $menuCode='';
103                 $descrCode='';
104                 $collection=array();
105                 $menuCode_sub='';
106                 $selectItems=array();
107                 $mIcons=array();
108                 $mJScmds=array();
109                 $onBlur=$GLOBALS['CLIENT']['FORMSTYLE'] ? 'this.blur();' : '';
110
111                 $selectItems[] = '<option value="">[ '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:buttons.selMenu_modules',1).' ]</option>';
112                 $mC=0;
113
114                         // Get collapsed configuration
115                 if ($collapsable == 1) {
116                         $config = is_array ($GLOBALS['BE_USER']->uc['moduleData']['alt_menu.php']) ? $GLOBALS['BE_USER']->uc['moduleData']['alt_menu.php'] : array();
117                         $collapsedOverride = t3lib_div::_GP('collapsedOverride');
118                         if (is_array ($collapsedOverride)) {
119                                 $config = array_merge ($config, $collapsedOverride);
120                         }
121
122                         if (t3lib_div::_GP('collapsableExpandAll') == 1) {
123                                 $config['expandAll'] = t3lib_div::_GP('expandAll');
124                         }
125
126                         if ($config['expandAll'] && is_array($collapsedOverride)) {
127                                 $config = $collapsedOverride;
128                         }
129
130                         $GLOBALS['BE_USER']->uc['moduleData']['alt_menu.php'] = $config;
131                         $GLOBALS['BE_USER']->writeUC($GLOBALS['BE_USER']->uc);
132
133                                 // all items have to be expanded when expandAll is set
134                         if($config['expandAll'] == 1) {
135                                 foreach($config as $key => $value) {
136                                         if($key != 'expandAll')
137                                                 $config[$key] = 0;
138                                 }
139                         }
140                 }
141
142                         // Traverse array with modules
143                 foreach ($theModules as $moduleName => $moduleInfo) {
144                         $mC++;
145
146                         $prefix = $this->getNavFramePrefix($moduleInfo);
147                         if ($prefix) {
148                                 $this->fsMod[]='fsMod.recentIds["'.$moduleName.'"]="";';
149                         }
150
151                                 // If there are submodules:
152                         if (is_array($moduleInfo['sub']))       {
153                                         // Finding the default module to display
154                                 if ($moduleInfo['defaultMod'])  {
155                                         $link = $moduleInfo['sub'][$moduleInfo['defaultMod']]['script'];
156                                 } else {
157                                         $subTemp = reset($moduleInfo['sub']);
158                                         $link = $subTemp['script'];
159                                 }
160                                 $link_sub = 1;  // Tells that the main modules links to a submodule
161                                 $link = '';     // Does not link to submodules...
162                         } else {
163                                 $link = $moduleInfo['script'];
164                                 $link_sub = 0;
165                         }
166
167                         $link = t3lib_div::resolveBackPath($link);
168
169                         $moduleKey = $moduleName.'_tab';
170                         $moduleCSSId = 'ID_'.t3lib_div::md5int($moduleName);
171
172                         $collection[$moduleKey] = array(
173                                 'moduleName' => $moduleName,
174                                 'title' => $GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey],
175                                 'onclick' => 'top.goToModule(\''.$moduleName.'\');',
176                         );
177
178                                 // Creating image icon
179                         $image = @getimagesize($this->mIconFile($GLOBALS['LANG']->moduleLabels['tabs_images'][$moduleKey],$backPath));
180                         $imageCode='';
181                         $descr3_title = $GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey].' ';
182                         if ($image)     {
183                                 $Ifilename = $this->mIconFilename($GLOBALS['LANG']->moduleLabels['tabs_images'][$moduleKey],$backPath);
184                                 $collection[$moduleKey]['icon'] = array($Ifilename, $image[3]);
185                                 $imageCode = '<img src="'.$Ifilename.'" '.$image[3].' alt="" />';
186                                 $descr3_imageCode = '<img src="'.$Ifilename.'" '.$image[3].' title="'.htmlspecialchars($descr3_title).'" alt="" />';
187                         } else {
188                                 $descr3_imageCode = '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/dummy_module.gif','width="14" height="12"').' title="'.htmlspecialchars($descr3_title).'" alt="" />';
189                         }
190
191                                 // Creating the various links:
192                         $label = $GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey];
193                         if ($link && $prefix)   $link=$prefix.rawurlencode($link);
194                         if ($link && !$dontLink)        {
195                                 $label = '<a href="#" onclick="top.goToModule(\''.$moduleName.'\');'.$onBlur.'return false;">'.$label.'</a>';   //  && !$link_sub
196
197                                 $mIcons[] = '<a href="#" onclick="top.goToModule(\''.$moduleName.'\');'.$onBlur.'return false;" class="c-mainitem" id="'.$moduleCSSId.'">'.$descr3_imageCode.'</a>';
198
199                                 $JScmd = '
200                                                 top.content.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$this->wrapLinkWithAB($link).'"+additionalGetVariables);
201                                                 top.highlightModuleMenuItem("'.$moduleCSSId.'",1);';
202                                 $mJScmds[] = "case '".$moduleName."': \n ".$JScmd." \n break;";
203                         }
204
205                         $selectItems[] = '<option value="top.goToModule(\''.$moduleName.'\');">'.htmlspecialchars($GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey]).'</option>';
206                         $label='&nbsp;<strong>'.$label.'</strong>&nbsp;';
207
208
209                                 // make menu collapsable
210                         if($collapsable == 1 && is_array($moduleInfo['sub'])) {
211                                 $collapseJS = 'onclick="window.location.href=\'alt_menu.php?collapsedOverride['.$moduleName.']='.($config[$moduleName] ? '0' : '1').'\'"';
212                                 $collapseIcon = t3lib_iconWorks::getSpriteIcon('actions-view-table-' . ($config[$moduleName] ? 'expand' : 'collapse'), array('class' => 'c-iconCollapse'));
213                         } else {
214                                 $collapseJS = $collapseIcon = '';
215                         }
216
217                                 // Creating a main item for the vertical menu (descr=0)
218                         $menuCode.='
219                                                 <tr class="c-mainitem" id="'.$moduleCSSId.'">
220                                                         <td colspan="3" '.$collapseJS.' >'.$imageCode.'<span class="c-label">'.$label.'</span>'.$collapseIcon.'</td>
221                                                 </tr>';
222
223                                 // Code for "About modules"
224                         $descrCode.='
225                                                 <tr class="c-mainitem">
226                                                         <td colspan="3">'.$imageCode.$label.'</td>
227                                                 </tr>';
228
229
230                                 // Hide submodules when collapsed:
231                         if($collapsable == 1 && $config[$moduleName] == 1 && $descr == 0 && $config['expandAll'] != 1) {
232                                 unset($moduleInfo['sub']);
233                         }
234
235                                 // Traversing submodules
236                         $subCode='';
237                         if (is_array($moduleInfo['sub']))       {
238                                 $collection[$moduleKey]['subitems'] = array();
239                                 $c=0;
240                                 foreach ($moduleInfo['sub'] as $subName => $subInfo) {
241                                         if ($c==0)              {
242                                                 $subCode.='
243                                                                 <tr class="c-first">
244                                                                         <td colspan="3"></td>
245                                                                 </tr>';
246                                                 $descrCode.='
247                                                                 <tr class="c-first">
248                                                                         <td colspan="3"></td>
249                                                                 </tr>';
250                                         }
251
252                                         $link = t3lib_div::resolveBackPath($subInfo['script']);
253                                         $prefix = $this->getNavFramePrefix($moduleInfo, $subInfo);
254
255                                         $subKey = $moduleName.'_'.$subName.'_tab';
256                                         $moduleCSSId = 'ID_'.t3lib_div::md5int($moduleName.'_'.$subName);
257
258                                         $collection[$moduleKey]['subitems'][$subKey] = array(
259                                                 'moduleName' => $moduleName.'_'.$subName,
260                                                 'title' => $GLOBALS['LANG']->moduleLabels['tabs'][$subKey],
261                                                 'onclick' => 'top.goToModule(\''.$moduleName.'_'.$subName.'\');',
262                                         );
263
264                                                 // Creating image icon
265                                         $image = @getimagesize($this->mIconFile($GLOBALS['LANG']->moduleLabels['tabs_images'][$subKey],$backPath));
266                                         $imageCode='';
267                                         $descr3_title = $GLOBALS['LANG']->moduleLabels['tabs'][$subKey].': '.$GLOBALS['LANG']->moduleLabels['labels'][$subKey.'label'];
268                                         if ($image)     {
269                                                 $Ifilename = $this->mIconFilename($GLOBALS['LANG']->moduleLabels['tabs_images'][$subKey],$backPath);
270                                                 $collection[$moduleKey]['subitems'][$subKey]['icon'] = array($Ifilename, $image[3]);
271                                                 $imageCode = '<img src="'.$Ifilename.'" '.$image[3].' title="'.htmlspecialchars($GLOBALS['LANG']->moduleLabels['labels'][$subKey.'label']).'" alt="" />';
272                                                 $descr3_imageCode = '<img src="'.$Ifilename.'" '.$image[3].' title="'.htmlspecialchars($descr3_title).'" alt="" />';
273                                         } else {
274                                                 $descr3_imageCode = '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/dummy_module.gif','width="14" height="12"').' title="'.htmlspecialchars($descr3_title).'" alt="" />';
275                                         }
276
277                                                 // Label for submodule:
278                                         $label = $GLOBALS['LANG']->moduleLabels['tabs'][$subKey];
279                                         $label_descr = ' title="'.htmlspecialchars($GLOBALS['LANG']->moduleLabels['labels'][$subKey.'label']).'"';
280                                         $flabel = htmlspecialchars($label);
281                                         $origLink = $link;
282                                         if ($link && $prefix)   $link=$prefix.rawurlencode($link);
283
284                                                 // Setting additional JavaScript if frameset script:
285                                         $addJS = '';
286                                         if ($moduleInfo['navFrameScript'])      {$addJS = "+'&id='+top.rawurlencodeAndRemoveSiteUrl(top.fsMod.recentIds['" . $moduleName . "'])";}
287
288                                                 // If there is a script to link to (and linking is not disabled.
289                                         if ($link && !$dontLink)        {
290                                                         // For condensed mode, send &cMR parameter to frameset script.
291                                                 if ($addJS && $GLOBALS['BE_USER']->uc['condensedMode']) {$addJS.=  "+(cMR?'&cMR=1':'')";}
292
293                                                         // Command for the selector box:
294                                                 $JScmd = '
295                                                                 top.content.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$this->wrapLinkWithAB($link).'"'.$addJS.'+additionalGetVariables);
296                                                                 top.fsMod.currentMainLoaded="'.$moduleName.'";
297                                                                 ';
298
299                                                 if ($subInfo['navFrameScript']) {
300                                                         $JScmd.='
301                                                                 top.currentSubScript="'.$origLink.'";';
302                                                 }
303
304                                                         // If there is a frameset script in place:
305                                                 if (!$GLOBALS['BE_USER']->uc['condensedMode'] && $moduleInfo['navFrameScript']) {
306
307                                                                 // use special nav script from sub module, otherwise from the main module
308                                                         $subNavFrameScript = $subInfo['navFrameScript'] ? $subInfo['navFrameScript'] : $moduleInfo['navFrameScript'];
309                                                         $subNavFrameScript = t3lib_div::resolveBackPath($subNavFrameScript);
310
311                                                                 // add GET params for sub module to the nav script
312                                                         $subNavFrameScript = $this->wrapLinkWithAB($subNavFrameScript).$subInfo['navFrameScriptParam'];
313
314                                                         $JScmd = '
315                                                                 if (top.content.list_frame && top.fsMod.currentMainLoaded=="'.$moduleName.'") {
316                                                                         top.currentSubScript="'.$origLink.'";
317                                                                         top.content.list_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$this->wrapLinkWithAB($origLink).'"'.$addJS.'+additionalGetVariables);
318                                                                         if(top.currentSubNavScript!="'.$subNavFrameScript.'") {
319                                                                                 top.currentSubNavScript="'.$subNavFrameScript.'";
320                                                                                 top.content.nav_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$subNavFrameScript.'");
321                                                                         }
322                                                                 } else {
323                                                                         top.content.location=top.TS.PATH_typo3+(
324                                                                                 top.nextLoadModuleUrl?
325                                                                                 "'.($prefix?$this->wrapLinkWithAB($link).'&exScript=':'').'listframe_loader.php":
326                                                                                 "'.$this->wrapLinkWithAB($link).'"'.$addJS.'+additionalGetVariables
327                                                                         );
328                                                                         top.fsMod.currentMainLoaded="'.$moduleName.'";
329                                                                         top.currentSubScript="'.$origLink.'";
330                                                                 }
331                                                                 ';
332                                                 }
333                                                 $selectItems[] = '<option value="top.goToModule(\''.$moduleName.'_'.$subName.'\');">'.htmlspecialchars('- '.$label).'</option>';
334                                                 $onClickString = htmlspecialchars('top.goToModule(\''.$moduleName.'_'.$subName.'\');'.$onBlur.'return false;');
335
336                                                 $flabel = '<a href="#" onclick="'.$onClickString.'"'.$label_descr.'>'.htmlspecialchars($label).'</a>';
337
338                                                 $mIcons[] = '<a href="#" onclick="'.$onClickString.'"'.$label_descr.' class="c-subitem" id="'.$moduleCSSId.'">'.$descr3_imageCode.'</a>';
339
340                                                 $JScmd.= '
341                                                                 top.highlightModuleMenuItem("'.$moduleCSSId.'");';
342                                                 $mJScmds[] = "case '".$moduleName.'_'.$subName."': \n ".$JScmd." \n break;";
343                                         }
344
345                                         $subCode.='
346                                                         <tr class="c-subitem-row" id="'.$moduleCSSId.'">
347                                                                 <td></td>
348                                                                 <td align="center">'.(!$GLOBALS['BE_USER']->uc['hideSubmoduleIcons']?$imageCode:'').'</td>
349                                                                 <td class="c-subitem-label">'.$flabel.'</td>
350                                                         </tr>';
351
352                                                 // For "About modules":
353                                         $moduleLabel = htmlspecialchars($GLOBALS['LANG']->moduleLabels['labels'][$subKey.'label']);
354                                         $moduleLabelHtml = !empty($moduleLabel) ? '<strong>' . $moduleLabel . '</strong><br />' : '';
355                                         $moduleDescription = $GLOBALS['LANG']->moduleLabels['labels'][$subKey.'descr'];
356
357                                         $descrCode.='
358                                                         <tr class="c-subitem-row">
359                                                                 <td align="center">'.$imageCode.'</td>
360                                                                 <td>'.$flabel.'&nbsp;&nbsp;</td>';
361
362                                         if (!empty($moduleLabel) || !empty($moduleDescription)) {
363                                                 $descrCode .= '
364                                                                 <td class="module-description">' . $moduleLabelHtml . $moduleDescription . '</td>';
365                                         } else {
366                                                 $descrCode .= '
367                                                                 <td>&nbsp;</td>';
368                                         }
369
370                                         $descrCode .= '
371                                                         </tr>';
372
373                                                 // Possibly adding a divider line
374                                         $c++;
375                                         if ($c<count($moduleInfo['sub']))       {
376                                                         // Divider
377                                                 $subCode.='
378                                                         <tr class="c-divrow">
379                                                                 <td colspan="3"><img'.t3lib_iconWorks::skinImg($backPath,'gfx/altmenuline.gif','width="105" height="3"').' alt="" /></td>
380                                                         </tr>';
381                                         }
382                                 }
383                                         // Spacer gif for top menu:
384                                 if (count($theModules)>$mC)     {
385                                         $mIcons[]='<img src="'.$backPath.'gfx/acm_spacer2.gif" width="8" height="12" hspace="3" alt="" />';
386                                 }
387                         }
388
389                         if (!empty($subCode)) {
390                                         // Add spacers after each main section:
391                                 $subCode .= '
392                                                 <tr class="c-endrow">
393                                                         <td colspan="3"></td>
394                                                 </tr>';
395                                 $descrCode .= '
396                                                 <tr class="c-endrow">
397                                                         <td colspan="3"></td>
398                                                 </tr>';
399
400                                         // Add sub-code:
401                                 $menuCode .= $subCode;
402                         }
403                 }
404                         // $descr==0:   Ordinary vertical menu
405                 if ($menuCode)  {
406                         if($collapsable == 1 || $config['expandAll'] == 1) {
407                                 $collapseAllHTML = '<tr class="c-endrow">
408                                                 <td></td>
409                                                 <td align="center">
410                                                                 <form action="alt_menu.php" method="get">
411                                                                         <input type="hidden" name="collapsableExpandAll" value="1" />
412                                                                         <input type="checkbox" name="expandAll" id="expandall" value="1" onclick="this.form.submit();" '.($config['expandAll']?'checked="checked"':'').' />
413                                                                 </form>
414                                                 </td>
415                                                 <td class="c-subitem-label"><label for="expandall">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.expandAll',1).'</label></td>
416                                         </tr>';
417                         } else {
418                                 $collapseAllHTML = '';
419                         }
420
421                         $final = '
422
423
424                                 <!--
425                                         Vertical module menu, shown in left frame of backend.
426                                 -->
427                                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-vmenu">
428                                         '.$menuCode.'
429                                         <tr class="c-endrow">
430                                                 <td colspan="3">'.t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'menu_modules', $GLOBALS['BACK_PATH']).'</td></tr>
431                                         '.$collapseAllHTML.'
432                                 </table>';
433                 }
434
435                         // Output for the "About modules" module
436                 if ($descr==1)  {
437                         $descrCode = '
438
439
440                                 <!--
441                                         Listing of modules, for Help > About modules
442                                 -->
443                                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-about-modules">
444                                         '.$descrCode.'
445                                 </table>';
446                         $final = $descrCode;
447                 }
448
449                         // selector-box menu
450                 if ($descr==2)  {
451
452                                 // Add admin-functions for clearing caches:
453                         if ($GLOBALS['BE_USER']->isAdmin())     {
454                                 $functionArray = $this->adminFunctions($backPath);
455                                 if (count($functionArray))      {
456                                         $selectItems[] = '<option value=""></option>';
457                                         foreach($functionArray as $fAoptions)   {
458                                                 $selectItems[] = '<option value="'.htmlspecialchars("window.location.href='".$fAoptions['href']."';").'">[ '.htmlspecialchars($fAoptions['title']).' ]</option>';
459                                         }
460                                 }
461                         }
462
463                                 // Logout item:
464                         $selectItems[] = '<option value=""></option>';
465                         $selectItems[] = '<option value="'.htmlspecialchars("top.location='logout.php';").'">[ '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:buttons.logout',1).' ]</option>';
466                         $final = '
467                                 <select name="menuselector" onchange="eval(this.options[this.selectedIndex].value);">
468                                         '.implode('
469                                         ',$selectItems).'
470                                 </select>';
471                 }
472                         // topmenu - horizontal line of icons!
473                 if ($descr==3)  {
474                         $final = ''.implode('',$mIcons).'';
475                 }
476
477                         // Output for the goToModules() function in main frameset.
478                 if ($descr==4)  {
479                         $final = chr(10).implode(chr(10),$mJScmds).chr(10);
480                 }
481
482                         // Output for TOPMENU BAR drop downs (but basically this is an array with which you can do many interesting things...)
483                 if ($descr==5)  {
484                         $final = $collection;
485                 }
486
487                         // Return result:
488                 return $final;
489         }
490
491         /**
492          * Returns a prefix used to call the navframe with parameters to call the scripts defined in the modules info array.
493          *
494          * @param       string          Module info array
495          * @param       string          Submodule info array
496          * @return      string          Result url string
497          */
498         function getNavFramePrefix($moduleInfo, $subModuleInfo=array()) {
499                 $prefix = '';
500                 $navFrameScript = $subModuleInfo['navFrameScript'] ? $subModuleInfo['navFrameScript'] : $moduleInfo['navFrameScript'];
501                 $navFrameScriptParam = isset($subModuleInfo['navFrameScriptParam']) ? $subModuleInfo['navFrameScriptParam'] : $moduleInfo['navFrameScriptParam'];
502                 if ($navFrameScript)    {
503                         $navFrameScript = t3lib_div::resolveBackPath($navFrameScript);
504                         $navFrameScript = $this->wrapLinkWithAB($navFrameScript);
505
506                         if ($GLOBALS['BE_USER']->uc['condensedMode'])   {
507                                 $prefix=$navFrameScript.$navFrameScriptParam.'&currentSubScript=';
508                         } else {
509                                 $prefix='alt_mod_frameset.php?'.
510                                         'fW="+top.TS.navFrameWidth+"'.
511                                         '&nav="+top.TS.PATH_typo3+"'.rawurlencode($navFrameScript.$navFrameScriptParam).
512                                         '&script=';
513                         }
514                 }
515                 return $prefix;
516         }
517
518         /**
519          * Returns $Ifilename readable for script in PATH_typo3.
520          * That means absolute names are just returned while relative names are prepended with $backPath (pointing back to typo3/ dir)
521          *
522          * @param       string          Icon filename
523          * @param       string          Back path
524          * @return      string          Result
525          * @see mIconFilename()
526          */
527         function mIconFile($Ifilename,$backPath)        {
528                 if (t3lib_div::isAbsPath($Ifilename))   {
529                         return $Ifilename;
530                 }
531                 return $backPath.$Ifilename;
532         }
533
534         /**
535          * Returns relative filename to the $Ifilename (for use in img-tags)
536          *
537          * @param       string          Icon filename
538          * @param       string          Back path
539          * @return      string          Result
540          * @see mIconFile()
541          */
542         function mIconFilename($Ifilename,$backPath)    {
543                 if (t3lib_div::isAbsPath($Ifilename))   {
544                         $Ifilename = '../'.substr($Ifilename,strlen(PATH_site));
545                 }
546                 return $backPath.$Ifilename;
547         }
548
549         /**
550          * Returns logout button.
551          *
552          * @return      string
553          */
554         function topButtons()   {
555                 $label = $GLOBALS['BE_USER']->user['ses_backuserid'] ? 'LLL:EXT:lang/locallang_core.php:buttons.exit' : 'LLL:EXT:lang/locallang_core.php:buttons.logout';
556                 $out = '<form action="logout.php" target="_top"><input type="submit" value="'.$GLOBALS['LANG']->sL($label,1).'" /></form>';
557                 return $out;
558         }
559
560         /**
561          * Returns logout button.
562          *
563          * @return      string
564          */
565         function adminButtons() {
566                 $functionArray = $this->adminFunctions('');
567
568                 $icons=array();
569                 foreach($functionArray as $fAoptions)   {
570                         $icons[]= '<a href="'.htmlspecialchars($fAoptions['href']).'">'.$fAoptions['icon'].'</a>';
571                 }
572
573                 return implode('',$icons);
574         }
575
576         /**
577          * Returns array with parts from which the admin functions can be constructed.
578          *
579          * @param       string          Backpath.
580          * @return      array
581          */
582         function adminFunctions($backPath)      {
583                 $functions=array();
584
585                         // Clearing of cache-files in typo3conf/ + menu
586                 if ($GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache'])     {
587                         $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_allTypo3Conf');
588                         $functions[]=array(
589                                 'id' => 'temp_CACHED',
590                                 'title' => $title,
591                                 'href' => $backPath .
592                                                 'tce_db.php?vC=' . $GLOBALS['BE_USER']->veriCode() .
593                                                 '&redirect=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')) .
594                                                 '&cacheCmd=temp_CACHED' .
595                                                 t3lib_BEfunc::getUrlToken('tceAction'),
596                                 'icon' => '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_cache_files_in_typo3c.gif','width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
597                         );
598                 }
599
600                         // Clear all page cache
601                 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all');
602                 $functions[]=array(
603                         'id' => 'all',
604                         'title' => $title,
605                         'href' => $backPath . 'tce_db.php?vC=' . $GLOBALS['BE_USER']->veriCode() .
606                                         '&redirect=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')) .
607                                         '&cacheCmd=all' .
608                                         t3lib_BEfunc::getUrlToken('tceAction'),
609                         'icon' => '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_all_cache.gif','width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
610                 );
611
612                         // Return functions
613                 return $functions;
614         }
615
616         /**
617          * Appends a '?' if there is none in the string already
618          *
619          * @param       string          Link URL
620          * @return      string
621          */
622         function wrapLinkWithAB($link)  {
623                 if (!strstr($link,'?')) {
624                         return $link.'?';
625                 } else return $link;
626         }
627
628         /**
629          * Generates some JavaScript code for the frame.
630          *
631          * @return      string  goToModule javascript function
632          */
633         function generateMenuJScode($loadedModules, $menuType = 4)      {
634                 global $TBE_TEMPLATE;
635
636                 $goToModuleSwitch = $this->topMenu($loadedModules, 0, '', $menuType);
637
638                 $jsCode = '
639         /**
640          * Function used to switch switch module.
641          */
642         var currentModuleLoaded = "";
643         function goToModule(modName,cMR_flag,addGetVars)        {       //
644                 var additionalGetVariables = "";
645                 if (addGetVars) additionalGetVariables = addGetVars;
646
647                 var cMR = 0;
648                 if (cMR_flag)   cMR = 1;
649
650                 currentModuleLoaded = modName;
651
652                 switch(modName) {'.$goToModuleSwitch.'
653                 }
654         }';
655
656                 return $jsCode;
657         }
658 }
659
660
661 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc'])) {
662         include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc']);
663 }
664 ?>