[TASK] Streamline return tags in phpdocs
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Page / PageRenderer.php
1 <?php
2 namespace TYPO3\CMS\Core\Page;
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\Routing\Router;
18 use TYPO3\CMS\Backend\Routing\UriBuilder;
19 use TYPO3\CMS\Backend\Utility\BackendUtility;
20 use TYPO3\CMS\Core\Cache\CacheManager;
21 use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
22 use TYPO3\CMS\Core\Localization\LocalizationFactory;
23 use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
24 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
25 use TYPO3\CMS\Core\Utility\GeneralUtility;
26 use TYPO3\CMS\Core\Utility\PathUtility;
27 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
28
29 /**
30 * TYPO3 pageRender class (new in TYPO3 4.3.0)
31 * This class render the HTML of a webpage, usable for BE and FE
32 */
33 class PageRenderer implements \TYPO3\CMS\Core\SingletonInterface
34 {
35 // Constants for the part to be rendered
36 const PART_COMPLETE = 0;
37 const PART_HEADER = 1;
38 const PART_FOOTER = 2;
39 // jQuery Core version that is shipped with TYPO3
40 const JQUERY_VERSION_LATEST = '3.2.1';
41 // jQuery namespace options
42 const JQUERY_NAMESPACE_NONE = 'none';
43 const JQUERY_NAMESPACE_DEFAULT = 'jQuery';
44 const JQUERY_NAMESPACE_DEFAULT_NOCONFLICT = 'defaultNoConflict';
45
46 /**
47 * @var bool
48 */
49 protected $compressJavascript = false;
50
51 /**
52 * @var bool
53 */
54 protected $compressCss = false;
55
56 /**
57 * @var bool
58 */
59 protected $removeLineBreaksFromTemplate = false;
60
61 /**
62 * @var bool
63 */
64 protected $concatenateFiles = false;
65
66 /**
67 * @var bool
68 */
69 protected $concatenateJavascript = false;
70
71 /**
72 * @var bool
73 */
74 protected $concatenateCss = false;
75
76 /**
77 * @var bool
78 */
79 protected $moveJsFromHeaderToFooter = false;
80
81 /**
82 * @var \TYPO3\CMS\Core\Charset\CharsetConverter
83 */
84 protected $csConvObj;
85
86 /**
87 * @var \TYPO3\CMS\Core\Localization\Locales
88 */
89 protected $locales;
90
91 /**
92 * The language key
93 * Two character string or 'default'
94 *
95 * @var string
96 */
97 protected $lang;
98
99 /**
100 * List of language dependencies for actual language. This is used for local variants of a language
101 * that depend on their "main" language, like Brazilian Portuguese or Canadian French.
102 *
103 * @var array
104 */
105 protected $languageDependencies = [];
106
107 /**
108 * @var \TYPO3\CMS\Core\Resource\ResourceCompressor
109 */
110 protected $compressor;
111
112 // Arrays containing associative array for the included files
113 /**
114 * @var array
115 */
116 protected $jsFiles = [];
117
118 /**
119 * @var array
120 */
121 protected $jsFooterFiles = [];
122
123 /**
124 * @var array
125 */
126 protected $jsLibs = [];
127
128 /**
129 * @var array
130 */
131 protected $jsFooterLibs = [];
132
133 /**
134 * @var array
135 */
136 protected $cssFiles = [];
137
138 /**
139 * @var array
140 */
141 protected $cssLibs = [];
142
143 /**
144 * The title of the page
145 *
146 * @var string
147 */
148 protected $title;
149
150 /**
151 * Charset for the rendering
152 *
153 * @var string
154 */
155 protected $charSet;
156
157 /**
158 * @var string
159 */
160 protected $favIcon;
161
162 /**
163 * @var string
164 */
165 protected $baseUrl;
166
167 /**
168 * @var bool
169 */
170 protected $renderXhtml = true;
171
172 // Static header blocks
173 /**
174 * @var string
175 */
176 protected $xmlPrologAndDocType = '';
177
178 /**
179 * @var array
180 */
181 protected $metaTags = [];
182
183 /**
184 * @var array
185 */
186 protected $inlineComments = [];
187
188 /**
189 * @var array
190 */
191 protected $headerData = [];
192
193 /**
194 * @var array
195 */
196 protected $footerData = [];
197
198 /**
199 * @var string
200 */
201 protected $titleTag = '<title>|</title>';
202
203 /**
204 * @var string
205 */
206 protected $metaCharsetTag = '<meta http-equiv="Content-Type" content="text/html; charset=|" />';
207
208 /**
209 * @var string
210 */
211 protected $htmlTag = '<html>';
212
213 /**
214 * @var string
215 */
216 protected $headTag = '<head>';
217
218 /**
219 * @var string
220 */
221 protected $baseUrlTag = '<base href="|" />';
222
223 /**
224 * @var string
225 */
226 protected $iconMimeType = '';
227
228 /**
229 * @var string
230 */
231 protected $shortcutTag = '<link rel="shortcut icon" href="%1$s"%2$s />';
232
233 // Static inline code blocks
234 /**
235 * @var array
236 */
237 protected $jsInline = [];
238
239 /**
240 * @var array
241 */
242 protected $jsFooterInline = [];
243
244 /**
245 * @var array
246 */
247 protected $extOnReadyCode = [];
248
249 /**
250 * @var array
251 */
252 protected $cssInline = [];
253
254 /**
255 * @var string
256 */
257 protected $bodyContent;
258
259 /**
260 * @var string
261 */
262 protected $templateFile;
263
264 /**
265 * @var array
266 */
267 protected $jsLibraryNames = ['extjs'];
268
269 // Paths to contributed libraries
270
271 /**
272 * default path to the requireJS library, relative to the typo3/ directory
273 * @var string
274 */
275 protected $requireJsPath = 'EXT:core/Resources/Public/JavaScript/Contrib/';
276
277 /**
278 * @var string
279 */
280 protected $extJsPath = 'EXT:core/Resources/Public/JavaScript/Contrib/extjs/';
281
282 /**
283 * The local directory where one can find jQuery versions and plugins
284 *
285 * @var string
286 */
287 protected $jQueryPath = 'EXT:core/Resources/Public/JavaScript/Contrib/jquery/';
288
289 // Internal flags for JS-libraries
290 /**
291 * This array holds all jQuery versions that should be included in the
292 * current page.
293 * Each version is described by "source", "version" and "namespace"
294 *
295 * The namespace of every particular version is the key
296 * of that array, because only one version per namespace can exist.
297 *
298 * The type "source" describes where the jQuery core should be included from
299 * currently, TYPO3 supports "local" (make use of jQuery path), "google",
300 * "jquery", "msn" and "cloudflare".
301 *
302 * Currently there are downsides to "local" which supports only the latest/shipped
303 * jQuery core out of the box.
304 *
305 * @var array
306 */
307 protected $jQueryVersions = [];
308
309 /**
310 * Array of jQuery version numbers shipped with the core
311 *
312 * @var array
313 */
314 protected $availableLocalJqueryVersions = [
315 self::JQUERY_VERSION_LATEST
316 ];
317
318 /**
319 * Array of jQuery CDNs with placeholders
320 *
321 * @var array
322 */
323 protected $jQueryCdnUrls = [
324 'google' => 'https://ajax.googleapis.com/ajax/libs/jquery/%1$s/jquery%2$s.js',
325 'msn' => 'https://ajax.aspnetcdn.com/ajax/jQuery/jquery-%1$s%2$s.js',
326 'jquery' => 'https://code.jquery.com/jquery-%1$s%2$s.js',
327 'cloudflare' => 'https://cdnjs.cloudflare.com/ajax/libs/jquery/%1$s/jquery%2$s.js'
328 ];
329
330 /**
331 * if set, the requireJS library is included
332 * @var bool
333 */
334 protected $addRequireJs = false;
335
336 /**
337 * inline configuration for requireJS
338 * @var array
339 */
340 protected $requireJsConfig = [];
341
342 /**
343 * @var bool
344 */
345 protected $addExtJS = false;
346
347 /**
348 * @var bool
349 */
350 protected $extDirectCodeAdded = false;
351
352 /**
353 * @var bool
354 */
355 protected $enableExtJsDebug = false;
356
357 /**
358 * @var bool
359 */
360 protected $enableJqueryDebug = false;
361
362 /**
363 * @var bool
364 */
365 protected $extJStheme = true;
366
367 /**
368 * @var bool
369 */
370 protected $extJScss = true;
371
372 /**
373 * @var array
374 */
375 protected $inlineLanguageLabels = [];
376
377 /**
378 * @var array
379 */
380 protected $inlineLanguageLabelFiles = [];
381
382 /**
383 * @var array
384 */
385 protected $inlineSettings = [];
386
387 /**
388 * @var array
389 */
390 protected $inlineJavascriptWrap = [];
391
392 /**
393 * @var array
394 */
395 protected $inlineCssWrap = [];
396
397 /**
398 * Saves error messages generated during compression
399 *
400 * @var string
401 */
402 protected $compressError = '';
403
404 /**
405 * Is empty string for HTML and ' /' for XHTML rendering
406 *
407 * @var string
408 */
409 protected $endingSlash = '';
410
411 /**
412 * @param string $templateFile Declare the used template file. Omit this parameter will use default template
413 */
414 public function __construct($templateFile = '')
415 {
416 $this->reset();
417 $this->csConvObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Charset\CharsetConverter::class);
418 $this->locales = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\Locales::class);
419 if ($templateFile !== '') {
420 $this->templateFile = $templateFile;
421 }
422 $this->inlineJavascriptWrap = [
423 '<script type="text/javascript">' . LF . '/*<![CDATA[*/' . LF,
424 '/*]]>*/' . LF . '</script>' . LF
425 ];
426 $this->inlineCssWrap = [
427 '<style type="text/css">' . LF . '/*<![CDATA[*/' . LF . '<!-- ' . LF,
428 '-->' . LF . '/*]]>*/' . LF . '</style>' . LF
429 ];
430 }
431
432 /**
433 * Reset all vars to initial values
434 */
435 protected function reset()
436 {
437 $this->templateFile = 'EXT:core/Resources/Private/Templates/PageRenderer.html';
438 $this->jsFiles = [];
439 $this->jsFooterFiles = [];
440 $this->jsInline = [];
441 $this->jsFooterInline = [];
442 $this->jsLibs = [];
443 $this->cssFiles = [];
444 $this->cssInline = [];
445 $this->metaTags = [];
446 $this->inlineComments = [];
447 $this->headerData = [];
448 $this->footerData = [];
449 $this->extOnReadyCode = [];
450 $this->jQueryVersions = [];
451 }
452
453 /*****************************************************/
454 /* */
455 /* Public Setters */
456 /* */
457 /* */
458 /*****************************************************/
459 /**
460 * Sets the title
461 *
462 * @param string $title title of webpage
463 */
464 public function setTitle($title)
465 {
466 $this->title = $title;
467 }
468
469 /**
470 * Enables/disables rendering of XHTML code
471 *
472 * @param bool $enable Enable XHTML
473 */
474 public function setRenderXhtml($enable)
475 {
476 $this->renderXhtml = $enable;
477 }
478
479 /**
480 * Sets xml prolog and docType
481 *
482 * @param string $xmlPrologAndDocType Complete tags for xml prolog and docType
483 */
484 public function setXmlPrologAndDocType($xmlPrologAndDocType)
485 {
486 $this->xmlPrologAndDocType = $xmlPrologAndDocType;
487 }
488
489 /**
490 * Sets meta charset
491 *
492 * @param string $charSet Used charset
493 */
494 public function setCharSet($charSet)
495 {
496 $this->charSet = $charSet;
497 }
498
499 /**
500 * Sets language
501 *
502 * @param string $lang Used language
503 */
504 public function setLanguage($lang)
505 {
506 $this->lang = $lang;
507 $this->languageDependencies = [];
508
509 // Language is found. Configure it:
510 if (in_array($this->lang, $this->locales->getLocales())) {
511 $this->languageDependencies[] = $this->lang;
512 foreach ($this->locales->getLocaleDependencies($this->lang) as $language) {
513 $this->languageDependencies[] = $language;
514 }
515 }
516 }
517
518 /**
519 * Set the meta charset tag
520 *
521 * @param string $metaCharsetTag
522 */
523 public function setMetaCharsetTag($metaCharsetTag)
524 {
525 $this->metaCharsetTag = $metaCharsetTag;
526 }
527
528 /**
529 * Sets html tag
530 *
531 * @param string $htmlTag Html tag
532 */
533 public function setHtmlTag($htmlTag)
534 {
535 $this->htmlTag = $htmlTag;
536 }
537
538 /**
539 * Sets HTML head tag
540 *
541 * @param string $headTag HTML head tag
542 */
543 public function setHeadTag($headTag)
544 {
545 $this->headTag = $headTag;
546 }
547
548 /**
549 * Sets favicon
550 *
551 * @param string $favIcon
552 */
553 public function setFavIcon($favIcon)
554 {
555 $this->favIcon = $favIcon;
556 }
557
558 /**
559 * Sets icon mime type
560 *
561 * @param string $iconMimeType
562 */
563 public function setIconMimeType($iconMimeType)
564 {
565 $this->iconMimeType = $iconMimeType;
566 }
567
568 /**
569 * Sets HTML base URL
570 *
571 * @param string $baseUrl HTML base URL
572 */
573 public function setBaseUrl($baseUrl)
574 {
575 $this->baseUrl = $baseUrl;
576 }
577
578 /**
579 * Sets template file
580 *
581 * @param string $file
582 */
583 public function setTemplateFile($file)
584 {
585 $this->templateFile = $file;
586 }
587
588 /**
589 * Sets Content for Body
590 *
591 * @param string $content
592 */
593 public function setBodyContent($content)
594 {
595 $this->bodyContent = $content;
596 }
597
598 /**
599 * Sets path to requireJS library (relative to typo3 directory)
600 *
601 * @param string $path Path to requireJS library
602 */
603 public function setRequireJsPath($path)
604 {
605 $this->requireJsPath = $path;
606 }
607
608 /**
609 * Sets Path for ExtJs library (relative to typo3 directory)
610 *
611 * @param string $path
612 */
613 public function setExtJsPath($path)
614 {
615 $this->extJsPath = $path;
616 }
617
618 /*****************************************************/
619 /* */
620 /* Public Enablers / Disablers */
621 /* */
622 /* */
623 /*****************************************************/
624 /**
625 * Enables MoveJsFromHeaderToFooter
626 */
627 public function enableMoveJsFromHeaderToFooter()
628 {
629 $this->moveJsFromHeaderToFooter = true;
630 }
631
632 /**
633 * Disables MoveJsFromHeaderToFooter
634 */
635 public function disableMoveJsFromHeaderToFooter()
636 {
637 $this->moveJsFromHeaderToFooter = false;
638 }
639
640 /**
641 * Enables compression of javascript
642 */
643 public function enableCompressJavascript()
644 {
645 $this->compressJavascript = true;
646 }
647
648 /**
649 * Disables compression of javascript
650 */
651 public function disableCompressJavascript()
652 {
653 $this->compressJavascript = false;
654 }
655
656 /**
657 * Enables compression of css
658 */
659 public function enableCompressCss()
660 {
661 $this->compressCss = true;
662 }
663
664 /**
665 * Disables compression of css
666 */
667 public function disableCompressCss()
668 {
669 $this->compressCss = false;
670 }
671
672 /**
673 * Enables concatenation of js and css files
674 */
675 public function enableConcatenateFiles()
676 {
677 $this->concatenateFiles = true;
678 }
679
680 /**
681 * Disables concatenation of js and css files
682 */
683 public function disableConcatenateFiles()
684 {
685 $this->concatenateFiles = false;
686 }
687
688 /**
689 * Enables concatenation of js files
690 */
691 public function enableConcatenateJavascript()
692 {
693 $this->concatenateJavascript = true;
694 }
695
696 /**
697 * Disables concatenation of js files
698 */
699 public function disableConcatenateJavascript()
700 {
701 $this->concatenateJavascript = false;
702 }
703
704 /**
705 * Enables concatenation of css files
706 */
707 public function enableConcatenateCss()
708 {
709 $this->concatenateCss = true;
710 }
711
712 /**
713 * Disables concatenation of css files
714 */
715 public function disableConcatenateCss()
716 {
717 $this->concatenateCss = false;
718 }
719
720 /**
721 * Sets removal of all line breaks in template
722 */
723 public function enableRemoveLineBreaksFromTemplate()
724 {
725 $this->removeLineBreaksFromTemplate = true;
726 }
727
728 /**
729 * Unsets removal of all line breaks in template
730 */
731 public function disableRemoveLineBreaksFromTemplate()
732 {
733 $this->removeLineBreaksFromTemplate = false;
734 }
735
736 /**
737 * Enables Debug Mode
738 * This is a shortcut to switch off all compress/concatenate features to enable easier debug
739 */
740 public function enableDebugMode()
741 {
742 $this->compressJavascript = false;
743 $this->compressCss = false;
744 $this->concatenateFiles = false;
745 $this->removeLineBreaksFromTemplate = false;
746 $this->enableExtJsDebug = true;
747 $this->enableJqueryDebug = true;
748 }
749
750 /*****************************************************/
751 /* */
752 /* Public Getters */
753 /* */
754 /* */
755 /*****************************************************/
756 /**
757 * Gets the title
758 *
759 * @return string $title Title of webpage
760 */
761 public function getTitle()
762 {
763 return $this->title;
764 }
765
766 /**
767 * Gets the charSet
768 *
769 * @return string $charSet
770 */
771 public function getCharSet()
772 {
773 return $this->charSet;
774 }
775
776 /**
777 * Gets the language
778 *
779 * @return string $lang
780 */
781 public function getLanguage()
782 {
783 return $this->lang;
784 }
785
786 /**
787 * Returns rendering mode XHTML or HTML
788 *
789 * @return bool TRUE if XHTML, FALSE if HTML
790 */
791 public function getRenderXhtml()
792 {
793 return $this->renderXhtml;
794 }
795
796 /**
797 * Gets html tag
798 *
799 * @return string $htmlTag Html tag
800 */
801 public function getHtmlTag()
802 {
803 return $this->htmlTag;
804 }
805
806 /**
807 * Get meta charset
808 *
809 * @return string
810 */
811 public function getMetaCharsetTag()
812 {
813 return $this->metaCharsetTag;
814 }
815
816 /**
817 * Gets head tag
818 *
819 * @return string $tag Head tag
820 */
821 public function getHeadTag()
822 {
823 return $this->headTag;
824 }
825
826 /**
827 * Gets favicon
828 *
829 * @return string $favIcon
830 */
831 public function getFavIcon()
832 {
833 return $this->favIcon;
834 }
835
836 /**
837 * Gets icon mime type
838 *
839 * @return string $iconMimeType
840 */
841 public function getIconMimeType()
842 {
843 return $this->iconMimeType;
844 }
845
846 /**
847 * Gets HTML base URL
848 *
849 * @return string $url
850 */
851 public function getBaseUrl()
852 {
853 return $this->baseUrl;
854 }
855
856 /**
857 * Gets template file
858 *
859 * @return string
860 */
861 public function getTemplateFile()
862 {
863 return $this->templateFile;
864 }
865
866 /**
867 * Gets MoveJsFromHeaderToFooter
868 *
869 * @return bool
870 */
871 public function getMoveJsFromHeaderToFooter()
872 {
873 return $this->moveJsFromHeaderToFooter;
874 }
875
876 /**
877 * Gets compress of javascript
878 *
879 * @return bool
880 */
881 public function getCompressJavascript()
882 {
883 return $this->compressJavascript;
884 }
885
886 /**
887 * Gets compress of css
888 *
889 * @return bool
890 */
891 public function getCompressCss()
892 {
893 return $this->compressCss;
894 }
895
896 /**
897 * Gets concatenate of js and css files
898 *
899 * @return bool
900 */
901 public function getConcatenateFiles()
902 {
903 return $this->concatenateFiles;
904 }
905
906 /**
907 * Gets concatenate of js files
908 *
909 * @return bool
910 */
911 public function getConcatenateJavascript()
912 {
913 return $this->concatenateJavascript;
914 }
915
916 /**
917 * Gets concatenate of css files
918 *
919 * @return bool
920 */
921 public function getConcatenateCss()
922 {
923 return $this->concatenateCss;
924 }
925
926 /**
927 * Gets remove of empty lines from template
928 *
929 * @return bool
930 */
931 public function getRemoveLineBreaksFromTemplate()
932 {
933 return $this->removeLineBreaksFromTemplate;
934 }
935
936 /**
937 * Gets content for body
938 *
939 * @return string
940 */
941 public function getBodyContent()
942 {
943 return $this->bodyContent;
944 }
945
946 /**
947 * Gets Path for ExtJs library (relative to typo3 directory)
948 *
949 * @return string
950 */
951 public function getExtJsPath()
952 {
953 return $this->extJsPath;
954 }
955
956 /**
957 * Gets the inline language labels.
958 *
959 * @return array The inline language labels
960 */
961 public function getInlineLanguageLabels()
962 {
963 return $this->inlineLanguageLabels;
964 }
965
966 /**
967 * Gets the inline language files
968 *
969 * @return array
970 */
971 public function getInlineLanguageLabelFiles()
972 {
973 return $this->inlineLanguageLabelFiles;
974 }
975
976 /*****************************************************/
977 /* */
978 /* Public Functions to add Data */
979 /* */
980 /* */
981 /*****************************************************/
982 /**
983 * Adds meta data
984 *
985 * @param string $meta Meta data (complete metatag)
986 */
987 public function addMetaTag($meta)
988 {
989 if (!in_array($meta, $this->metaTags)) {
990 $this->metaTags[] = $meta;
991 }
992 }
993
994 /**
995 * Adds inline HTML comment
996 *
997 * @param string $comment
998 */
999 public function addInlineComment($comment)
1000 {
1001 if (!in_array($comment, $this->inlineComments)) {
1002 $this->inlineComments[] = $comment;
1003 }
1004 }
1005
1006 /**
1007 * Adds header data
1008 *
1009 * @param string $data Free header data for HTML header
1010 */
1011 public function addHeaderData($data)
1012 {
1013 if (!in_array($data, $this->headerData)) {
1014 $this->headerData[] = $data;
1015 }
1016 }
1017
1018 /**
1019 * Adds footer data
1020 *
1021 * @param string $data Free header data for HTML header
1022 */
1023 public function addFooterData($data)
1024 {
1025 if (!in_array($data, $this->footerData)) {
1026 $this->footerData[] = $data;
1027 }
1028 }
1029
1030 /**
1031 * Adds JS Library. JS Library block is rendered on top of the JS files.
1032 *
1033 * @param string $name Arbitrary identifier
1034 * @param string $file File name
1035 * @param string $type Content Type
1036 * @param bool $compress Flag if library should be compressed
1037 * @param bool $forceOnTop Flag if added library should be inserted at begin of this block
1038 * @param string $allWrap
1039 * @param bool $excludeFromConcatenation
1040 * @param string $splitChar The char used to split the allWrap value, default is "|"
1041 * @param bool $async Flag if property 'async="async"' should be added to JavaScript tags
1042 * @param string $integrity Subresource Integrity (SRI)
1043 */
1044 public function addJsLibrary($name, $file, $type = 'text/javascript', $compress = false, $forceOnTop = false, $allWrap = '', $excludeFromConcatenation = false, $splitChar = '|', $async = false, $integrity = '')
1045 {
1046 if (!$type) {
1047 $type = 'text/javascript';
1048 }
1049 if (!in_array(strtolower($name), $this->jsLibs)) {
1050 $this->jsLibs[strtolower($name)] = [
1051 'file' => $file,
1052 'type' => $type,
1053 'section' => self::PART_HEADER,
1054 'compress' => $compress,
1055 'forceOnTop' => $forceOnTop,
1056 'allWrap' => $allWrap,
1057 'excludeFromConcatenation' => $excludeFromConcatenation,
1058 'splitChar' => $splitChar,
1059 'async' => $async,
1060 'integrity' => $integrity,
1061 ];
1062 }
1063 }
1064
1065 /**
1066 * Adds JS Library to Footer. JS Library block is rendered on top of the Footer JS files.
1067 *
1068 * @param string $name Arbitrary identifier
1069 * @param string $file File name
1070 * @param string $type Content Type
1071 * @param bool $compress Flag if library should be compressed
1072 * @param bool $forceOnTop Flag if added library should be inserted at begin of this block
1073 * @param string $allWrap
1074 * @param bool $excludeFromConcatenation
1075 * @param string $splitChar The char used to split the allWrap value, default is "|"
1076 * @param bool $async Flag if property 'async="async"' should be added to JavaScript tags
1077 * @param string $integrity Subresource Integrity (SRI)
1078 */
1079 public function addJsFooterLibrary($name, $file, $type = 'text/javascript', $compress = false, $forceOnTop = false, $allWrap = '', $excludeFromConcatenation = false, $splitChar = '|', $async = false, $integrity = '')
1080 {
1081 if (!$type) {
1082 $type = 'text/javascript';
1083 }
1084 if (!in_array(strtolower($name), $this->jsLibs)) {
1085 $this->jsLibs[strtolower($name)] = [
1086 'file' => $file,
1087 'type' => $type,
1088 'section' => self::PART_FOOTER,
1089 'compress' => $compress,
1090 'forceOnTop' => $forceOnTop,
1091 'allWrap' => $allWrap,
1092 'excludeFromConcatenation' => $excludeFromConcatenation,
1093 'splitChar' => $splitChar,
1094 'async' => $async,
1095 'integrity' => $integrity,
1096 ];
1097 }
1098 }
1099
1100 /**
1101 * Adds JS file
1102 *
1103 * @param string $file File name
1104 * @param string $type Content Type
1105 * @param bool $compress
1106 * @param bool $forceOnTop
1107 * @param string $allWrap
1108 * @param bool $excludeFromConcatenation
1109 * @param string $splitChar The char used to split the allWrap value, default is "|"
1110 * @param bool $async Flag if property 'async="async"' should be added to JavaScript tags
1111 * @param string $integrity Subresource Integrity (SRI)
1112 */
1113 public function addJsFile($file, $type = 'text/javascript', $compress = true, $forceOnTop = false, $allWrap = '', $excludeFromConcatenation = false, $splitChar = '|', $async = false, $integrity = '')
1114 {
1115 if (!$type) {
1116 $type = 'text/javascript';
1117 }
1118 if (!isset($this->jsFiles[$file])) {
1119 $this->jsFiles[$file] = [
1120 'file' => $file,
1121 'type' => $type,
1122 'section' => self::PART_HEADER,
1123 'compress' => $compress,
1124 'forceOnTop' => $forceOnTop,
1125 'allWrap' => $allWrap,
1126 'excludeFromConcatenation' => $excludeFromConcatenation,
1127 'splitChar' => $splitChar,
1128 'async' => $async,
1129 'integrity' => $integrity,
1130 ];
1131 }
1132 }
1133
1134 /**
1135 * Adds JS file to footer
1136 *
1137 * @param string $file File name
1138 * @param string $type Content Type
1139 * @param bool $compress
1140 * @param bool $forceOnTop
1141 * @param string $allWrap
1142 * @param bool $excludeFromConcatenation
1143 * @param string $splitChar The char used to split the allWrap value, default is "|"
1144 * @param bool $async Flag if property 'async="async"' should be added to JavaScript tags
1145 * @param string $integrity Subresource Integrity (SRI)
1146 */
1147 public function addJsFooterFile($file, $type = 'text/javascript', $compress = true, $forceOnTop = false, $allWrap = '', $excludeFromConcatenation = false, $splitChar = '|', $async = false, $integrity = '')
1148 {
1149 if (!$type) {
1150 $type = 'text/javascript';
1151 }
1152 if (!isset($this->jsFiles[$file])) {
1153 $this->jsFiles[$file] = [
1154 'file' => $file,
1155 'type' => $type,
1156 'section' => self::PART_FOOTER,
1157 'compress' => $compress,
1158 'forceOnTop' => $forceOnTop,
1159 'allWrap' => $allWrap,
1160 'excludeFromConcatenation' => $excludeFromConcatenation,
1161 'splitChar' => $splitChar,
1162 'async' => $async,
1163 'integrity' => $integrity,
1164 ];
1165 }
1166 }
1167
1168 /**
1169 * Adds JS inline code
1170 *
1171 * @param string $name
1172 * @param string $block
1173 * @param bool $compress
1174 * @param bool $forceOnTop
1175 */
1176 public function addJsInlineCode($name, $block, $compress = true, $forceOnTop = false)
1177 {
1178 if (!isset($this->jsInline[$name]) && !empty($block)) {
1179 $this->jsInline[$name] = [
1180 'code' => $block . LF,
1181 'section' => self::PART_HEADER,
1182 'compress' => $compress,
1183 'forceOnTop' => $forceOnTop
1184 ];
1185 }
1186 }
1187
1188 /**
1189 * Adds JS inline code to footer
1190 *
1191 * @param string $name
1192 * @param string $block
1193 * @param bool $compress
1194 * @param bool $forceOnTop
1195 */
1196 public function addJsFooterInlineCode($name, $block, $compress = true, $forceOnTop = false)
1197 {
1198 if (!isset($this->jsInline[$name]) && !empty($block)) {
1199 $this->jsInline[$name] = [
1200 'code' => $block . LF,
1201 'section' => self::PART_FOOTER,
1202 'compress' => $compress,
1203 'forceOnTop' => $forceOnTop
1204 ];
1205 }
1206 }
1207
1208 /**
1209 * Adds Ext.onready code, which will be wrapped in Ext.onReady(function() {...});
1210 *
1211 * @param string $block Javascript code
1212 * @param bool $forceOnTop Position of the javascript code (TRUE for putting it on top, default is FALSE = bottom)
1213 */
1214 public function addExtOnReadyCode($block, $forceOnTop = false)
1215 {
1216 if (!in_array($block, $this->extOnReadyCode)) {
1217 if ($forceOnTop) {
1218 array_unshift($this->extOnReadyCode, $block);
1219 } else {
1220 $this->extOnReadyCode[] = $block;
1221 }
1222 }
1223 }
1224
1225 /**
1226 * Adds the ExtDirect code
1227 *
1228 * @param array $filterNamespaces Limit the output to defined namespaces. If empty, all namespaces are generated
1229 */
1230 public function addExtDirectCode(array $filterNamespaces = [])
1231 {
1232 if ($this->extDirectCodeAdded) {
1233 return;
1234 }
1235 $this->extDirectCodeAdded = true;
1236 if (empty($filterNamespaces)) {
1237 $filterNamespaces = ['TYPO3'];
1238 }
1239
1240 // Add language labels for ExtDirect
1241 $this->addInlineLanguageLabelArray([
1242 'extDirect_timeoutHeader' => 'LLL:EXT:lang/Resources/Private/Language/locallang_misc.xlf:extDirect_timeoutHeader',
1243 'extDirect_timeoutMessage' => 'LLL:EXT:lang/Resources/Private/Language/locallang_misc.xlf:extDirect_timeoutMessage'
1244 ], true);
1245
1246 $token = ($api = '');
1247 if (TYPO3_MODE === 'BE') {
1248 $formprotection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
1249 $token = $formprotection->generateToken('extDirect');
1250
1251 // Debugger Console strings
1252 $this->addInlineLanguageLabelFile('EXT:core/Resources/Private/Language/debugger.xlf');
1253
1254 $this->addInlineLanguageLabelFile('EXT:core/Resources/Private/Language/wizard.xlf');
1255 }
1256 /** @var $extDirect \TYPO3\CMS\Core\ExtDirect\ExtDirectApi */
1257 $extDirect = GeneralUtility::makeInstance(\TYPO3\CMS\Core\ExtDirect\ExtDirectApi::class);
1258 $api = $extDirect->getApiPhp($filterNamespaces);
1259 if ($api) {
1260 $this->addJsInlineCode('TYPO3ExtDirectAPI', $api, false);
1261 }
1262 // Note: we need to iterate through the object, because the addProvider method
1263 // does this only with multiple arguments
1264 $this->addExtOnReadyCode('
1265 (function() {
1266 TYPO3.ExtDirectToken = "' . $token . '";
1267 for (var api in Ext.app.ExtDirectAPI) {
1268 var provider = Ext.Direct.addProvider(Ext.app.ExtDirectAPI[api]);
1269 provider.on("beforecall", function(provider, transaction, meta) {
1270 if (transaction.data) {
1271 transaction.data[transaction.data.length] = TYPO3.ExtDirectToken;
1272 } else {
1273 transaction.data = [TYPO3.ExtDirectToken];
1274 }
1275 });
1276
1277 provider.on("call", function(provider, transaction, meta) {
1278 if (transaction.isForm) {
1279 transaction.params.securityToken = TYPO3.ExtDirectToken;
1280 }
1281 });
1282 }
1283 })();
1284
1285 var extDirectDebug = function(message, header, group) {
1286 var DebugConsole = null;
1287
1288 if (top && top.TYPO3 && typeof top.TYPO3.DebugConsole === "object") {
1289 DebugConsole = top.TYPO3.DebugConsole;
1290 } else if (typeof TYPO3 === "object" && typeof TYPO3.DebugConsole === "object") {
1291 DebugConsole = TYPO3.DebugConsole;
1292 }
1293
1294 if (DebugConsole !== null) {
1295 DebugConsole.add(message, header, group);
1296 } else if (typeof console === "object") {
1297 console.log(message);
1298 } else {
1299 document.write(message);
1300 }
1301 };
1302
1303 Ext.Direct.on("exception", function(event) {
1304 if (event.code === Ext.Direct.exceptions.TRANSPORT && !event.where) {
1305 top.TYPO3.Notification.error(
1306 TYPO3.l10n.localize("extDirect_timeoutHeader"),
1307 TYPO3.l10n.localize("extDirect_timeoutMessage")
1308 );
1309 } else {
1310 var backtrace = "";
1311 if (event.code === "parse") {
1312 extDirectDebug(
1313 "<p>" + event.xhr.responseText + "<\\/p>",
1314 event.type,
1315 "ExtDirect - Exception"
1316 );
1317 } else if (event.code === "router") {
1318 top.TYPO3.Notification.error(
1319 event.code,
1320 event.message
1321 );
1322 } else if (event.where) {
1323 backtrace = "<p style=\\"margin-top: 20px;\\">" +
1324 "<strong>Backtrace:<\\/strong><br \\/>" +
1325 event.where.replace(/#/g, "<br \\/>#") +
1326 "<\\/p>";
1327 extDirectDebug(
1328 "<p>" + event.message + "<\\/p>" + backtrace,
1329 event.method,
1330 "ExtDirect - Exception"
1331 );
1332 }
1333
1334
1335 }
1336 });
1337
1338 Ext.Direct.on("event", function(event, provider) {
1339 if (typeof event.debug !== "undefined" && event.debug !== "") {
1340 extDirectDebug(event.debug, event.method, "ExtDirect - Debug");
1341 }
1342 });
1343 ', true);
1344 }
1345
1346 /**
1347 * Adds CSS file
1348 *
1349 * @param string $file
1350 * @param string $rel
1351 * @param string $media
1352 * @param string $title
1353 * @param bool $compress
1354 * @param bool $forceOnTop
1355 * @param string $allWrap
1356 * @param bool $excludeFromConcatenation
1357 * @param string $splitChar The char used to split the allWrap value, default is "|"
1358 */
1359 public function addCssFile($file, $rel = 'stylesheet', $media = 'all', $title = '', $compress = true, $forceOnTop = false, $allWrap = '', $excludeFromConcatenation = false, $splitChar = '|')
1360 {
1361 if (!isset($this->cssFiles[$file])) {
1362 $this->cssFiles[$file] = [
1363 'file' => $file,
1364 'rel' => $rel,
1365 'media' => $media,
1366 'title' => $title,
1367 'compress' => $compress,
1368 'forceOnTop' => $forceOnTop,
1369 'allWrap' => $allWrap,
1370 'excludeFromConcatenation' => $excludeFromConcatenation,
1371 'splitChar' => $splitChar
1372 ];
1373 }
1374 }
1375
1376 /**
1377 * Adds CSS file
1378 *
1379 * @param string $file
1380 * @param string $rel
1381 * @param string $media
1382 * @param string $title
1383 * @param bool $compress
1384 * @param bool $forceOnTop
1385 * @param string $allWrap
1386 * @param bool $excludeFromConcatenation
1387 * @param string $splitChar The char used to split the allWrap value, default is "|"
1388 */
1389 public function addCssLibrary($file, $rel = 'stylesheet', $media = 'all', $title = '', $compress = true, $forceOnTop = false, $allWrap = '', $excludeFromConcatenation = false, $splitChar = '|')
1390 {
1391 if (!isset($this->cssLibs[$file])) {
1392 $this->cssLibs[$file] = [
1393 'file' => $file,
1394 'rel' => $rel,
1395 'media' => $media,
1396 'title' => $title,
1397 'compress' => $compress,
1398 'forceOnTop' => $forceOnTop,
1399 'allWrap' => $allWrap,
1400 'excludeFromConcatenation' => $excludeFromConcatenation,
1401 'splitChar' => $splitChar
1402 ];
1403 }
1404 }
1405
1406 /**
1407 * Adds CSS inline code
1408 *
1409 * @param string $name
1410 * @param string $block
1411 * @param bool $compress
1412 * @param bool $forceOnTop
1413 */
1414 public function addCssInlineBlock($name, $block, $compress = false, $forceOnTop = false)
1415 {
1416 if (!isset($this->cssInline[$name]) && !empty($block)) {
1417 $this->cssInline[$name] = [
1418 'code' => $block,
1419 'compress' => $compress,
1420 'forceOnTop' => $forceOnTop
1421 ];
1422 }
1423 }
1424
1425 /**
1426 * Call this function if you need to include the jQuery library
1427 *
1428 * @param null|string $version The jQuery version that should be included, either "latest" or any available version
1429 * @param null|string $source The location of the jQuery source, can be "local", "google", "msn", "jquery" or just an URL to your jQuery lib
1430 * @param string $namespace The namespace in which the jQuery object of the specific version should be stored.
1431 * @throws \UnexpectedValueException
1432 */
1433 public function loadJquery($version = null, $source = null, $namespace = self::JQUERY_NAMESPACE_DEFAULT)
1434 {
1435 // Set it to the version that is shipped with the TYPO3 core
1436 if ($version === null || $version === 'latest') {
1437 $version = self::JQUERY_VERSION_LATEST;
1438 }
1439 // Check if the source is set, otherwise set it to "default"
1440 if ($source === null) {
1441 $source = 'local';
1442 }
1443 if ($source === 'local' && !in_array($version, $this->availableLocalJqueryVersions)) {
1444 throw new \UnexpectedValueException('The requested jQuery version is not available in the local filesystem.', 1341505305);
1445 }
1446 if (!preg_match('/^[a-zA-Z0-9]+$/', $namespace)) {
1447 throw new \UnexpectedValueException('The requested namespace contains non alphanumeric characters.', 1341571604);
1448 }
1449 $this->jQueryVersions[$namespace] = [
1450 'version' => $version,
1451 'source' => $source
1452 ];
1453 }
1454
1455 /**
1456 * Call function if you need the requireJS library
1457 * this automatically adds the JavaScript path of all loaded extensions in the requireJS path option
1458 * so it resolves names like TYPO3/CMS/MyExtension/MyJsFile to EXT:MyExtension/Resources/Public/JavaScript/MyJsFile.js
1459 * when using requireJS
1460 */
1461 public function loadRequireJs()
1462 {
1463 if (!empty($this->requireJsConfig)) {
1464 return;
1465 }
1466 $this->addRequireJs = true;
1467
1468 $loadedExtensions = ExtensionManagementUtility::getLoadedExtensionListArray();
1469 $isDevelopment = GeneralUtility::getApplicationContext()->isDevelopment();
1470 $cacheIdentifier = 'requireJS_' . md5(implode(',', $loadedExtensions) . ($isDevelopment ? ':dev' : ''));
1471 /** @var VariableFrontend $cache */
1472 $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('assets');
1473 $this->requireJsConfig = $cache->get($cacheIdentifier);
1474
1475 // if we did not get a configuration from the cache, compute and store it in the cache
1476 if (empty($this->requireJsConfig)) {
1477 $this->requireJsConfig = $this->computeRequireJsConfig($isDevelopment, $loadedExtensions);
1478 $cache->set($cacheIdentifier, $this->requireJsConfig);
1479 }
1480 }
1481
1482 /**
1483 * Computes the RequireJS configuration, mainly consisting of the paths to the core and all extension JavaScript
1484 * resource folders plus some additional generic configuration.
1485 *
1486 * @param bool $isDevelopment
1487 * @param array $loadedExtensions
1488 * @return array The RequireJS configuration
1489 */
1490 protected function computeRequireJsConfig($isDevelopment, array $loadedExtensions)
1491 {
1492 // load all paths to map to package names / namespaces
1493 $requireJsConfig = [];
1494
1495 // In order to avoid browser caching of JS files, adding a GET parameter to the files loaded via requireJS
1496 if ($isDevelopment) {
1497 $requireJsConfig['urlArgs'] = 'bust=' . $GLOBALS['EXEC_TIME'];
1498 } else {
1499 $requireJsConfig['urlArgs'] = 'bust=' . GeneralUtility::hmac(TYPO3_version . PATH_site);
1500 }
1501 $corePath = ExtensionManagementUtility::extPath('core', 'Resources/Public/JavaScript/Contrib/');
1502 $corePath = PathUtility::getAbsoluteWebPath($corePath);
1503 // first, load all paths for the namespaces, and configure contrib libs.
1504 $requireJsConfig['paths'] = [
1505 'jquery-ui' => $corePath . 'jquery-ui',
1506 'datatables' => $corePath . 'jquery.dataTables',
1507 'matchheight' => $corePath . 'jquery.matchHeight-min',
1508 'nprogress' => $corePath . 'nprogress',
1509 'moment' => $corePath . 'moment',
1510 'cropper' => $corePath . 'cropper.min',
1511 'imagesloaded' => $corePath . 'imagesloaded.pkgd.min',
1512 'bootstrap' => $corePath . 'bootstrap/bootstrap',
1513 'twbs/bootstrap-datetimepicker' => $corePath . 'bootstrap-datetimepicker',
1514 'autosize' => $corePath . 'autosize',
1515 'taboverride' => $corePath . 'taboverride.min',
1516 'twbs/bootstrap-slider' => $corePath . 'bootstrap-slider.min',
1517 'jquery/autocomplete' => $corePath . 'jquery.autocomplete',
1518 'd3' => $corePath . 'd3/d3'
1519 ];
1520
1521 foreach ($loadedExtensions as $packageName) {
1522 $fullJsPath = 'EXT:' . $packageName . '/Resources/Public/JavaScript/';
1523 $fullJsPath = GeneralUtility::getFileAbsFileName($fullJsPath);
1524 $fullJsPath = PathUtility::getAbsoluteWebPath($fullJsPath);
1525 $fullJsPath = rtrim($fullJsPath, '/');
1526 if ($fullJsPath) {
1527 $requireJsConfig['paths']['TYPO3/CMS/' . GeneralUtility::underscoredToUpperCamelCase($packageName)] = $fullJsPath;
1528 }
1529 }
1530
1531 // check if additional AMD modules need to be loaded if a single AMD module is initialized
1532 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules'])) {
1533 $this->addInlineSettingArray(
1534 'RequireJS.PostInitializationModules',
1535 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules']
1536 );
1537 }
1538
1539 return $requireJsConfig;
1540 }
1541
1542 /**
1543 * Add additional configuration to require js.
1544 *
1545 * Configuration will be merged recursive with overrule.
1546 *
1547 * To add another path mapping deliver the following configuration:
1548 * 'paths' => array(
1549 * 'EXTERN/mybootstrapjs' => 'sysext/.../twbs/bootstrap.min',
1550 * ),
1551 *
1552 * @param array $configuration The configuration that will be merged with existing one.
1553 */
1554 public function addRequireJsConfiguration(array $configuration)
1555 {
1556 if (TYPO3_MODE === 'BE') {
1557 // Load RequireJS in backend context at first. Doing this in FE could break the output
1558 $this->loadRequireJs();
1559 }
1560 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->requireJsConfig, $configuration);
1561 }
1562
1563 /**
1564 * includes an AMD-compatible JS file by resolving the ModuleName, and then requires the file via a requireJS request,
1565 * additionally allowing to execute JavaScript code afterwards
1566 *
1567 * this function only works for AMD-ready JS modules, used like "define('TYPO3/CMS/Backend/FormEngine..."
1568 * in the JS file
1569 *
1570 * TYPO3/CMS/Backend/FormEngine =>
1571 * "TYPO3": Vendor Name
1572 * "CMS": Product Name
1573 * "Backend": Extension Name
1574 * "FormEngine": FileName in the Resources/Public/JavaScript folder
1575 *
1576 * @param string $mainModuleName Must be in the form of "TYPO3/CMS/PackageName/ModuleName" e.g. "TYPO3/CMS/Backend/FormEngine"
1577 * @param string $callBackFunction loaded right after the requireJS loading, must be wrapped in function() {}
1578 */
1579 public function loadRequireJsModule($mainModuleName, $callBackFunction = null)
1580 {
1581 $inlineCodeKey = $mainModuleName;
1582 // make sure requireJS is initialized
1583 $this->loadRequireJs();
1584
1585 // execute the main module, and load a possible callback function
1586 $javaScriptCode = 'require(["' . $mainModuleName . '"]';
1587 if ($callBackFunction !== null) {
1588 $inlineCodeKey .= sha1($callBackFunction);
1589 $javaScriptCode .= ', ' . $callBackFunction;
1590 }
1591 $javaScriptCode .= ');';
1592 $this->addJsInlineCode('RequireJS-Module-' . $inlineCodeKey, $javaScriptCode);
1593 }
1594
1595 /**
1596 * call this function if you need the extJS library
1597 *
1598 * @param bool $css Flag, if set the ext-css will be loaded
1599 * @param bool $theme Flag, if set the ext-theme "grey" will be loaded
1600 */
1601 public function loadExtJS($css = true, $theme = true)
1602 {
1603 $this->addExtJS = true;
1604 $this->extJStheme = $theme;
1605 $this->extJScss = $css;
1606 }
1607
1608 /**
1609 * Call this function to load debug version of ExtJS. Use this for development only
1610 */
1611 public function enableExtJsDebug()
1612 {
1613 $this->enableExtJsDebug = true;
1614 }
1615
1616 /**
1617 * Adds Javascript Inline Label. This will occur in TYPO3.lang - object
1618 * The label can be used in scripts with TYPO3.lang.<key>
1619 * Need extJs loaded
1620 *
1621 * @param string $key
1622 * @param string $value
1623 */
1624 public function addInlineLanguageLabel($key, $value)
1625 {
1626 $this->inlineLanguageLabels[$key] = $value;
1627 }
1628
1629 /**
1630 * Adds Javascript Inline Label Array. This will occur in TYPO3.lang - object
1631 * The label can be used in scripts with TYPO3.lang.<key>
1632 * Array will be merged with existing array.
1633 * Need extJs loaded
1634 *
1635 * @param array $array
1636 * @param bool $parseWithLanguageService
1637 */
1638 public function addInlineLanguageLabelArray(array $array, $parseWithLanguageService = false)
1639 {
1640 if ($parseWithLanguageService === true) {
1641 foreach ($array as $key => $value) {
1642 if (TYPO3_MODE === 'FE') {
1643 $array[$key] = $this->getTypoScriptFrontendController()->sL($value);
1644 } else {
1645 $array[$key] = $this->getLanguageService()->sL($value);
1646 }
1647 }
1648 }
1649
1650 $this->inlineLanguageLabels = array_merge($this->inlineLanguageLabels, $array);
1651 }
1652
1653 /**
1654 * Gets labels to be used in JavaScript fetched from a locallang file.
1655 *
1656 * @param string $fileRef Input is a file-reference (see GeneralUtility::getFileAbsFileName). That file is expected to be a 'locallang.xlf' file containing a valid XML TYPO3 language structure.
1657 * @param string $selectionPrefix Prefix to select the correct labels (default: '')
1658 * @param string $stripFromSelectionName String to be removed from the label names in the output. (default: '')
1659 * @param int $errorMode Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception
1660 */
1661 public function addInlineLanguageLabelFile($fileRef, $selectionPrefix = '', $stripFromSelectionName = '', $errorMode = 0)
1662 {
1663 $index = md5($fileRef . $selectionPrefix . $stripFromSelectionName);
1664 if ($fileRef && !isset($this->inlineLanguageLabelFiles[$index])) {
1665 $this->inlineLanguageLabelFiles[$index] = [
1666 'fileRef' => $fileRef,
1667 'selectionPrefix' => $selectionPrefix,
1668 'stripFromSelectionName' => $stripFromSelectionName,
1669 'errorMode' => $errorMode
1670 ];
1671 }
1672 }
1673
1674 /**
1675 * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
1676 * The label can be used in scripts with TYPO3.setting.<key>
1677 * Need extJs loaded
1678 *
1679 * @param string $namespace
1680 * @param string $key
1681 * @param string $value
1682 */
1683 public function addInlineSetting($namespace, $key, $value)
1684 {
1685 if ($namespace) {
1686 if (strpos($namespace, '.')) {
1687 $parts = explode('.', $namespace);
1688 $a = &$this->inlineSettings;
1689 foreach ($parts as $part) {
1690 $a = &$a[$part];
1691 }
1692 $a[$key] = $value;
1693 } else {
1694 $this->inlineSettings[$namespace][$key] = $value;
1695 }
1696 } else {
1697 $this->inlineSettings[$key] = $value;
1698 }
1699 }
1700
1701 /**
1702 * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
1703 * The label can be used in scripts with TYPO3.setting.<key>
1704 * Array will be merged with existing array.
1705 * Need extJs loaded
1706 *
1707 * @param string $namespace
1708 * @param array $array
1709 */
1710 public function addInlineSettingArray($namespace, array $array)
1711 {
1712 if ($namespace) {
1713 if (strpos($namespace, '.')) {
1714 $parts = explode('.', $namespace);
1715 $a = &$this->inlineSettings;
1716 foreach ($parts as $part) {
1717 $a = &$a[$part];
1718 }
1719 $a = array_merge((array)$a, $array);
1720 } else {
1721 $this->inlineSettings[$namespace] = array_merge((array)$this->inlineSettings[$namespace], $array);
1722 }
1723 } else {
1724 $this->inlineSettings = array_merge($this->inlineSettings, $array);
1725 }
1726 }
1727
1728 /**
1729 * Adds content to body content
1730 *
1731 * @param string $content
1732 */
1733 public function addBodyContent($content)
1734 {
1735 $this->bodyContent .= $content;
1736 }
1737
1738 /*****************************************************/
1739 /* */
1740 /* Render Functions */
1741 /* */
1742 /*****************************************************/
1743 /**
1744 * Render the section (Header or Footer)
1745 *
1746 * @param int $part Section which should be rendered: self::PART_COMPLETE, self::PART_HEADER or self::PART_FOOTER
1747 * @return string Content of rendered section
1748 */
1749 public function render($part = self::PART_COMPLETE)
1750 {
1751 $this->prepareRendering();
1752 list($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs) = $this->renderJavaScriptAndCss();
1753 $metaTags = implode(LF, $this->metaTags);
1754 $markerArray = $this->getPreparedMarkerArray($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs, $metaTags);
1755 $template = $this->getTemplateForPart($part);
1756
1757 // The page renderer needs a full reset, even when only rendering one part of the page
1758 // This means that you can only register footer files *after* the header has been already rendered.
1759 // In case you render the footer part first, header files can only be added *after* the footer has been rendered
1760 $this->reset();
1761 $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
1762 return trim($templateService->substituteMarkerArray($template, $markerArray, '###|###'));
1763 }
1764
1765 /**
1766 * Render the page but not the JavaScript and CSS Files
1767 *
1768 * @param string $substituteHash The hash that is used for the placehoder markers
1769 * @access private
1770 * @return string Content of rendered section
1771 */
1772 public function renderPageWithUncachedObjects($substituteHash)
1773 {
1774 $this->prepareRendering();
1775 $markerArray = $this->getPreparedMarkerArrayForPageWithUncachedObjects($substituteHash);
1776 $template = $this->getTemplateForPart(self::PART_COMPLETE);
1777 $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
1778 return trim($templateService->substituteMarkerArray($template, $markerArray, '###|###'));
1779 }
1780
1781 /**
1782 * Renders the JavaScript and CSS files that have been added during processing
1783 * of uncached content objects (USER_INT, COA_INT)
1784 *
1785 * @param string $cachedPageContent
1786 * @param string $substituteHash The hash that is used for the placehoder markers
1787 * @access private
1788 * @return string
1789 */
1790 public function renderJavaScriptAndCssForProcessingOfUncachedContentObjects($cachedPageContent, $substituteHash)
1791 {
1792 $this->prepareRendering();
1793 list($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs) = $this->renderJavaScriptAndCss();
1794 $title = $this->title ? str_replace('|', htmlspecialchars($this->title), $this->titleTag) : '';
1795 $markerArray = [
1796 '<!-- ###TITLE' . $substituteHash . '### -->' => $title,
1797 '<!-- ###CSS_LIBS' . $substituteHash . '### -->' => $cssLibs,
1798 '<!-- ###CSS_INCLUDE' . $substituteHash . '### -->' => $cssFiles,
1799 '<!-- ###CSS_INLINE' . $substituteHash . '### -->' => $cssInline,
1800 '<!-- ###JS_INLINE' . $substituteHash . '### -->' => $jsInline,
1801 '<!-- ###JS_INCLUDE' . $substituteHash . '### -->' => $jsFiles,
1802 '<!-- ###JS_LIBS' . $substituteHash . '### -->' => $jsLibs,
1803 '<!-- ###META' . $substituteHash . '### -->' => implode(LF, $this->metaTags),
1804 '<!-- ###HEADERDATA' . $substituteHash . '### -->' => implode(LF, $this->headerData),
1805 '<!-- ###FOOTERDATA' . $substituteHash . '### -->' => implode(LF, $this->footerData),
1806 '<!-- ###JS_LIBS_FOOTER' . $substituteHash . '### -->' => $jsFooterLibs,
1807 '<!-- ###JS_INCLUDE_FOOTER' . $substituteHash . '### -->' => $jsFooterFiles,
1808 '<!-- ###JS_INLINE_FOOTER' . $substituteHash . '### -->' => $jsFooterInline
1809 ];
1810 foreach ($markerArray as $placeHolder => $content) {
1811 $cachedPageContent = str_replace($placeHolder, $content, $cachedPageContent);
1812 }
1813 $this->reset();
1814 return $cachedPageContent;
1815 }
1816
1817 /**
1818 * Remove ending slashes from static header block
1819 * if the page is being rendered as html (not xhtml)
1820 * and define property $this->endingSlash for further use
1821 */
1822 protected function prepareRendering()
1823 {
1824 if ($this->getRenderXhtml()) {
1825 $this->endingSlash = ' /';
1826 } else {
1827 $this->metaCharsetTag = str_replace(' />', '>', $this->metaCharsetTag);
1828 $this->baseUrlTag = str_replace(' />', '>', $this->baseUrlTag);
1829 $this->shortcutTag = str_replace(' />', '>', $this->shortcutTag);
1830 $this->endingSlash = '';
1831 }
1832 }
1833
1834 /**
1835 * Renders all JavaScript and CSS
1836 *
1837 * @return array<string>
1838 */
1839 protected function renderJavaScriptAndCss()
1840 {
1841 $this->executePreRenderHook();
1842 $mainJsLibs = $this->renderMainJavaScriptLibraries();
1843 if ($this->concatenateFiles || $this->concatenateJavascript || $this->concatenateCss) {
1844 // Do the file concatenation
1845 $this->doConcatenate();
1846 }
1847 if ($this->compressCss || $this->compressJavascript) {
1848 // Do the file compression
1849 $this->doCompress();
1850 }
1851 $this->executeRenderPostTransformHook();
1852 $cssLibs = $this->renderCssLibraries();
1853 $cssFiles = $this->renderCssFiles();
1854 $cssInline = $this->renderCssInline();
1855 list($jsLibs, $jsFooterLibs) = $this->renderAdditionalJavaScriptLibraries();
1856 list($jsFiles, $jsFooterFiles) = $this->renderJavaScriptFiles();
1857 list($jsInline, $jsFooterInline) = $this->renderInlineJavaScript();
1858 $jsLibs = $mainJsLibs . $jsLibs;
1859 if ($this->moveJsFromHeaderToFooter) {
1860 $jsFooterLibs = $jsLibs . LF . $jsFooterLibs;
1861 $jsLibs = '';
1862 $jsFooterFiles = $jsFiles . LF . $jsFooterFiles;
1863 $jsFiles = '';
1864 $jsFooterInline = $jsInline . LF . $jsFooterInline;
1865 $jsInline = '';
1866 }
1867 $this->executePostRenderHook($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs);
1868 return [$jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs];
1869 }
1870
1871 /**
1872 * Fills the marker array with the given strings and trims each value
1873 *
1874 * @param $jsLibs string
1875 * @param $jsFiles string
1876 * @param $jsFooterFiles string
1877 * @param $cssLibs string
1878 * @param $cssFiles string
1879 * @param $jsInline string
1880 * @param $cssInline string
1881 * @param $jsFooterInline string
1882 * @param $jsFooterLibs string
1883 * @param $metaTags string
1884 * @return array Marker array
1885 */
1886 protected function getPreparedMarkerArray($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs, $metaTags)
1887 {
1888 $markerArray = [
1889 'XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType,
1890 'HTMLTAG' => $this->htmlTag,
1891 'HEADTAG' => $this->headTag,
1892 'METACHARSET' => $this->charSet ? str_replace('|', htmlspecialchars($this->charSet), $this->metaCharsetTag) : '',
1893 'INLINECOMMENT' => $this->inlineComments ? LF . LF . '<!-- ' . LF . implode(LF, $this->inlineComments) . '-->' . LF . LF : '',
1894 'BASEURL' => $this->baseUrl ? str_replace('|', $this->baseUrl, $this->baseUrlTag) : '',
1895 'SHORTCUT' => $this->favIcon ? sprintf($this->shortcutTag, htmlspecialchars($this->favIcon), $this->iconMimeType) : '',
1896 'CSS_LIBS' => $cssLibs,
1897 'CSS_INCLUDE' => $cssFiles,
1898 'CSS_INLINE' => $cssInline,
1899 'JS_INLINE' => $jsInline,
1900 'JS_INCLUDE' => $jsFiles,
1901 'JS_LIBS' => $jsLibs,
1902 'TITLE' => $this->title ? str_replace('|', htmlspecialchars($this->title), $this->titleTag) : '',
1903 'META' => $metaTags,
1904 'HEADERDATA' => $this->headerData ? implode(LF, $this->headerData) : '',
1905 'FOOTERDATA' => $this->footerData ? implode(LF, $this->footerData) : '',
1906 'JS_LIBS_FOOTER' => $jsFooterLibs,
1907 'JS_INCLUDE_FOOTER' => $jsFooterFiles,
1908 'JS_INLINE_FOOTER' => $jsFooterInline,
1909 'BODY' => $this->bodyContent
1910 ];
1911 $markerArray = array_map('trim', $markerArray);
1912 return $markerArray;
1913 }
1914
1915 /**
1916 * Fills the marker array with the given strings and trims each value
1917 *
1918 * @param string $substituteHash The hash that is used for the placehoder markers
1919 * @return array Marker array
1920 */
1921 protected function getPreparedMarkerArrayForPageWithUncachedObjects($substituteHash)
1922 {
1923 $markerArray = [
1924 'XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType,
1925 'HTMLTAG' => $this->htmlTag,
1926 'HEADTAG' => $this->headTag,
1927 'METACHARSET' => $this->charSet ? str_replace('|', htmlspecialchars($this->charSet), $this->metaCharsetTag) : '',
1928 'INLINECOMMENT' => $this->inlineComments ? LF . LF . '<!-- ' . LF . implode(LF, $this->inlineComments) . '-->' . LF . LF : '',
1929 'BASEURL' => $this->baseUrl ? str_replace('|', $this->baseUrl, $this->baseUrlTag) : '',
1930 'SHORTCUT' => $this->favIcon ? sprintf($this->shortcutTag, htmlspecialchars($this->favIcon), $this->iconMimeType) : '',
1931 'META' => '<!-- ###META' . $substituteHash . '### -->',
1932 'BODY' => $this->bodyContent,
1933 'TITLE' => '<!-- ###TITLE' . $substituteHash . '### -->',
1934 'CSS_LIBS' => '<!-- ###CSS_LIBS' . $substituteHash . '### -->',
1935 'CSS_INCLUDE' => '<!-- ###CSS_INCLUDE' . $substituteHash . '### -->',
1936 'CSS_INLINE' => '<!-- ###CSS_INLINE' . $substituteHash . '### -->',
1937 'JS_INLINE' => '<!-- ###JS_INLINE' . $substituteHash . '### -->',
1938 'JS_INCLUDE' => '<!-- ###JS_INCLUDE' . $substituteHash . '### -->',
1939 'JS_LIBS' => '<!-- ###JS_LIBS' . $substituteHash . '### -->',
1940 'HEADERDATA' => '<!-- ###HEADERDATA' . $substituteHash . '### -->',
1941 'FOOTERDATA' => '<!-- ###FOOTERDATA' . $substituteHash . '### -->',
1942 'JS_LIBS_FOOTER' => '<!-- ###JS_LIBS_FOOTER' . $substituteHash . '### -->',
1943 'JS_INCLUDE_FOOTER' => '<!-- ###JS_INCLUDE_FOOTER' . $substituteHash . '### -->',
1944 'JS_INLINE_FOOTER' => '<!-- ###JS_INLINE_FOOTER' . $substituteHash . '### -->'
1945 ];
1946 $markerArray = array_map('trim', $markerArray);
1947 return $markerArray;
1948 }
1949
1950 /**
1951 * Reads the template file and returns the requested part as string
1952 *
1953 * @param int $part
1954 * @return string
1955 */
1956 protected function getTemplateForPart($part)
1957 {
1958 $templateFile = GeneralUtility::getFileAbsFileName($this->templateFile);
1959 if (is_file($templateFile)) {
1960 $template = file_get_contents($templateFile);
1961 if ($this->removeLineBreaksFromTemplate) {
1962 $template = strtr($template, [LF => '', CR => '']);
1963 }
1964 if ($part !== self::PART_COMPLETE) {
1965 $templatePart = explode('###BODY###', $template);
1966 $template = $templatePart[$part - 1];
1967 }
1968 } else {
1969 $template = '';
1970 }
1971 return $template;
1972 }
1973
1974 /**
1975 * Helper function for render the main JavaScript libraries,
1976 * currently: RequireJS, jQuery, ExtJS
1977 *
1978 * @return string Content with JavaScript libraries
1979 */
1980 protected function renderMainJavaScriptLibraries()
1981 {
1982 $out = '';
1983
1984 // Include RequireJS
1985 if ($this->addRequireJs) {
1986 // load the paths of the requireJS configuration
1987 $out .= GeneralUtility::wrapJS('var require = ' . json_encode($this->requireJsConfig)) . LF;
1988 // directly after that, include the require.js file
1989 $out .= '<script src="' . $this->processJsFile($this->requireJsPath . 'require.js') . '" type="text/javascript"></script>' . LF;
1990 }
1991
1992 // Include jQuery Core for each namespace, depending on the version and source
1993 if (!empty($this->jQueryVersions)) {
1994 foreach ($this->jQueryVersions as $namespace => $jQueryVersion) {
1995 $out .= $this->renderJqueryScriptTag($jQueryVersion['version'], $jQueryVersion['source'], $namespace);
1996 }
1997 }
1998
1999 // Include extJS
2000 if ($this->addExtJS) {
2001 // Use the base adapter all the time
2002 $out .= '<script src="' . $this->processJsFile($this->extJsPath . 'adapter/ext-base' . ($this->enableExtJsDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF;
2003 $out .= '<script src="' . $this->processJsFile($this->extJsPath . 'ext-all' . ($this->enableExtJsDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF;
2004 // Add extJS localization
2005 // Load standard ISO mapping and modify for use with ExtJS
2006 $localeMap = $this->locales->getIsoMapping();
2007 $localeMap[''] = 'en';
2008 $localeMap['default'] = 'en';
2009 // Greek
2010 $localeMap['gr'] = 'el_GR';
2011 // Norwegian Bokmaal
2012 $localeMap['no'] = 'no_BO';
2013 // Swedish
2014 $localeMap['se'] = 'se_SV';
2015 $extJsLang = isset($localeMap[$this->lang]) ? $localeMap[$this->lang] : $this->lang;
2016 $extJsLocaleFile = $this->extJsPath . 'locale/ext-lang-' . $extJsLang . '.js';
2017 if (file_exists(PATH_site . $extJsLocaleFile)) {
2018 $out .= '<script src="' . $this->processJsFile($extJsLocaleFile) . '" type="text/javascript" charset="utf-8"></script>' . LF;
2019 }
2020 // Remove extjs from JScodeLibArray
2021 unset($this->jsFiles[$this->extJsPath . 'ext-all.js'], $this->jsFiles[$this->extJsPath . 'ext-all-debug.js']);
2022 }
2023 $this->loadJavaScriptLanguageStrings();
2024 if (TYPO3_MODE === 'BE') {
2025 $this->addAjaxUrlsToInlineSettings();
2026 }
2027 $inlineSettings = $this->inlineLanguageLabels ? 'TYPO3.lang = ' . json_encode($this->inlineLanguageLabels) . ';' : '';
2028 $inlineSettings .= $this->inlineSettings ? 'TYPO3.settings = ' . json_encode($this->inlineSettings) . ';' : '';
2029 if ($this->addExtJS) {
2030 // Set clear.gif, move it on top, add handler code
2031 $code = '';
2032 if (!empty($this->extOnReadyCode)) {
2033 foreach ($this->extOnReadyCode as $block) {
2034 $code .= $block;
2035 }
2036 }
2037 $clearGifPath = GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Public/Images/clear.gif');
2038 $clearGifPath = htmlspecialchars(PathUtility::getAbsoluteWebPath($clearGifPath));
2039 $out .= $this->inlineJavascriptWrap[0] . '
2040 Ext.ns("TYPO3");
2041 Ext.BLANK_IMAGE_URL = "' . $clearGifPath . '";
2042 Ext.SSL_SECURE_URL = "' . $clearGifPath . '";' . LF
2043 . $inlineSettings
2044 . 'Ext.onReady(function() {'
2045 . $code
2046 . ' });'
2047 . $this->inlineJavascriptWrap[1];
2048 $this->extOnReadyCode = [];
2049 // Include TYPO3.l10n object
2050 if (TYPO3_MODE === 'BE') {
2051 $out .= '<script src="' . $this->processJsFile('EXT:lang/Resources/Public/JavaScript/Typo3Lang.js') . '" type="text/javascript" charset="utf-8"></script>' . LF;
2052 }
2053 if ($this->extJScss) {
2054 if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
2055 $this->addCssLibrary($GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'all', '', true);
2056 } else {
2057 $this->addCssLibrary($this->extJsPath . 'resources/css/ext-all-notheme.css', 'stylesheet', 'all', '', true);
2058 }
2059 }
2060 if ($this->extJStheme) {
2061 if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
2062 $this->addCssLibrary($GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'all', '', true);
2063 } else {
2064 $this->addCssLibrary($this->extJsPath . 'resources/css/xtheme-blue.css', 'stylesheet', 'all', '', true);
2065 }
2066 }
2067 } else {
2068 // no extJS loaded, but still inline settings
2069 if ($inlineSettings !== '') {
2070 // make sure the global TYPO3 is available
2071 $inlineSettings = 'var TYPO3 = TYPO3 || {};' . CRLF . $inlineSettings;
2072 $out .= $this->inlineJavascriptWrap[0] . $inlineSettings . $this->inlineJavascriptWrap[1];
2073 // Add language module only if also jquery is guaranteed to be there
2074 if (TYPO3_MODE === 'BE' && !empty($this->jQueryVersions)) {
2075 $this->loadRequireJsModule('TYPO3/CMS/Lang/Lang');
2076 }
2077 }
2078 }
2079 return $out;
2080 }
2081
2082 /**
2083 * Load the language strings into JavaScript
2084 */
2085 protected function loadJavaScriptLanguageStrings()
2086 {
2087 if (!empty($this->inlineLanguageLabelFiles)) {
2088 foreach ($this->inlineLanguageLabelFiles as $languageLabelFile) {
2089 $this->includeLanguageFileForInline($languageLabelFile['fileRef'], $languageLabelFile['selectionPrefix'], $languageLabelFile['stripFromSelectionName'], $languageLabelFile['errorMode']);
2090 }
2091 }
2092 $this->inlineLanguageLabelFiles = [];
2093 // Convert settings back to UTF-8 since json_encode() only works with UTF-8:
2094 if (TYPO3_MODE === 'FE' && $this->getCharSet() !== 'utf-8') {
2095 if ($this->inlineSettings) {
2096 $this->csConvObj->convArray($this->inlineSettings, $this->getCharSet(), 'utf-8');
2097 }
2098 }
2099 }
2100
2101 /**
2102 * Make URLs to all backend ajax handlers available as inline setting.
2103 */
2104 protected function addAjaxUrlsToInlineSettings()
2105 {
2106 $ajaxUrls = [];
2107 // Note: this method of adding Ajax URLs is @deprecated as of TYPO3 v8, and will be removed in TYPO3 v9
2108 foreach ($GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX'] as $ajaxHandler => $_) {
2109 $ajaxUrls[$ajaxHandler] = BackendUtility::getAjaxUrl($ajaxHandler);
2110 }
2111
2112 // also add the ajax-based routes
2113 /** @var UriBuilder $uriBuilder */
2114 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
2115 /** @var Router $router */
2116 $router = GeneralUtility::makeInstance(Router::class);
2117 $routes = $router->getRoutes();
2118 foreach ($routes as $routeIdentifier => $route) {
2119 if ($route->getOption('ajax')) {
2120 $uri = (string)$uriBuilder->buildUriFromRoute($routeIdentifier);
2121 // use the shortened value in order to use this in JavaScript
2122 $routeIdentifier = str_replace('ajax_', '', $routeIdentifier);
2123 $ajaxUrls[$routeIdentifier] = $uri;
2124 }
2125 }
2126
2127 $this->inlineSettings['ajaxUrls'] = $ajaxUrls;
2128 }
2129
2130 /**
2131 * Renders the HTML script tag for the given jQuery version.
2132 *
2133 * @param string $version The jQuery version that should be included, either "latest" or any available version
2134 * @param string $source The location of the jQuery source, can be "local", "google", "msn" or "jquery
2135 * @param string $namespace The namespace in which the jQuery object of the specific version should be stored
2136 * @return string
2137 */
2138 protected function renderJqueryScriptTag($version, $source, $namespace)
2139 {
2140 switch (true) {
2141 case isset($this->jQueryCdnUrls[$source]):
2142 if ($this->enableJqueryDebug) {
2143 $minifyPart = '';
2144 } else {
2145 $minifyPart = '.min';
2146 }
2147 $jQueryFileName = sprintf($this->jQueryCdnUrls[$source], $version, $minifyPart);
2148 break;
2149 case $source === 'local':
2150 $jQueryFileName = $this->jQueryPath . 'jquery-' . rawurlencode($version);
2151 if ($this->enableJqueryDebug) {
2152 $jQueryFileName .= '.js';
2153 } else {
2154 $jQueryFileName .= '.min.js';
2155 }
2156 $jQueryFileName = $this->processJsFile($jQueryFileName);
2157 break;
2158 default:
2159 $jQueryFileName = $source;
2160 }
2161 // Include the jQuery Core
2162 $scriptTag = '<script src="' . htmlspecialchars($jQueryFileName) . '" type="text/javascript"></script>' . LF;
2163 // Set the noConflict mode to be available via "TYPO3.jQuery" in all installations
2164 switch ($namespace) {
2165 case self::JQUERY_NAMESPACE_DEFAULT_NOCONFLICT:
2166 $scriptTag .= GeneralUtility::wrapJS('jQuery.noConflict();') . LF;
2167 break;
2168 case self::JQUERY_NAMESPACE_NONE:
2169 break;
2170 case self::JQUERY_NAMESPACE_DEFAULT:
2171
2172 default:
2173 $scriptTag .= GeneralUtility::wrapJS('var TYPO3 = TYPO3 || {}; TYPO3.' . $namespace . ' = jQuery.noConflict(true); var $ = TYPO3.' . $namespace . ';') . LF;
2174 }
2175 return $scriptTag;
2176 }
2177
2178 /**
2179 * Render CSS library files
2180 *
2181 * @return string
2182 */
2183 protected function renderCssLibraries()
2184 {
2185 $cssFiles = '';
2186 if (!empty($this->cssLibs)) {
2187 foreach ($this->cssLibs as $file => $properties) {
2188 $file = $this->getStreamlinedFileName($file);
2189 $tag = '<link rel="' . htmlspecialchars($properties['rel'])
2190 . '" type="text/css" href="' . htmlspecialchars($file)
2191 . '" media="' . htmlspecialchars($properties['media']) . '"'
2192 . ($properties['title'] ? ' title="' . htmlspecialchars($properties['title']) . '"' : '')
2193 . $this->endingSlash . '>';
2194 if ($properties['allWrap']) {
2195 $wrapArr = explode($properties['splitChar'] ?: '|', $properties['allWrap'], 2);
2196 $tag = $wrapArr[0] . $tag . $wrapArr[1];
2197 }
2198 $tag .= LF;
2199 if ($properties['forceOnTop']) {
2200 $cssFiles = $tag . $cssFiles;
2201 } else {
2202 $cssFiles .= $tag;
2203 }
2204 }
2205 }
2206 return $cssFiles;
2207 }
2208
2209 /**
2210 * Render CSS files
2211 *
2212 * @return string
2213 */
2214 protected function renderCssFiles()
2215 {
2216 $cssFiles = '';
2217 if (!empty($this->cssFiles)) {
2218 foreach ($this->cssFiles as $file => $properties) {
2219 $file = $this->getStreamlinedFileName($file);
2220 $tag = '<link rel="' . htmlspecialchars($properties['rel'])
2221 . '" type="text/css" href="' . htmlspecialchars($file)
2222 . '" media="' . htmlspecialchars($properties['media']) . '"'
2223 . ($properties['title'] ? ' title="' . htmlspecialchars($properties['title']) . '"' : '')
2224 . $this->endingSlash . '>';
2225 if ($properties['allWrap']) {
2226 $wrapArr = explode($properties['splitChar'] ?: '|', $properties['allWrap'], 2);
2227 $tag = $wrapArr[0] . $tag . $wrapArr[1];
2228 }
2229 $tag .= LF;
2230 if ($properties['forceOnTop']) {
2231 $cssFiles = $tag . $cssFiles;
2232 } else {
2233 $cssFiles .= $tag;
2234 }
2235 }
2236 }
2237 return $cssFiles;
2238 }
2239
2240 /**
2241 * Render inline CSS
2242 *
2243 * @return string
2244 */
2245 protected function renderCssInline()
2246 {
2247 $cssInline = '';
2248 if (!empty($this->cssInline)) {
2249 foreach ($this->cssInline as $name => $properties) {
2250 $cssCode = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF;
2251 if ($properties['forceOnTop']) {
2252 $cssInline = $cssCode . $cssInline;
2253 } else {
2254 $cssInline .= $cssCode;
2255 }
2256 }
2257 $cssInline = $this->inlineCssWrap[0] . $cssInline . $this->inlineCssWrap[1];
2258 }
2259 return $cssInline;
2260 }
2261
2262 /**
2263 * Render JavaScipt libraries
2264 *
2265 * @return array<string> jsLibs and jsFooterLibs strings
2266 */
2267 protected function renderAdditionalJavaScriptLibraries()
2268 {
2269 $jsLibs = '';
2270 $jsFooterLibs = '';
2271 if (!empty($this->jsLibs)) {
2272 foreach ($this->jsLibs as $properties) {
2273 $properties['file'] = $this->getStreamlinedFileName($properties['file']);
2274 $async = ($properties['async']) ? ' async="async"' : '';
2275 $integrity = ($properties['integrity']) ? ' integrity="' . htmlspecialchars($properties['integrity']) . '" crossorigin="anonymous"' : '';
2276 $tag = '<script src="' . htmlspecialchars($properties['file']) . '" type="' . htmlspecialchars($properties['type']) . '"' . $async . $integrity . '></script>';
2277 if ($properties['allWrap']) {
2278 $wrapArr = explode($properties['splitChar'] ?: '|', $properties['allWrap'], 2);
2279 $tag = $wrapArr[0] . $tag . $wrapArr[1];
2280 }
2281 $tag .= LF;
2282 if ($properties['forceOnTop']) {
2283 if ($properties['section'] === self::PART_HEADER) {
2284 $jsLibs = $tag . $jsLibs;
2285 } else {
2286 $jsFooterLibs = $tag . $jsFooterLibs;
2287 }
2288 } else {
2289 if ($properties['section'] === self::PART_HEADER) {
2290 $jsLibs .= $tag;
2291 } else {
2292 $jsFooterLibs .= $tag;
2293 }
2294 }
2295 }
2296 }
2297 if ($this->moveJsFromHeaderToFooter) {
2298 $jsFooterLibs = $jsLibs . LF . $jsFooterLibs;
2299 $jsLibs = '';
2300 }
2301 return [$jsLibs, $jsFooterLibs];
2302 }
2303
2304 /**
2305 * Render JavaScript files
2306 *
2307 * @return array<string> jsFiles and jsFooterFiles strings
2308 */
2309 protected function renderJavaScriptFiles()
2310 {
2311 $jsFiles = '';
2312 $jsFooterFiles = '';
2313 if (!empty($this->jsFiles)) {
2314 foreach ($this->jsFiles as $file => $properties) {
2315 $file = $this->getStreamlinedFileName($file);
2316 $async = ($properties['async']) ? ' async="async"' : '';
2317 $integrity = ($properties['integrity']) ? ' integrity="' . htmlspecialchars($properties['integrity']) . '" crossorigin="anonymous"' : '';
2318 $tag = '<script src="' . htmlspecialchars($file) . '" type="' . htmlspecialchars($properties['type']) . '"' . $async . $integrity . '></script>';
2319 if ($properties['allWrap']) {
2320 $wrapArr = explode($properties['splitChar'] ?: '|', $properties['allWrap'], 2);
2321 $tag = $wrapArr[0] . $tag . $wrapArr[1];
2322 }
2323 $tag .= LF;
2324 if ($properties['forceOnTop']) {
2325 if ($properties['section'] === self::PART_HEADER) {
2326 $jsFiles = $tag . $jsFiles;
2327 } else {
2328 $jsFooterFiles = $tag . $jsFooterFiles;
2329 }
2330 } else {
2331 if ($properties['section'] === self::PART_HEADER) {
2332 $jsFiles .= $tag;
2333 } else {
2334 $jsFooterFiles .= $tag;
2335 }
2336 }
2337 }
2338 }
2339 if ($this->moveJsFromHeaderToFooter) {
2340 $jsFooterFiles = $jsFiles . $jsFooterFiles;
2341 $jsFiles = '';
2342 }
2343 return [$jsFiles, $jsFooterFiles];
2344 }
2345
2346 /**
2347 * Render inline JavaScript
2348 *
2349 * @return array<string> jsInline and jsFooterInline string
2350 */
2351 protected function renderInlineJavaScript()
2352 {
2353 $jsInline = '';
2354 $jsFooterInline = '';
2355 if (!empty($this->jsInline)) {
2356 foreach ($this->jsInline as $name => $properties) {
2357 $jsCode = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF;
2358 if ($properties['forceOnTop']) {
2359 if ($properties['section'] === self::PART_HEADER) {
2360 $jsInline = $jsCode . $jsInline;
2361 } else {
2362 $jsFooterInline = $jsCode . $jsFooterInline;
2363 }
2364 } else {
2365 if ($properties['section'] === self::PART_HEADER) {
2366 $jsInline .= $jsCode;
2367 } else {
2368 $jsFooterInline .= $jsCode;
2369 }
2370 }
2371 }
2372 }
2373 if ($jsInline) {
2374 $jsInline = $this->inlineJavascriptWrap[0] . $jsInline . $this->inlineJavascriptWrap[1];
2375 }
2376 if ($jsFooterInline) {
2377 $jsFooterInline = $this->inlineJavascriptWrap[0] . $jsFooterInline . $this->inlineJavascriptWrap[1];
2378 }
2379 if ($this->moveJsFromHeaderToFooter) {
2380 $jsFooterInline = $jsInline . $jsFooterInline;
2381 $jsInline = '';
2382 }
2383 return [$jsInline, $jsFooterInline];
2384 }
2385
2386 /**
2387 * Include language file for inline usage
2388 *
2389 * @param string $fileRef
2390 * @param string $selectionPrefix
2391 * @param string $stripFromSelectionName
2392 * @param int $errorMode
2393 * @throws \RuntimeException
2394 */
2395 protected function includeLanguageFileForInline($fileRef, $selectionPrefix = '', $stripFromSelectionName = '', $errorMode = 0)
2396 {
2397 if (!isset($this->lang) || !isset($this->charSet)) {
2398 throw new \RuntimeException('Language and character encoding are not set.', 1284906026);
2399 }
2400 $labelsFromFile = [];
2401 $allLabels = $this->readLLfile($fileRef, $errorMode);
2402 if ($allLabels !== false) {
2403 // Merge language specific translations:
2404 if ($this->lang !== 'default' && isset($allLabels[$this->lang])) {
2405 $labels = array_merge($allLabels['default'], $allLabels[$this->lang]);
2406 } else {
2407 $labels = $allLabels['default'];
2408 }
2409 // Iterate through all locallang labels:
2410 foreach ($labels as $label => $value) {
2411 // If $selectionPrefix is set, only respect labels that start with $selectionPrefix
2412 if ($selectionPrefix === '' || strpos($label, $selectionPrefix) === 0) {
2413 // Remove substring $stripFromSelectionName from label
2414 $label = str_replace($stripFromSelectionName, '', $label);
2415 $labelsFromFile[$label] = $value;
2416 }
2417 }
2418 $this->inlineLanguageLabels = array_merge($this->inlineLanguageLabels, $labelsFromFile);
2419 }
2420 }
2421
2422 /**
2423 * Reads a locallang file.
2424 *
2425 * @param string $fileRef Reference to a relative filename to include.
2426 * @param int $errorMode Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception
2427 * @return array Returns the $LOCAL_LANG array found in the file. If no array found, returns empty array.
2428 */
2429 protected function readLLfile($fileRef, $errorMode = 0)
2430 {
2431 /** @var $languageFactory LocalizationFactory */
2432 $languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
2433
2434 if ($this->lang !== 'default') {
2435 $languages = array_reverse($this->languageDependencies);
2436 // At least we need to have English
2437 if (empty($languages)) {
2438 $languages[] = 'default';
2439 }
2440 } else {
2441 $languages = ['default'];
2442 }
2443
2444 $localLanguage = [];
2445 foreach ($languages as $language) {
2446 $tempLL = $languageFactory->getParsedData($fileRef, $language, $this->charSet, $errorMode);
2447
2448 $localLanguage['default'] = $tempLL['default'];
2449 if (!isset($localLanguage[$this->lang])) {
2450 $localLanguage[$this->lang] = $localLanguage['default'];
2451 }
2452 if ($this->lang !== 'default' && isset($tempLL[$language])) {
2453 // Merge current language labels onto labels from previous language
2454 // This way we have a labels with fall back applied
2455 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($localLanguage[$this->lang], $tempLL[$language], true, false);
2456 }
2457 }
2458
2459 return $localLanguage;
2460 }
2461
2462 /*****************************************************/
2463 /* */
2464 /* Tools */
2465 /* */
2466 /*****************************************************/
2467 /**
2468 * Concatenate files into one file
2469 * registered handler
2470 */
2471 protected function doConcatenate()
2472 {
2473 $this->doConcatenateCss();
2474 $this->doConcatenateJavaScript();
2475 }
2476
2477 /**
2478 * Concatenate JavaScript files according to the configuration.
2479 */
2480 protected function doConcatenateJavaScript()
2481 {
2482 if ($this->concatenateFiles || $this->concatenateJavascript) {
2483 if (!empty($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsConcatenateHandler'])) {
2484 // use external concatenation routine
2485 $params = [
2486 'jsLibs' => &$this->jsLibs,
2487 'jsFiles' => &$this->jsFiles,
2488 'jsFooterFiles' => &$this->jsFooterFiles,
2489 'headerData' => &$this->headerData,
2490 'footerData' => &$this->footerData
2491 ];
2492 GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsConcatenateHandler'], $params, $this);
2493 } else {
2494 $this->jsLibs = $this->getCompressor()->concatenateJsFiles($this->jsLibs);
2495 $this->jsFiles = $this->getCompressor()->concatenateJsFiles($this->jsFiles);
2496 $this->jsFooterFiles = $this->getCompressor()->concatenateJsFiles($this->jsFooterFiles);
2497 }
2498 }
2499 }
2500
2501 /**
2502 * Concatenate CSS files according to configuration.
2503 */
2504 protected function doConcatenateCss()
2505 {
2506 if ($this->concatenateFiles || $this->concatenateCss) {
2507 if (!empty($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssConcatenateHandler'])) {
2508 // use external concatenation routine
2509 $params = [
2510 'cssFiles' => &$this->cssFiles,
2511 'cssLibs' => &$this->cssLibs,
2512 'headerData' => &$this->headerData,
2513 'footerData' => &$this->footerData
2514 ];
2515 GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssConcatenateHandler'], $params, $this);
2516 } else {
2517 $cssOptions = [];
2518 if (TYPO3_MODE === 'BE') {
2519 $cssOptions = ['baseDirectories' => $GLOBALS['TBE_TEMPLATE']->getSkinStylesheetDirectories()];
2520 }
2521 $this->cssLibs = $this->getCompressor()->concatenateCssFiles($this->cssLibs, $cssOptions);
2522 $this->cssFiles = $this->getCompressor()->concatenateCssFiles($this->cssFiles, $cssOptions);
2523 }
2524 }
2525 }
2526
2527 /**
2528 * Compresses inline code
2529 */
2530 protected function doCompress()
2531 {
2532 $this->doCompressJavaScript();
2533 $this->doCompressCss();
2534 }
2535
2536 /**
2537 * Compresses CSS according to configuration.
2538 */
2539 protected function doCompressCss()
2540 {
2541 if ($this->compressCss) {
2542 if (!empty($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler'])) {
2543 // Use external compression routine
2544 $params = [
2545 'cssInline' => &$this->cssInline,
2546 'cssFiles' => &$this->cssFiles,
2547 'cssLibs' => &$this->cssLibs,
2548 'headerData' => &$this->headerData,
2549 'footerData' => &$this->footerData
2550 ];
2551 GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler'], $params, $this);
2552 } else {
2553 $this->cssLibs = $this->getCompressor()->compressCssFiles($this->cssLibs);
2554 $this->cssFiles = $this->getCompressor()->compressCssFiles($this->cssFiles);
2555 }
2556 }
2557 }
2558
2559 /**
2560 * Compresses JavaScript according to configuration.
2561 */
2562 protected function doCompressJavaScript()
2563 {
2564 if ($this->compressJavascript) {
2565 if (!empty($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler'])) {
2566 // Use external compression routine
2567 $params = [
2568 'jsInline' => &$this->jsInline,
2569 'jsFooterInline' => &$this->jsFooterInline,
2570 'jsLibs' => &$this->jsLibs,
2571 'jsFiles' => &$this->jsFiles,
2572 'jsFooterFiles' => &$this->jsFooterFiles,
2573 'headerData' => &$this->headerData,
2574 'footerData' => &$this->footerData
2575 ];
2576 GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler'], $params, $this);
2577 } else {
2578 // Traverse the arrays, compress files
2579 if (!empty($this->jsInline)) {
2580 foreach ($this->jsInline as $name => $properties) {
2581 if ($properties['compress']) {
2582 $error = '';
2583 $this->jsInline[$name]['code'] = GeneralUtility::minifyJavaScript($properties['code'], $error);
2584 if ($error) {
2585 $this->compressError .= 'Error with minify JS Inline Block "' . $name . '": ' . $error . LF;
2586 }
2587 }
2588 }
2589 }
2590 $this->jsLibs = $this->getCompressor()->compressJsFiles($this->jsLibs);
2591 $this->jsFiles = $this->getCompressor()->compressJsFiles($this->jsFiles);
2592 $this->jsFooterFiles = $this->getCompressor()->compressJsFiles($this->jsFooterFiles);
2593 }
2594 }
2595 }
2596
2597 /**
2598 * Returns instance of \TYPO3\CMS\Core\Resource\ResourceCompressor
2599 *
2600 * @return \TYPO3\CMS\Core\Resource\ResourceCompressor
2601 */
2602 protected function getCompressor()
2603 {
2604 if ($this->compressor === null) {
2605 $this->compressor = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\ResourceCompressor::class);
2606 }
2607 return $this->compressor;
2608 }
2609
2610 /**
2611 * Processes a Javascript file dependent on the current context
2612 *
2613 * Adds the version number for Frontend, compresses the file for Backend
2614 *
2615 * @param string $filename Filename
2616 * @return string New filename
2617 */
2618 protected function processJsFile($filename)
2619 {
2620 $filename = $this->getStreamlinedFileName($filename, false);
2621 if ($this->compressJavascript) {
2622 $filename = $this->getCompressor()->compressJsFile($filename);
2623 } elseif (TYPO3_MODE === 'FE') {
2624 $filename = GeneralUtility::createVersionNumberedFilename($filename);
2625 }
2626 return PathUtility::getAbsoluteWebPath($filename);
2627 }
2628
2629 /**
2630 * This function acts as a wrapper to allow relative and paths starting with EXT: to be dealt with
2631 * in this very case to always return the absolute web path to be included directly before output.
2632 *
2633 * This is mainly added so the EXT: syntax can be resolved for PageRenderer in one central place,
2634 * and hopefully removed in the future by one standard API call.
2635 *
2636 * @param string $file the filename to process
2637 * @param bool $prepareForOutput whether the file should be prepared as version numbered file and prefixed as absolute webpath
2638 * @return string
2639 * @internal
2640 */
2641 protected function getStreamlinedFileName($file, $prepareForOutput = true)
2642 {
2643 if (strpos($file, 'EXT:') === 0) {
2644 $file = GeneralUtility::getFileAbsFileName($file);
2645 // as the path is now absolute, make it "relative" to the current script to stay compatible
2646 $file = PathUtility::getRelativePathTo($file);
2647 $file = rtrim($file, '/');
2648 } else {
2649 $file = GeneralUtility::resolveBackPath($file);
2650 }
2651 if ($prepareForOutput) {
2652 $file = GeneralUtility::createVersionNumberedFilename($file);
2653 $file = PathUtility::getAbsoluteWebPath($file);
2654 }
2655 return $file;
2656 }
2657
2658 /**
2659 * Returns global frontend controller
2660 *
2661 * @return TypoScriptFrontendController
2662 */
2663 protected function getTypoScriptFrontendController()
2664 {
2665 return $GLOBALS['TSFE'];
2666 }
2667
2668 /**
2669 * Returns global language service instance
2670 *
2671 * @return \TYPO3\CMS\Lang\LanguageService
2672 */
2673 protected function getLanguageService()
2674 {
2675 return $GLOBALS['LANG'];
2676 }
2677
2678 /*****************************************************/
2679 /* */
2680 /* Hooks */
2681 /* */
2682 /*****************************************************/
2683 /**
2684 * Execute PreRenderHook for possible manipulation
2685 */
2686 protected function executePreRenderHook()
2687 {
2688 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'])) {
2689 $params = [
2690 'jsLibs' => &$this->jsLibs,
2691 'jsFooterLibs' => &$this->jsFooterLibs,
2692 'jsFiles' => &$this->jsFiles,
2693 'jsFooterFiles' => &$this->jsFooterFiles,
2694 'cssLibs' => &$this->cssLibs,
2695 'cssFiles' => &$this->cssFiles,
2696 'headerData' => &$this->headerData,
2697 'footerData' => &$this->footerData,
2698 'jsInline' => &$this->jsInline,
2699 'jsFooterInline' => &$this->jsFooterInline,
2700 'cssInline' => &$this->cssInline
2701 ];
2702 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'] as $hook) {
2703 GeneralUtility::callUserFunction($hook, $params, $this);
2704 }
2705 }
2706 }
2707
2708 /**
2709 * PostTransform for possible manipulation of concatenated and compressed files
2710 */
2711 protected function executeRenderPostTransformHook()
2712 {
2713 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postTransform'])) {
2714 $params = [
2715 'jsLibs' => &$this->jsLibs,
2716 'jsFooterLibs' => &$this->jsFooterLibs,
2717 'jsFiles' => &$this->jsFiles,
2718 'jsFooterFiles' => &$this->jsFooterFiles,
2719 'cssLibs' => &$this->cssLibs,
2720 'cssFiles' => &$this->cssFiles,
2721 'headerData' => &$this->headerData,
2722 'footerData' => &$this->footerData,
2723 'jsInline' => &$this->jsInline,
2724 'jsFooterInline' => &$this->jsFooterInline,
2725 'cssInline' => &$this->cssInline
2726 ];
2727 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postTransform'] as $hook) {
2728 GeneralUtility::callUserFunction($hook, $params, $this);
2729 }
2730 }
2731 }
2732
2733 /**
2734 * Execute postRenderHook for possible manipulation
2735 *
2736 * @param $jsLibs string
2737 * @param $jsFiles string
2738 * @param $jsFooterFiles string
2739 * @param $cssLibs string
2740 * @param $cssFiles string
2741 * @param $jsInline string
2742 * @param $cssInline string
2743 * @param $jsFooterInline string
2744 * @param $jsFooterLibs string
2745 */
2746 protected function executePostRenderHook(&$jsLibs, &$jsFiles, &$jsFooterFiles, &$cssLibs, &$cssFiles, &$jsInline, &$cssInline, &$jsFooterInline, &$jsFooterLibs)
2747 {
2748 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess'])) {
2749 $params = [
2750 'jsLibs' => &$jsLibs,
2751 'jsFiles' => &$jsFiles,
2752 'jsFooterFiles' => &$jsFooterFiles,
2753 'cssLibs' => &$cssLibs,
2754 'cssFiles' => &$cssFiles,
2755 'headerData' => &$this->headerData,
2756 'footerData' => &$this->footerData,
2757 'jsInline' => &$jsInline,
2758 'cssInline' => &$cssInline,
2759 'xmlPrologAndDocType' => &$this->xmlPrologAndDocType,
2760 'htmlTag' => &$this->htmlTag,
2761 'headTag' => &$this->headTag,
2762 'charSet' => &$this->charSet,
2763 'metaCharsetTag' => &$this->metaCharsetTag,
2764 'shortcutTag' => &$this->shortcutTag,
2765 'inlineComments' => &$this->inlineComments,
2766 'baseUrl' => &$this->baseUrl,
2767 'baseUrlTag' => &$this->baseUrlTag,
2768 'favIcon' => &$this->favIcon,
2769 'iconMimeType' => &$this->iconMimeType,
2770 'titleTag' => &$this->titleTag,
2771 'title' => &$this->title,
2772 'metaTags' => &$this->metaTags,
2773 'jsFooterInline' => &$jsFooterInline,
2774 'jsFooterLibs' => &$jsFooterLibs,
2775 'bodyContent' => &$this->bodyContent
2776 ];
2777 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess'] as $hook) {
2778 GeneralUtility::callUserFunction($hook, $params, $this);
2779 }
2780 }
2781 }
2782 }