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