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