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