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