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