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