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