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