[TASK] Move LanguageService to EXT:core
[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 'matchheight' => $corePath . 'jquery.matchHeight-min',
1507 'nprogress' => $corePath . 'nprogress',
1508 'moment' => $corePath . 'moment',
1509 'cropper' => $corePath . 'cropper.min',
1510 'imagesloaded' => $corePath . 'imagesloaded.pkgd.min',
1511 'bootstrap' => $corePath . 'bootstrap/bootstrap',
1512 'twbs/bootstrap-datetimepicker' => $corePath . 'bootstrap-datetimepicker',
1513 'autosize' => $corePath . 'autosize',
1514 'taboverride' => $corePath . 'taboverride.min',
1515 'twbs/bootstrap-slider' => $corePath . 'bootstrap-slider.min',
1516 'jquery/autocomplete' => $corePath . 'jquery.autocomplete',
1517 'd3' => $corePath . 'd3/d3'
1518 ];
1519
1520 foreach ($loadedExtensions as $packageName) {
1521 $fullJsPath = 'EXT:' . $packageName . '/Resources/Public/JavaScript/';
1522 $fullJsPath = GeneralUtility::getFileAbsFileName($fullJsPath);
1523 $fullJsPath = PathUtility::getAbsoluteWebPath($fullJsPath);
1524 $fullJsPath = rtrim($fullJsPath, '/');
1525 if ($fullJsPath) {
1526 $requireJsConfig['paths']['TYPO3/CMS/' . GeneralUtility::underscoredToUpperCamelCase($packageName)] = $fullJsPath;
1527 }
1528 }
1529
1530 // check if additional AMD modules need to be loaded if a single AMD module is initialized
1531 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules'])) {
1532 $this->addInlineSettingArray(
1533 'RequireJS.PostInitializationModules',
1534 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules']
1535 );
1536 }
1537
1538 return $requireJsConfig;
1539 }
1540
1541 /**
1542 * Add additional configuration to require js.
1543 *
1544 * Configuration will be merged recursive with overrule.
1545 *
1546 * To add another path mapping deliver the following configuration:
1547 * 'paths' => array(
1548 * 'EXTERN/mybootstrapjs' => 'sysext/.../twbs/bootstrap.min',
1549 * ),
1550 *
1551 * @param array $configuration The configuration that will be merged with existing one.
1552 */
1553 public function addRequireJsConfiguration(array $configuration)
1554 {
1555 if (TYPO3_MODE === 'BE') {
1556 // Load RequireJS in backend context at first. Doing this in FE could break the output
1557 $this->loadRequireJs();
1558 }
1559 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->requireJsConfig, $configuration);
1560 }
1561
1562 /**
1563 * includes an AMD-compatible JS file by resolving the ModuleName, and then requires the file via a requireJS request,
1564 * additionally allowing to execute JavaScript code afterwards
1565 *
1566 * this function only works for AMD-ready JS modules, used like "define('TYPO3/CMS/Backend/FormEngine..."
1567 * in the JS file
1568 *
1569 * TYPO3/CMS/Backend/FormEngine =>
1570 * "TYPO3": Vendor Name
1571 * "CMS": Product Name
1572 * "Backend": Extension Name
1573 * "FormEngine": FileName in the Resources/Public/JavaScript folder
1574 *
1575 * @param string $mainModuleName Must be in the form of "TYPO3/CMS/PackageName/ModuleName" e.g. "TYPO3/CMS/Backend/FormEngine"
1576 * @param string $callBackFunction loaded right after the requireJS loading, must be wrapped in function() {}
1577 */
1578 public function loadRequireJsModule($mainModuleName, $callBackFunction = null)
1579 {
1580 $inlineCodeKey = $mainModuleName;
1581 // make sure requireJS is initialized
1582 $this->loadRequireJs();
1583
1584 // execute the main module, and load a possible callback function
1585 $javaScriptCode = 'require(["' . $mainModuleName . '"]';
1586 if ($callBackFunction !== null) {
1587 $inlineCodeKey .= sha1($callBackFunction);
1588 $javaScriptCode .= ', ' . $callBackFunction;
1589 }
1590 $javaScriptCode .= ');';
1591 $this->addJsInlineCode('RequireJS-Module-' . $inlineCodeKey, $javaScriptCode);
1592 }
1593
1594 /**
1595 * call this function if you need the extJS library
1596 *
1597 * @param bool $css Flag, if set the ext-css will be loaded
1598 * @param bool $theme Flag, if set the ext-theme "grey" will be loaded
1599 */
1600 public function loadExtJS($css = true, $theme = true)
1601 {
1602 $this->addExtJS = true;
1603 $this->extJStheme = $theme;
1604 $this->extJScss = $css;
1605 }
1606
1607 /**
1608 * Call this function to load debug version of ExtJS. Use this for development only
1609 */
1610 public function enableExtJsDebug()
1611 {
1612 $this->enableExtJsDebug = true;
1613 }
1614
1615 /**
1616 * Adds Javascript Inline Label. This will occur in TYPO3.lang - object
1617 * The label can be used in scripts with TYPO3.lang.<key>
1618 * Need extJs loaded
1619 *
1620 * @param string $key
1621 * @param string $value
1622 */
1623 public function addInlineLanguageLabel($key, $value)
1624 {
1625 $this->inlineLanguageLabels[$key] = $value;
1626 }
1627
1628 /**
1629 * Adds Javascript Inline Label Array. This will occur in TYPO3.lang - object
1630 * The label can be used in scripts with TYPO3.lang.<key>
1631 * Array will be merged with existing array.
1632 * Need extJs loaded
1633 *
1634 * @param array $array
1635 * @param bool $parseWithLanguageService
1636 */
1637 public function addInlineLanguageLabelArray(array $array, $parseWithLanguageService = false)
1638 {
1639 if ($parseWithLanguageService === true) {
1640 foreach ($array as $key => $value) {
1641 if (TYPO3_MODE === 'FE') {
1642 $array[$key] = $this->getTypoScriptFrontendController()->sL($value);
1643 } else {
1644 $array[$key] = $this->getLanguageService()->sL($value);
1645 }
1646 }
1647 }
1648
1649 $this->inlineLanguageLabels = array_merge($this->inlineLanguageLabels, $array);
1650 }
1651
1652 /**
1653 * Gets labels to be used in JavaScript fetched from a locallang file.
1654 *
1655 * @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.
1656 * @param string $selectionPrefix Prefix to select the correct labels (default: '')
1657 * @param string $stripFromSelectionName String to be removed from the label names in the output. (default: '')
1658 */
1659 public function addInlineLanguageLabelFile($fileRef, $selectionPrefix = '', $stripFromSelectionName = '')
1660 {
1661 $index = md5($fileRef . $selectionPrefix . $stripFromSelectionName);
1662 if ($fileRef && !isset($this->inlineLanguageLabelFiles[$index])) {
1663 $this->inlineLanguageLabelFiles[$index] = [
1664 'fileRef' => $fileRef,
1665 'selectionPrefix' => $selectionPrefix,
1666 'stripFromSelectionName' => $stripFromSelectionName
1667 ];
1668 }
1669 }
1670
1671 /**
1672 * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
1673 * The label can be used in scripts with TYPO3.setting.<key>
1674 * Need extJs loaded
1675 *
1676 * @param string $namespace
1677 * @param string $key
1678 * @param string $value
1679 */
1680 public function addInlineSetting($namespace, $key, $value)
1681 {
1682 if ($namespace) {
1683 if (strpos($namespace, '.')) {
1684 $parts = explode('.', $namespace);
1685 $a = &$this->inlineSettings;
1686 foreach ($parts as $part) {
1687 $a = &$a[$part];
1688 }
1689 $a[$key] = $value;
1690 } else {
1691 $this->inlineSettings[$namespace][$key] = $value;
1692 }
1693 } else {
1694 $this->inlineSettings[$key] = $value;
1695 }
1696 }
1697
1698 /**
1699 * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
1700 * The label can be used in scripts with TYPO3.setting.<key>
1701 * Array will be merged with existing array.
1702 * Need extJs loaded
1703 *
1704 * @param string $namespace
1705 * @param array $array
1706 */
1707 public function addInlineSettingArray($namespace, array $array)
1708 {
1709 if ($namespace) {
1710 if (strpos($namespace, '.')) {
1711 $parts = explode('.', $namespace);
1712 $a = &$this->inlineSettings;
1713 foreach ($parts as $part) {
1714 $a = &$a[$part];
1715 }
1716 $a = array_merge((array)$a, $array);
1717 } else {
1718 $this->inlineSettings[$namespace] = array_merge((array)$this->inlineSettings[$namespace], $array);
1719 }
1720 } else {
1721 $this->inlineSettings = array_merge($this->inlineSettings, $array);
1722 }
1723 }
1724
1725 /**
1726 * Adds content to body content
1727 *
1728 * @param string $content
1729 */
1730 public function addBodyContent($content)
1731 {
1732 $this->bodyContent .= $content;
1733 }
1734
1735 /*****************************************************/
1736 /* */
1737 /* Render Functions */
1738 /* */
1739 /*****************************************************/
1740 /**
1741 * Render the section (Header or Footer)
1742 *
1743 * @param int $part Section which should be rendered: self::PART_COMPLETE, self::PART_HEADER or self::PART_FOOTER
1744 * @return string Content of rendered section
1745 */
1746 public function render($part = self::PART_COMPLETE)
1747 {
1748 $this->prepareRendering();
1749 list($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs) = $this->renderJavaScriptAndCss();
1750 $metaTags = implode(LF, $this->metaTags);
1751 $markerArray = $this->getPreparedMarkerArray($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs, $metaTags);
1752 $template = $this->getTemplateForPart($part);
1753
1754 // The page renderer needs a full reset, even when only rendering one part of the page
1755 // This means that you can only register footer files *after* the header has been already rendered.
1756 // In case you render the footer part first, header files can only be added *after* the footer has been rendered
1757 $this->reset();
1758 $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
1759 return trim($templateService->substituteMarkerArray($template, $markerArray, '###|###'));
1760 }
1761
1762 /**
1763 * Render the page but not the JavaScript and CSS Files
1764 *
1765 * @param string $substituteHash The hash that is used for the placehoder markers
1766 * @access private
1767 * @return string Content of rendered section
1768 */
1769 public function renderPageWithUncachedObjects($substituteHash)
1770 {
1771 $this->prepareRendering();
1772 $markerArray = $this->getPreparedMarkerArrayForPageWithUncachedObjects($substituteHash);
1773 $template = $this->getTemplateForPart(self::PART_COMPLETE);
1774 $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
1775 return trim($templateService->substituteMarkerArray($template, $markerArray, '###|###'));
1776 }
1777
1778 /**
1779 * Renders the JavaScript and CSS files that have been added during processing
1780 * of uncached content objects (USER_INT, COA_INT)
1781 *
1782 * @param string $cachedPageContent
1783 * @param string $substituteHash The hash that is used for the placehoder markers
1784 * @access private
1785 * @return string
1786 */
1787 public function renderJavaScriptAndCssForProcessingOfUncachedContentObjects($cachedPageContent, $substituteHash)
1788 {
1789 $this->prepareRendering();
1790 list($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs) = $this->renderJavaScriptAndCss();
1791 $title = $this->title ? str_replace('|', htmlspecialchars($this->title), $this->titleTag) : '';
1792 $markerArray = [
1793 '<!-- ###TITLE' . $substituteHash . '### -->' => $title,
1794 '<!-- ###CSS_LIBS' . $substituteHash . '### -->' => $cssLibs,
1795 '<!-- ###CSS_INCLUDE' . $substituteHash . '### -->' => $cssFiles,
1796 '<!-- ###CSS_INLINE' . $substituteHash . '### -->' => $cssInline,
1797 '<!-- ###JS_INLINE' . $substituteHash . '### -->' => $jsInline,
1798 '<!-- ###JS_INCLUDE' . $substituteHash . '### -->' => $jsFiles,
1799 '<!-- ###JS_LIBS' . $substituteHash . '### -->' => $jsLibs,
1800 '<!-- ###META' . $substituteHash . '### -->' => implode(LF, $this->metaTags),
1801 '<!-- ###HEADERDATA' . $substituteHash . '### -->' => implode(LF, $this->headerData),
1802 '<!-- ###FOOTERDATA' . $substituteHash . '### -->' => implode(LF, $this->footerData),
1803 '<!-- ###JS_LIBS_FOOTER' . $substituteHash . '### -->' => $jsFooterLibs,
1804 '<!-- ###JS_INCLUDE_FOOTER' . $substituteHash . '### -->' => $jsFooterFiles,
1805 '<!-- ###JS_INLINE_FOOTER' . $substituteHash . '### -->' => $jsFooterInline
1806 ];
1807 foreach ($markerArray as $placeHolder => $content) {
1808 $cachedPageContent = str_replace($placeHolder, $content, $cachedPageContent);
1809 }
1810 $this->reset();
1811 return $cachedPageContent;
1812 }
1813
1814 /**
1815 * Remove ending slashes from static header block
1816 * if the page is being rendered as html (not xhtml)
1817 * and define property $this->endingSlash for further use
1818 */
1819 protected function prepareRendering()
1820 {
1821 if ($this->getRenderXhtml()) {
1822 $this->endingSlash = ' /';
1823 } else {
1824 $this->metaCharsetTag = str_replace(' />', '>', $this->metaCharsetTag);
1825 $this->baseUrlTag = str_replace(' />', '>', $this->baseUrlTag);
1826 $this->shortcutTag = str_replace(' />', '>', $this->shortcutTag);
1827 $this->endingSlash = '';
1828 }
1829 }
1830
1831 /**
1832 * Renders all JavaScript and CSS
1833 *
1834 * @return array<string>
1835 */
1836 protected function renderJavaScriptAndCss()
1837 {
1838 $this->executePreRenderHook();
1839 $mainJsLibs = $this->renderMainJavaScriptLibraries();
1840 if ($this->concatenateFiles || $this->concatenateJavascript || $this->concatenateCss) {
1841 // Do the file concatenation
1842 $this->doConcatenate();
1843 }
1844 if ($this->compressCss || $this->compressJavascript) {
1845 // Do the file compression
1846 $this->doCompress();
1847 }
1848 $this->executeRenderPostTransformHook();
1849 $cssLibs = $this->renderCssLibraries();
1850 $cssFiles = $this->renderCssFiles();
1851 $cssInline = $this->renderCssInline();
1852 list($jsLibs, $jsFooterLibs) = $this->renderAdditionalJavaScriptLibraries();
1853 list($jsFiles, $jsFooterFiles) = $this->renderJavaScriptFiles();
1854 list($jsInline, $jsFooterInline) = $this->renderInlineJavaScript();
1855 $jsLibs = $mainJsLibs . $jsLibs;
1856 if ($this->moveJsFromHeaderToFooter) {
1857 $jsFooterLibs = $jsLibs . LF . $jsFooterLibs;
1858 $jsLibs = '';
1859 $jsFooterFiles = $jsFiles . LF . $jsFooterFiles;
1860 $jsFiles = '';
1861 $jsFooterInline = $jsInline . LF . $jsFooterInline;
1862 $jsInline = '';
1863 }
1864 $this->executePostRenderHook($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs);
1865 return [$jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs];
1866 }
1867
1868 /**
1869 * Fills the marker array with the given strings and trims each value
1870 *
1871 * @param $jsLibs string
1872 * @param $jsFiles string
1873 * @param $jsFooterFiles string
1874 * @param $cssLibs string
1875 * @param $cssFiles string
1876 * @param $jsInline string
1877 * @param $cssInline string
1878 * @param $jsFooterInline string
1879 * @param $jsFooterLibs string
1880 * @param $metaTags string
1881 * @return array Marker array
1882 */
1883 protected function getPreparedMarkerArray($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs, $metaTags)
1884 {
1885 $markerArray = [
1886 'XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType,
1887 'HTMLTAG' => $this->htmlTag,
1888 'HEADTAG' => $this->headTag,
1889 'METACHARSET' => $this->charSet ? str_replace('|', htmlspecialchars($this->charSet), $this->metaCharsetTag) : '',
1890 'INLINECOMMENT' => $this->inlineComments ? LF . LF . '<!-- ' . LF . implode(LF, $this->inlineComments) . '-->' . LF . LF : '',
1891 'BASEURL' => $this->baseUrl ? str_replace('|', $this->baseUrl, $this->baseUrlTag) : '',
1892 'SHORTCUT' => $this->favIcon ? sprintf($this->shortcutTag, htmlspecialchars($this->favIcon), $this->iconMimeType) : '',
1893 'CSS_LIBS' => $cssLibs,
1894 'CSS_INCLUDE' => $cssFiles,
1895 'CSS_INLINE' => $cssInline,
1896 'JS_INLINE' => $jsInline,
1897 'JS_INCLUDE' => $jsFiles,
1898 'JS_LIBS' => $jsLibs,
1899 'TITLE' => $this->title ? str_replace('|', htmlspecialchars($this->title), $this->titleTag) : '',
1900 'META' => $metaTags,
1901 'HEADERDATA' => $this->headerData ? implode(LF, $this->headerData) : '',
1902 'FOOTERDATA' => $this->footerData ? implode(LF, $this->footerData) : '',
1903 'JS_LIBS_FOOTER' => $jsFooterLibs,
1904 'JS_INCLUDE_FOOTER' => $jsFooterFiles,
1905 'JS_INLINE_FOOTER' => $jsFooterInline,
1906 'BODY' => $this->bodyContent
1907 ];
1908 $markerArray = array_map('trim', $markerArray);
1909 return $markerArray;
1910 }
1911
1912 /**
1913 * Fills the marker array with the given strings and trims each value
1914 *
1915 * @param string $substituteHash The hash that is used for the placehoder markers
1916 * @return array Marker array
1917 */
1918 protected function getPreparedMarkerArrayForPageWithUncachedObjects($substituteHash)
1919 {
1920 $markerArray = [
1921 'XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType,
1922 'HTMLTAG' => $this->htmlTag,
1923 'HEADTAG' => $this->headTag,
1924 'METACHARSET' => $this->charSet ? str_replace('|', htmlspecialchars($this->charSet), $this->metaCharsetTag) : '',
1925 'INLINECOMMENT' => $this->inlineComments ? LF . LF . '<!-- ' . LF . implode(LF, $this->inlineComments) . '-->' . LF . LF : '',
1926 'BASEURL' => $this->baseUrl ? str_replace('|', $this->baseUrl, $this->baseUrlTag) : '',
1927 'SHORTCUT' => $this->favIcon ? sprintf($this->shortcutTag, htmlspecialchars($this->favIcon), $this->iconMimeType) : '',
1928 'META' => '<!-- ###META' . $substituteHash . '### -->',
1929 'BODY' => $this->bodyContent,
1930 'TITLE' => '<!-- ###TITLE' . $substituteHash . '### -->',
1931 'CSS_LIBS' => '<!-- ###CSS_LIBS' . $substituteHash . '### -->',
1932 'CSS_INCLUDE' => '<!-- ###CSS_INCLUDE' . $substituteHash . '### -->',
1933 'CSS_INLINE' => '<!-- ###CSS_INLINE' . $substituteHash . '### -->',
1934 'JS_INLINE' => '<!-- ###JS_INLINE' . $substituteHash . '### -->',
1935 'JS_INCLUDE' => '<!-- ###JS_INCLUDE' . $substituteHash . '### -->',
1936 'JS_LIBS' => '<!-- ###JS_LIBS' . $substituteHash . '### -->',
1937 'HEADERDATA' => '<!-- ###HEADERDATA' . $substituteHash . '### -->',
1938 'FOOTERDATA' => '<!-- ###FOOTERDATA' . $substituteHash . '### -->',
1939 'JS_LIBS_FOOTER' => '<!-- ###JS_LIBS_FOOTER' . $substituteHash . '### -->',
1940 'JS_INCLUDE_FOOTER' => '<!-- ###JS_INCLUDE_FOOTER' . $substituteHash . '### -->',
1941 'JS_INLINE_FOOTER' => '<!-- ###JS_INLINE_FOOTER' . $substituteHash . '### -->'
1942 ];
1943 $markerArray = array_map('trim', $markerArray);
1944 return $markerArray;
1945 }
1946
1947 /**
1948 * Reads the template file and returns the requested part as string
1949 *
1950 * @param int $part
1951 * @return string
1952 */
1953 protected function getTemplateForPart($part)
1954 {
1955 $templateFile = GeneralUtility::getFileAbsFileName($this->templateFile);
1956 if (is_file($templateFile)) {
1957 $template = file_get_contents($templateFile);
1958 if ($this->removeLineBreaksFromTemplate) {
1959 $template = strtr($template, [LF => '', CR => '']);
1960 }
1961 if ($part !== self::PART_COMPLETE) {
1962 $templatePart = explode('###BODY###', $template);
1963 $template = $templatePart[$part - 1];
1964 }
1965 } else {
1966 $template = '';
1967 }
1968 return $template;
1969 }
1970
1971 /**
1972 * Helper function for render the main JavaScript libraries,
1973 * currently: RequireJS, jQuery, ExtJS
1974 *
1975 * @return string Content with JavaScript libraries
1976 */
1977 protected function renderMainJavaScriptLibraries()
1978 {
1979 $out = '';
1980
1981 // Include RequireJS
1982 if ($this->addRequireJs) {
1983 // load the paths of the requireJS configuration
1984 $out .= GeneralUtility::wrapJS('var require = ' . json_encode($this->requireJsConfig)) . LF;
1985 // directly after that, include the require.js file
1986 $out .= '<script src="' . $this->processJsFile($this->requireJsPath . 'require.js') . '" type="text/javascript"></script>' . LF;
1987 }
1988
1989 // Include jQuery Core for each namespace, depending on the version and source
1990 if (!empty($this->jQueryVersions)) {
1991 foreach ($this->jQueryVersions as $namespace => $jQueryVersion) {
1992 $out .= $this->renderJqueryScriptTag($jQueryVersion['version'], $jQueryVersion['source'], $namespace);
1993 }
1994 }
1995
1996 // Include extJS
1997 if ($this->addExtJS) {
1998 // Use the base adapter all the time
1999 $out .= '<script src="' . $this->processJsFile($this->extJsPath . 'adapter/ext-base' . ($this->enableExtJsDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF;
2000 $out .= '<script src="' . $this->processJsFile($this->extJsPath . 'ext-all' . ($this->enableExtJsDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF;
2001 // Add extJS localization
2002 // Load standard ISO mapping and modify for use with ExtJS
2003 $localeMap = $this->locales->getIsoMapping();
2004 $localeMap[''] = 'en';
2005 $localeMap['default'] = 'en';
2006 // Greek
2007 $localeMap['gr'] = 'el_GR';
2008 // Norwegian Bokmaal
2009 $localeMap['no'] = 'no_BO';
2010 // Swedish
2011 $localeMap['se'] = 'se_SV';
2012 $extJsLang = isset($localeMap[$this->lang]) ? $localeMap[$this->lang] : $this->lang;
2013 $extJsLocaleFile = $this->extJsPath . 'locale/ext-lang-' . $extJsLang . '.js';
2014 if (file_exists(PATH_site . $extJsLocaleFile)) {
2015 $out .= '<script src="' . $this->processJsFile($extJsLocaleFile) . '" type="text/javascript" charset="utf-8"></script>' . LF;
2016 }
2017 // Remove extjs from JScodeLibArray
2018 unset($this->jsFiles[$this->extJsPath . 'ext-all.js'], $this->jsFiles[$this->extJsPath . 'ext-all-debug.js']);
2019 }
2020 $this->loadJavaScriptLanguageStrings();
2021 if (TYPO3_MODE === 'BE') {
2022 $this->addAjaxUrlsToInlineSettings();
2023 }
2024 $inlineSettings = $this->inlineLanguageLabels ? 'TYPO3.lang = ' . json_encode($this->inlineLanguageLabels) . ';' : '';
2025 $inlineSettings .= $this->inlineSettings ? 'TYPO3.settings = ' . json_encode($this->inlineSettings) . ';' : '';
2026 if ($this->addExtJS) {
2027 // Set clear.gif, move it on top, add handler code
2028 $code = '';
2029 if (!empty($this->extOnReadyCode)) {
2030 foreach ($this->extOnReadyCode as $block) {
2031 $code .= $block;
2032 }
2033 }
2034 $clearGifPath = GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Public/Images/clear.gif');
2035 $clearGifPath = htmlspecialchars(PathUtility::getAbsoluteWebPath($clearGifPath));
2036 $out .= $this->inlineJavascriptWrap[0] . '
2037 Ext.ns("TYPO3");
2038 Ext.BLANK_IMAGE_URL = "' . $clearGifPath . '";
2039 Ext.SSL_SECURE_URL = "' . $clearGifPath . '";' . LF
2040 . $inlineSettings
2041 . 'Ext.onReady(function() {'
2042 . $code
2043 . ' });'
2044 . $this->inlineJavascriptWrap[1];
2045 $this->extOnReadyCode = [];
2046 // Include TYPO3.l10n object
2047 if (TYPO3_MODE === 'BE') {
2048 $out .= '<script src="' . $this->processJsFile('EXT:lang/Resources/Public/JavaScript/Typo3Lang.js') . '" type="text/javascript" charset="utf-8"></script>' . LF;
2049 }
2050 if ($this->extJScss) {
2051 if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
2052 $this->addCssLibrary($GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'all', '', true);
2053 } else {
2054 $this->addCssLibrary($this->extJsPath . 'resources/css/ext-all-notheme.css', 'stylesheet', 'all', '', true);
2055 }
2056 }
2057 if ($this->extJStheme) {
2058 if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
2059 $this->addCssLibrary($GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'all', '', true);
2060 } else {
2061 $this->addCssLibrary($this->extJsPath . 'resources/css/xtheme-blue.css', 'stylesheet', 'all', '', true);
2062 }
2063 }
2064 } else {
2065 // no extJS loaded, but still inline settings
2066 if ($inlineSettings !== '') {
2067 // make sure the global TYPO3 is available
2068 $inlineSettings = 'var TYPO3 = TYPO3 || {};' . CRLF . $inlineSettings;
2069 $out .= $this->inlineJavascriptWrap[0] . $inlineSettings . $this->inlineJavascriptWrap[1];
2070 // Add language module only if also jquery is guaranteed to be there
2071 if (TYPO3_MODE === 'BE' && !empty($this->jQueryVersions)) {
2072 $this->loadRequireJsModule('TYPO3/CMS/Lang/Lang');
2073 }
2074 }
2075 }
2076 return $out;
2077 }
2078
2079 /**
2080 * Load the language strings into JavaScript
2081 */
2082 protected function loadJavaScriptLanguageStrings()
2083 {
2084 if (!empty($this->inlineLanguageLabelFiles)) {
2085 foreach ($this->inlineLanguageLabelFiles as $languageLabelFile) {
2086 $this->includeLanguageFileForInline($languageLabelFile['fileRef'], $languageLabelFile['selectionPrefix'], $languageLabelFile['stripFromSelectionName']);
2087 }
2088 }
2089 $this->inlineLanguageLabelFiles = [];
2090 // Convert settings back to UTF-8 since json_encode() only works with UTF-8:
2091 if (TYPO3_MODE === 'FE' && $this->getCharSet() !== 'utf-8') {
2092 if ($this->inlineSettings) {
2093 $this->csConvObj->convArray($this->inlineSettings, $this->getCharSet(), 'utf-8');
2094 }
2095 }
2096 }
2097
2098 /**
2099 * Make URLs to all backend ajax handlers available as inline setting.
2100 */
2101 protected function addAjaxUrlsToInlineSettings()
2102 {
2103 $ajaxUrls = [];
2104 // Add the ajax-based routes
2105 /** @var UriBuilder $uriBuilder */
2106 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
2107 /** @var Router $router */
2108 $router = GeneralUtility::makeInstance(Router::class);
2109 $routes = $router->getRoutes();
2110 foreach ($routes as $routeIdentifier => $route) {
2111 if ($route->getOption('ajax')) {
2112 $uri = (string)$uriBuilder->buildUriFromRoute($routeIdentifier);
2113 // use the shortened value in order to use this in JavaScript
2114 $routeIdentifier = str_replace('ajax_', '', $routeIdentifier);
2115 $ajaxUrls[$routeIdentifier] = $uri;
2116 }
2117 }
2118
2119 $this->inlineSettings['ajaxUrls'] = $ajaxUrls;
2120 }
2121
2122 /**
2123 * Renders the HTML script tag for the given jQuery version.
2124 *
2125 * @param string $version The jQuery version that should be included, either "latest" or any available version
2126 * @param string $source The location of the jQuery source, can be "local", "google", "msn" or "jquery
2127 * @param string $namespace The namespace in which the jQuery object of the specific version should be stored
2128 * @return string
2129 */
2130 protected function renderJqueryScriptTag($version, $source, $namespace)
2131 {
2132 switch (true) {
2133 case isset($this->jQueryCdnUrls[$source]):
2134 if ($this->enableJqueryDebug) {
2135 $minifyPart = '';
2136 } else {
2137 $minifyPart = '.min';
2138 }
2139 $jQueryFileName = sprintf($this->jQueryCdnUrls[$source], $version, $minifyPart);
2140 break;
2141 case $source === 'local':
2142 $jQueryFileName = $this->jQueryPath . 'jquery-' . rawurlencode($version);
2143 if ($this->enableJqueryDebug) {
2144 $jQueryFileName .= '.js';
2145 } else {
2146 $jQueryFileName .= '.min.js';
2147 }
2148 $jQueryFileName = $this->processJsFile($jQueryFileName);
2149 break;
2150 default:
2151 $jQueryFileName = $source;
2152 }
2153 // Include the jQuery Core
2154 $scriptTag = '<script src="' . htmlspecialchars($jQueryFileName) . '" type="text/javascript"></script>' . LF;
2155 // Set the noConflict mode to be available via "TYPO3.jQuery" in all installations
2156 switch ($namespace) {
2157 case self::JQUERY_NAMESPACE_DEFAULT_NOCONFLICT:
2158 $scriptTag .= GeneralUtility::wrapJS('jQuery.noConflict();') . LF;
2159 break;
2160 case self::JQUERY_NAMESPACE_NONE:
2161 break;
2162 case self::JQUERY_NAMESPACE_DEFAULT:
2163
2164 default:
2165 $scriptTag .= GeneralUtility::wrapJS('var TYPO3 = TYPO3 || {}; TYPO3.' . $namespace . ' = jQuery.noConflict(true); var $ = TYPO3.' . $namespace . ';') . LF;
2166 }
2167 return $scriptTag;
2168 }
2169
2170 /**
2171 * Render CSS library files
2172 *
2173 * @return string
2174 */
2175 protected function renderCssLibraries()
2176 {
2177 $cssFiles = '';
2178 if (!empty($this->cssLibs)) {
2179 foreach ($this->cssLibs as $file => $properties) {
2180 $file = $this->getStreamlinedFileName($file);
2181 $tag = '<link rel="' . htmlspecialchars($properties['rel'])
2182 . '" type="text/css" href="' . htmlspecialchars($file)
2183 . '" media="' . htmlspecialchars($properties['media']) . '"'
2184 . ($properties['title'] ? ' title="' . htmlspecialchars($properties['title']) . '"' : '')
2185 . $this->endingSlash . '>';
2186 if ($properties['allWrap']) {
2187 $wrapArr = explode($properties['splitChar'] ?: '|', $properties['allWrap'], 2);
2188 $tag = $wrapArr[0] . $tag . $wrapArr[1];
2189 }
2190 $tag .= LF;
2191 if ($properties['forceOnTop']) {
2192 $cssFiles = $tag . $cssFiles;
2193 } else {
2194 $cssFiles .= $tag;
2195 }
2196 }
2197 }
2198 return $cssFiles;
2199 }
2200
2201 /**
2202 * Render CSS files
2203 *
2204 * @return string
2205 */
2206 protected function renderCssFiles()
2207 {
2208 $cssFiles = '';
2209 if (!empty($this->cssFiles)) {
2210 foreach ($this->cssFiles as $file => $properties) {
2211 $file = $this->getStreamlinedFileName($file);
2212 $tag = '<link rel="' . htmlspecialchars($properties['rel'])
2213 . '" type="text/css" href="' . htmlspecialchars($file)
2214 . '" media="' . htmlspecialchars($properties['media']) . '"'
2215 . ($properties['title'] ? ' title="' . htmlspecialchars($properties['title']) . '"' : '')
2216 . $this->endingSlash . '>';
2217 if ($properties['allWrap']) {
2218 $wrapArr = explode($properties['splitChar'] ?: '|', $properties['allWrap'], 2);
2219 $tag = $wrapArr[0] . $tag . $wrapArr[1];
2220 }
2221 $tag .= LF;
2222 if ($properties['forceOnTop']) {
2223 $cssFiles = $tag . $cssFiles;
2224 } else {
2225 $cssFiles .= $tag;
2226 }
2227 }
2228 }
2229 return $cssFiles;
2230 }
2231
2232 /**
2233 * Render inline CSS
2234 *
2235 * @return string
2236 */
2237 protected function renderCssInline()
2238 {
2239 $cssInline = '';
2240 if (!empty($this->cssInline)) {
2241 foreach ($this->cssInline as $name => $properties) {
2242 $cssCode = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF;
2243 if ($properties['forceOnTop']) {
2244 $cssInline = $cssCode . $cssInline;
2245 } else {
2246 $cssInline .= $cssCode;
2247 }
2248 }
2249 $cssInline = $this->inlineCssWrap[0] . $cssInline . $this->inlineCssWrap[1];
2250 }
2251 return $cssInline;
2252 }
2253
2254 /**
2255 * Render JavaScipt libraries
2256 *
2257 * @return array<string> jsLibs and jsFooterLibs strings
2258 */
2259 protected function renderAdditionalJavaScriptLibraries()
2260 {
2261 $jsLibs = '';
2262 $jsFooterLibs = '';
2263 if (!empty($this->jsLibs)) {
2264 foreach ($this->jsLibs as $properties) {
2265 $properties['file'] = $this->getStreamlinedFileName($properties['file']);
2266 $async = ($properties['async']) ? ' async="async"' : '';
2267 $integrity = ($properties['integrity']) ? ' integrity="' . htmlspecialchars($properties['integrity']) . '" crossorigin="anonymous"' : '';
2268 $tag = '<script src="' . htmlspecialchars($properties['file']) . '" type="' . htmlspecialchars($properties['type']) . '"' . $async . $integrity . '></script>';
2269 if ($properties['allWrap']) {
2270 $wrapArr = explode($properties['splitChar'] ?: '|', $properties['allWrap'], 2);
2271 $tag = $wrapArr[0] . $tag . $wrapArr[1];
2272 }
2273 $tag .= LF;
2274 if ($properties['forceOnTop']) {
2275 if ($properties['section'] === self::PART_HEADER) {
2276 $jsLibs = $tag . $jsLibs;
2277 } else {
2278 $jsFooterLibs = $tag . $jsFooterLibs;
2279 }
2280 } else {
2281 if ($properties['section'] === self::PART_HEADER) {
2282 $jsLibs .= $tag;
2283 } else {
2284 $jsFooterLibs .= $tag;
2285 }
2286 }
2287 }
2288 }
2289 if ($this->moveJsFromHeaderToFooter) {
2290 $jsFooterLibs = $jsLibs . LF . $jsFooterLibs;
2291 $jsLibs = '';
2292 }
2293 return [$jsLibs, $jsFooterLibs];
2294 }
2295
2296 /**
2297 * Render JavaScript files
2298 *
2299 * @return array<string> jsFiles and jsFooterFiles strings
2300 */
2301 protected function renderJavaScriptFiles()
2302 {
2303 $jsFiles = '';
2304 $jsFooterFiles = '';
2305 if (!empty($this->jsFiles)) {
2306 foreach ($this->jsFiles as $file => $properties) {
2307 $file = $this->getStreamlinedFileName($file);
2308 $async = ($properties['async']) ? ' async="async"' : '';
2309 $integrity = ($properties['integrity']) ? ' integrity="' . htmlspecialchars($properties['integrity']) . '" crossorigin="anonymous"' : '';
2310 $tag = '<script src="' . htmlspecialchars($file) . '" type="' . htmlspecialchars($properties['type']) . '"' . $async . $integrity . '></script>';
2311 if ($properties['allWrap']) {
2312 $wrapArr = explode($properties['splitChar'] ?: '|', $properties['allWrap'], 2);
2313 $tag = $wrapArr[0] . $tag . $wrapArr[1];
2314 }
2315 $tag .= LF;
2316 if ($properties['forceOnTop']) {
2317 if ($properties['section'] === self::PART_HEADER) {
2318 $jsFiles = $tag . $jsFiles;
2319 } else {
2320 $jsFooterFiles = $tag . $jsFooterFiles;
2321 }
2322 } else {
2323 if ($properties['section'] === self::PART_HEADER) {
2324 $jsFiles .= $tag;
2325 } else {
2326 $jsFooterFiles .= $tag;
2327 }
2328 }
2329 }
2330 }
2331 if ($this->moveJsFromHeaderToFooter) {
2332 $jsFooterFiles = $jsFiles . $jsFooterFiles;
2333 $jsFiles = '';
2334 }
2335 return [$jsFiles, $jsFooterFiles];
2336 }
2337
2338 /**
2339 * Render inline JavaScript
2340 *
2341 * @return array<string> jsInline and jsFooterInline string
2342 */
2343 protected function renderInlineJavaScript()
2344 {
2345 $jsInline = '';
2346 $jsFooterInline = '';
2347 if (!empty($this->jsInline)) {
2348 foreach ($this->jsInline as $name => $properties) {
2349 $jsCode = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF;
2350 if ($properties['forceOnTop']) {
2351 if ($properties['section'] === self::PART_HEADER) {
2352 $jsInline = $jsCode . $jsInline;
2353 } else {
2354 $jsFooterInline = $jsCode . $jsFooterInline;
2355 }
2356 } else {
2357 if ($properties['section'] === self::PART_HEADER) {
2358 $jsInline .= $jsCode;
2359 } else {
2360 $jsFooterInline .= $jsCode;
2361 }
2362 }
2363 }
2364 }
2365 if ($jsInline) {
2366 $jsInline = $this->inlineJavascriptWrap[0] . $jsInline . $this->inlineJavascriptWrap[1];
2367 }
2368 if ($jsFooterInline) {
2369 $jsFooterInline = $this->inlineJavascriptWrap[0] . $jsFooterInline . $this->inlineJavascriptWrap[1];
2370 }
2371 if ($this->moveJsFromHeaderToFooter) {
2372 $jsFooterInline = $jsInline . $jsFooterInline;
2373 $jsInline = '';
2374 }
2375 return [$jsInline, $jsFooterInline];
2376 }
2377
2378 /**
2379 * Include language file for inline usage
2380 *
2381 * @param string $fileRef
2382 * @param string $selectionPrefix
2383 * @param string $stripFromSelectionName
2384 * @throws \RuntimeException
2385 */
2386 protected function includeLanguageFileForInline($fileRef, $selectionPrefix = '', $stripFromSelectionName = '')
2387 {
2388 if (!isset($this->lang) || !isset($this->charSet)) {
2389 throw new \RuntimeException('Language and character encoding are not set.', 1284906026);
2390 }
2391 $labelsFromFile = [];
2392 $allLabels = $this->readLLfile($fileRef);
2393 if ($allLabels !== false) {
2394 // Merge language specific translations:
2395 if ($this->lang !== 'default' && isset($allLabels[$this->lang])) {
2396 $labels = array_merge($allLabels['default'], $allLabels[$this->lang]);
2397 } else {
2398 $labels = $allLabels['default'];
2399 }
2400 // Iterate through all locallang labels:
2401 foreach ($labels as $label => $value) {
2402 // If $selectionPrefix is set, only respect labels that start with $selectionPrefix
2403 if ($selectionPrefix === '' || strpos($label, $selectionPrefix) === 0) {
2404 // Remove substring $stripFromSelectionName from label
2405 $label = str_replace($stripFromSelectionName, '', $label);
2406 $labelsFromFile[$label] = $value;
2407 }
2408 }
2409 $this->inlineLanguageLabels = array_merge($this->inlineLanguageLabels, $labelsFromFile);
2410 }
2411 }
2412
2413 /**
2414 * Reads a locallang file.
2415 *
2416 * @param string $fileRef Reference to a relative filename to include.
2417 * @return array Returns the $LOCAL_LANG array found in the file. If no array found, returns empty array.
2418 */
2419 protected function readLLfile($fileRef)
2420 {
2421 /** @var $languageFactory LocalizationFactory */
2422 $languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
2423
2424 if ($this->lang !== 'default') {
2425 $languages = array_reverse($this->languageDependencies);
2426 // At least we need to have English
2427 if (empty($languages)) {
2428 $languages[] = 'default';
2429 }
2430 } else {
2431 $languages = ['default'];
2432 }
2433
2434 $localLanguage = [];
2435 foreach ($languages as $language) {
2436 $tempLL = $languageFactory->getParsedData($fileRef, $language);
2437
2438 $localLanguage['default'] = $tempLL['default'];
2439 if (!isset($localLanguage[$this->lang])) {
2440 $localLanguage[$this->lang] = $localLanguage['default'];
2441 }
2442 if ($this->lang !== 'default' && isset($tempLL[$language])) {
2443 // Merge current language labels onto labels from previous language
2444 // This way we have a labels with fall back applied
2445 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($localLanguage[$this->lang], $tempLL[$language], true, false);
2446 }
2447 }
2448
2449 return $localLanguage;
2450 }
2451
2452 /*****************************************************/
2453 /* */
2454 /* Tools */
2455 /* */
2456 /*****************************************************/
2457 /**
2458 * Concatenate files into one file
2459 * registered handler
2460 */
2461 protected function doConcatenate()
2462 {
2463 $this->doConcatenateCss();
2464 $this->doConcatenateJavaScript();
2465 }
2466
2467 /**
2468 * Concatenate JavaScript files according to the configuration.
2469 */
2470 protected function doConcatenateJavaScript()
2471 {
2472 if ($this->concatenateFiles || $this->concatenateJavascript) {
2473 if (!empty($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsConcatenateHandler'])) {
2474 // use external concatenation routine
2475 $params = [
2476 'jsLibs' => &$this->jsLibs,
2477 'jsFiles' => &$this->jsFiles,
2478 'jsFooterFiles' => &$this->jsFooterFiles,
2479 'headerData' => &$this->headerData,
2480 'footerData' => &$this->footerData
2481 ];
2482 GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsConcatenateHandler'], $params, $this);
2483 } else {
2484 $this->jsLibs = $this->getCompressor()->concatenateJsFiles($this->jsLibs);
2485 $this->jsFiles = $this->getCompressor()->concatenateJsFiles($this->jsFiles);
2486 $this->jsFooterFiles = $this->getCompressor()->concatenateJsFiles($this->jsFooterFiles);
2487 }
2488 }
2489 }
2490
2491 /**
2492 * Concatenate CSS files according to configuration.
2493 */
2494 protected function doConcatenateCss()
2495 {
2496 if ($this->concatenateFiles || $this->concatenateCss) {
2497 if (!empty($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssConcatenateHandler'])) {
2498 // use external concatenation routine
2499 $params = [
2500 'cssFiles' => &$this->cssFiles,
2501 'cssLibs' => &$this->cssLibs,
2502 'headerData' => &$this->headerData,
2503 'footerData' => &$this->footerData
2504 ];
2505 GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssConcatenateHandler'], $params, $this);
2506 } else {
2507 $cssOptions = [];
2508 if (TYPO3_MODE === 'BE') {
2509 $cssOptions = ['baseDirectories' => $GLOBALS['TBE_TEMPLATE']->getSkinStylesheetDirectories()];
2510 }
2511 $this->cssLibs = $this->getCompressor()->concatenateCssFiles($this->cssLibs, $cssOptions);
2512 $this->cssFiles = $this->getCompressor()->concatenateCssFiles($this->cssFiles, $cssOptions);
2513 }
2514 }
2515 }
2516
2517 /**
2518 * Compresses inline code
2519 */
2520 protected function doCompress()
2521 {
2522 $this->doCompressJavaScript();
2523 $this->doCompressCss();
2524 }
2525
2526 /**
2527 * Compresses CSS according to configuration.
2528 */
2529 protected function doCompressCss()
2530 {
2531 if ($this->compressCss) {
2532 if (!empty($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler'])) {
2533 // Use external compression routine
2534 $params = [
2535 'cssInline' => &$this->cssInline,
2536 'cssFiles' => &$this->cssFiles,
2537 'cssLibs' => &$this->cssLibs,
2538 'headerData' => &$this->headerData,
2539 'footerData' => &$this->footerData
2540 ];
2541 GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler'], $params, $this);
2542 } else {
2543 $this->cssLibs = $this->getCompressor()->compressCssFiles($this->cssLibs);
2544 $this->cssFiles = $this->getCompressor()->compressCssFiles($this->cssFiles);
2545 }
2546 }
2547 }
2548
2549 /**
2550 * Compresses JavaScript according to configuration.
2551 */
2552 protected function doCompressJavaScript()
2553 {
2554 if ($this->compressJavascript) {
2555 if (!empty($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler'])) {
2556 // Use external compression routine
2557 $params = [
2558 'jsInline' => &$this->jsInline,
2559 'jsFooterInline' => &$this->jsFooterInline,
2560 'jsLibs' => &$this->jsLibs,
2561 'jsFiles' => &$this->jsFiles,
2562 'jsFooterFiles' => &$this->jsFooterFiles,
2563 'headerData' => &$this->headerData,
2564 'footerData' => &$this->footerData
2565 ];
2566 GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler'], $params, $this);
2567 } else {
2568 // Traverse the arrays, compress files
2569 if (!empty($this->jsInline)) {
2570 foreach ($this->jsInline as $name => $properties) {
2571 if ($properties['compress']) {
2572 $error = '';
2573 $this->jsInline[$name]['code'] = GeneralUtility::minifyJavaScript($properties['code'], $error);
2574 if ($error) {
2575 $this->compressError .= 'Error with minify JS Inline Block "' . $name . '": ' . $error . LF;
2576 }
2577 }
2578 }
2579 }
2580 $this->jsLibs = $this->getCompressor()->compressJsFiles($this->jsLibs);
2581 $this->jsFiles = $this->getCompressor()->compressJsFiles($this->jsFiles);
2582 $this->jsFooterFiles = $this->getCompressor()->compressJsFiles($this->jsFooterFiles);
2583 }
2584 }
2585 }
2586
2587 /**
2588 * Returns instance of \TYPO3\CMS\Core\Resource\ResourceCompressor
2589 *
2590 * @return \TYPO3\CMS\Core\Resource\ResourceCompressor
2591 */
2592 protected function getCompressor()
2593 {
2594 if ($this->compressor === null) {
2595 $this->compressor = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\ResourceCompressor::class);
2596 }
2597 return $this->compressor;
2598 }
2599
2600 /**
2601 * Processes a Javascript file dependent on the current context
2602 *
2603 * Adds the version number for Frontend, compresses the file for Backend
2604 *
2605 * @param string $filename Filename
2606 * @return string New filename
2607 */
2608 protected function processJsFile($filename)
2609 {
2610 $filename = $this->getStreamlinedFileName($filename, false);
2611 if ($this->compressJavascript) {
2612 $filename = $this->getCompressor()->compressJsFile($filename);
2613 } elseif (TYPO3_MODE === 'FE') {
2614 $filename = GeneralUtility::createVersionNumberedFilename($filename);
2615 }
2616 return PathUtility::getAbsoluteWebPath($filename);
2617 }
2618
2619 /**
2620 * This function acts as a wrapper to allow relative and paths starting with EXT: to be dealt with
2621 * in this very case to always return the absolute web path to be included directly before output.
2622 *
2623 * This is mainly added so the EXT: syntax can be resolved for PageRenderer in one central place,
2624 * and hopefully removed in the future by one standard API call.
2625 *
2626 * @param string $file the filename to process
2627 * @param bool $prepareForOutput whether the file should be prepared as version numbered file and prefixed as absolute webpath
2628 * @return string
2629 * @internal
2630 */
2631 protected function getStreamlinedFileName($file, $prepareForOutput = true)
2632 {
2633 if (strpos($file, 'EXT:') === 0) {
2634 $file = GeneralUtility::getFileAbsFileName($file);
2635 // as the path is now absolute, make it "relative" to the current script to stay compatible
2636 $file = PathUtility::getRelativePathTo($file);
2637 $file = rtrim($file, '/');
2638 } else {
2639 $file = GeneralUtility::resolveBackPath($file);
2640 }
2641 if ($prepareForOutput) {
2642 $file = GeneralUtility::createVersionNumberedFilename($file);
2643 $file = PathUtility::getAbsoluteWebPath($file);
2644 }
2645 return $file;
2646 }
2647
2648 /**
2649 * Returns global frontend controller
2650 *
2651 * @return TypoScriptFrontendController
2652 */
2653 protected function getTypoScriptFrontendController()
2654 {
2655 return $GLOBALS['TSFE'];
2656 }
2657
2658 /**
2659 * Returns global language service instance
2660 *
2661 * @return \TYPO3\CMS\Core\Localization\LanguageService
2662 */
2663 protected function getLanguageService()
2664 {
2665 return $GLOBALS['LANG'];
2666 }
2667
2668 /*****************************************************/
2669 /* */
2670 /* Hooks */
2671 /* */
2672 /*****************************************************/
2673 /**
2674 * Execute PreRenderHook for possible manipulation
2675 */
2676 protected function executePreRenderHook()
2677 {
2678 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'])) {
2679 $params = [
2680 'jsLibs' => &$this->jsLibs,
2681 'jsFooterLibs' => &$this->jsFooterLibs,
2682 'jsFiles' => &$this->jsFiles,
2683 'jsFooterFiles' => &$this->jsFooterFiles,
2684 'cssLibs' => &$this->cssLibs,
2685 'cssFiles' => &$this->cssFiles,
2686 'headerData' => &$this->headerData,
2687 'footerData' => &$this->footerData,
2688 'jsInline' => &$this->jsInline,
2689 'jsFooterInline' => &$this->jsFooterInline,
2690 'cssInline' => &$this->cssInline
2691 ];
2692 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'] as $hook) {
2693 GeneralUtility::callUserFunction($hook, $params, $this);
2694 }
2695 }
2696 }
2697
2698 /**
2699 * PostTransform for possible manipulation of concatenated and compressed files
2700 */
2701 protected function executeRenderPostTransformHook()
2702 {
2703 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postTransform'])) {
2704 $params = [
2705 'jsLibs' => &$this->jsLibs,
2706 'jsFooterLibs' => &$this->jsFooterLibs,
2707 'jsFiles' => &$this->jsFiles,
2708 'jsFooterFiles' => &$this->jsFooterFiles,
2709 'cssLibs' => &$this->cssLibs,
2710 'cssFiles' => &$this->cssFiles,
2711 'headerData' => &$this->headerData,
2712 'footerData' => &$this->footerData,
2713 'jsInline' => &$this->jsInline,
2714 'jsFooterInline' => &$this->jsFooterInline,
2715 'cssInline' => &$this->cssInline
2716 ];
2717 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postTransform'] as $hook) {
2718 GeneralUtility::callUserFunction($hook, $params, $this);
2719 }
2720 }
2721 }
2722
2723 /**
2724 * Execute postRenderHook for possible manipulation
2725 *
2726 * @param $jsLibs string
2727 * @param $jsFiles string
2728 * @param $jsFooterFiles string
2729 * @param $cssLibs string
2730 * @param $cssFiles string
2731 * @param $jsInline string
2732 * @param $cssInline string
2733 * @param $jsFooterInline string
2734 * @param $jsFooterLibs string
2735 */
2736 protected function executePostRenderHook(&$jsLibs, &$jsFiles, &$jsFooterFiles, &$cssLibs, &$cssFiles, &$jsInline, &$cssInline, &$jsFooterInline, &$jsFooterLibs)
2737 {
2738 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess'])) {
2739 $params = [
2740 'jsLibs' => &$jsLibs,
2741 'jsFiles' => &$jsFiles,
2742 'jsFooterFiles' => &$jsFooterFiles,
2743 'cssLibs' => &$cssLibs,
2744 'cssFiles' => &$cssFiles,
2745 'headerData' => &$this->headerData,
2746 'footerData' => &$this->footerData,
2747 'jsInline' => &$jsInline,
2748 'cssInline' => &$cssInline,
2749 'xmlPrologAndDocType' => &$this->xmlPrologAndDocType,
2750 'htmlTag' => &$this->htmlTag,
2751 'headTag' => &$this->headTag,
2752 'charSet' => &$this->charSet,
2753 'metaCharsetTag' => &$this->metaCharsetTag,
2754 'shortcutTag' => &$this->shortcutTag,
2755 'inlineComments' => &$this->inlineComments,
2756 'baseUrl' => &$this->baseUrl,
2757 'baseUrlTag' => &$this->baseUrlTag,
2758 'favIcon' => &$this->favIcon,
2759 'iconMimeType' => &$this->iconMimeType,
2760 'titleTag' => &$this->titleTag,
2761 'title' => &$this->title,
2762 'metaTags' => &$this->metaTags,
2763 'jsFooterInline' => &$jsFooterInline,
2764 'jsFooterLibs' => &$jsFooterLibs,
2765 'bodyContent' => &$this->bodyContent
2766 ];
2767 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess'] as $hook) {
2768 GeneralUtility::callUserFunction($hook, $params, $this);
2769 }
2770 }
2771 }
2772 }