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