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