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