[BUGFIX] BE User Settings cannot be saved by clicking enter
[Packages/TYPO3.CMS.git] / typo3 / sysext / aboutmodules / class.tx_aboutmodules_functions.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 Kasper Skårhøj (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 /**
29 * This class is deprecated and unmaintained. It was once used to render the main
30 * menus of the backend for alt_main.php and friends, but is unused now.
31 *
32 * Class for generation of the module menu.
33 * Will make the vertical, horizontal, selectorbox based menus AND the "about modules" display.
34 * Basically it traverses the module structure and generates output based on that.
35 *
36 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
37 * @package TYPO3
38 * @subpackage core
39 * @deprecated since 4.7, will be removed in 6.1
40 */
41 class tx_aboutmodules_Functions {
42
43 // Internal
44 var $fsMod = array();
45
46 /**
47 * Default constructor throws deprecation warning
48 */
49 public function __construct() {
50 t3lib_div::deprecationLog('class tx_aboutmodules_Functions is deprecated, unused in core since 4.3 and unmaintained. It will be removed in 6.1.');
51 }
52
53 /**
54 * Creates the menu of modules.
55 *
56 * $descr determines the type of menu made:
57 * 0 = Ordinary vertical menu
58 * 1 = Descriptions for 'About modules' display
59 * 2 = selector-box menu
60 * 3 = topmenu - horizontal line of icons!
61 * 4 = part of JavaScript switch contruct for alt_main.php frameset.
62 *
63 * @param array $theModules is the output from load_modules class ($this->loadModules->modules)
64 * @param boolean $dontLink == TRUE will prevent the output from being linked with A-tags (used in the 'beuser' extension)
65 * @param string $backPath must be the 'backPath' to PATH_typo3 from where the menu is displayed.
66 * @param integer $descr determines the type of menu made (see above)
67 * @return string The menu HTML
68 */
69 function topMenu($theModules, $dontLink = 0, $backPath = '', $descr = 0) {
70
71 // By default module sections are collapsable, only if they are explicitly turned off via TSconfig, they are not:
72 $tmpArr = $GLOBALS['BE_USER']->getTSConfig('options.moduleMenuCollapsable');
73 $collapsable = (isset($tmpArr['value']) && $tmpArr['value'] == 0) ? 0 : 1;
74 unset($tmpArr);
75
76 // Initialize vars:
77 $final = '';
78 $menuCode = '';
79 $descrCode = '';
80 $collection = array();
81 $menuCode_sub = '';
82 $selectItems = array();
83 $mIcons = array();
84 $mJScmds = array();
85 $onBlur = $GLOBALS['CLIENT']['FORMSTYLE'] ? 'this.blur();' : '';
86
87 $selectItems[] = '<option value="">[ ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:buttons.selMenu_modules', 1) . ' ]</option>';
88 $mC = 0;
89
90 // Get collapsed configuration
91 if ($collapsable == 1) {
92 $config = is_array($GLOBALS['BE_USER']->uc['moduleData']['alt_menu.php'])
93 ? $GLOBALS['BE_USER']->uc['moduleData']['alt_menu.php'] : array();
94 $collapsedOverride = t3lib_div::_GP('collapsedOverride');
95 if (is_array($collapsedOverride)) {
96 $config = array_merge($config, $collapsedOverride);
97 }
98
99 if (t3lib_div::_GP('collapsableExpandAll') == 1) {
100 $config['expandAll'] = t3lib_div::_GP('expandAll');
101 }
102
103 if ($config['expandAll'] && is_array($collapsedOverride)) {
104 $config = $collapsedOverride;
105 }
106
107 $GLOBALS['BE_USER']->uc['moduleData']['alt_menu.php'] = $config;
108 $GLOBALS['BE_USER']->writeUC($GLOBALS['BE_USER']->uc);
109
110 // all items have to be expanded when expandAll is set
111 if ($config['expandAll'] == 1) {
112 foreach ($config as $key => $value) {
113 if ($key != 'expandAll') {
114 $config[$key] = 0;
115 }
116 }
117 }
118 }
119
120 // Traverse array with modules
121 foreach ($theModules as $moduleName => $moduleInfo) {
122 $mC++;
123
124 $prefix = $this->getNavFramePrefix($moduleInfo);
125 if ($prefix) {
126 $this->fsMod[] = 'fsMod.recentIds["' . $moduleName . '"]="";';
127 }
128
129 // If there are submodules:
130 if (is_array($moduleInfo['sub'])) {
131 // Finding the default module to display
132 if ($moduleInfo['defaultMod']) {
133 $link = $moduleInfo['sub'][$moduleInfo['defaultMod']]['script'];
134 } else {
135 $subTemp = reset($moduleInfo['sub']);
136 $link = $subTemp['script'];
137 }
138 $link_sub = 1; // Tells that the main modules links to a submodule
139 $link = ''; // Does not link to submodules...
140 } else {
141 $link = $moduleInfo['script'];
142 $link_sub = 0;
143 }
144
145 $link = t3lib_div::resolveBackPath($link);
146
147 $moduleKey = $moduleName . '_tab';
148 $moduleCSSId = 'ID_' . t3lib_div::md5int($moduleName);
149
150 $collection[$moduleKey] = array(
151 'moduleName' => $moduleName,
152 'title' => $GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey],
153 'onclick' => 'top.goToModule(\'' . $moduleName . '\');',
154 );
155
156 // Creating image icon
157 $image = @getimagesize($this->mIconFile($GLOBALS['LANG']->moduleLabels['tabs_images'][$moduleKey], $backPath));
158 $imageCode = '';
159 $descr3_title = $GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey] . ' ';
160 if ($image) {
161 $Ifilename = $this->mIconFilename($GLOBALS['LANG']->moduleLabels['tabs_images'][$moduleKey], $backPath);
162 $collection[$moduleKey]['icon'] = array($Ifilename, $image[3]);
163 $imageCode = '<img src="' . $Ifilename . '" ' . $image[3] . ' alt="" />';
164 $descr3_imageCode = '<img src="' . $Ifilename . '" ' . $image[3] . ' title="' . htmlspecialchars($descr3_title) . '" alt="" />';
165 } else {
166 $descr3_imageCode = '<img' . t3lib_iconWorks::skinImg($backPath, 'gfx/dummy_module.gif', 'width="14" height="12"') . ' title="' . htmlspecialchars($descr3_title) . '" alt="" />';
167 }
168
169 // Creating the various links:
170 $label = $GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey];
171 if ($link && $prefix) {
172 $link = $prefix . rawurlencode($link);
173 }
174 if ($link && !$dontLink) {
175 $label = '<a href="#" onclick="top.goToModule(\'' . $moduleName . '\');' . $onBlur . 'return false;">' . $label . '</a>';
176
177 $mIcons[] = '<a href="#" onclick="top.goToModule(\'' . $moduleName . '\');' . $onBlur . 'return false;" class="c-mainitem" id="' . $moduleCSSId . '">' . $descr3_imageCode . '</a>';
178
179 $JScmd = '
180 top.content.location=top.getModuleUrl(top.TS.PATH_typo3+"' . $this->wrapLinkWithAB($link) . '"+additionalGetVariables);
181 top.highlightModuleMenuItem("' . $moduleCSSId . '",1);';
182 $mJScmds[] = "case '" . $moduleName . "': \n " . $JScmd . " \n break;";
183 }
184
185 $selectItems[] = '<option value="top.goToModule(\'' . $moduleName . '\');">' . htmlspecialchars($GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey]) . '</option>';
186 $label = '&nbsp;<strong>' . $label . '</strong>&nbsp;';
187
188 // make menu collapsable
189 if ($collapsable == 1 && is_array($moduleInfo['sub'])) {
190 $collapseJS = 'onclick="window.location.href=\'alt_menu.php?collapsedOverride[' . $moduleName . ']=' . ($config[$moduleName]
191 ? '0' : '1') . '\'"';
192 $collapseIcon = t3lib_iconWorks::getSpriteIcon('actions-view-table-' . ($config[$moduleName] ? 'expand'
193 : 'collapse'), array('class' => 'c-iconCollapse'));
194 } else {
195 $collapseJS = $collapseIcon = '';
196 }
197
198 // Creating a main item for the vertical menu (descr=0)
199 $menuCode .= '
200 <tr class="c-mainitem" id="' . $moduleCSSId . '">
201 <td colspan="3" ' . $collapseJS . ' >' . $imageCode . '<span class="c-label">' . $label . '</span>' . $collapseIcon . '</td>
202 </tr>';
203
204 // Code for "About modules"
205 $descrCode .= '
206 <tr class="c-mainitem">
207 <td colspan="3">' . $imageCode . $label . '</td>
208 </tr>';
209
210 // Hide submodules when collapsed:
211 if ($collapsable == 1 && $config[$moduleName] == 1 && $descr == 0 && $config['expandAll'] != 1) {
212 unset($moduleInfo['sub']);
213 }
214
215 // Traversing submodules
216 $subCode = '';
217 if (is_array($moduleInfo['sub'])) {
218 $collection[$moduleKey]['subitems'] = array();
219 $c = 0;
220 foreach ($moduleInfo['sub'] as $subName => $subInfo) {
221 if ($c == 0) {
222 $subCode .= '
223 <tr class="c-first">
224 <td colspan="3"></td>
225 </tr>';
226 $descrCode .= '
227 <tr class="c-first">
228 <td colspan="3"></td>
229 </tr>';
230 }
231
232 $link = t3lib_div::resolveBackPath($subInfo['script']);
233 $prefix = $this->getNavFramePrefix($moduleInfo, $subInfo);
234
235 $subKey = $moduleName . '_' . $subName . '_tab';
236 $moduleCSSId = 'ID_' . t3lib_div::md5int($moduleName . '_' . $subName);
237
238 $collection[$moduleKey]['subitems'][$subKey] = array(
239 'moduleName' => $moduleName . '_' . $subName,
240 'title' => $GLOBALS['LANG']->moduleLabels['tabs'][$subKey],
241 'onclick' => 'top.goToModule(\'' . $moduleName . '_' . $subName . '\');',
242 );
243
244 // Creating image icon
245 $image = @getimagesize($this->mIconFile($GLOBALS['LANG']->moduleLabels['tabs_images'][$subKey], $backPath));
246 $imageCode = '';
247 $descr3_title = $GLOBALS['LANG']->moduleLabels['tabs'][$subKey] . ': ' . $GLOBALS['LANG']->moduleLabels['labels'][$subKey . 'label'];
248 if ($image) {
249 $Ifilename = $this->mIconFilename($GLOBALS['LANG']->moduleLabels['tabs_images'][$subKey], $backPath);
250 $collection[$moduleKey]['subitems'][$subKey]['icon'] = array($Ifilename, $image[3]);
251 $imageCode = '<img src="' . $Ifilename . '" ' . $image[3] . ' title="' . htmlspecialchars($GLOBALS['LANG']->moduleLabels['labels'][$subKey . 'label']) . '" alt="" />';
252 $descr3_imageCode = '<img src="' . $Ifilename . '" ' . $image[3] . ' title="' . htmlspecialchars($descr3_title) . '" alt="" />';
253 } else {
254 $descr3_imageCode = '<img' . t3lib_iconWorks::skinImg($backPath, 'gfx/dummy_module.gif', 'width="14" height="12"') . ' title="' . htmlspecialchars($descr3_title) . '" alt="" />';
255 }
256
257 // Label for submodule:
258 $label = $GLOBALS['LANG']->moduleLabels['tabs'][$subKey];
259 $label_descr = ' title="' . htmlspecialchars($GLOBALS['LANG']->moduleLabels['labels'][$subKey . 'label']) . '"';
260 $flabel = htmlspecialchars($label);
261 $origLink = $link;
262 if ($link && $prefix) {
263 $link = $prefix . rawurlencode($link);
264 }
265
266 // Setting additional JavaScript if frameset script:
267 $addJS = '';
268 if ($moduleInfo['navFrameScript']) {
269 $addJS = "+'&id='+top.rawurlencodeAndRemoveSiteUrl(top.fsMod.recentIds['" . $moduleName . "'])";
270 }
271
272 // If there is a script to link to (and linking is not disabled.
273 if ($link && !$dontLink) {
274 // For condensed mode, send &cMR parameter to frameset script.
275 if ($addJS && $GLOBALS['BE_USER']->uc['condensedMode']) {
276 $addJS .= "+(cMR?'&cMR=1':'')";
277 }
278
279 // Command for the selector box:
280 $JScmd = '
281 top.content.location=top.getModuleUrl(top.TS.PATH_typo3+"' . $this->wrapLinkWithAB($link) . '"' . $addJS . '+additionalGetVariables);
282 top.fsMod.currentMainLoaded="' . $moduleName . '";
283 ';
284
285 if ($subInfo['navFrameScript']) {
286 $JScmd .= '
287 top.currentSubScript="' . $origLink . '";';
288 }
289
290 // If there is a frameset script in place:
291 if (!$GLOBALS['BE_USER']->uc['condensedMode'] && $moduleInfo['navFrameScript']) {
292
293 // use special nav script from sub module, otherwise from the main module
294 $subNavFrameScript = $subInfo['navFrameScript'] ? $subInfo['navFrameScript']
295 : $moduleInfo['navFrameScript'];
296 $subNavFrameScript = t3lib_div::resolveBackPath($subNavFrameScript);
297
298 // add GET params for sub module to the nav script
299 $subNavFrameScript = $this->wrapLinkWithAB($subNavFrameScript) . $subInfo['navFrameScriptParam'];
300
301 $JScmd = '
302 if (top.content.list_frame && top.fsMod.currentMainLoaded=="' . $moduleName . '") {
303 top.currentSubScript="' . $origLink . '";
304 top.content.list_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"' . $this->wrapLinkWithAB($origLink) . '"' . $addJS . '+additionalGetVariables);
305 if(top.currentSubNavScript!="' . $subNavFrameScript . '") {
306 top.currentSubNavScript="' . $subNavFrameScript . '";
307 top.content.nav_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"' . $subNavFrameScript . '");
308 }
309 } else {
310 top.content.location=top.TS.PATH_typo3+(
311 top.nextLoadModuleUrl?
312 "' . ($prefix ? $this->wrapLinkWithAB($link) . '&exScript=' : '') . 'listframe_loader.php":
313 "' . $this->wrapLinkWithAB($link) . '"' . $addJS . '+additionalGetVariables
314 );
315 top.fsMod.currentMainLoaded="' . $moduleName . '";
316 top.currentSubScript="' . $origLink . '";
317 }
318 ';
319 }
320 $selectItems[] = '<option value="top.goToModule(\'' . $moduleName . '_' . $subName . '\');">' . htmlspecialchars('- ' . $label) . '</option>';
321 $onClickString = htmlspecialchars('top.goToModule(\'' . $moduleName . '_' . $subName . '\');' . $onBlur . 'return false;');
322
323 $flabel = '<a href="#" onclick="' . $onClickString . '"' . $label_descr . '>' . htmlspecialchars($label) . '</a>';
324
325 $mIcons[] = '<a href="#" onclick="' . $onClickString . '"' . $label_descr . ' class="c-subitem" id="' . $moduleCSSId . '">' . $descr3_imageCode . '</a>';
326
327 $JScmd .= '
328 top.highlightModuleMenuItem("' . $moduleCSSId . '");';
329 $mJScmds[] = "case '" . $moduleName . '_' . $subName . "': \n " . $JScmd . " \n break;";
330 }
331
332 $subCode .= '
333 <tr class="c-subitem-row" id="' . $moduleCSSId . '">
334 <td></td>
335 <td align="center">' . (!$GLOBALS['BE_USER']->uc['hideSubmoduleIcons'] ? $imageCode
336 : '') . '</td>
337 <td class="c-subitem-label">' . $flabel . '</td>
338 </tr>';
339
340 // For "About modules":
341 $moduleLabel = htmlspecialchars($GLOBALS['LANG']->moduleLabels['labels'][$subKey . 'label']);
342 $moduleLabelHtml = !empty($moduleLabel) ? '<strong>' . $moduleLabel . '</strong><br />' : '';
343 $moduleDescription = $GLOBALS['LANG']->moduleLabels['labels'][$subKey . 'descr'];
344
345 $descrCode .= '
346 <tr class="c-subitem-row">
347 <td align="center">' . $imageCode . '</td>
348 <td>' . $flabel . '&nbsp;&nbsp;</td>';
349
350 if (!empty($moduleLabel) || !empty($moduleDescription)) {
351 $descrCode .= '
352 <td class="module-description">' . $moduleLabelHtml . $moduleDescription . '</td>';
353 } else {
354 $descrCode .= '
355 <td>&nbsp;</td>';
356 }
357
358 $descrCode .= '
359 </tr>';
360
361 // Possibly adding a divider line
362 $c++;
363 if ($c < count($moduleInfo['sub'])) {
364 // Divider
365 $subCode .= '
366 <tr class="c-divrow">
367 <td colspan="3"><img' . t3lib_iconWorks::skinImg($backPath, 'gfx/altmenuline.gif', 'width="105" height="3"') . ' alt="" /></td>
368 </tr>';
369 }
370 }
371 // Spacer gif for top menu:
372 if (count($theModules) > $mC) {
373 $mIcons[] = '<img src="' . $backPath . 'gfx/acm_spacer2.gif" width="8" height="12" hspace="3" alt="" />';
374 }
375 }
376
377 if (!empty($subCode)) {
378 // Add spacers after each main section:
379 $subCode .= '
380 <tr class="c-endrow">
381 <td colspan="3"></td>
382 </tr>';
383 $descrCode .= '
384 <tr class="c-endrow">
385 <td colspan="3"></td>
386 </tr>';
387
388 // Add sub-code:
389 $menuCode .= $subCode;
390 }
391 }
392 // $descr==0: Ordinary vertical menu
393 if ($menuCode) {
394 if ($collapsable == 1 || $config['expandAll'] == 1) {
395 $collapseAllHTML = '<tr class="c-endrow">
396 <td></td>
397 <td align="center">
398 <form action="alt_menu.php" method="get">
399 <input type="hidden" name="collapsableExpandAll" value="1" />
400 <input type="checkbox" name="expandAll" id="expandall" value="1" onclick="this.form.submit();" ' . ($config['expandAll']
401 ? 'checked="checked"' : '') . ' />
402 </form>
403 </td>
404 <td class="c-subitem-label"><label for="expandall">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.expandAll', 1) . '</label></td>
405 </tr>';
406 } else {
407 $collapseAllHTML = '';
408 }
409
410 $final = '
411
412
413 <!--
414 Vertical module menu, shown in left frame of backend.
415 -->
416 <table border="0" cellpadding="0" cellspacing="0" id="typo3-vmenu">
417 ' . $menuCode . '
418 <tr class="c-endrow">
419 <td colspan="3">' . t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'menu_modules', $GLOBALS['BACK_PATH']) . '</td></tr>
420 ' . $collapseAllHTML . '
421 </table>';
422 }
423
424 // Output for the "About modules" module
425 if ($descr == 1) {
426 $descrCode = '
427
428
429 <!--
430 Listing of modules, for Help > About modules
431 -->
432 <table border="0" cellpadding="0" cellspacing="0" id="typo3-about-modules">
433 ' . $descrCode . '
434 </table>';
435 $final = $descrCode;
436 }
437
438 // selector-box menu
439 if ($descr == 2) {
440
441 // Add admin-functions for clearing caches:
442 if ($GLOBALS['BE_USER']->isAdmin()) {
443 $functionArray = $this->adminFunctions($backPath);
444 if (count($functionArray)) {
445 $selectItems[] = '<option value=""></option>';
446 foreach ($functionArray as $fAoptions) {
447 $selectItems[] = '<option value="' . htmlspecialchars("window.location.href='" . $fAoptions['href'] . "';") . '">[ ' . htmlspecialchars($fAoptions['title']) . ' ]</option>';
448 }
449 }
450 }
451
452 // Logout item:
453 $selectItems[] = '<option value=""></option>';
454 $selectItems[] = '<option value="' . htmlspecialchars("top.location='logout.php';") . '">[ ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:buttons.logout', 1) . ' ]</option>';
455 $final = '
456 <select name="menuselector" onchange="eval(this.options[this.selectedIndex].value);">
457 ' . implode('
458 ', $selectItems) . '
459 </select>';
460 }
461 // topmenu - horizontal line of icons!
462 if ($descr == 3) {
463 $final = '' . implode('', $mIcons) . '';
464 }
465
466 // Output for the goToModules() function in main frameset.
467 if ($descr == 4) {
468 $final = chr(10) . implode(chr(10), $mJScmds) . chr(10);
469 }
470
471 // Output for TOPMENU BAR drop downs (but basically this is an array with which you can do many interesting things...)
472 if ($descr == 5) {
473 $final = $collection;
474 }
475
476 // Return result:
477 return $final;
478 }
479
480 /**
481 * Returns a prefix used to call the navframe with parameters to call the scripts defined in the modules info array.
482 *
483 * @param string Module info array
484 * @param string Submodule info array
485 * @return string Result url string
486 */
487 function getNavFramePrefix($moduleInfo, $subModuleInfo = array()) {
488 $prefix = '';
489 $navFrameScript = $subModuleInfo['navFrameScript'] ? $subModuleInfo['navFrameScript']
490 : $moduleInfo['navFrameScript'];
491 $navFrameScriptParam = isset($subModuleInfo['navFrameScriptParam']) ? $subModuleInfo['navFrameScriptParam']
492 : $moduleInfo['navFrameScriptParam'];
493 if ($navFrameScript) {
494 $navFrameScript = t3lib_div::resolveBackPath($navFrameScript);
495 $navFrameScript = $this->wrapLinkWithAB($navFrameScript);
496
497 if ($GLOBALS['BE_USER']->uc['condensedMode']) {
498 $prefix = $navFrameScript . $navFrameScriptParam . '&currentSubScript=';
499 } else {
500 $prefix = 'alt_mod_frameset.php?' .
501 'fW="+top.TS.navFrameWidth+"' .
502 '&nav="+top.TS.PATH_typo3+"' . rawurlencode($navFrameScript . $navFrameScriptParam) .
503 '&script=';
504 }
505 }
506 return $prefix;
507 }
508
509 /**
510 * Returns $Ifilename readable for script in PATH_typo3.
511 * That means absolute names are just returned while relative names are prepended with $backPath (pointing back to typo3/ dir)
512 *
513 * @param string Icon filename
514 * @param string Back path
515 * @return string Result
516 * @see mIconFilename()
517 */
518 function mIconFile($Ifilename, $backPath) {
519 if (t3lib_div::isAbsPath($Ifilename)) {
520 return $Ifilename;
521 }
522 return $backPath . $Ifilename;
523 }
524
525 /**
526 * Returns relative filename to the $Ifilename (for use in img-tags)
527 *
528 * @param string Icon filename
529 * @param string Back path
530 * @return string Result
531 * @see mIconFile()
532 */
533 function mIconFilename($Ifilename, $backPath) {
534 if (t3lib_div::isAbsPath($Ifilename)) {
535 $Ifilename = '../' . substr($Ifilename, strlen(PATH_site));
536 }
537 return $backPath . $Ifilename;
538 }
539
540 /**
541 * Returns logout button.
542 *
543 * @return string
544 */
545 function topButtons() {
546 $label = $GLOBALS['BE_USER']->user['ses_backuserid'] ? 'LLL:EXT:lang/locallang_core.php:buttons.exit'
547 : 'LLL:EXT:lang/locallang_core.php:buttons.logout';
548 $out = '<form action="logout.php" target="_top"><input type="submit" value="' . $GLOBALS['LANG']->sL($label, 1) . '" /></form>';
549 return $out;
550 }
551
552 /**
553 * Returns logout button.
554 *
555 * @return string
556 */
557 function adminButtons() {
558 $functionArray = $this->adminFunctions('');
559
560 $icons = array();
561 foreach ($functionArray as $fAoptions) {
562 $icons[] = '<a href="' . htmlspecialchars($fAoptions['href']) . '">' . $fAoptions['icon'] . '</a>';
563 }
564
565 return implode('', $icons);
566 }
567
568 /**
569 * Returns array with parts from which the admin functions can be constructed.
570 *
571 * @param string Backpath.
572 * @return array
573 */
574 function adminFunctions($backPath) {
575 $functions = array();
576
577 // Clearing of cache-files in typo3conf/ + menu
578 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_allTypo3Conf');
579 $functions[] = array(
580 'id' => 'temp_CACHED',
581 'title' => $title,
582 'href' => $backPath .
583 'tce_db.php?vC=' . $GLOBALS['BE_USER']->veriCode() .
584 '&redirect=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')) .
585 '&cacheCmd=temp_CACHED' .
586 t3lib_BEfunc::getUrlToken('tceAction'),
587 'icon' => '<img' . t3lib_iconWorks::skinImg($backPath, 'gfx/clear_cache_files_in_typo3c.gif', 'width="21" height="18"') . ' title="' . htmlspecialchars($title) . '" alt="" />'
588 );
589
590 // Clear all page cache
591 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all');
592 $functions[] = array(
593 'id' => 'all',
594 'title' => $title,
595 'href' => $backPath . 'tce_db.php?vC=' . $GLOBALS['BE_USER']->veriCode() .
596 '&redirect=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')) .
597 '&cacheCmd=all' .
598 t3lib_BEfunc::getUrlToken('tceAction'),
599 'icon' => '<img' . t3lib_iconWorks::skinImg($backPath, 'gfx/clear_all_cache.gif', 'width="21" height="18"') . ' title="' . htmlspecialchars($title) . '" alt="" />'
600 );
601
602 // Return functions
603 return $functions;
604 }
605
606 /**
607 * Appends a '?' if there is none in the string already
608 *
609 * @param string Link URL
610 * @return string
611 */
612 function wrapLinkWithAB($link) {
613 if (!strstr($link, '?')) {
614 return $link . '?';
615 } else {
616 return $link;
617 }
618 }
619
620 /**
621 * Generates some JavaScript code for the frame.
622 *
623 * @return string goToModule javascript function
624 */
625 function generateMenuJScode($loadedModules, $menuType = 4) {
626 $goToModuleSwitch = $this->topMenu($loadedModules, 0, '', $menuType);
627
628 $jsCode = '
629 /**
630 * Function used to switch switch module.
631 */
632 var currentModuleLoaded = "";
633 function goToModule(modName,cMR_flag,addGetVars) { //
634 var additionalGetVariables = "";
635 if (addGetVars) additionalGetVariables = addGetVars;
636
637 var cMR = 0;
638 if (cMR_flag) cMR = 1;
639
640 currentModuleLoaded = modName;
641
642 switch(modName) {' . $goToModuleSwitch . '
643 }
644 }';
645
646 return $jsCode;
647 }
648 }
649 ?>