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