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