[BUGFIX] Move issueCommand to BackendUtility
[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 DYNAMIC tab-menu where the tabs or collapsible are rendered with bootstrap markup
401 *
402 * @param array $menuItems Numeric array where each entry is an array in itself with associative keys: "label"
403 * contains the label for the TAB, "content" contains the HTML content that goes into the
404 * div-layer of the tabs content. "description" contains description text to be shown in the
405 * layer. "linkTitle" is short text for the title attribute of the tab-menu link (mouse-over
406 * text of tab). "stateIcon" indicates a standard status icon (see ->icon(),
407 * values: -1, 1, 2, 3). "icon" is an image tag placed before the text.
408 * @param string $identString Identification string. This should be unique for every instance of a dynamic menu!
409 * @param int $defaultTabIndex Default tab to open (for toggle <=0). Value corresponds to integer-array index + 1
410 * (index zero is "1", index "1" is 2 etc.). A value of zero (or something non-existing
411 * will result in no default tab open.
412 * @param bool $collapsible If set, the tabs are rendered as headers instead over each sheet. Effectively this means
413 * there is no tab menu, but rather a foldout/fold-in menu.
414 * @param bool $wrapContent If set, the content is wrapped in div structure which provides a padding and border
415 * style. Set this FALSE to get unstyled content pane with fullsize content area.
416 * @param bool $storeLastActiveTab If set, the last open tab is stored in local storage and will be re-open again.
417 * If you don't need this feature, e.g. for wizards like import/export you can
418 * disable this behaviour.
419 * @return string
420 */
421 public function getDynamicTabMenu(array $menuItems, $identString, $defaultTabIndex = 1, $collapsible = false, $wrapContent = true, $storeLastActiveTab = true)
422 {
423 $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tabs');
424 $templatePathAndFileName = 'EXT:backend/Resources/Private/Templates/DocumentTemplate/' . ($collapsible ? 'Collapse.html' : 'Tabs.html');
425 $view = GeneralUtility::makeInstance(StandaloneView::class);
426 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templatePathAndFileName));
427 $view->assignMultiple(array(
428 'id' => $this->getDynTabMenuId($identString),
429 'items' => $menuItems,
430 'defaultTabIndex' => $defaultTabIndex,
431 'wrapContent' => $wrapContent,
432 'storeLastActiveTab' => $storeLastActiveTab,
433 'BACK_PATH' => $GLOBALS['BACK_PATH']
434 ));
435 return $view->render();
436 }
437
438 /**
439 * Creates the id for dynTabMenus.
440 *
441 * @param string $identString Identification string. This should be unique for every instance of a dynamic menu!
442 * @return string The id with a short MD5 of $identString and prefixed "DTM-", like "DTM-2e8791854a
443 */
444 public function getDynTabMenuId($identString)
445 {
446 $id = 'DTM-' . GeneralUtility::shortMD5($identString);
447 return $id;
448 }
449
450
451
452 /*******************************************
453 * THE FOLLOWING METHODS ARE SUBJECT TO BE DEPRECATED / DROPPED!
454 *
455 * These methods have been copied over from DocumentTemplate and enables
456 * core modules to drop the dependency to DocumentTemplate altogether without
457 * rewriting these modules now.
458 * The methods below are marked as internal and will be removed
459 * one-by-one with further refactoring of modules.
460 *
461 * Do not use these methods within own extensions if possible or
462 * be prepared to change this later again.
463 *******************************************/
464
465 /**
466 * Includes a javascript library that exists in the core /typo3/ directory
467 *
468 * @param string $lib Library name. Call it with the full path like
469 * "sysext/core/Resources/Public/JavaScript/QueryGenerator.js" to load it
470 *
471 * @return void
472 * @internal
473 */
474 public function loadJavascriptLib($lib)
475 {
476 // @todo: maybe we can remove this one as well
477 $this->pageRenderer->addJsFile($lib);
478 }
479
480 /**
481 * Returns a linked shortcut-icon which will call the shortcut frame and set a
482 * shortcut there back to the calling page/module
483 *
484 * @param string $gvList Is the list of GET variables to store (if any)
485 * @param string $setList Is the list of SET[] variables to store
486 * (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS
487 * for backend modules
488 * @param string $modName Module name string
489 * @param string|int $motherModName Is used to enter the "parent module
490 * name" if the module is a submodule under eg. Web>* or File>*. You
491 * can also set this value to 1 in which case the currentLoadedModule
492 * is sent to the shortcut script (so - not a fixed value!) - that is used
493 * in file_edit and wizard_rte modules where those are really running as
494 * a part of another module.
495 * @param string $displayName When given this name is used instead of the
496 * module name.
497 * @param string $classes Additional CSS classes for the link around the icon
498 *
499 * @return string HTML content
500 * @todo Make this thing return a button object
501 * @internal
502 */
503 public function makeShortcutIcon($gvList, $setList, $modName, $motherModName = '', $displayName = '', $classes = 'btn btn-default btn-sm')
504 {
505 $gvList = 'route,' . $gvList;
506 $storeUrl = $this->makeShortcutUrl($gvList, $setList);
507 $pathInfo = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
508 // Fallback for alt_mod. We still pass in the old xMOD... stuff,
509 // but TBE_MODULES only knows about "record_edit".
510 // We still need to pass the xMOD name to createShortcut below,
511 // since this is used for icons.
512 $moduleName = $modName === 'xMOD_alt_doc.php' ? 'record_edit' : $modName;
513 // Add the module identifier automatically if typo3/index.php is used:
514 if (GeneralUtility::_GET('M') !== null && isset($GLOBALS['TBE_MODULES']['_PATHS'][$moduleName])) {
515 $storeUrl = '&M=' . $moduleName . $storeUrl;
516 }
517 if ((int)$motherModName === 1) {
518 $motherModule = 'top.currentModuleLoaded';
519 } elseif ($motherModName) {
520 $motherModule = GeneralUtility::quoteJSvalue($motherModName);
521 } else {
522 $motherModule = '\'\'';
523 }
524 $confirmationText = GeneralUtility::quoteJSvalue(
525 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.makeBookmark')
526 );
527
528 $shortcutUrl = $pathInfo['path'] . '?' . $storeUrl;
529 $shortcutExist = BackendUtility::shortcutExists($shortcutUrl);
530
531 if ($shortcutExist) {
532 return '<a class="active ' . htmlspecialchars($classes) . '" title="">' .
533 $this->iconFactory->getIcon('actions-system-shortcut-active', Icon::SIZE_SMALL)->render() . '</a>';
534 }
535
536 $url = GeneralUtility::quoteJSvalue(rawurlencode($shortcutUrl));
537 $onClick = 'top.TYPO3.ShortcutMenu.createShortcut(' . GeneralUtility::quoteJSvalue(rawurlencode($modName)) .
538 ', ' . $url . ', ' . $confirmationText . ', ' . $motherModule . ', this, ' . GeneralUtility::quoteJSvalue($displayName) . ');return false;';
539
540 return '<a href="#" class="' . htmlspecialchars($classes) . '" onclick="' . htmlspecialchars($onClick) . '" title="' .
541 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.makeBookmark', true) . '">' .
542 $this->iconFactory->getIcon('actions-system-shortcut-new', Icon::SIZE_SMALL)->render() . '</a>';
543 }
544
545 /**
546 * MAKE url for storing
547 * Internal func
548 *
549 * @param string $gvList Is the list of GET variables to store (if any)
550 * @param string $setList Is the list of SET[] variables to store (if any)
551 * - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend
552 * modules
553 *
554 * @return string
555 * @internal
556 */
557 public function makeShortcutUrl($gvList, $setList)
558 {
559 $getParams = GeneralUtility::_GET();
560 $storeArray = array_merge(
561 GeneralUtility::compileSelectedGetVarsFromArray($gvList, $getParams),
562 array('SET' => GeneralUtility::compileSelectedGetVarsFromArray($setList, (array)$GLOBALS['SOBE']->MOD_SETTINGS))
563 );
564 return GeneralUtility::implodeArrayForUrl('', $storeArray);
565 }
566
567 /**
568 * Creates the version selector for the page id inputted.
569 * Requires the core version management extension, "version" to be loaded.
570 *
571 * @param int $id Page id to create selector for.
572 * @param bool $noAction If set, there will be no button for swapping page.
573 *
574 * @return string
575 * @internal
576 */
577 public function getVersionSelector($id, $noAction = false)
578 {
579 if (ExtensionManagementUtility::isLoaded('version')
580 && !ExtensionManagementUtility::isLoaded('workspaces')
581 ) {
582 /**
583 * For Code Completion
584 *
585 * @var $versionGuiObj VersionView
586 */
587 $versionGuiObj = GeneralUtility::makeInstance(VersionView::class);
588 return $versionGuiObj->getVersionSelector($id, $noAction);
589 }
590 return '';
591 }
592
593 /**
594 * Begins an output section and sets header and content
595 *
596 * @param string $label The header
597 * @param string $text The HTML-content
598 * @param bool $noStrToUpper A flag that will prevent the header from
599 * being converted to uppercase
600 * @param bool $sH Defines the type of header (if set, "<h3>" rather
601 * than the default "h4")
602 * @param int $type The number of an icon to show with the header
603 * (see the icon-function). -1,1,2,3
604 * @param bool $allowHtmlInHeader If set, HTML tags are allowed in
605 * $label (otherwise this value is by default htmlspecialchars()'ed)
606 *
607 * @return string HTML content
608 * @internal
609 */
610 public function section($label, $text, $noStrToUpper = false, $sH = false, $type = 0, $allowHtmlInHeader = false)
611 {
612 $str = '';
613 // Setting header
614 if ($label) {
615 if (!$allowHtmlInHeader) {
616 $label = htmlspecialchars($label);
617 }
618 $str .= $this->sectionHeader($this->icons($type) . $label, $sH, $noStrToUpper ? '' : ' class="uppercase"');
619 }
620 // Setting content
621 $str .= '
622
623 <!-- Section content -->
624 ' . $text;
625 return $this->sectionBegin() . $str;
626 }
627
628 /**
629 * Inserts a divider image
630 * Ends a section (if open) before inserting the image
631 *
632 * @param int $dist The margin-top/-bottom of the <hr> ruler.
633 *
634 * @return string HTML content
635 * @internal
636 */
637 public function divider($dist)
638 {
639 $dist = (int)$dist;
640 $str = '
641
642 <!-- DIVIDER -->
643 <hr style="margin-top: ' . $dist . 'px; margin-bottom: ' . $dist . 'px;" />
644 ';
645 return $this->sectionEnd() . $str;
646 }
647
648 /**
649 * Returns a blank <div>-section with a height
650 *
651 * @param int $dist Padding-top for the div-section
652 *
653 * @return string HTML content
654 * @internal
655 */
656 public function spacer($dist)
657 {
658 if ($dist > 0) {
659 return '
660
661 <!-- Spacer element -->
662 <div style="padding-top: ' . (int)$dist . 'px;"></div>
663 ';
664 }
665 return '';
666 }
667
668 /**
669 * Make a section header.
670 * Begins a section if not already open.
671 *
672 * @param string $label The label between the <h3> or <h4> tags. (Allows HTML)
673 * @param bool $sH If set, <h3> is used, otherwise <h4>
674 * @param string $addAttribute Additional attributes to h-tag, eg. ' class=""'
675 *
676 * @return string HTML content
677 * @internal
678 */
679 public function sectionHeader($label, $sH = false, $addAttribute = '')
680 {
681 $tag = $sH ? 'h2' : 'h3';
682 if ($addAttribute && $addAttribute[0] !== ' ') {
683 $addAttribute = ' ' . $addAttribute;
684 }
685 $str = '
686
687 <!-- Section header -->
688 <' . $tag . $addAttribute . '>' . $label . '</' . $tag . '>
689 ';
690 return $this->sectionBegin() . $str;
691 }
692
693 /**
694 * Begins an output section.
695 * Returns the <div>-begin tag AND sets the ->sectionFlag TRUE
696 * (if the ->sectionFlag is not already set!)
697 * You can call this function even if a section is already begun
698 * since the function will only return something if the sectionFlag
699 * is not already set!
700 *
701 * @return string HTML content
702 * @internal
703 */
704 public function sectionBegin()
705 {
706 if (!$this->sectionFlag) {
707 $this->sectionFlag = 1;
708 $str = '
709
710 <!-- ***********************
711 Begin output section.
712 *********************** -->
713 <div>
714 ';
715 return $str;
716 }
717 return '';
718 }
719
720 /**
721 * Ends and output section
722 * Returns the </div>-end tag AND clears the ->sectionFlag
723 * (but does so only IF the sectionFlag is set - that is a section is 'open')
724 * See sectionBegin() also.
725 *
726 * @return string HTML content
727 * @internal
728 */
729 public function sectionEnd()
730 {
731 if ($this->sectionFlag) {
732 $this->sectionFlag = 0;
733 return '
734 </div>
735 <!-- *********************
736 End output section.
737 ********************* -->
738 ';
739 }
740 return '';
741 }
742
743
744
745 /**
746 * Returns the BE USER Object
747 *
748 * @return BackendUserAuthentication
749 */
750 protected function getBackendUserAuthentication()
751 {
752 return $GLOBALS['BE_USER'];
753 }
754
755 /**
756 * Returns the LanguageService
757 *
758 * @return LanguageService
759 */
760 protected function getLanguageService()
761 {
762 return $GLOBALS['LANG'];
763 }
764
765 /**
766 * Returns an image-tag with an 18x16 icon of the following types:
767 *
768 * $type:
769 * -1:» OK icon (Check-mark)
770 * 1:» Notice (Speach-bubble)
771 * 2:» Warning (Yellow triangle)
772 * 3:» Fatal error (Red stop sign)
773 *
774 * @param int $type See description
775 *
776 * @return string HTML image tag (if applicable)
777 * @internal
778 */
779 public function icons($type)
780 {
781 $icon = '';
782 switch ($type) {
783 case self::STATUS_ICON_ERROR:
784 $icon = 'status-dialog-error';
785 break;
786 case self::STATUS_ICON_WARNING:
787 $icon = 'status-dialog-warning';
788 break;
789 case self::STATUS_ICON_NOTIFICATION:
790 $icon = 'status-dialog-notification';
791 break;
792 case self::STATUS_ICON_OK:
793 $icon = 'status-dialog-ok';
794 break;
795 default:
796 // Do nothing
797 }
798 if ($icon != '') {
799 return $this->iconFactory->getIcon($icon, Icon::SIZE_SMALL)->render();
800 }
801 return '';
802 }
803
804 /**
805 * Returns JavaScript variables setting the returnUrl and thisScript location for use by JavaScript on the page.
806 * Used in fx. db_list.php (Web>List)
807 *
808 * @param string $thisLocation URL to "this location" / current script
809 * @return string Urls are returned as JavaScript variables T3_RETURN_URL and T3_THIS_LOCATION
810 * @see typo3/db_list.php
811 * @internal
812 */
813 public function redirectUrls($thisLocation = '')
814 {
815 $thisLocation = $thisLocation ? $thisLocation : GeneralUtility::linkThisScript(array(
816 'CB' => '',
817 'SET' => '',
818 'cmd' => '',
819 'popViewId' => ''
820 ));
821 $out = '
822 var T3_RETURN_URL = ' . GeneralUtility::quoteJSvalue(str_replace('%20', '', rawurlencode(GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'))))) . ';
823 var T3_THIS_LOCATION = ' . GeneralUtility::quoteJSvalue(str_replace('%20', '', rawurlencode($thisLocation))) . '
824 ';
825 return $out;
826 }
827
828 /**
829 * Returns the header-bar in the top of most backend modules
830 * Closes section if open.
831 *
832 * @param string $text The text string for the header
833 * @return string HTML content
834 * @internal
835 */
836 public function header($text)
837 {
838 $str = '
839
840 <!-- MAIN Header in page top -->
841 <h1 class="t3js-title-inlineedit">' . htmlspecialchars($text) . '</h1>
842 ';
843 return $this->sectionEnd() . $str;
844 }
845 }