[BUGFIX] FormEngine: Inline getDynamicTabMenu
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Template / ModuleTemplate.php
1 <?php
2 namespace TYPO3\CMS\Backend\Template;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
20 use TYPO3\CMS\Core\Imaging\Icon;
21 use TYPO3\CMS\Core\Imaging\IconFactory;
22 use TYPO3\CMS\Core\Page\PageRenderer;
23 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
24 use TYPO3\CMS\Core\Utility\GeneralUtility;
25 use TYPO3\CMS\Fluid\View\Exception\InvalidTemplateResourceException;
26 use TYPO3\CMS\Fluid\View\StandaloneView;
27 use TYPO3\CMS\Lang\LanguageService;
28 use TYPO3\CMS\Version\View\VersionView;
29
30 /**
31 * A class taking care of the "outer" HTML of a module, especially
32 * the doc header and other related parts.
33 *
34 * @internal This API is not yet carved in stone and may be adapted later.
35 */
36 class ModuleTemplate
37 {
38 /**
39 * Error Icon Constant
40 *
41 * @internal
42 */
43 const STATUS_ICON_ERROR = 3;
44
45 /**
46 * Warning Icon Constant
47 *
48 * @internal
49 */
50 const STATUS_ICON_WARNING = 2;
51
52 /**
53 * Notification Icon Constant
54 *
55 * @internal
56 */
57 const STATUS_ICON_NOTIFICATION = 1;
58
59 /**
60 * OK Icon Constant
61 *
62 * @internal
63 */
64 const STATUS_ICON_OK = -1;
65
66 /**
67 * DocHeaderComponent
68 *
69 * @var DocHeaderComponent
70 */
71 protected $docHeaderComponent;
72
73 /**
74 * Javascript Code Array
75 * Used for inline JS
76 *
77 * @var array
78 */
79 protected $javascriptCodeArray = [];
80
81 /**
82 * Expose the pageRenderer
83 *
84 * @var PageRenderer
85 */
86 protected $pageRenderer;
87
88 /**
89 * TemplateRootPath
90 *
91 * @var string[]
92 */
93 protected $templateRootPaths = ['EXT:backend/Resources/Private/Templates'];
94
95 /**
96 * PartialRootPath
97 *
98 * @var string[]
99 */
100 protected $partialRootPaths = ['EXT:backend/Resources/Private/Partials'];
101
102 /**
103 * LayoutRootPath
104 *
105 * @var string[]
106 */
107 protected $layoutRootPaths = ['EXT:backend/Resources/Private/Layouts'];
108
109 /**
110 * Template name
111 *
112 * @var string
113 */
114 protected $templateFile = 'Module.html';
115
116 /**
117 * Fluid Standalone View
118 *
119 * @var StandaloneView
120 */
121 protected $view;
122
123 /**
124 * Content String
125 *
126 * @var string
127 */
128 protected $content = '';
129
130 /**
131 * Defines whether a section has been opened before
132 *
133 * @var int
134 */
135 protected $sectionFlag = 0;
136
137 /**
138 * IconFactory Member
139 *
140 * @var IconFactory
141 */
142 protected $iconFactory;
143
144 /**
145 * Module ID
146 *
147 * @var string
148 */
149 protected $moduleId = '';
150
151 /**
152 * Module Name
153 *
154 * @var string
155 */
156 protected $moduleName = '';
157
158 /**
159 * Title Tag
160 *
161 * @var string
162 */
163 protected $title = '';
164
165 /**
166 * Gets the standalone view.
167 *
168 * @return StandaloneView
169 */
170 public function getView()
171 {
172 return $this->view;
173 }
174
175 /**
176 * Set content
177 *
178 * @param string $content Content of the module
179 * @return void
180 */
181 public function setContent($content)
182 {
183 $this->view->assign('content', $content);
184 }
185
186 /**
187 * Set title tag
188 *
189 * @param string $title
190 */
191 public function setTitle($title)
192 {
193 $this->title = $title;
194 }
195
196 /**
197 * Returns the IconFactory
198 *
199 * @return IconFactory
200 */
201 public function getIconFactory()
202 {
203 return $this->iconFactory;
204 }
205
206 /**
207 * Class constructor
208 * Sets up view and property objects
209 *
210 * @throws InvalidTemplateResourceException In case a template is invalid
211 */
212 public function __construct()
213 {
214 $this->view = GeneralUtility::makeInstance(StandaloneView::class);
215 $this->view->setPartialRootPaths($this->partialRootPaths);
216 $this->view->setTemplateRootPaths($this->templateRootPaths);
217 $this->view->setLayoutRootPaths($this->layoutRootPaths);
218 $this->view->setTemplate($this->templateFile);
219 $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
220 $this->docHeaderComponent = GeneralUtility::makeInstance(DocHeaderComponent::class);
221 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
222 }
223
224 /**
225 * Loads all necessary Javascript Files
226 *
227 * @return void
228 */
229 protected function loadJavaScripts()
230 {
231 $this->pageRenderer->loadJquery();
232 $this->pageRenderer->loadRequireJsModule('bootstrap');
233 $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ContextHelp');
234 $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DocumentHeader');
235 $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/SplitButtons');
236 }
237
238 /**
239 * Loads all necessary stylesheets
240 *
241 * @return void
242 */
243 protected function loadStylesheets()
244 {
245 if ($GLOBALS['TBE_STYLES']['stylesheet']) {
246 $this->pageRenderer->addCssFile($GLOBALS['TBE_STYLES']['stylesheet']);
247 }
248 if ($GLOBALS['TBE_STYLES']['stylesheet2']) {
249 $this->pageRenderer->addCssFile($GLOBALS['TBE_STYLES']['stylesheet2']);
250 }
251 }
252
253 /**
254 * Sets mandatory parameters for the view (pageRenderer)
255 *
256 * @return void
257 */
258 protected function setupPage()
259 {
260 // Yes, hardcoded on purpose
261 $this->pageRenderer->setXmlPrologAndDocType('<!DOCTYPE html>');
262 $this->pageRenderer->setCharSet('utf-8');
263 $this->pageRenderer->setLanguage('default');
264 $this->pageRenderer->addMetaTag('<meta name="viewport" content="width=device-width, initial-scale=1">');
265 }
266
267 /**
268 * Wrapper function for adding JS inline blocks
269 *
270 * @return void
271 */
272 protected function setJavaScriptCodeArray()
273 {
274 foreach ($this->javascriptCodeArray as $name => $code) {
275 $this->pageRenderer->addJsInlineCode($name, $code, false);
276 }
277 }
278
279 /**
280 * Adds JS inline blocks of code to the internal registry
281 *
282 * @param string $name Javascript code block name
283 * @param string $code Inline Javascript
284 *
285 * @return void
286 */
287 public function addJavaScriptCode($name = '', $code = '')
288 {
289 $this->javascriptCodeArray[$name] = $code;
290 }
291
292 /**
293 * Get the DocHeader
294 *
295 * @return DocHeaderComponent
296 */
297 public function getDocHeaderComponent()
298 {
299 return $this->docHeaderComponent;
300 }
301
302 /**
303 * Returns the fully rendered view
304 *
305 * @return string
306 */
307 public function renderContent()
308 {
309 $this->setupPage();
310 $this->pageRenderer->setTitle($this->title);
311 $this->loadJavaScripts();
312 $this->setJavaScriptCodeArray();
313 $this->loadStylesheets();
314
315 $this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
316 if ($this->moduleId) {
317 $this->view->assign('moduleId', $this->moduleId);
318 }
319 if ($this->moduleName) {
320 $this->view->assign('moduleName', $this->moduleName);
321 }
322
323 $renderedPage = $this->pageRenderer->render(PageRenderer::PART_HEADER);
324 $renderedPage .= $this->view->render();
325 $renderedPage .= $this->pageRenderer->addJsFooterInlineCode('updateSignals', BackendUtility::getUpdateSignalCode());
326 $renderedPage .= $this->pageRenderer->render(PageRenderer::PART_FOOTER);
327
328 return $renderedPage;
329 }
330
331 /**
332 * Get PageRenderer
333 *
334 * @return PageRenderer
335 */
336 public function getPageRenderer()
337 {
338 return $this->pageRenderer;
339 }
340
341 /**
342 * Set form tag
343 *
344 * @param string $formTag Form tag to add
345 *
346 * @return void
347 */
348 public function setForm($formTag = '')
349 {
350 $this->view->assign('formTag', $formTag);
351 }
352
353 /**
354 * Sets the ModuleId
355 *
356 * @param string $moduleId ID of the module
357 *
358 * @return void
359 */
360 public function setModuleId($moduleId)
361 {
362 $this->moduleId = $moduleId;
363 $this->registerModuleMenu($moduleId);
364 }
365
366 /**
367 * Sets the ModuleName
368 *
369 * @param string $moduleName Name of the module
370 *
371 * @return void
372 */
373 public function setModuleName($moduleName)
374 {
375 $this->moduleName = $moduleName;
376 }
377
378 /**
379 * Generates the Menu for things like Web->Info
380 *
381 * @param $moduleMenuIdentifier
382 */
383 public function registerModuleMenu($moduleMenuIdentifier)
384 {
385 if (isset($GLOBALS['TBE_MODULES_EXT'][$moduleMenuIdentifier])) {
386 $menuEntries =
387 $GLOBALS['TBE_MODULES_EXT'][$moduleMenuIdentifier]['MOD_MENU']['function'];
388 $menu = $this->getDocHeaderComponent()->getMenuRegistry()->makeMenu()->setIdentifier('MOD_FUNC');
389 foreach ($menuEntries as $menuEntry) {
390 $menuItem = $menu->makeMenuItem()
391 ->setTitle($menuEntry['title'])
392 ->setHref('#');
393 $menu->addMenuItem($menuItem);
394 }
395 $this->docHeaderComponent->getMenuRegistry()->addMenu($menu);
396 }
397 }
398
399 /**
400 * Creates a tab menu where the tabs or collapsible are rendered with bootstrap markup
401 *
402 * @param array $menuItems Tab elements, each element is an array with "label" and "content"
403 * @param string $domId DOM id attribute, will be appended with an iteration number per tab.
404 * @param int $defaultTabIndex Default tab to open (for toggle <=0). Value corresponds to integer-array index + 1
405 * (index zero is "1", index "1" is 2 etc.). A value of zero (or something non-existing
406 * will result in no default tab open.
407 * @param bool $collapsible If set, the tabs are rendered as headers instead over each sheet. Effectively this means
408 * there is no tab menu, but rather a foldout/fold-in menu.
409 * @param bool $wrapContent If set, the content is wrapped in div structure which provides a padding and border
410 * style. Set this FALSE to get unstyled content pane with fullsize content area.
411 * @param bool $storeLastActiveTab If set, the last open tab is stored in local storage and will be re-open again.
412 * If you don't need this feature, e.g. for wizards like import/export you can
413 * disable this behaviour.
414 * @return string
415 */
416 public function getDynamicTabMenu(array $menuItems, $domId, $defaultTabIndex = 1, $collapsible = false, $wrapContent = true, $storeLastActiveTab = true)
417 {
418 $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tabs');
419 $templatePathAndFileName = 'EXT:backend/Resources/Private/Templates/DocumentTemplate/' . ($collapsible ? 'Collapse.html' : 'Tabs.html');
420 $view = GeneralUtility::makeInstance(StandaloneView::class);
421 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templatePathAndFileName));
422 $view->assignMultiple(array(
423 'id' => 'DTM-' . GeneralUtility::shortMD5($domId),
424 'items' => $menuItems,
425 'defaultTabIndex' => $defaultTabIndex,
426 'wrapContent' => $wrapContent,
427 'storeLastActiveTab' => $storeLastActiveTab,
428 ));
429 return $view->render();
430 }
431
432 /*******************************************
433 * THE FOLLOWING METHODS ARE SUBJECT TO BE DEPRECATED / DROPPED!
434 *
435 * These methods have been copied over from DocumentTemplate and enables
436 * core modules to drop the dependency to DocumentTemplate altogether without
437 * rewriting these modules now.
438 * The methods below are marked as internal and will be removed
439 * one-by-one with further refactoring of modules.
440 *
441 * Do not use these methods within own extensions if possible or
442 * be prepared to change this later again.
443 *******************************************/
444
445 /**
446 * Includes a javascript library that exists in the core /typo3/ directory
447 *
448 * @param string $lib Library name. Call it with the full path like
449 * "sysext/core/Resources/Public/JavaScript/QueryGenerator.js" to load it
450 *
451 * @return void
452 * @internal
453 */
454 public function loadJavascriptLib($lib)
455 {
456 // @todo: maybe we can remove this one as well
457 $this->pageRenderer->addJsFile($lib);
458 }
459
460 /**
461 * Returns a linked shortcut-icon which will call the shortcut frame and set a
462 * shortcut there back to the calling page/module
463 *
464 * @param string $gvList Is the list of GET variables to store (if any)
465 * @param string $setList Is the list of SET[] variables to store
466 * (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS
467 * for backend modules
468 * @param string $modName Module name string
469 * @param string|int $motherModName Is used to enter the "parent module
470 * name" if the module is a submodule under eg. Web>* or File>*. You
471 * can also set this value to 1 in which case the currentLoadedModule
472 * is sent to the shortcut script (so - not a fixed value!) - that is used
473 * in file_edit and wizard_rte modules where those are really running as
474 * a part of another module.
475 * @param string $displayName When given this name is used instead of the
476 * module name.
477 * @param string $classes Additional CSS classes for the link around the icon
478 *
479 * @return string HTML content
480 * @todo Make this thing return a button object
481 * @internal
482 */
483 public function makeShortcutIcon($gvList, $setList, $modName, $motherModName = '', $displayName = '', $classes = 'btn btn-default btn-sm')
484 {
485 $gvList = 'route,' . $gvList;
486 $storeUrl = $this->makeShortcutUrl($gvList, $setList);
487 $pathInfo = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
488 // Fallback for alt_mod. We still pass in the old xMOD... stuff,
489 // but TBE_MODULES only knows about "record_edit".
490 // We still need to pass the xMOD name to createShortcut below,
491 // since this is used for icons.
492 $moduleName = $modName === 'xMOD_alt_doc.php' ? 'record_edit' : $modName;
493 // Add the module identifier automatically if typo3/index.php is used:
494 if (GeneralUtility::_GET('M') !== null && isset($GLOBALS['TBE_MODULES']['_PATHS'][$moduleName])) {
495 $storeUrl = '&M=' . $moduleName . $storeUrl;
496 }
497 if ((int)$motherModName === 1) {
498 $motherModule = 'top.currentModuleLoaded';
499 } elseif ($motherModName) {
500 $motherModule = GeneralUtility::quoteJSvalue($motherModName);
501 } else {
502 $motherModule = '\'\'';
503 }
504 $confirmationText = GeneralUtility::quoteJSvalue(
505 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.makeBookmark')
506 );
507
508 $shortcutUrl = $pathInfo['path'] . '?' . $storeUrl;
509 $shortcutExist = BackendUtility::shortcutExists($shortcutUrl);
510
511 if ($shortcutExist) {
512 return '<a class="active ' . htmlspecialchars($classes) . '" title="">' .
513 $this->iconFactory->getIcon('actions-system-shortcut-active', Icon::SIZE_SMALL)->render() . '</a>';
514 }
515
516 $url = GeneralUtility::quoteJSvalue(rawurlencode($shortcutUrl));
517 $onClick = 'top.TYPO3.ShortcutMenu.createShortcut(' . GeneralUtility::quoteJSvalue(rawurlencode($modName)) .
518 ', ' . $url . ', ' . $confirmationText . ', ' . $motherModule . ', this, ' . GeneralUtility::quoteJSvalue($displayName) . ');return false;';
519
520 return '<a href="#" class="' . htmlspecialchars($classes) . '" onclick="' . htmlspecialchars($onClick) . '" title="' .
521 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.makeBookmark', true) . '">' .
522 $this->iconFactory->getIcon('actions-system-shortcut-new', Icon::SIZE_SMALL)->render() . '</a>';
523 }
524
525 /**
526 * MAKE url for storing
527 * Internal func
528 *
529 * @param string $gvList Is the list of GET variables to store (if any)
530 * @param string $setList Is the list of SET[] variables to store (if any)
531 * - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend
532 * modules
533 *
534 * @return string
535 * @internal
536 */
537 public function makeShortcutUrl($gvList, $setList)
538 {
539 $getParams = GeneralUtility::_GET();
540 $storeArray = array_merge(
541 GeneralUtility::compileSelectedGetVarsFromArray($gvList, $getParams),
542 array('SET' => GeneralUtility::compileSelectedGetVarsFromArray($setList, (array)$GLOBALS['SOBE']->MOD_SETTINGS))
543 );
544 return GeneralUtility::implodeArrayForUrl('', $storeArray);
545 }
546
547 /**
548 * Creates the version selector for the page id inputted.
549 * Requires the core version management extension, "version" to be loaded.
550 *
551 * @param int $id Page id to create selector for.
552 * @param bool $noAction If set, there will be no button for swapping page.
553 *
554 * @return string
555 * @internal
556 */
557 public function getVersionSelector($id, $noAction = false)
558 {
559 if (ExtensionManagementUtility::isLoaded('version')
560 && !ExtensionManagementUtility::isLoaded('workspaces')
561 ) {
562 /**
563 * For Code Completion
564 *
565 * @var $versionGuiObj VersionView
566 */
567 $versionGuiObj = GeneralUtility::makeInstance(VersionView::class);
568 return $versionGuiObj->getVersionSelector($id, $noAction);
569 }
570 return '';
571 }
572
573 /**
574 * Begins an output section and sets header and content
575 *
576 * @param string $label The header
577 * @param string $text The HTML-content
578 * @param bool $noStrToUpper A flag that will prevent the header from
579 * being converted to uppercase
580 * @param bool $sH Defines the type of header (if set, "<h3>" rather
581 * than the default "h4")
582 * @param int $type The number of an icon to show with the header
583 * (see the icon-function). -1,1,2,3
584 * @param bool $allowHtmlInHeader If set, HTML tags are allowed in
585 * $label (otherwise this value is by default htmlspecialchars()'ed)
586 *
587 * @return string HTML content
588 * @internal
589 */
590 public function section($label, $text, $noStrToUpper = false, $sH = false, $type = 0, $allowHtmlInHeader = false)
591 {
592 $str = '';
593 // Setting header
594 if ($label) {
595 if (!$allowHtmlInHeader) {
596 $label = htmlspecialchars($label);
597 }
598 $str .= $this->sectionHeader($this->icons($type) . $label, $sH, $noStrToUpper ? '' : ' class="uppercase"');
599 }
600 // Setting content
601 $str .= '
602
603 <!-- Section content -->
604 ' . $text;
605 return $this->sectionBegin() . $str;
606 }
607
608 /**
609 * Inserts a divider image
610 * Ends a section (if open) before inserting the image
611 *
612 * @param int $dist The margin-top/-bottom of the <hr> ruler.
613 *
614 * @return string HTML content
615 * @internal
616 */
617 public function divider($dist)
618 {
619 $dist = (int)$dist;
620 $str = '
621
622 <!-- DIVIDER -->
623 <hr style="margin-top: ' . $dist . 'px; margin-bottom: ' . $dist . 'px;" />
624 ';
625 return $this->sectionEnd() . $str;
626 }
627
628 /**
629 * Returns a blank <div>-section with a height
630 *
631 * @param int $dist Padding-top for the div-section
632 *
633 * @return string HTML content
634 * @internal
635 */
636 public function spacer($dist)
637 {
638 if ($dist > 0) {
639 return '
640
641 <!-- Spacer element -->
642 <div style="padding-top: ' . (int)$dist . 'px;"></div>
643 ';
644 }
645 return '';
646 }
647
648 /**
649 * Make a section header.
650 * Begins a section if not already open.
651 *
652 * @param string $label The label between the <h3> or <h4> tags. (Allows HTML)
653 * @param bool $sH If set, <h3> is used, otherwise <h4>
654 * @param string $addAttribute Additional attributes to h-tag, eg. ' class=""'
655 *
656 * @return string HTML content
657 * @internal
658 */
659 public function sectionHeader($label, $sH = false, $addAttribute = '')
660 {
661 $tag = $sH ? 'h2' : 'h3';
662 if ($addAttribute && $addAttribute[0] !== ' ') {
663 $addAttribute = ' ' . $addAttribute;
664 }
665 $str = '
666
667 <!-- Section header -->
668 <' . $tag . $addAttribute . '>' . $label . '</' . $tag . '>
669 ';
670 return $this->sectionBegin() . $str;
671 }
672
673 /**
674 * Begins an output section.
675 * Returns the <div>-begin tag AND sets the ->sectionFlag TRUE
676 * (if the ->sectionFlag is not already set!)
677 * You can call this function even if a section is already begun
678 * since the function will only return something if the sectionFlag
679 * is not already set!
680 *
681 * @return string HTML content
682 * @internal
683 */
684 public function sectionBegin()
685 {
686 if (!$this->sectionFlag) {
687 $this->sectionFlag = 1;
688 $str = '
689
690 <!-- ***********************
691 Begin output section.
692 *********************** -->
693 <div>
694 ';
695 return $str;
696 }
697 return '';
698 }
699
700 /**
701 * Ends and output section
702 * Returns the </div>-end tag AND clears the ->sectionFlag
703 * (but does so only IF the sectionFlag is set - that is a section is 'open')
704 * See sectionBegin() also.
705 *
706 * @return string HTML content
707 * @internal
708 */
709 public function sectionEnd()
710 {
711 if ($this->sectionFlag) {
712 $this->sectionFlag = 0;
713 return '
714 </div>
715 <!-- *********************
716 End output section.
717 ********************* -->
718 ';
719 }
720 return '';
721 }
722
723
724
725 /**
726 * Returns the BE USER Object
727 *
728 * @return BackendUserAuthentication
729 */
730 protected function getBackendUserAuthentication()
731 {
732 return $GLOBALS['BE_USER'];
733 }
734
735 /**
736 * Returns the LanguageService
737 *
738 * @return LanguageService
739 */
740 protected function getLanguageService()
741 {
742 return $GLOBALS['LANG'];
743 }
744
745 /**
746 * Returns an image-tag with an 18x16 icon of the following types:
747 *
748 * $type:
749 * -1:» OK icon (Check-mark)
750 * 1:» Notice (Speach-bubble)
751 * 2:» Warning (Yellow triangle)
752 * 3:» Fatal error (Red stop sign)
753 *
754 * @param int $type See description
755 *
756 * @return string HTML image tag (if applicable)
757 * @internal
758 */
759 public function icons($type)
760 {
761 $icon = '';
762 switch ($type) {
763 case self::STATUS_ICON_ERROR:
764 $icon = 'status-dialog-error';
765 break;
766 case self::STATUS_ICON_WARNING:
767 $icon = 'status-dialog-warning';
768 break;
769 case self::STATUS_ICON_NOTIFICATION:
770 $icon = 'status-dialog-notification';
771 break;
772 case self::STATUS_ICON_OK:
773 $icon = 'status-dialog-ok';
774 break;
775 default:
776 // Do nothing
777 }
778 if ($icon != '') {
779 return $this->iconFactory->getIcon($icon, Icon::SIZE_SMALL)->render();
780 }
781 return '';
782 }
783
784 /**
785 * Returns JavaScript variables setting the returnUrl and thisScript location for use by JavaScript on the page.
786 * Used in fx. db_list.php (Web>List)
787 *
788 * @param string $thisLocation URL to "this location" / current script
789 * @return string Urls are returned as JavaScript variables T3_RETURN_URL and T3_THIS_LOCATION
790 * @see typo3/db_list.php
791 * @internal
792 */
793 public function redirectUrls($thisLocation = '')
794 {
795 $thisLocation = $thisLocation ? $thisLocation : GeneralUtility::linkThisScript(array(
796 'CB' => '',
797 'SET' => '',
798 'cmd' => '',
799 'popViewId' => ''
800 ));
801 $out = '
802 var T3_RETURN_URL = ' . GeneralUtility::quoteJSvalue(str_replace('%20', '', rawurlencode(GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'))))) . ';
803 var T3_THIS_LOCATION = ' . GeneralUtility::quoteJSvalue(str_replace('%20', '', rawurlencode($thisLocation))) . '
804 ';
805 return $out;
806 }
807
808 /**
809 * Returns the header-bar in the top of most backend modules
810 * Closes section if open.
811 *
812 * @param string $text The text string for the header
813 * @return string HTML content
814 * @internal
815 */
816 public function header($text)
817 {
818 $str = '
819
820 <!-- MAIN Header in page top -->
821 <h1 class="t3js-title-inlineedit">' . htmlspecialchars($text) . '</h1>
822 ';
823 return $this->sectionEnd() . $str;
824 }
825 }