[TASK] Move BE Login BrowserLanguage detection to Locales
[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 /** @var $extDirect \TYPO3\CMS\Core\ExtDirect\ExtDirectApi */
1340 $extDirect = GeneralUtility::makeInstance(\TYPO3\CMS\Core\ExtDirect\ExtDirectApi::class);
1341 $api = $extDirect->getApiPhp($filterNamespaces);
1342 if ($api) {
1343 $this->addJsInlineCode('TYPO3ExtDirectAPI', $api, false);
1344 }
1345 // Note: we need to iterate thru the object, because the addProvider method
1346 // does this only with multiple arguments
1347 $this->addExtOnReadyCode('
1348 (function() {
1349 TYPO3.ExtDirectToken = "' . $token . '";
1350 for (var api in Ext.app.ExtDirectAPI) {
1351 var provider = Ext.Direct.addProvider(Ext.app.ExtDirectAPI[api]);
1352 provider.on("beforecall", function(provider, transaction, meta) {
1353 if (transaction.data) {
1354 transaction.data[transaction.data.length] = TYPO3.ExtDirectToken;
1355 } else {
1356 transaction.data = [TYPO3.ExtDirectToken];
1357 }
1358 });
1359
1360 provider.on("call", function(provider, transaction, meta) {
1361 if (transaction.isForm) {
1362 transaction.params.securityToken = TYPO3.ExtDirectToken;
1363 }
1364 });
1365 }
1366 })();
1367
1368 var extDirectDebug = function(message, header, group) {
1369 var DebugConsole = null;
1370
1371 if (top && top.TYPO3 && typeof top.TYPO3.DebugConsole === "object") {
1372 DebugConsole = top.TYPO3.DebugConsole;
1373 } else if (typeof TYPO3 === "object" && typeof TYPO3.DebugConsole === "object") {
1374 DebugConsole = TYPO3.DebugConsole;
1375 }
1376
1377 if (DebugConsole !== null) {
1378 DebugConsole.add(message, header, group);
1379 } else if (typeof console === "object") {
1380 console.log(message);
1381 } else {
1382 document.write(message);
1383 }
1384 };
1385
1386 Ext.Direct.on("exception", function(event) {
1387 if (event.code === Ext.Direct.exceptions.TRANSPORT && !event.where) {
1388 top.TYPO3.Notification.error(
1389 TYPO3.l10n.localize("extDirect_timeoutHeader"),
1390 TYPO3.l10n.localize("extDirect_timeoutMessage")
1391 );
1392 } else {
1393 var backtrace = "";
1394 if (event.code === "parse") {
1395 extDirectDebug(
1396 "<p>" + event.xhr.responseText + "<\\/p>",
1397 event.type,
1398 "ExtDirect - Exception"
1399 );
1400 } else if (event.code === "router") {
1401 top.TYPO3.Notification.error(
1402 event.code,
1403 event.message
1404 );
1405 } else if (event.where) {
1406 backtrace = "<p style=\\"margin-top: 20px;\\">" +
1407 "<strong>Backtrace:<\\/strong><br \\/>" +
1408 event.where.replace(/#/g, "<br \\/>#") +
1409 "<\\/p>";
1410 extDirectDebug(
1411 "<p>" + event.message + "<\\/p>" + backtrace,
1412 event.method,
1413 "ExtDirect - Exception"
1414 );
1415 }
1416
1417
1418 }
1419 });
1420
1421 Ext.Direct.on("event", function(event, provider) {
1422 if (typeof event.debug !== "undefined" && event.debug !== "") {
1423 extDirectDebug(event.debug, event.method, "ExtDirect - Debug");
1424 }
1425 });
1426 ', true);
1427 }
1428
1429 /**
1430 * Adds CSS file
1431 *
1432 * @param string $file
1433 * @param string $rel
1434 * @param string $media
1435 * @param string $title
1436 * @param bool $compress
1437 * @param bool $forceOnTop
1438 * @param string $allWrap
1439 * @param bool $excludeFromConcatenation
1440 * @param string $splitChar The char used to split the allWrap value, default is "|"
1441 * @return void
1442 */
1443 public function addCssFile($file, $rel = 'stylesheet', $media = 'all', $title = '', $compress = true, $forceOnTop = false, $allWrap = '', $excludeFromConcatenation = false, $splitChar = '|')
1444 {
1445 if (!isset($this->cssFiles[$file])) {
1446 $this->cssFiles[$file] = array(
1447 'file' => $file,
1448 'rel' => $rel,
1449 'media' => $media,
1450 'title' => $title,
1451 'compress' => $compress,
1452 'forceOnTop' => $forceOnTop,
1453 'allWrap' => $allWrap,
1454 'excludeFromConcatenation' => $excludeFromConcatenation,
1455 'splitChar' => $splitChar
1456 );
1457 }
1458 }
1459
1460 /**
1461 * Adds CSS file
1462 *
1463 * @param string $file
1464 * @param string $rel
1465 * @param string $media
1466 * @param string $title
1467 * @param bool $compress
1468 * @param bool $forceOnTop
1469 * @param string $allWrap
1470 * @param bool $excludeFromConcatenation
1471 * @param string $splitChar The char used to split the allWrap value, default is "|"
1472 * @return void
1473 */
1474 public function addCssLibrary($file, $rel = 'stylesheet', $media = 'all', $title = '', $compress = true, $forceOnTop = false, $allWrap = '', $excludeFromConcatenation = false, $splitChar = '|')
1475 {
1476 if (!isset($this->cssLibs[$file])) {
1477 $this->cssLibs[$file] = array(
1478 'file' => $file,
1479 'rel' => $rel,
1480 'media' => $media,
1481 'title' => $title,
1482 'compress' => $compress,
1483 'forceOnTop' => $forceOnTop,
1484 'allWrap' => $allWrap,
1485 'excludeFromConcatenation' => $excludeFromConcatenation,
1486 'splitChar' => $splitChar
1487 );
1488 }
1489 }
1490
1491 /**
1492 * Adds CSS inline code
1493 *
1494 * @param string $name
1495 * @param string $block
1496 * @param bool $compress
1497 * @param bool $forceOnTop
1498 * @return void
1499 */
1500 public function addCssInlineBlock($name, $block, $compress = false, $forceOnTop = false)
1501 {
1502 if (!isset($this->cssInline[$name]) && !empty($block)) {
1503 $this->cssInline[$name] = array(
1504 'code' => $block,
1505 'compress' => $compress,
1506 'forceOnTop' => $forceOnTop
1507 );
1508 }
1509 }
1510
1511 /**
1512 * Call this function if you need to include the jQuery library
1513 *
1514 * @param null|string $version The jQuery version that should be included, either "latest" or any available version
1515 * @param null|string $source The location of the jQuery source, can be "local", "google", "msn", "jquery" or just an URL to your jQuery lib
1516 * @param string $namespace The namespace in which the jQuery object of the specific version should be stored.
1517 * @return void
1518 * @throws \UnexpectedValueException
1519 */
1520 public function loadJquery($version = null, $source = null, $namespace = self::JQUERY_NAMESPACE_DEFAULT)
1521 {
1522 // Set it to the version that is shipped with the TYPO3 core
1523 if ($version === null || $version === 'latest') {
1524 $version = self::JQUERY_VERSION_LATEST;
1525 }
1526 // Check if the source is set, otherwise set it to "default"
1527 if ($source === null) {
1528 $source = 'local';
1529 }
1530 if ($source === 'local' && !in_array($version, $this->availableLocalJqueryVersions)) {
1531 throw new \UnexpectedValueException('The requested jQuery version is not available in the local filesystem.', 1341505305);
1532 }
1533 if (!preg_match('/^[a-zA-Z0-9]+$/', $namespace)) {
1534 throw new \UnexpectedValueException('The requested namespace contains non alphanumeric characters.', 1341571604);
1535 }
1536 $this->jQueryVersions[$namespace] = array(
1537 'version' => $version,
1538 'source' => $source
1539 );
1540 }
1541
1542 /**
1543 * Call function if you need the requireJS library
1544 * this automatically adds the JavaScript path of all loaded extensions in the requireJS path option
1545 * so it resolves names like TYPO3/CMS/MyExtension/MyJsFile to EXT:MyExtension/Resources/Public/JavaScript/MyJsFile.js
1546 * when using requireJS
1547 *
1548 * @return void
1549 */
1550 public function loadRequireJs()
1551 {
1552
1553 // load all paths to map to package names / namespaces
1554 if (empty($this->requireJsConfig)) {
1555 // In order to avoid browser caching of JS files, adding a GET parameter to the files loaded via requireJS
1556 if (GeneralUtility::getApplicationContext()->isDevelopment()) {
1557 $this->requireJsConfig['urlArgs'] = 'bust=' . $GLOBALS['EXEC_TIME'];
1558 } else {
1559 $this->requireJsConfig['urlArgs'] = 'bust=' . GeneralUtility::hmac(TYPO3_version . PATH_site);
1560 }
1561 $corePath = ExtensionManagementUtility::extPath('core', 'Resources/Public/JavaScript/Contrib/');
1562 $corePath = PathUtility::getAbsoluteWebPath($corePath);
1563 // first, load all paths for the namespaces, and configure contrib libs.
1564 $this->requireJsConfig['paths'] = array(
1565 'jquery-ui' => $corePath . 'jquery-ui',
1566 'datatables' => $corePath . 'jquery.dataTables',
1567 'nprogress' => $corePath . 'nprogress',
1568 'moment' => $corePath . 'moment',
1569 'cropper' => $corePath . 'cropper.min',
1570 'imagesloaded' => $corePath . 'imagesloaded.pkgd.min',
1571 'bootstrap' => $corePath . 'bootstrap/bootstrap',
1572 'twbs/bootstrap-datetimepicker' => $corePath . 'bootstrap-datetimepicker',
1573 'autosize' => $corePath . 'autosize',
1574 'taboverride' => $corePath . 'taboverride.min',
1575 'twbs/bootstrap-slider' => $corePath . 'bootstrap-slider.min',
1576 'jquery/autocomplete' => $corePath . 'jquery.autocomplete',
1577 );
1578 // get all extensions that are loaded
1579 $loadedExtensions = ExtensionManagementUtility::getLoadedExtensionListArray();
1580 foreach ($loadedExtensions as $packageName) {
1581 $fullJsPath = 'EXT:' . $packageName . '/Resources/Public/JavaScript/';
1582 $fullJsPath = GeneralUtility::getFileAbsFileName($fullJsPath);
1583 $fullJsPath = PathUtility::getAbsoluteWebPath($fullJsPath);
1584 $fullJsPath = rtrim($fullJsPath, '/');
1585 if ($fullJsPath) {
1586 $this->requireJsConfig['paths']['TYPO3/CMS/' . GeneralUtility::underscoredToUpperCamelCase($packageName)] = $fullJsPath;
1587 }
1588 }
1589
1590 // check if additional AMD modules need to be loaded if a single AMD module is initialized
1591 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules'])) {
1592 $this->addInlineSettingArray('RequireJS.PostInitializationModules', $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules']);
1593 }
1594 }
1595
1596 $this->addRequireJs = true;
1597 }
1598
1599 /**
1600 * Add additional configuration to require js.
1601 *
1602 * Configuration will be merged recursive with overrule.
1603 *
1604 * To add another path mapping deliver the following configuration:
1605 * 'paths' => array(
1606 * 'EXTERN/mybootstrapjs' => 'sysext/.../twbs/bootstrap.min',
1607 * ),
1608 *
1609 * @param array $configuration The configuration that will be merged with existing one.
1610 * @return void
1611 */
1612 public function addRequireJsConfiguration(array $configuration)
1613 {
1614 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->requireJsConfig, $configuration);
1615 }
1616
1617 /**
1618 * includes an AMD-compatible JS file by resolving the ModuleName, and then requires the file via a requireJS request,
1619 * additionally allowing to execute JavaScript code afterwards
1620 *
1621 * this function only works for AMD-ready JS modules, used like "define('TYPO3/CMS/Backend/FormEngine..."
1622 * in the JS file
1623 *
1624 * TYPO3/CMS/Backend/FormEngine =>
1625 * "TYPO3": Vendor Name
1626 * "CMS": Product Name
1627 * "Backend": Extension Name
1628 * "FormEngine": FileName in the Resources/Public/JavaScript folder
1629 *
1630 * @param string $mainModuleName Must be in the form of "TYPO3/CMS/PackageName/ModuleName" e.g. "TYPO3/CMS/Backend/FormEngine"
1631 * @param string $callBackFunction loaded right after the requireJS loading, must be wrapped in function() {}
1632 * @return void
1633 */
1634 public function loadRequireJsModule($mainModuleName, $callBackFunction = null)
1635 {
1636 $inlineCodeKey = $mainModuleName;
1637 // make sure requireJS is initialized
1638 $this->loadRequireJs();
1639
1640 // execute the main module, and load a possible callback function
1641 $javaScriptCode = 'require(["' . $mainModuleName . '"]';
1642 if ($callBackFunction !== null) {
1643 $inlineCodeKey .= sha1($callBackFunction);
1644 $javaScriptCode .= ', ' . $callBackFunction;
1645 }
1646 $javaScriptCode .= ');';
1647 $this->addJsInlineCode('RequireJS-Module-' . $inlineCodeKey, $javaScriptCode);
1648 }
1649
1650 /**
1651 * call this function if you need the extJS library
1652 *
1653 * @param bool $css Flag, if set the ext-css will be loaded
1654 * @param bool $theme Flag, if set the ext-theme "grey" will be loaded
1655 * @return void
1656 */
1657 public function loadExtJS($css = true, $theme = true)
1658 {
1659 $this->addExtJS = true;
1660 $this->extJStheme = $theme;
1661 $this->extJScss = $css;
1662 }
1663
1664 /**
1665 * Call this function to load debug version of ExtJS. Use this for development only
1666 *
1667 * @return void
1668 */
1669 public function enableExtJsDebug()
1670 {
1671 $this->enableExtJsDebug = true;
1672 }
1673
1674 /**
1675 * Adds Javascript Inline Label. This will occur in TYPO3.lang - object
1676 * The label can be used in scripts with TYPO3.lang.<key>
1677 * Need extJs loaded
1678 *
1679 * @param string $key
1680 * @param string $value
1681 * @return void
1682 */
1683 public function addInlineLanguageLabel($key, $value)
1684 {
1685 $this->inlineLanguageLabels[$key] = $value;
1686 }
1687
1688 /**
1689 * Adds Javascript Inline Label Array. This will occur in TYPO3.lang - object
1690 * The label can be used in scripts with TYPO3.lang.<key>
1691 * Array will be merged with existing array.
1692 * Need extJs loaded
1693 *
1694 * @param array $array
1695 * @param bool $parseWithLanguageService
1696 * @return void
1697 */
1698 public function addInlineLanguageLabelArray(array $array, $parseWithLanguageService = false)
1699 {
1700 if ($parseWithLanguageService === true) {
1701 foreach ($array as $key => $value) {
1702 if (TYPO3_MODE === 'FE') {
1703 $array[$key] = $this->getTypoScriptFrontendController()->sL($value);
1704 } else {
1705 $array[$key] = $this->getLanguageService()->sL($value);
1706 }
1707 }
1708 }
1709
1710 $this->inlineLanguageLabels = array_merge($this->inlineLanguageLabels, $array);
1711 }
1712
1713 /**
1714 * Gets labels to be used in JavaScript fetched from a locallang file.
1715 *
1716 * @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.
1717 * @param string $selectionPrefix Prefix to select the correct labels (default: '')
1718 * @param string $stripFromSelectionName String to be removed from the label names in the output. (default: '')
1719 * @param int $errorMode Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception
1720 * @return void
1721 */
1722 public function addInlineLanguageLabelFile($fileRef, $selectionPrefix = '', $stripFromSelectionName = '', $errorMode = 0)
1723 {
1724 $index = md5($fileRef . $selectionPrefix . $stripFromSelectionName);
1725 if ($fileRef && !isset($this->inlineLanguageLabelFiles[$index])) {
1726 $this->inlineLanguageLabelFiles[$index] = array(
1727 'fileRef' => $fileRef,
1728 'selectionPrefix' => $selectionPrefix,
1729 'stripFromSelectionName' => $stripFromSelectionName,
1730 'errorMode' => $errorMode
1731 );
1732 }
1733 }
1734
1735 /**
1736 * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
1737 * The label can be used in scripts with TYPO3.setting.<key>
1738 * Need extJs loaded
1739 *
1740 * @param string $namespace
1741 * @param string $key
1742 * @param string $value
1743 * @return void
1744 */
1745 public function addInlineSetting($namespace, $key, $value)
1746 {
1747 if ($namespace) {
1748 if (strpos($namespace, '.')) {
1749 $parts = explode('.', $namespace);
1750 $a = &$this->inlineSettings;
1751 foreach ($parts as $part) {
1752 $a = &$a[$part];
1753 }
1754 $a[$key] = $value;
1755 } else {
1756 $this->inlineSettings[$namespace][$key] = $value;
1757 }
1758 } else {
1759 $this->inlineSettings[$key] = $value;
1760 }
1761 }
1762
1763 /**
1764 * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
1765 * The label can be used in scripts with TYPO3.setting.<key>
1766 * Array will be merged with existing array.
1767 * Need extJs loaded
1768 *
1769 * @param string $namespace
1770 * @param array $array
1771 * @return void
1772 */
1773 public function addInlineSettingArray($namespace, array $array)
1774 {
1775 if ($namespace) {
1776 if (strpos($namespace, '.')) {
1777 $parts = explode('.', $namespace);
1778 $a = &$this->inlineSettings;
1779 foreach ($parts as $part) {
1780 $a = &$a[$part];
1781 }
1782 $a = array_merge((array)$a, $array);
1783 } else {
1784 $this->inlineSettings[$namespace] = array_merge((array)$this->inlineSettings[$namespace], $array);
1785 }
1786 } else {
1787 $this->inlineSettings = array_merge($this->inlineSettings, $array);
1788 }
1789 }
1790
1791 /**
1792 * Adds content to body content
1793 *
1794 * @param string $content
1795 * @return void
1796 */
1797 public function addBodyContent($content)
1798 {
1799 $this->bodyContent .= $content;
1800 }
1801
1802 /*****************************************************/
1803 /* */
1804 /* Render Functions */
1805 /* */
1806 /*****************************************************/
1807 /**
1808 * Render the section (Header or Footer)
1809 *
1810 * @param int $part Section which should be rendered: self::PART_COMPLETE, self::PART_HEADER or self::PART_FOOTER
1811 * @return string Content of rendered section
1812 */
1813 public function render($part = self::PART_COMPLETE)
1814 {
1815 $this->prepareRendering();
1816 list($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs) = $this->renderJavaScriptAndCss();
1817 $metaTags = implode(LF, $this->metaTags);
1818 $markerArray = $this->getPreparedMarkerArray($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs, $metaTags);
1819 $template = $this->getTemplateForPart($part);
1820
1821 // The page renderer needs a full reset, even when only rendering one part of the page
1822 // This means that you can only register footer files *after* the header has been already rendered.
1823 // In case you render the footer part first, header files can only be added *after* the footer has been rendered
1824 $this->reset();
1825 $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
1826 return trim($templateService->substituteMarkerArray($template, $markerArray, '###|###'));
1827 }
1828
1829 /**
1830 * Render the page but not the JavaScript and CSS Files
1831 *
1832 * @param string $substituteHash The hash that is used for the placehoder markers
1833 * @access private
1834 * @return string Content of rendered section
1835 */
1836 public function renderPageWithUncachedObjects($substituteHash)
1837 {
1838 $this->prepareRendering();
1839 $markerArray = $this->getPreparedMarkerArrayForPageWithUncachedObjects($substituteHash);
1840 $template = $this->getTemplateForPart(self::PART_COMPLETE);
1841 $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
1842 return trim($templateService->substituteMarkerArray($template, $markerArray, '###|###'));
1843 }
1844
1845 /**
1846 * Renders the JavaScript and CSS files that have been added during processing
1847 * of uncached content objects (USER_INT, COA_INT)
1848 *
1849 * @param string $cachedPageContent
1850 * @param string $substituteHash The hash that is used for the placehoder markers
1851 * @access private
1852 * @return string
1853 */
1854 public function renderJavaScriptAndCssForProcessingOfUncachedContentObjects($cachedPageContent, $substituteHash)
1855 {
1856 $this->prepareRendering();
1857 list($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs) = $this->renderJavaScriptAndCss();
1858 $title = $this->title ? str_replace('|', htmlspecialchars($this->title), $this->titleTag) : '';
1859 $markerArray = array(
1860 '<!-- ###TITLE' . $substituteHash . '### -->' => $title,
1861 '<!-- ###CSS_LIBS' . $substituteHash . '### -->' => $cssLibs,
1862 '<!-- ###CSS_INCLUDE' . $substituteHash . '### -->' => $cssFiles,
1863 '<!-- ###CSS_INLINE' . $substituteHash . '### -->' => $cssInline,
1864 '<!-- ###JS_INLINE' . $substituteHash . '### -->' => $jsInline,
1865 '<!-- ###JS_INCLUDE' . $substituteHash . '### -->' => $jsFiles,
1866 '<!-- ###JS_LIBS' . $substituteHash . '### -->' => $jsLibs,
1867 '<!-- ###HEADERDATA' . $substituteHash . '### -->' => implode(LF, $this->headerData),
1868 '<!-- ###FOOTERDATA' . $substituteHash . '### -->' => implode(LF, $this->footerData),
1869 '<!-- ###JS_LIBS_FOOTER' . $substituteHash . '### -->' => $jsFooterLibs,
1870 '<!-- ###JS_INCLUDE_FOOTER' . $substituteHash . '### -->' => $jsFooterFiles,
1871 '<!-- ###JS_INLINE_FOOTER' . $substituteHash . '### -->' => $jsFooterInline
1872 );
1873 foreach ($markerArray as $placeHolder => $content) {
1874 $cachedPageContent = str_replace($placeHolder, $content, $cachedPageContent);
1875 }
1876 $this->reset();
1877 return $cachedPageContent;
1878 }
1879
1880 /**
1881 * Remove ending slashes from static header block
1882 * if the page is beeing rendered as html (not xhtml)
1883 * and define property $this->endingSlash for further use
1884 *
1885 * @return void
1886 */
1887 protected function prepareRendering()
1888 {
1889 if ($this->getRenderXhtml()) {
1890 $this->endingSlash = ' /';
1891 } else {
1892 $this->metaCharsetTag = str_replace(' />', '>', $this->metaCharsetTag);
1893 $this->baseUrlTag = str_replace(' />', '>', $this->baseUrlTag);
1894 $this->shortcutTag = str_replace(' />', '>', $this->shortcutTag);
1895 $this->endingSlash = '';
1896 }
1897 }
1898
1899 /**
1900 * Renders all JavaScript and CSS
1901 *
1902 * @return array<string>
1903 */
1904 protected function renderJavaScriptAndCss()
1905 {
1906 $this->executePreRenderHook();
1907 $mainJsLibs = $this->renderMainJavaScriptLibraries();
1908 if ($this->concatenateFiles || $this->concatenateJavascript || $this->concatenateCss) {
1909 // Do the file concatenation
1910 $this->doConcatenate();
1911 }
1912 if ($this->compressCss || $this->compressJavascript) {
1913 // Do the file compression
1914 $this->doCompress();
1915 }
1916 $this->executeRenderPostTransformHook();
1917 $cssLibs = $this->renderCssLibraries();
1918 $cssFiles = $this->renderCssFiles();
1919 $cssInline = $this->renderCssInline();
1920 list($jsLibs, $jsFooterLibs) = $this->renderAdditionalJavaScriptLibraries();
1921 list($jsFiles, $jsFooterFiles) = $this->renderJavaScriptFiles();
1922 list($jsInline, $jsFooterInline) = $this->renderInlineJavaScript();
1923 $jsLibs = $mainJsLibs . $jsLibs;
1924 if ($this->moveJsFromHeaderToFooter) {
1925 $jsFooterLibs = $jsLibs . LF . $jsFooterLibs;
1926 $jsLibs = '';
1927 $jsFooterFiles = $jsFiles . LF . $jsFooterFiles;
1928 $jsFiles = '';
1929 $jsFooterInline = $jsInline . LF . $jsFooterInline;
1930 $jsInline = '';
1931 }
1932 $this->executePostRenderHook($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs);
1933 return array($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs);
1934 }
1935
1936 /**
1937 * Fills the marker array with the given strings and trims each value
1938 *
1939 * @param $jsLibs string
1940 * @param $jsFiles string
1941 * @param $jsFooterFiles string
1942 * @param $cssLibs string
1943 * @param $cssFiles string
1944 * @param $jsInline string
1945 * @param $cssInline string
1946 * @param $jsFooterInline string
1947 * @param $jsFooterLibs string
1948 * @param $metaTags string
1949 * @return array Marker array
1950 */
1951 protected function getPreparedMarkerArray($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs, $metaTags)
1952 {
1953 $markerArray = array(
1954 'XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType,
1955 'HTMLTAG' => $this->htmlTag,
1956 'HEADTAG' => $this->headTag,
1957 'METACHARSET' => $this->charSet ? str_replace('|', htmlspecialchars($this->charSet), $this->metaCharsetTag) : '',
1958 'INLINECOMMENT' => $this->inlineComments ? LF . LF . '<!-- ' . LF . implode(LF, $this->inlineComments) . '-->' . LF . LF : '',
1959 'BASEURL' => $this->baseUrl ? str_replace('|', $this->baseUrl, $this->baseUrlTag) : '',
1960 'SHORTCUT' => $this->favIcon ? sprintf($this->shortcutTag, htmlspecialchars($this->favIcon), $this->iconMimeType) : '',
1961 'CSS_LIBS' => $cssLibs,
1962 'CSS_INCLUDE' => $cssFiles,
1963 'CSS_INLINE' => $cssInline,
1964 'JS_INLINE' => $jsInline,
1965 'JS_INCLUDE' => $jsFiles,
1966 'JS_LIBS' => $jsLibs,
1967 'TITLE' => $this->title ? str_replace('|', htmlspecialchars($this->title), $this->titleTag) : '',
1968 'META' => $metaTags,
1969 'HEADERDATA' => $this->headerData ? implode(LF, $this->headerData) : '',
1970 'FOOTERDATA' => $this->footerData ? implode(LF, $this->footerData) : '',
1971 'JS_LIBS_FOOTER' => $jsFooterLibs,
1972 'JS_INCLUDE_FOOTER' => $jsFooterFiles,
1973 'JS_INLINE_FOOTER' => $jsFooterInline,
1974 'BODY' => $this->bodyContent
1975 );
1976 $markerArray = array_map('trim', $markerArray);
1977 return $markerArray;
1978 }
1979
1980 /**
1981 * Fills the marker array with the given strings and trims each value
1982 *
1983 * @param string $substituteHash The hash that is used for the placehoder markers
1984 * @return array Marker array
1985 */
1986 protected function getPreparedMarkerArrayForPageWithUncachedObjects($substituteHash)
1987 {
1988 $markerArray = array(
1989 'XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType,
1990 'HTMLTAG' => $this->htmlTag,
1991 'HEADTAG' => $this->headTag,
1992 'METACHARSET' => $this->charSet ? str_replace('|', htmlspecialchars($this->charSet), $this->metaCharsetTag) : '',
1993 'INLINECOMMENT' => $this->inlineComments ? LF . LF . '<!-- ' . LF . implode(LF, $this->inlineComments) . '-->' . LF . LF : '',
1994 'BASEURL' => $this->baseUrl ? str_replace('|', $this->baseUrl, $this->baseUrlTag) : '',
1995 'SHORTCUT' => $this->favIcon ? sprintf($this->shortcutTag, htmlspecialchars($this->favIcon), $this->iconMimeType) : '',
1996 'META' => implode(LF, $this->metaTags),
1997 'BODY' => $this->bodyContent,
1998 'TITLE' => '<!-- ###TITLE' . $substituteHash . '### -->',
1999 'CSS_LIBS' => '<!-- ###CSS_LIBS' . $substituteHash . '### -->',
2000 'CSS_INCLUDE' => '<!-- ###CSS_INCLUDE' . $substituteHash . '### -->',
2001 'CSS_INLINE' => '<!-- ###CSS_INLINE' . $substituteHash . '### -->',
2002 'JS_INLINE' => '<!-- ###JS_INLINE' . $substituteHash . '### -->',
2003 'JS_INCLUDE' => '<!-- ###JS_INCLUDE' . $substituteHash . '### -->',
2004 'JS_LIBS' => '<!-- ###JS_LIBS' . $substituteHash . '### -->',
2005 'HEADERDATA' => '<!-- ###HEADERDATA' . $substituteHash . '### -->',
2006 'FOOTERDATA' => '<!-- ###FOOTERDATA' . $substituteHash . '### -->',
2007 'JS_LIBS_FOOTER' => '<!-- ###JS_LIBS_FOOTER' . $substituteHash . '### -->',
2008 'JS_INCLUDE_FOOTER' => '<!-- ###JS_INCLUDE_FOOTER' . $substituteHash . '### -->',
2009 'JS_INLINE_FOOTER' => '<!-- ###JS_INLINE_FOOTER' . $substituteHash . '### -->'
2010 );
2011 $markerArray = array_map('trim', $markerArray);
2012 return $markerArray;
2013 }
2014
2015 /**
2016 * Reads the template file and returns the requested part as string
2017 *
2018 * @param int $part
2019 * @return string
2020 */
2021 protected function getTemplateForPart($part)
2022 {
2023 $templateFile = GeneralUtility::getFileAbsFileName($this->templateFile, true);
2024 $template = GeneralUtility::getUrl($templateFile);
2025 if ($this->removeLineBreaksFromTemplate) {
2026 $template = strtr($template, array(LF => '', CR => ''));
2027 }
2028 if ($part !== self::PART_COMPLETE) {
2029 $templatePart = explode('###BODY###', $template);
2030 $template = $templatePart[$part - 1];
2031 }
2032 return $template;
2033 }
2034
2035 /**
2036 * Helper function for render the main JavaScript libraries,
2037 * currently: RequireJS, jQuery, ExtJS
2038 *
2039 * @return string Content with JavaScript libraries
2040 */
2041 protected function renderMainJavaScriptLibraries()
2042 {
2043 $out = '';
2044
2045 // Include RequireJS
2046 if ($this->addRequireJs) {
2047 // load the paths of the requireJS configuration
2048 $out .= GeneralUtility::wrapJS('var require = ' . json_encode($this->requireJsConfig)) . LF;
2049 // directly after that, include the require.js file
2050 $out .= '<script src="' . $this->processJsFile(($this->backPath . $this->requireJsPath . 'require.js')) . '" type="text/javascript"></script>' . LF;
2051 }
2052
2053 // Include jQuery Core for each namespace, depending on the version and source
2054 if (!empty($this->jQueryVersions)) {
2055 foreach ($this->jQueryVersions as $namespace => $jQueryVersion) {
2056 $out .= $this->renderJqueryScriptTag($jQueryVersion['version'], $jQueryVersion['source'], $namespace);
2057 }
2058 }
2059 // Include extJS
2060 if ($this->addExtJS) {
2061 // Use the base adapter all the time
2062 $out .= '<script src="' . $this->processJsFile(($this->backPath . $this->extJsPath . 'adapter/ext-base' . ($this->enableExtJsDebug ? '-debug' : '') . '.js')) . '" type="text/javascript"></script>' . LF;
2063 $out .= '<script src="' . $this->processJsFile(($this->backPath . $this->extJsPath . 'ext-all' . ($this->enableExtJsDebug ? '-debug' : '') . '.js')) . '" type="text/javascript"></script>' . LF;
2064 // Add extJS localization
2065 // Load standard ISO mapping and modify for use with ExtJS
2066 $localeMap = $this->locales->getIsoMapping();
2067 $localeMap[''] = 'en';
2068 $localeMap['default'] = 'en';
2069 // Greek
2070 $localeMap['gr'] = 'el_GR';
2071 // Norwegian Bokmaal
2072 $localeMap['no'] = 'no_BO';
2073 // Swedish
2074 $localeMap['se'] = 'se_SV';
2075 $extJsLang = isset($localeMap[$this->lang]) ? $localeMap[$this->lang] : $this->lang;
2076 $extJsLocaleFile = $this->extJsPath . 'locale/ext-lang-' . $extJsLang . '.js';
2077 if (file_exists(PATH_typo3 . $extJsLocaleFile)) {
2078 $out .= '<script src="' . $this->processJsFile(($this->backPath . $extJsLocaleFile)) . '" type="text/javascript" charset="utf-8"></script>' . LF;
2079 }
2080 // Remove extjs from JScodeLibArray
2081 unset($this->jsFiles[$this->backPath . $this->extJsPath . 'ext-all.js'], $this->jsFiles[$this->backPath . $this->extJsPath . 'ext-all-debug.js']);
2082 }
2083 $this->loadJavaScriptLanguageStrings();
2084 if (TYPO3_MODE === 'BE') {
2085 $this->addAjaxUrlsToInlineSettings();
2086 }
2087 $inlineSettings = $this->inlineLanguageLabels ? 'TYPO3.lang = ' . json_encode($this->inlineLanguageLabels) . ';' : '';
2088 $inlineSettings .= $this->inlineSettings ? 'TYPO3.settings = ' . json_encode($this->inlineSettings) . ';' : '';
2089 if ($this->addExtJS) {
2090 // Set clear.gif, move it on top, add handler code
2091 $code = '';
2092 if (!empty($this->extOnReadyCode)) {
2093 foreach ($this->extOnReadyCode as $block) {
2094 $code .= $block;
2095 }
2096 }
2097 $clearGifPath = htmlspecialchars(GeneralUtility::locationHeaderUrl($this->backPath . ExtensionManagementUtility::extRelPath('backend') . 'Resources/Public/Images/clear.gif'));
2098 $out .= $this->inlineJavascriptWrap[0] . '
2099 Ext.ns("TYPO3");
2100 Ext.BLANK_IMAGE_URL = "' . $clearGifPath . '";
2101 Ext.SSL_SECURE_URL = "' . $clearGifPath . '";' . LF
2102 . $inlineSettings
2103 . 'Ext.onReady(function() {'
2104 . $code
2105 . ' });'
2106 . $this->inlineJavascriptWrap[1];
2107 $this->extOnReadyCode = array();
2108 // Include TYPO3.l10n object
2109 if (TYPO3_MODE === 'BE') {
2110 $out .= '<script src="' . $this->processJsFile(($this->backPath . ExtensionManagementUtility::extRelPath('lang') . 'Resources/Public/JavaScript/Typo3Lang.js')) . '" type="text/javascript" charset="utf-8"></script>' . LF;
2111 }
2112 if ($this->extJScss) {
2113 if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
2114 $this->addCssLibrary($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'all', '', true);
2115 } else {
2116 $this->addCssLibrary($this->backPath . $this->extJsPath . 'resources/css/ext-all-notheme.css', 'stylesheet', 'all', '', true);
2117 }
2118 }
2119 if ($this->extJStheme) {
2120 if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
2121 $this->addCssLibrary($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'all', '', true);
2122 } else {
2123 $this->addCssLibrary($this->backPath . $this->extJsPath . 'resources/css/xtheme-blue.css', 'stylesheet', 'all', '', true);
2124 }
2125 }
2126 } else {
2127 // no extJS loaded, but still inline settings
2128 if ($inlineSettings !== '') {
2129 // make sure the global TYPO3 is available
2130 $inlineSettings = 'var TYPO3 = TYPO3 || {};' . CRLF . $inlineSettings;
2131 $out .= $this->inlineJavascriptWrap[0] . $inlineSettings . $this->inlineJavascriptWrap[1];
2132 // Add language module only if also jquery is guaranteed to be there
2133 if (TYPO3_MODE === 'BE' && !empty($this->jQueryVersions)) {
2134 $this->loadRequireJsModule('TYPO3/CMS/Lang/Lang');
2135 }
2136 }
2137 }
2138 return $out;
2139 }
2140
2141 /**
2142 * Load the language strings into JavaScript
2143 */
2144 protected function loadJavaScriptLanguageStrings()
2145 {
2146 if (!empty($this->inlineLanguageLabelFiles)) {
2147 foreach ($this->inlineLanguageLabelFiles as $languageLabelFile) {
2148 $this->includeLanguageFileForInline($languageLabelFile['fileRef'], $languageLabelFile['selectionPrefix'], $languageLabelFile['stripFromSelectionName'], $languageLabelFile['errorMode']);
2149 }
2150 }
2151 $this->inlineLanguageLabelFiles = array();
2152 // Convert labels/settings back to UTF-8 since json_encode() only works with UTF-8:
2153 if (TYPO3_MODE === 'FE' && $this->getCharSet() !== 'utf-8') {
2154 if ($this->inlineLanguageLabels) {
2155 $this->csConvObj->convArray($this->inlineLanguageLabels, $this->getCharSet(), 'utf-8');
2156 }
2157 if ($this->inlineSettings) {
2158 $this->csConvObj->convArray($this->inlineSettings, $this->getCharSet(), 'utf-8');
2159 }
2160 }
2161 }
2162
2163 /**
2164 * Make URLs to all backend ajax handlers available as inline setting.
2165 */
2166 protected function addAjaxUrlsToInlineSettings()
2167 {
2168 $ajaxUrls = array();
2169 foreach ($GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX'] as $ajaxHandler => $_) {
2170 $ajaxUrls[$ajaxHandler] = BackendUtility::getAjaxUrl($ajaxHandler);
2171 }
2172
2173 // also add the ajax-based routes
2174 /** @var UriBuilder $uriBuilder */
2175 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
2176 /** @var Router $router */
2177 $router = GeneralUtility::makeInstance(Router::class);
2178 $routes = $router->getRoutes();
2179 foreach ($routes as $routeIdentifier => $route) {
2180 if ($route->getOption('ajax')) {
2181 $uri = (string)$uriBuilder->buildUriFromRoute($routeIdentifier);
2182 // use the shortened value in order to use this in JavaScript
2183 $routeIdentifier = str_replace('ajax_', '', $routeIdentifier);
2184 $ajaxUrls[$routeIdentifier] = $uri;
2185 }
2186 }
2187
2188 $this->inlineSettings['ajaxUrls'] = $ajaxUrls;
2189 }
2190
2191 /**
2192 * Renders the HTML script tag for the given jQuery version.
2193 *
2194 * @param string $version The jQuery version that should be included, either "latest" or any available version
2195 * @param string $source The location of the jQuery source, can be "local", "google", "msn" or "jquery
2196 * @param string $namespace The namespace in which the jQuery object of the specific version should be stored
2197 * @return string
2198 */
2199 protected function renderJqueryScriptTag($version, $source, $namespace)
2200 {
2201 switch (true) {
2202 case isset($this->jQueryCdnUrls[$source]):
2203 if ($this->enableJqueryDebug) {
2204 $minifyPart = '';
2205 } else {
2206 $minifyPart = '.min';
2207 }
2208 $jQueryFileName = sprintf($this->jQueryCdnUrls[$source], $version, $minifyPart);
2209 break;
2210 case $source === 'local':
2211 $jQueryFileName = $this->backPath . $this->jQueryPath . 'jquery-' . rawurlencode($version);
2212 if ($this->enableJqueryDebug) {
2213 $jQueryFileName .= '.js';
2214 } else {
2215 $jQueryFileName .= '.min.js';
2216 }
2217 break;
2218 default:
2219 $jQueryFileName = $source;
2220 }
2221 // Include the jQuery Core
2222 $scriptTag = '<script src="' . htmlspecialchars($jQueryFileName) . '" type="text/javascript"></script>' . LF;
2223 // Set the noConflict mode to be available via "TYPO3.jQuery" in all installations
2224 switch ($namespace) {
2225 case self::JQUERY_NAMESPACE_DEFAULT_NOCONFLICT:
2226 $scriptTag .= GeneralUtility::wrapJS('jQuery.noConflict();') . LF;
2227 break;
2228 case self::JQUERY_NAMESPACE_NONE:
2229 break;
2230 case self::JQUERY_NAMESPACE_DEFAULT:
2231
2232 default:
2233 $scriptTag .= GeneralUtility::wrapJS('var TYPO3 = TYPO3 || {}; TYPO3.' . $namespace . ' = jQuery.noConflict(true);') . LF;
2234 }
2235 return $scriptTag;
2236 }
2237
2238 /**
2239 * Render CSS library files
2240 *
2241 * @return string
2242 */
2243 protected function renderCssLibraries()
2244 {
2245 $cssFiles = '';
2246 if (!empty($this->cssLibs)) {
2247 foreach ($this->cssLibs as $file => $properties) {
2248 $file = GeneralUtility::resolveBackPath($file);
2249 $file = GeneralUtility::createVersionNumberedFilename($file);
2250 $tag = '<link rel="' . htmlspecialchars($properties['rel'])
2251 . '" type="text/css" href="' . htmlspecialchars($file)
2252 . '" media="' . htmlspecialchars($properties['media']) . '"'
2253 . ($properties['title'] ? ' title="' . htmlspecialchars($properties['title']) . '"' : '')
2254 . $this->endingSlash . '>';
2255 if ($properties['allWrap']) {
2256 $wrapArr = explode($properties['splitChar'] ?: '|', $properties['allWrap'], 2);
2257 $tag = $wrapArr[0] . $tag . $wrapArr[1];
2258 }
2259 $tag .= LF;
2260 if ($properties['forceOnTop']) {
2261 $cssFiles = $tag . $cssFiles;
2262 } else {
2263 $cssFiles .= $tag;
2264 }
2265 }
2266 }
2267 return $cssFiles;
2268 }
2269
2270 /**
2271 * Render CSS files
2272 *
2273 * @return string
2274 */
2275 protected function renderCssFiles()
2276 {
2277 $cssFiles = '';
2278 if (!empty($this->cssFiles)) {
2279 foreach ($this->cssFiles as $file => $properties) {
2280 $file = GeneralUtility::resolveBackPath($file);
2281 $file = GeneralUtility::createVersionNumberedFilename($file);
2282 $tag = '<link rel="' . htmlspecialchars($properties['rel'])
2283 . '" type="text/css" href="' . htmlspecialchars($file)
2284 . '" media="' . htmlspecialchars($properties['media']) . '"'
2285 . ($properties['title'] ? ' title="' . htmlspecialchars($properties['title']) . '"' : '')
2286 . $this->endingSlash . '>';
2287 if ($properties['allWrap']) {
2288 $wrapArr = explode($properties['splitChar'] ?: '|', $properties['allWrap'], 2);
2289 $tag = $wrapArr[0] . $tag . $wrapArr[1];
2290 }
2291 $tag .= LF;
2292 if ($properties['forceOnTop']) {
2293 $cssFiles = $tag . $cssFiles;
2294 } else {
2295 $cssFiles .= $tag;
2296 }
2297 }
2298 }
2299 return $cssFiles;
2300 }
2301
2302 /**
2303 * Render inline CSS
2304 *
2305 * @return string
2306 */
2307 protected function renderCssInline()
2308 {
2309 $cssInline = '';
2310 if (!empty($this->cssInline)) {
2311 foreach ($this->cssInline as $name => $properties) {
2312 $cssCode = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF;
2313 if ($properties['forceOnTop']) {
2314 $cssInline = $cssCode . $cssInline;
2315 } else {
2316 $cssInline .= $cssCode;
2317 }
2318 }
2319 $cssInline = $this->inlineCssWrap[0] . $cssInline . $this->inlineCssWrap[1];
2320 }
2321 return $cssInline;
2322 }
2323
2324 /**
2325 * Render JavaScipt libraries
2326 *
2327 * @return array<string> jsLibs and jsFooterLibs strings
2328 */
2329 protected function renderAdditionalJavaScriptLibraries()
2330 {
2331 $jsLibs = '';
2332 $jsFooterLibs = '';
2333 if (!empty($this->jsLibs)) {
2334 foreach ($this->jsLibs as $properties) {
2335 $properties['file'] = GeneralUtility::resolveBackPath($properties['file']);
2336 $properties['file'] = GeneralUtility::createVersionNumberedFilename($properties['file']);
2337 $async = ($properties['async']) ? ' async="async"' : '';
2338 $integrity = ($properties['integrity']) ? ' integrity="' . htmlspecialchars($properties['integrity']) . '"' : '';
2339 $tag = '<script src="' . htmlspecialchars($properties['file']) . '" type="' . htmlspecialchars($properties['type']) . '"' . $async . $integrity . '></script>';
2340 if ($properties['allWrap']) {
2341 $wrapArr = explode($properties['splitChar'] ?: '|', $properties['allWrap'], 2);
2342 $tag = $wrapArr[0] . $tag . $wrapArr[1];
2343 }
2344 $tag .= LF;
2345 if ($properties['forceOnTop']) {
2346 if ($properties['section'] === self::PART_HEADER) {
2347 $jsLibs = $tag . $jsLibs;
2348 } else {
2349 $jsFooterLibs = $tag . $jsFooterLibs;
2350 }
2351 } else {
2352 if ($properties['section'] === self::PART_HEADER) {
2353 $jsLibs .= $tag;
2354 } else {
2355 $jsFooterLibs .= $tag;
2356 }
2357 }
2358 }
2359 }
2360 if ($this->moveJsFromHeaderToFooter) {
2361 $jsFooterLibs = $jsLibs . LF . $jsFooterLibs;
2362 $jsLibs = '';
2363 }
2364 return array($jsLibs, $jsFooterLibs);
2365 }
2366
2367 /**
2368 * Render JavaScript files
2369 *
2370 * @return array<string> jsFiles and jsFooterFiles strings
2371 */
2372 protected function renderJavaScriptFiles()
2373 {
2374 $jsFiles = '';
2375 $jsFooterFiles = '';
2376 if (!empty($this->jsFiles)) {
2377 foreach ($this->jsFiles as $file => $properties) {
2378 $file = GeneralUtility::resolveBackPath($file);
2379 $file = GeneralUtility::createVersionNumberedFilename($file);
2380 $async = ($properties['async']) ? ' async="async"' : '';
2381 $integrity = ($properties['integrity']) ? ' integrity="' . htmlspecialchars($properties['integrity']) . '"' : '';
2382 $tag = '<script src="' . htmlspecialchars($file) . '" type="' . htmlspecialchars($properties['type']) . '"' . $async . $integrity . '></script>';
2383 if ($properties['allWrap']) {
2384 $wrapArr = explode($properties['splitChar'] ?: '|', $properties['allWrap'], 2);
2385 $tag = $wrapArr[0] . $tag . $wrapArr[1];
2386 }
2387 $tag .= LF;
2388 if ($properties['forceOnTop']) {
2389 if ($properties['section'] === self::PART_HEADER) {
2390 $jsFiles = $tag . $jsFiles;
2391 } else {
2392 $jsFooterFiles = $tag . $jsFooterFiles;
2393 }
2394 } else {
2395 if ($properties['section'] === self::PART_HEADER) {
2396 $jsFiles .= $tag;
2397 } else {
2398 $jsFooterFiles .= $tag;
2399 }
2400 }
2401 }
2402 }
2403 if ($this->moveJsFromHeaderToFooter) {
2404 $jsFooterFiles = $jsFiles . $jsFooterFiles;
2405 $jsFiles = '';
2406 }
2407 return array($jsFiles, $jsFooterFiles);
2408 }
2409
2410 /**
2411 * Render inline JavaScript
2412 *
2413 * @return array<string> jsInline and jsFooterInline string
2414 */
2415 protected function renderInlineJavaScript()
2416 {
2417 $jsInline = '';
2418 $jsFooterInline = '';
2419 if (!empty($this->jsInline)) {
2420 foreach ($this->jsInline as $name => $properties) {
2421 $jsCode = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF;
2422 if ($properties['forceOnTop']) {
2423 if ($properties['section'] === self::PART_HEADER) {
2424 $jsInline = $jsCode . $jsInline;
2425 } else {
2426 $jsFooterInline = $jsCode . $jsFooterInline;
2427 }
2428 } else {
2429 if ($properties['section'] === self::PART_HEADER) {
2430 $jsInline .= $jsCode;
2431 } else {
2432 $jsFooterInline .= $jsCode;
2433 }
2434 }
2435 }
2436 }
2437 if ($jsInline) {
2438 $jsInline = $this->inlineJavascriptWrap[0] . $jsInline . $this->inlineJavascriptWrap[1];
2439 }
2440 if ($jsFooterInline) {
2441 $jsFooterInline = $this->inlineJavascriptWrap[0] . $jsFooterInline . $this->inlineJavascriptWrap[1];
2442 }
2443 if ($this->moveJsFromHeaderToFooter) {
2444 $jsFooterInline = $jsInline . $jsFooterInline;
2445 $jsInline = '';
2446 }
2447 return array($jsInline, $jsFooterInline);
2448 }
2449
2450 /**
2451 * Include language file for inline usage
2452 *
2453 * @param string $fileRef
2454 * @param string $selectionPrefix
2455 * @param string $stripFromSelectionName
2456 * @param int $errorMode
2457 * @return void
2458 * @throws \RuntimeException
2459 */
2460 protected function includeLanguageFileForInline($fileRef, $selectionPrefix = '', $stripFromSelectionName = '', $errorMode = 0)
2461 {
2462 if (!isset($this->lang) || !isset($this->charSet)) {
2463 throw new \RuntimeException('Language and character encoding are not set.', 1284906026);
2464 }
2465 $labelsFromFile = array();
2466 $allLabels = $this->readLLfile($fileRef, $errorMode);
2467 if ($allLabels !== false) {
2468 // Merge language specific translations:
2469 if ($this->lang !== 'default' && isset($allLabels[$this->lang])) {
2470 $labels = array_merge($allLabels['default'], $allLabels[$this->lang]);
2471 } else {
2472 $labels = $allLabels['default'];
2473 }
2474 // Iterate through all locallang labels:
2475 foreach ($labels as $label => $value) {
2476 // If $selectionPrefix is set, only respect labels that start with $selectionPrefix
2477 if ($selectionPrefix === '' || strpos($label, $selectionPrefix) === 0) {
2478 // Remove substring $stripFromSelectionName from label
2479 $label = str_replace($stripFromSelectionName, '', $label);
2480 $labelsFromFile[$label] = $value;
2481 }
2482 }
2483 $this->inlineLanguageLabels = array_merge($this->inlineLanguageLabels, $labelsFromFile);
2484 }
2485 }
2486
2487 /**
2488 * Reads a locallang file.
2489 *
2490 * @param string $fileRef Reference to a relative filename to include.
2491 * @param int $errorMode Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception
2492 * @return array Returns the $LOCAL_LANG array found in the file. If no array found, returns empty array.
2493 */
2494 protected function readLLfile($fileRef, $errorMode = 0)
2495 {
2496 /** @var $languageFactory LocalizationFactory */
2497 $languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
2498
2499 if ($this->lang !== 'default') {
2500 $languages = array_reverse($this->languageDependencies);
2501 // At least we need to have English
2502 if (empty($languages)) {
2503 $languages[] = 'default';
2504 }
2505 } else {
2506 $languages = array('default');
2507 }
2508
2509 $localLanguage = array();
2510 foreach ($languages as $language) {
2511 $tempLL = $languageFactory->getParsedData($fileRef, $language, $this->charSet, $errorMode);
2512
2513 $localLanguage['default'] = $tempLL['default'];
2514 if (!isset($localLanguage[$this->lang])) {
2515 $localLanguage[$this->lang] = $localLanguage['default'];
2516 }
2517 if ($this->lang !== 'default' && isset($tempLL[$language])) {
2518 // Merge current language labels onto labels from previous language
2519 // This way we have a labels with fall back applied
2520 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($localLanguage[$this->lang], $tempLL[$language], true, false);
2521 }
2522 }
2523
2524 return $localLanguage;
2525 }
2526
2527 /*****************************************************/
2528 /* */
2529 /* Tools */
2530 /* */
2531 /*****************************************************/
2532 /**
2533 * Concatenate files into one file
2534 * registered handler
2535 *
2536 * @return void
2537 */
2538 protected function doConcatenate()
2539 {
2540 $this->doConcatenateCss();
2541 $this->doConcatenateJavaScript();
2542 }
2543
2544 /**
2545 * Concatenate JavaScript files according to the configuration.
2546 *
2547 * @return void
2548 */
2549 protected function doConcatenateJavaScript()
2550 {
2551 if ($this->concatenateFiles || $this->concatenateJavascript) {
2552 if (!empty($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsConcatenateHandler'])) {
2553 // use external concatenation routine
2554 $params = array(
2555 'jsLibs' => &$this->jsLibs,
2556 'jsFiles' => &$this->jsFiles,
2557 'jsFooterFiles' => &$this->jsFooterFiles,
2558 'headerData' => &$this->headerData,
2559 'footerData' => &$this->footerData
2560 );
2561 GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsConcatenateHandler'], $params, $this);
2562 } else {
2563 $this->jsLibs = $this->getCompressor()->concatenateJsFiles($this->jsLibs);
2564 $this->jsFiles = $this->getCompressor()->concatenateJsFiles($this->jsFiles);
2565 $this->jsFooterFiles = $this->getCompressor()->concatenateJsFiles($this->jsFooterFiles);
2566 }
2567 }
2568 }
2569
2570 /**
2571 * Concatenate CSS files according to configuration.
2572 *
2573 * @return void
2574 */
2575 protected function doConcatenateCss()
2576 {
2577 if ($this->concatenateFiles || $this->concatenateCss) {
2578 if (!empty($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssConcatenateHandler'])) {
2579 // use external concatenation routine
2580 $params = array(
2581 'cssFiles' => &$this->cssFiles,
2582 'cssLibs' => &$this->cssLibs,
2583 'headerData' => &$this->headerData,
2584 'footerData' => &$this->footerData
2585 );
2586 GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssConcatenateHandler'], $params, $this);
2587 } else {
2588 $cssOptions = array();
2589 if (TYPO3_MODE === 'BE') {
2590 $cssOptions = array('baseDirectories' => $GLOBALS['TBE_TEMPLATE']->getSkinStylesheetDirectories());
2591 }
2592 $this->cssLibs = $this->getCompressor()->concatenateCssFiles($this->cssLibs, $cssOptions);
2593 $this->cssFiles = $this->getCompressor()->concatenateCssFiles($this->cssFiles, $cssOptions);
2594 }
2595 }
2596 }
2597
2598 /**
2599 * Compresses inline code
2600 *
2601 * @return void
2602 */
2603 protected function doCompress()
2604 {
2605 $this->doCompressJavaScript();
2606 $this->doCompressCss();
2607 }
2608
2609 /**
2610 * Compresses CSS according to configuration.
2611 *
2612 * @return void
2613 */
2614 protected function doCompressCss()
2615 {
2616 if ($this->compressCss) {
2617 if (!empty($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler'])) {
2618 // Use external compression routine
2619 $params = array(
2620 'cssInline' => &$this->cssInline,
2621 'cssFiles' => &$this->cssFiles,
2622 'cssLibs' => &$this->cssLibs,
2623 'headerData' => &$this->headerData,
2624 'footerData' => &$this->footerData
2625 );
2626 GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler'], $params, $this);
2627 } else {
2628 $this->cssLibs = $this->getCompressor()->compressCssFiles($this->cssLibs);
2629 $this->cssFiles = $this->getCompressor()->compressCssFiles($this->cssFiles);
2630 }
2631 }
2632 }
2633
2634 /**
2635 * Compresses JavaScript according to configuration.
2636 *
2637 * @return void
2638 */
2639 protected function doCompressJavaScript()
2640 {
2641 if ($this->compressJavascript) {
2642 if (!empty($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler'])) {
2643 // Use external compression routine
2644 $params = array(
2645 'jsInline' => &$this->jsInline,
2646 'jsFooterInline' => &$this->jsFooterInline,
2647 'jsLibs' => &$this->jsLibs,
2648 'jsFiles' => &$this->jsFiles,
2649 'jsFooterFiles' => &$this->jsFooterFiles,
2650 'headerData' => &$this->headerData,
2651 'footerData' => &$this->footerData
2652 );
2653 GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler'], $params, $this);
2654 } else {
2655 // Traverse the arrays, compress files
2656 if (!empty($this->jsInline)) {
2657 foreach ($this->jsInline as $name => $properties) {
2658 if ($properties['compress']) {
2659 $error = '';
2660 $this->jsInline[$name]['code'] = GeneralUtility::minifyJavaScript($properties['code'], $error);
2661 if ($error) {
2662 $this->compressError .= 'Error with minify JS Inline Block "' . $name . '": ' . $error . LF;
2663 }
2664 }
2665 }
2666 }
2667 $this->jsLibs = $this->getCompressor()->compressJsFiles($this->jsLibs);
2668 $this->jsFiles = $this->getCompressor()->compressJsFiles($this->jsFiles);
2669 $this->jsFooterFiles = $this->getCompressor()->compressJsFiles($this->jsFooterFiles);
2670 }
2671 }
2672 }
2673
2674 /**
2675 * Returns instance of \TYPO3\CMS\Core\Resource\ResourceCompressor
2676 *
2677 * @return \TYPO3\CMS\Core\Resource\ResourceCompressor
2678 */
2679 protected function getCompressor()
2680 {
2681 if ($this->compressor === null) {
2682 $this->compressor = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\ResourceCompressor::class);
2683 }
2684 return $this->compressor;
2685 }
2686
2687 /**
2688 * Processes a Javascript file dependent on the current context
2689 *
2690 * Adds the version number for Frontend, compresses the file for Backend
2691 *
2692 * @param string $filename Filename
2693 * @return string New filename
2694 */
2695 protected function processJsFile($filename)
2696 {
2697 switch (TYPO3_MODE) {
2698 case 'FE':
2699 if ($this->compressJavascript) {
2700 $filename = $this->getCompressor()->compressJsFile($filename);
2701 } else {
2702 $filename = GeneralUtility::createVersionNumberedFilename($filename);
2703 }
2704 break;
2705 case 'BE':
2706 if ($this->compressJavascript) {
2707 $filename = $this->getCompressor()->compressJsFile($filename);
2708 }
2709 break;
2710 }
2711 return $filename;
2712 }
2713
2714 /**
2715 * Returns global frontend controller
2716 *
2717 * @return TypoScriptFrontendController
2718 */
2719 protected function getTypoScriptFrontendController()
2720 {
2721 return $GLOBALS['TSFE'];
2722 }
2723
2724 /**
2725 * Returns global language service instance
2726 *
2727 * @return \TYPO3\CMS\Lang\LanguageService
2728 */
2729 protected function getLanguageService()
2730 {
2731 return $GLOBALS['LANG'];
2732 }
2733
2734 /*****************************************************/
2735 /* */
2736 /* Hooks */
2737 /* */
2738 /*****************************************************/
2739 /**
2740 * Execute PreRenderHook for possible manipulation
2741 *
2742 * @return void
2743 */
2744 protected function executePreRenderHook()
2745 {
2746 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'])) {
2747 $params = array(
2748 'jsLibs' => &$this->jsLibs,
2749 'jsFooterLibs' => &$this->jsFooterLibs,
2750 'jsFiles' => &$this->jsFiles,
2751 'jsFooterFiles' => &$this->jsFooterFiles,
2752 'cssFiles' => &$this->cssFiles,
2753 'headerData' => &$this->headerData,
2754 'footerData' => &$this->footerData,
2755 'jsInline' => &$this->jsInline,
2756 'jsFooterInline' => &$this->jsFooterInline,
2757 'cssInline' => &$this->cssInline
2758 );
2759 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'] as $hook) {
2760 GeneralUtility::callUserFunction($hook, $params, $this);
2761 }
2762 }
2763 }
2764
2765 /**
2766 * PostTransform for possible manipulation of concatenated and compressed files
2767 *
2768 * @return void
2769 */
2770 protected function executeRenderPostTransformHook()
2771 {
2772 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postTransform'])) {
2773 $params = array(
2774 'jsLibs' => &$this->jsLibs,
2775 'jsFooterLibs' => &$this->jsFooterLibs,
2776 'jsFiles' => &$this->jsFiles,
2777 'jsFooterFiles' => &$this->jsFooterFiles,
2778 'cssFiles' => &$this->cssFiles,
2779 'headerData' => &$this->headerData,
2780 'footerData' => &$this->footerData,
2781 'jsInline' => &$this->jsInline,
2782 'jsFooterInline' => &$this->jsFooterInline,
2783 'cssInline' => &$this->cssInline
2784 );
2785 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postTransform'] as $hook) {
2786 GeneralUtility::callUserFunction($hook, $params, $this);
2787 }
2788 }
2789 }
2790
2791 /**
2792 * Execute postRenderHook for possible manipulation
2793 *
2794 * @param $jsLibs string
2795 * @param $jsFiles string
2796 * @param $jsFooterFiles string
2797 * @param $cssLibs string
2798 * @param $cssFiles string
2799 * @param $jsInline string
2800 * @param $cssInline string
2801 * @param $jsFooterInline string
2802 * @param $jsFooterLibs string
2803 * @return void
2804 */
2805 protected function executePostRenderHook(&$jsLibs, &$jsFiles, &$jsFooterFiles, &$cssLibs, &$cssFiles, &$jsInline, &$cssInline, &$jsFooterInline, &$jsFooterLibs)
2806 {
2807 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess'])) {
2808 $params = array(
2809 'jsLibs' => &$jsLibs,
2810 'jsFiles' => &$jsFiles,
2811 'jsFooterFiles' => &$jsFooterFiles,
2812 'cssLibs' => &$cssLibs,
2813 'cssFiles' => &$cssFiles,
2814 'headerData' => &$this->headerData,
2815 'footerData' => &$this->footerData,
2816 'jsInline' => &$jsInline,
2817 'cssInline' => &$cssInline,
2818 'xmlPrologAndDocType' => &$this->xmlPrologAndDocType,
2819 'htmlTag' => &$this->htmlTag,
2820 'headTag' => &$this->headTag,
2821 'charSet' => &$this->charSet,
2822 'metaCharsetTag' => &$this->metaCharsetTag,
2823 'shortcutTag' => &$this->shortcutTag,
2824 'inlineComments' => &$this->inlineComments,
2825 'baseUrl' => &$this->baseUrl,
2826 'baseUrlTag' => &$this->baseUrlTag,
2827 'favIcon' => &$this->favIcon,
2828 'iconMimeType' => &$this->iconMimeType,
2829 'titleTag' => &$this->titleTag,
2830 'title' => &$this->title,
2831 'metaTags' => &$this->metaTags,
2832 'jsFooterInline' => &$jsFooterInline,
2833 'jsFooterLibs' => &$jsFooterLibs,
2834 'bodyContent' => &$this->bodyContent
2835 );
2836 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess'] as $hook) {
2837 GeneralUtility::callUserFunction($hook, $params, $this);
2838 }
2839 }
2840 }
2841 }