* Merging all changes from TYPO3_4-0 branch back into HEAD
[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 = ($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 ($subInfo['navFrameScript']) {
294                                                         $JScmd.='
295                                                                 top.currentSubScript="'.$origLink.'";';
296                                                 }
297
298                                                         // If there is a frameset script in place:
299                                                 if (!$BE_USER->uc['condensedMode'] && $moduleInfo['navFrameScript'])    {
300
301                                                                 // use special nav script from sub module, otherwise from the main module
302                                                         $subNavFrameScript = $subInfo['navFrameScript'] ? $subInfo['navFrameScript'] : $moduleInfo['navFrameScript'];
303                                                         $subNavFrameScript = t3lib_div::resolveBackPath($subNavFrameScript);
304
305                                                                 // add GET params for sub module to the nav script
306                                                         $subNavFrameScript = $this->wrapLinkWithAB($subNavFrameScript).$subInfo['navFrameScriptParam'];
307
308                                                         $JScmd = '
309                                                                 if (top.content.list_frame && top.fsMod.currentMainLoaded=="'.$moduleName.'") {
310                                                                         top.currentSubScript="'.$origLink.'";
311                                                                         top.content.list_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$this->wrapLinkWithAB($origLink).'"'.$addJS.'+additionalGetVariables);
312                                                                         if(top.currentSubNavScript!="'.$subNavFrameScript.'") {
313                                                                                 top.currentSubNavScript="'.$subNavFrameScript.'";
314                                                                                 top.content.nav_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$subNavFrameScript.'");
315                                                                         }
316                                                                 } else {
317                                                                         top.content.location=top.TS.PATH_typo3+(
318                                                                                 top.nextLoadModuleUrl?
319                                                                                 "'.($prefix?$this->wrapLinkWithAB($link).'&exScript=':'').'listframe_loader.php":
320                                                                                 "'.$this->wrapLinkWithAB($link).'"'.$addJS.'+additionalGetVariables
321                                                                         );
322                                                                         top.fsMod.currentMainLoaded="'.$moduleName.'";
323                                                                         top.currentSubScript="'.$origLink.'";
324                                                                 }
325                                                                 ';
326                                                 }
327                                                 $selectItems[] = '<option value="top.goToModule(\''.$moduleName.'_'.$subName.'\');">'.htmlspecialchars('- '.$label).'</option>';
328                                                 $onClickString = htmlspecialchars('top.goToModule(\''.$moduleName.'_'.$subName.'\');'.$onBlur.'return false;');
329
330                                                 $flabel = '<a href="#" onclick="'.$onClickString.'"'.$label_descr.'>'.htmlspecialchars($label).'</a>';
331
332                                                 $mIcons[] = '<a href="#" onclick="'.$onClickString.'"'.$label_descr.' class="c-subitem" id="'.$moduleCSSId.'">'.$descr3_imageCode.'</a>';
333
334                                                 $JScmd.= '
335                                                                 top.highlightModuleMenuItem("'.$moduleCSSId.'");';
336                                                 $mJScmds[] = "case '".$moduleName.'_'.$subName."': \n ".$JScmd." \n break;";
337                                         }
338
339                                         $subCode.='
340                                                         <tr class="c-subitem-row" id="'.$moduleCSSId.'">
341                                                                 <td></td>
342                                                                 <td align="center">'.(!$BE_USER->uc['hideSubmoduleIcons']?$imageCode:'').'</td>
343                                                                 <td class="c-subitem-label">'.$flabel.'</td>
344                                                         </tr>';
345
346                                                 // For "About modules":
347                                         $descrCode.='
348                                                         <tr class="c-subitem-row">
349                                                                 <td align="center">'.$imageCode.'</td>
350                                                                 <td>'.$flabel.'&nbsp;&nbsp;</td>
351                                                                 <td><strong>'.htmlspecialchars($LANG->moduleLabels['labels'][$subKey.'label']).'</strong><br />'.$LANG->moduleLabels['labels'][$subKey.'descr'].'</td>
352                                                         </tr>';
353
354                                                 // Possibly adding a divider line
355                                         $c++;
356                                         if ($c<count($moduleInfo['sub']))       {
357                                                         // Divider
358                                                 $subCode.='
359                                                         <tr class="c-divrow">
360                                                                 <td colspan="3"><img'.t3lib_iconWorks::skinImg($backPath,'gfx/altmenuline.gif','width="105" height="3"').' alt="" /></td>
361                                                         </tr>';
362                                         }
363                                 }
364                                         // Spacer gif for top menu:
365                                 if (count($theModules)>$mC)     {
366                                         $mIcons[]='<img src="'.$backPath.'gfx/acm_spacer2.gif" width="8" height="12" hspace="3" alt="" />';
367                                 }
368                         }
369
370                                 // Add spacers after each main section:
371                         $subCode.='
372                                         <tr class="c-endrow">
373                                                 <td colspan="3"></td>
374                                         </tr>';
375                         $descrCode.='
376                                         <tr class="c-endrow">
377                                                 <td colspan="3"></td>
378                                         </tr>';
379
380                                 // Add sub-code:
381                         $menuCode.=$subCode;
382                 }
383
384                         // $descr==0:   Ordinary vertical menu
385                 if ($menuCode)  {
386                         if($collapsable == 1 || $config['expandAll'] == 1) {
387                                 $collapseAllHTML = '<tr class="c-endrow">
388                                                 <td></td>
389                                                 <td align="center">
390                                                                 <form action="alt_menu.php" method="get">
391                                                                         <input type="hidden" name="collapsableExpandAll" value="1" />
392                                                                         <input type="checkbox" name="expandAll" id="expandall" value="1" onclick="this.form.submit();" '.($config['expandAll']?'checked="checked"':'').' />
393                                                                 </form>
394                                                 </td>
395                                                 <td class="c-subitem-label"><label for="expandall">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.expandAll',1).'</label></td>
396                                         </tr>';
397                         } else {
398                                 $collapseAllHTML = '';
399                         }
400
401                         $final = '
402
403
404                                 <!--
405                                         Vertical module menu, shown in left frame of backend.
406                                 -->
407                                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-vmenu">
408                                         '.$menuCode.'
409                                         <tr class="c-endrow">
410                                                 <td colspan="3">'.t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'menu_modules', $GLOBALS['BACK_PATH']).'</td></tr>
411                                         '.$collapseAllHTML.'
412                                 </table>';
413                 }
414
415                         // Output for the "About modules" module
416                 if ($descr==1)  {
417                         $descrCode = '
418
419
420                                 <!--
421                                         Listing of modules, for Help > About modules
422                                 -->
423                                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-about-modules">
424                                         '.$descrCode.'
425                                 </table>';
426                         $final = $descrCode;
427                 }
428
429                         // selector-box menu
430                 if ($descr==2)  {
431
432                                 // Add admin-functions for clearing caches:
433                         if ($BE_USER->isAdmin())        {
434                                 $functionArray = $this->adminFunctions($backPath);
435                                 if (count($functionArray))      {
436                                         $selectItems[] = '<option value=""></option>';
437                                         foreach($functionArray as $fAoptions)   {
438                                                 $selectItems[] = '<option value="'.htmlspecialchars("window.location.href='".$fAoptions['href']."';").'">[ '.htmlspecialchars($fAoptions['title']).' ]</option>';
439                                         }
440                                 }
441                         }
442
443                                 // Logout item:
444                         $selectItems[] = '<option value=""></option>';
445                         $selectItems[] = '<option value="'.htmlspecialchars("top.location='logout.php';").'">[ '.$LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.logout',1).' ]</option>';
446                         $final = '
447                                 <select name="menuselector" onchange="eval(this.options[this.selectedIndex].value);">
448                                         '.implode('
449                                         ',$selectItems).'
450                                 </select>';
451                 }
452                         // topmenu - horizontal line of icons!
453                 if ($descr==3)  {
454                         $final = ''.implode('',$mIcons).'';
455                 }
456
457                         // Output for the goToModules() function in main frameset.
458                 if ($descr==4)  {
459                         $final = chr(10).implode(chr(10),$mJScmds).chr(10);
460                 }
461
462                         // Return result:
463                 return $final;
464         }
465
466         /**
467          * Returns a prefix used to call the navframe with parameters to call the scripts defined in the modules info array.
468          *
469          * @param       string          Module info array
470          * @param       string          Submodule info array
471          * @return      string          Result url string
472          */
473         function getNavFramePrefix($moduleInfo, $subModuleInfo=array()) {
474                 global $BE_USER;
475
476                 $prefix = '';
477                 $navFrameScript = $subModuleInfo['navFrameScript'] ? $subModuleInfo['navFrameScript'] : $moduleInfo['navFrameScript'];
478                 $navFrameScriptParam = isset($subModuleInfo['navFrameScriptParam']) ? $subModuleInfo['navFrameScriptParam'] : $moduleInfo['navFrameScriptParam'];
479                 if ($navFrameScript)    {
480                         $navFrameScript = t3lib_div::resolveBackPath($navFrameScript);
481                         $navFrameScript = $this->wrapLinkWithAB($navFrameScript);
482
483                         if ($BE_USER->uc['condensedMode'])      {
484                                 $prefix=$navFrameScript.$navFrameScriptParam.'&currentSubScript=';
485                         } else {
486                                 $prefix='alt_mod_frameset.php?'.
487                                         'fW="+top.TS.navFrameWidth+"'.
488                                         '&nav="+top.TS.PATH_typo3+"'.rawurlencode($navFrameScript.$navFrameScriptParam).
489                                         '&script=';
490                         }
491                 }
492                 return $prefix;
493         }
494
495         /**
496          * Returns $Ifilename readable for script in PATH_typo3.
497          * That means absolute names are just returned while relative names are prepended with $backPath (pointing back to typo3/ dir)
498          *
499          * @param       string          Icon filename
500          * @param       string          Back path
501          * @return      string          Result
502          * @see mIconFilename()
503          */
504         function mIconFile($Ifilename,$backPath)        {
505                 if (t3lib_div::isAbsPath($Ifilename))   {
506                         return $Ifilename;
507                 }
508                 return $backPath.$Ifilename;
509         }
510
511         /**
512          * Returns relative filename to the $Ifilename (for use in img-tags)
513          *
514          * @param       string          Icon filename
515          * @param       string          Back path
516          * @return      string          Result
517          * @see mIconFile()
518          */
519         function mIconFilename($Ifilename,$backPath)    {
520                 if (t3lib_div::isAbsPath($Ifilename))   {
521                         $Ifilename = '../'.substr($Ifilename,strlen(PATH_site));
522                 }
523                 return $backPath.$Ifilename;
524         }
525
526         /**
527          * Returns logout button.
528          *
529          * @return      string
530          */
531         function topButtons()   {
532                 global $LANG;
533
534                 $label = $GLOBALS['BE_USER']->user['ses_backuserid'] ? 'LLL:EXT:lang/locallang_core.php:buttons.exit' : 'LLL:EXT:lang/locallang_core.php:buttons.logout';
535                 $out.= '<form action="logout.php" target="_top"><input type="submit" value="'.$LANG->sL($label,1).'" /></form>';
536                 return $out;
537         }
538
539         /**
540          * Returns logout button.
541          *
542          * @return      string
543          */
544         function adminButtons() {
545                 global $LANG;
546
547                 $functionArray = $this->adminFunctions('');
548
549                 $icons=array();
550                 foreach($functionArray as $fAoptions)   {
551                         $icons[]= '<a href="'.htmlspecialchars($fAoptions['href']).'">'.$fAoptions['icon'].'</a>';
552                 }
553
554                 return implode('',$icons);
555         }
556
557         /**
558          * Returns array with parts from which the admin functions can be constructed.
559          *
560          * @param       string          Backpath.
561          * @return      array
562          */
563         function adminFunctions($backPath)      {
564                 global $LANG,$BE_USER,$TYPO3_CONF_VARS;
565
566                 $functions=array();
567
568                         // Clearing of cache-files in typo3conf/ + menu
569                 if ($TYPO3_CONF_VARS['EXT']['extCache'])        {
570                         $title = $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_allTypo3Conf');
571                         $functions[]=array(
572                                 'title' => $title,
573                                 'href' => $backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')).'&cacheCmd=temp_CACHED',
574                                 'icon' => '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_cache_files_in_typo3c.gif','width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
575                         );
576                 }
577
578                         // Clear all page cache
579                 $title = $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all');
580                 $functions[]=array(
581                         'title' => $title,
582                         'href' => $backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')).'&cacheCmd=all',
583                         'icon' => '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_all_cache.gif','width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
584                 );
585
586                         // Return functions
587                 return $functions;
588         }
589
590         /**
591          * Appends a '?' if there is none in the string already
592          *
593          * @param       string          Link URL
594          * @return      string
595          */
596         function wrapLinkWithAB($link)  {
597                 if (!strstr($link,'?')) {
598                         return $link.'?';
599                 } else return $link;
600         }
601 }
602
603
604 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc'])      {
605         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc']);
606 }
607 ?>