Added the media field for page type "Shortcut" as well
[Packages/TYPO3.CMS.git] / typo3 / class.alt_menu_functions.inc
1 <?php
2 /***************************************************************
3 *  Copyright notice
4 *
5 *  (c) 1999-2005 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.rawurlencode(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                                         $descrCode.='
359                                                         <tr class="c-subitem-row">
360                                                                 <td align="center">'.$imageCode.'</td>
361                                                                 <td>'.$flabel.'&nbsp;&nbsp;</td>
362                                                                 <td><strong>'.htmlspecialchars($LANG->moduleLabels['labels'][$subKey.'label']).'</strong><br />'.$LANG->moduleLabels['labels'][$subKey.'descr'].'</td>
363                                                         </tr>';
364
365                                                 // Possibly adding a divider line
366                                         $c++;
367                                         if ($c<count($moduleInfo['sub']))       {
368                                                         // Divider
369                                                 $subCode.='
370                                                         <tr class="c-divrow">
371                                                                 <td colspan="3"><img'.t3lib_iconWorks::skinImg($backPath,'gfx/altmenuline.gif','width="105" height="3"').' alt="" /></td>
372                                                         </tr>';
373                                         }
374                                 }
375                                         // Spacer gif for top menu:
376                                 if (count($theModules)>$mC)     {
377                                         $mIcons[]='<img src="'.$backPath.'gfx/acm_spacer2.gif" width="8" height="12" hspace="3" alt="" />';
378                                 }
379                         }
380
381                                 // Add spacers after each main section:
382                         $subCode.='
383                                         <tr class="c-endrow">
384                                                 <td colspan="3"></td>
385                                         </tr>';
386                         $descrCode.='
387                                         <tr class="c-endrow">
388                                                 <td colspan="3"></td>
389                                         </tr>';
390
391                                 // Add sub-code:
392                         $menuCode.=$subCode;
393                 }
394
395                         // $descr==0:   Ordinary vertical menu
396                 if ($menuCode)  {
397                         if($collapsable == 1 || $config['expandAll'] == 1) {
398                                 $collapseAllHTML = '<tr class="c-endrow">
399                                                 <td></td>
400                                                 <td align="center">
401                                                                 <form action="alt_menu.php" method="get">
402                                                                         <input type="hidden" name="collapsableExpandAll" value="1" />
403                                                                         <input type="checkbox" name="expandAll" id="expandall" value="1" onclick="this.form.submit();" '.($config['expandAll']?'checked="checked"':'').' />
404                                                                 </form>
405                                                 </td>
406                                                 <td class="c-subitem-label"><label for="expandall">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.expandAll',1).'</label></td>
407                                         </tr>';
408                         } else {
409                                 $collapseAllHTML = '';
410                         }
411
412                         $final = '
413
414
415                                 <!--
416                                         Vertical module menu, shown in left frame of backend.
417                                 -->
418                                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-vmenu">
419                                         '.$menuCode.'
420                                         <tr class="c-endrow">
421                                                 <td colspan="3">'.t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'menu_modules', $GLOBALS['BACK_PATH']).'</td></tr>
422                                         '.$collapseAllHTML.'
423                                 </table>';
424                 }
425
426                         // Output for the "About modules" module
427                 if ($descr==1)  {
428                         $descrCode = '
429
430
431                                 <!--
432                                         Listing of modules, for Help > About modules
433                                 -->
434                                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-about-modules">
435                                         '.$descrCode.'
436                                 </table>';
437                         $final = $descrCode;
438                 }
439
440                         // selector-box menu
441                 if ($descr==2)  {
442
443                                 // Add admin-functions for clearing caches:
444                         if ($BE_USER->isAdmin())        {
445                                 $functionArray = $this->adminFunctions($backPath);
446                                 if (count($functionArray))      {
447                                         $selectItems[] = '<option value=""></option>';
448                                         foreach($functionArray as $fAoptions)   {
449                                                 $selectItems[] = '<option value="'.htmlspecialchars("window.location.href='".$fAoptions['href']."';").'">[ '.htmlspecialchars($fAoptions['title']).' ]</option>';
450                                         }
451                                 }
452                         }
453
454                                 // Logout item:
455                         $selectItems[] = '<option value=""></option>';
456                         $selectItems[] = '<option value="'.htmlspecialchars("top.location='logout.php';").'">[ '.$LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.logout',1).' ]</option>';
457                         $final = '
458                                 <select name="menuselector" onchange="eval(this.options[this.selectedIndex].value);">
459                                         '.implode('
460                                         ',$selectItems).'
461                                 </select>';
462                 }
463                         // topmenu - horizontal line of icons!
464                 if ($descr==3)  {
465                         $final = ''.implode('',$mIcons).'';
466                 }
467
468                         // Output for the goToModules() function in main frameset.
469                 if ($descr==4)  {
470                         $final = chr(10).implode(chr(10),$mJScmds).chr(10);
471                 }
472
473                         // Output for TOPMENU BAR drop downs (but basically this is an array with which you can do many interesting things...)
474                 if ($descr==5)  {
475                         $final = $collection;
476                 }
477
478                         // Return result:
479                 return $final;
480         }
481
482         /**
483          * Returns a prefix used to call the navframe with parameters to call the scripts defined in the modules info array.
484          *
485          * @param       string          Module info array
486          * @param       string          Submodule info array
487          * @return      string          Result url string
488          */
489         function getNavFramePrefix($moduleInfo, $subModuleInfo=array()) {
490                 global $BE_USER;
491
492                 $prefix = '';
493                 $navFrameScript = $subModuleInfo['navFrameScript'] ? $subModuleInfo['navFrameScript'] : $moduleInfo['navFrameScript'];
494                 $navFrameScriptParam = isset($subModuleInfo['navFrameScriptParam']) ? $subModuleInfo['navFrameScriptParam'] : $moduleInfo['navFrameScriptParam'];
495                 if ($navFrameScript)    {
496                         $navFrameScript = t3lib_div::resolveBackPath($navFrameScript);
497                         $navFrameScript = $this->wrapLinkWithAB($navFrameScript);
498
499                         if ($BE_USER->uc['condensedMode'])      {
500                                 $prefix=$navFrameScript.$navFrameScriptParam.'&currentSubScript=';
501                         } else {
502                                 $prefix='alt_mod_frameset.php?'.
503                                         'fW="+top.TS.navFrameWidth+"'.
504                                         '&nav="+top.TS.PATH_typo3+"'.rawurlencode($navFrameScript.$navFrameScriptParam).
505                                         '&script=';
506                         }
507                 }
508                 return $prefix;
509         }
510
511         /**
512          * Returns $Ifilename readable for script in PATH_typo3.
513          * That means absolute names are just returned while relative names are prepended with $backPath (pointing back to typo3/ dir)
514          *
515          * @param       string          Icon filename
516          * @param       string          Back path
517          * @return      string          Result
518          * @see mIconFilename()
519          */
520         function mIconFile($Ifilename,$backPath)        {
521                 if (t3lib_div::isAbsPath($Ifilename))   {
522                         return $Ifilename;
523                 }
524                 return $backPath.$Ifilename;
525         }
526
527         /**
528          * Returns relative filename to the $Ifilename (for use in img-tags)
529          *
530          * @param       string          Icon filename
531          * @param       string          Back path
532          * @return      string          Result
533          * @see mIconFile()
534          */
535         function mIconFilename($Ifilename,$backPath)    {
536                 if (t3lib_div::isAbsPath($Ifilename))   {
537                         $Ifilename = '../'.substr($Ifilename,strlen(PATH_site));
538                 }
539                 return $backPath.$Ifilename;
540         }
541
542         /**
543          * Returns logout button.
544          *
545          * @return      string
546          */
547         function topButtons()   {
548                 global $LANG;
549
550                 $label = $GLOBALS['BE_USER']->user['ses_backuserid'] ? 'LLL:EXT:lang/locallang_core.php:buttons.exit' : 'LLL:EXT:lang/locallang_core.php:buttons.logout';
551                 $out.= '<form action="logout.php" target="_top"><input type="submit" value="'.$LANG->sL($label,1).'" /></form>';
552                 return $out;
553         }
554
555         /**
556          * Returns logout button.
557          *
558          * @return      string
559          */
560         function adminButtons() {
561                 global $LANG;
562
563                 $functionArray = $this->adminFunctions('');
564
565                 $icons=array();
566                 foreach($functionArray as $fAoptions)   {
567                         $icons[]= '<a href="'.htmlspecialchars($fAoptions['href']).'">'.$fAoptions['icon'].'</a>';
568                 }
569
570                 return implode('',$icons);
571         }
572
573         /**
574          * Returns array with parts from which the admin functions can be constructed.
575          *
576          * @param       string          Backpath.
577          * @return      array
578          */
579         function adminFunctions($backPath)      {
580                 global $LANG,$BE_USER,$TYPO3_CONF_VARS;
581
582                 $functions=array();
583
584                         // Clearing of cache-files in typo3conf/ + menu
585                 if ($TYPO3_CONF_VARS['EXT']['extCache'])        {
586                         $title = $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_allTypo3Conf');
587                         $functions[]=array(
588                                 'id' => 'temp_CACHED',
589                                 'title' => $title,
590                                 'href' => $backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')).'&cacheCmd=temp_CACHED',
591                                 'icon' => '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_cache_files_in_typo3c.gif','width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
592                         );
593                 }
594
595                         // Clear all page cache
596                 $title = $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all');
597                 $functions[]=array(
598                         'id' => 'all',
599                         'title' => $title,
600                         'href' => $backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')).'&cacheCmd=all',
601                         'icon' => '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_all_cache.gif','width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
602                 );
603
604                         // Return functions
605                 return $functions;
606         }
607
608         /**
609          * Appends a '?' if there is none in the string already
610          *
611          * @param       string          Link URL
612          * @return      string
613          */
614         function wrapLinkWithAB($link)  {
615                 if (!strstr($link,'?')) {
616                         return $link.'?';
617                 } else return $link;
618         }
619         
620         /**
621          * Generates some JavaScript code for the frame.
622          *
623          * @return      string  goToModule javascript function
624          */
625         function generateMenuJScode($loadedModules, $menuType = 4)      {
626                 global $TBE_TEMPLATE;
627                 
628                 $goToModuleSwitch = $this->topMenu($loadedModules, 0, '', $menuType);
629
630                 $jsCode = '
631         /**
632          * Function used to switch switch module.
633          */
634         var currentModuleLoaded = "";
635         function goToModule(modName,cMR_flag,addGetVars)        {       //
636                 var additionalGetVariables = "";
637                 if (addGetVars) additionalGetVariables = addGetVars;
638
639                 var cMR = 0;
640                 if (cMR_flag)   cMR = 1;
641
642                 currentModuleLoaded = modName;
643
644                 switch(modName) {'.$goToModuleSwitch.'
645                 }
646         }';
647                 
648                 return $jsCode;
649         }
650 }
651
652
653 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc'])      {
654         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc']);
655 }
656 ?>