2 /***************************************************************
5 * (c) 2009-2011 Steffen Kamper (info@sk-typo3.de)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
29 * TYPO3 pageRender class (new in TYPO3 4.3.0)
30 * This class render the HTML of a webpage, usable for BE and FE
32 * @author Steffen Kamper <info@sk-typo3.de>
37 class t3lib_PageRenderer
implements t3lib_Singleton
{
39 protected $compressJavascript = FALSE;
40 protected $compressCss = FALSE;
41 protected $removeLineBreaksFromTemplate = FALSE;
43 protected $concatenateFiles = FALSE;
45 protected $moveJsFromHeaderToFooter = FALSE;
47 /* @var t3lib_cs Instance of t3lib_cs */
51 /* @var t3lib_Compressor Instance of t3lib_Compressor */
52 protected $compressor;
54 // static array containing associative array for the included files
55 protected static $jsFiles = array();
56 protected static $jsFooterFiles = array();
57 protected static $jsLibs = array();
58 protected static $jsFooterLibs = array();
59 protected static $cssFiles = array();
66 protected $renderXhtml = TRUE;
68 // static header blocks
69 protected $xmlPrologAndDocType = '';
70 protected $metaTags = array();
71 protected $inlineComments = array();
72 protected $headerData = array();
73 protected $footerData = array();
74 protected $titleTag = '<title>|</title>';
75 protected $metaCharsetTag = '<meta http-equiv="Content-Type" content="text/html; charset=|" />';
76 protected $htmlTag = '<html>';
77 protected $headTag = '<head>';
78 protected $baseUrlTag = '<base href="|" />';
79 protected $iconMimeType = '';
80 protected $shortcutTag = '<link rel="shortcut icon" href="%1$s"%2$s />
81 <link rel="icon" href="%1$s"%2$s />';
83 // static inline code blocks
84 protected $jsInline = array();
85 protected $jsFooterInline = array();
86 protected $extOnReadyCode = array();
87 protected $cssInline = array();
89 protected $bodyContent;
91 protected $templateFile;
93 protected $jsLibraryNames = array('prototype', 'scriptaculous', 'extjs');
95 const PART_COMPLETE
= 0;
96 const PART_HEADER
= 1;
97 const PART_FOOTER
= 2;
99 // paths to contibuted libraries
100 protected $prototypePath = 'contrib/prototype/';
101 protected $scriptaculousPath = 'contrib/scriptaculous/';
102 protected $extCorePath = 'contrib/extjs/';
103 protected $extJsPath = 'contrib/extjs/';
104 protected $svgPath = 'contrib/websvg/';
107 // internal flags for JS-libraries
108 protected $addPrototype = FALSE;
109 protected $addScriptaculous = FALSE;
110 protected $addScriptaculousModules = array('builder' => FALSE, 'effects' => FALSE, 'dragdrop' => FALSE, 'controls' => FALSE, 'slider' => FALSE);
111 protected $addExtJS = FALSE;
112 protected $addExtCore = FALSE;
113 protected $extJSadapter = 'ext/ext-base.js';
116 protected $enableExtJsDebug = FALSE;
117 protected $enableExtCoreDebug = FALSE;
119 // available adapters for extJs
120 const EXTJS_ADAPTER_JQUERY
= 'jquery';
121 const EXTJS_ADAPTER_PROTOTYPE
= 'prototype';
122 const EXTJS_ADAPTER_YUI
= 'yui';
124 protected $extJStheme = TRUE;
125 protected $extJScss = TRUE;
127 protected $enableExtJSQuickTips = FALSE;
129 protected $inlineLanguageLabels = array();
130 protected $inlineLanguageLabelFiles = array();
131 protected $inlineSettings = array();
133 protected $inlineJavascriptWrap = array();
135 // saves error messages generated during compression
136 protected $compressError = '';
139 protected $addSvg = FALSE;
140 protected $enableSvgDebug = FALSE;
143 // used by BE modules
149 * @param string $templateFile declare the used template file. Omit this parameter will use default template
150 * @param string $backPath relative path to typo3-folder. It varies for BE modules, in FE it will be typo3/
153 public function __construct($templateFile = '', $backPath = NULL) {
156 $this->csConvObj
= t3lib_div
::makeInstance('t3lib_cs');
158 if (strlen($templateFile)) {
159 $this->templateFile
= $templateFile;
161 $this->backPath
= isset($backPath) ?
$backPath : $GLOBALS['BACK_PATH'];
163 $this->inlineJavascriptWrap
= array(
164 '<script type="text/javascript">' . LF
. '/*<![CDATA[*/' . LF
. '<!-- ' . LF
,
165 '// -->' . LF
. '/*]]>*/' . LF
. '</script>' . LF
167 $this->inlineCssWrap
= array(
168 '<style type="text/css">' . LF
. '/*<![CDATA[*/' . LF
. '<!-- ' . LF
,
169 '-->' . LF
. '/*]]>*/' . LF
. '</style>' . LF
175 * reset all vars to initial values
179 protected function reset() {
180 $this->templateFile
= TYPO3_mainDir
. 'templates/template_page_backend.html';
181 $this->jsFiles
= array();
182 $this->jsFooterFiles
= array();
183 $this->jsInline
= array();
184 $this->jsFooterInline
= array();
185 $this->jsLibs
= array();
186 $this->cssFiles
= array();
187 $this->cssInline
= array();
188 $this->metaTags
= array();
189 $this->inlineComments
= array();
190 $this->headerData
= array();
191 $this->footerData
= array();
192 $this->extOnReadyCode
= array();
195 /*****************************************************/
200 /*****************************************************/
205 * @param string $title title of webpage
208 public function setTitle($title) {
209 $this->title
= $title;
214 * Enables/disables rendering of XHTML code
216 * @param boolean $enable Enable XHTML
219 public function setRenderXhtml($enable) {
220 $this->renderXhtml
= $enable;
224 * Sets xml prolog and docType
226 * @param string $xmlPrologAndDocType complete tags for xml prolog and docType
229 public function setXmlPrologAndDocType($xmlPrologAndDocType) {
230 $this->xmlPrologAndDocType
= $xmlPrologAndDocType;
236 * @param string $charSet used charset
239 public function setCharSet($charSet) {
240 $this->charSet
= $charSet;
246 * @param string $lang used language
249 public function setLanguage($lang) {
256 * @param string $htmlTag html tag
259 public function setHtmlTag($htmlTag) {
260 $this->htmlTag
= $htmlTag;
266 * @param string $tag head tag
269 public function setHeadTag($headTag) {
270 $this->headTag
= $headTag;
276 * @param string $favIcon
279 public function setFavIcon($favIcon) {
280 $this->favIcon
= $favIcon;
284 * Sets icon mime type
286 * @param string $iconMimeType
289 public function setIconMimeType($iconMimeType) {
290 $this->iconMimeType
= $iconMimeType;
299 public function setBaseUrl($baseUrl) {
300 $this->baseUrl
= $baseUrl;
306 * @param string $file
309 public function setTemplateFile($file) {
310 $this->templateFile
= $file;
316 * @param string $backPath
319 public function setBackPath($backPath) {
320 $this->backPath
= $backPath;
324 * Sets Content for Body
326 * @param string $content
329 public function setBodyContent($content) {
330 $this->bodyContent
= $content;
334 * Sets Path for prototype library (relative to typo3 directory)
339 public function setPrototypePath($path) {
340 $this->prototypePath
= $path;
344 * Sets Path for scriptaculous library (relative to typo3 directory)
346 * @param string $path
349 public function setScriptaculousPath($path) {
350 $this->scriptaculousPath
= $path;
354 * Sets Path for Ext Core library (relative to typo3 directory)
356 * @param string $path
359 public function setExtCorePath($path) {
360 $this->extCorePath
= $path;
364 * Sets Path for ExtJs library (relative to typo3 directory)
366 * @param string $path
369 public function setExtJsPath($path) {
370 $this->extJsPath
= $path;
374 * Sets Path for SVG library (websvg)
376 * @param string $path
379 public function setSvgPath($path) {
380 $this->svgPath
= $path;
383 /*****************************************************/
385 /* Public Enablers / Disablers */
388 /*****************************************************/
391 * Enables MoveJsFromHeaderToFooter
396 public function enableMoveJsFromHeaderToFooter() {
397 $this->moveJsFromHeaderToFooter
= TRUE;
401 * Disables MoveJsFromHeaderToFooter
406 public function disableMoveJsFromHeaderToFooter() {
407 $this->moveJsFromHeaderToFooter
= FALSE;
411 * Enables compression of javascript
416 public function enableCompressJavascript() {
417 $this->compressJavascript
= TRUE;
421 * Disables compression of javascript
426 public function disableCompressJavascript() {
427 $this->compressJavascript
= FALSE;
431 * Enables compression of css
436 public function enableCompressCss() {
437 $this->compressCss
= TRUE;
441 * Disables compression of css
446 public function disableCompressCss() {
447 $this->compressCss
= FALSE;
451 * Enables concatenation of js/css files
456 public function enableConcatenateFiles() {
457 $this->concatenateFiles
= TRUE;
461 * Disables concatenation of js/css files
466 public function disableConcatenateFiles() {
467 $this->concatenateFiles
= FALSE;
471 * Sets removal of all line breaks in template
476 public function enableRemoveLineBreaksFromTemplate() {
477 $this->removeLineBreaksFromTemplate
= TRUE;
481 * Unsets removal of all line breaks in template
486 public function disableRemoveLineBreaksFromTemplate() {
487 $this->removeLineBreaksFromTemplate
= FALSE;
492 * This is a shortcut to switch off all compress/concatenate features to enable easier debug
497 public function enableDebugMode() {
498 $this->compressJavascript
= FALSE;
499 $this->compressCss
= FALSE;
500 $this->concatenateFiles
= FALSE;
501 $this->removeLineBreaksFromTemplate
= FALSE;
502 $this->enableExtCoreDebug
= TRUE;
503 $this->enableExtJsDebug
= TRUE;
504 $this->enableSvgDebug
= TRUE;
507 /*****************************************************/
512 /*****************************************************/
517 * @return string $title title of webpage
519 public function getTitle() {
526 * @return string $charSet
528 public function getCharSet() {
529 return $this->charSet
;
535 * @return string $lang
537 public function getLanguage() {
542 * Returns rendering mode XHTML or HTML
544 * @return boolean TRUE if XHTML, FALSE if HTML
546 public function getRenderXhtml() {
547 return $this->renderXhtml
;
553 * @return string $htmlTag html tag
555 public function getHtmlTag() {
556 return $this->htmlTag
;
562 * @return string $tag head tag
564 public function getHeadTag() {
565 return $this->headTag
;
571 * @return string $favIcon
573 public function getFavIcon() {
574 return $this->favIcon
;
578 * Gets icon mime type
580 * @return string $iconMimeType
582 public function getIconMimeType() {
583 return $this->iconMimeType
;
589 * @return string $url
591 public function getBaseUrl() {
592 return $this->baseUrl
;
598 * @return string $file
600 public function getTemplateFile($file) {
601 return $this->templateFile
;
605 * Gets MoveJsFromHeaderToFooter
609 public function getMoveJsFromHeaderToFooter() {
610 return $this->moveJsFromHeaderToFooter
;
614 * Gets compress of javascript
618 public function getCompressJavascript() {
619 return $this->compressJavascript
;
623 * Gets compress of css
627 public function getCompressCss() {
628 return $this->compressCss
;
632 * Gets concatenate of files
636 public function getConcatenateFiles() {
637 return $this->concatenateFiles
;
641 * Gets remove of empty lines from template
645 public function getRemoveLineBreaksFromTemplate() {
646 return $this->removeLineBreaksFromTemplate
;
650 * Gets content for body
654 public function getBodyContent() {
655 return $this->bodyContent
;
659 * Gets Path for prototype library (relative to typo3 directory)
663 public function getPrototypePath() {
664 return $this->prototypePath
;
668 * Gets Path for scriptaculous library (relative to typo3 directory)
672 public function getScriptaculousPath() {
673 return $this->scriptaculousPath
;
677 * Gets Path for Ext Core library (relative to typo3 directory)
681 public function getExtCorePath() {
682 return $this->extCorePath
;
686 * Gets Path for ExtJs library (relative to typo3 directory)
690 public function getExtJsPath() {
691 return $this->extJsPath
;
695 * Gets Path for SVG library (relative to typo3 directory)
699 public function getSvgPath() {
700 return $this->svgPath
;
704 * Gets the inline language labels.
706 * @return array The inline language labels
708 public function getInlineLanguageLabels() {
709 return $this->inlineLanguageLabels
;
713 * Gets the inline language files
717 public function getInlineLanguageLabelFiles() {
718 return $this->inlineLanguageLabelFiles
;
721 /*****************************************************/
723 /* Public Function to add Data */
726 /*****************************************************/
731 * @param string $meta meta data (complete metatag)
734 public function addMetaTag($meta) {
735 if (!in_array($meta, $this->metaTags
)) {
736 $this->metaTags
[] = $meta;
741 * Adds inline HTML comment
743 * @param string $comment
746 public function addInlineComment($comment) {
747 if (!in_array($comment, $this->inlineComments
)) {
748 $this->inlineComments
[] = $comment;
755 * @param string $data free header data for HTML header
758 public function addHeaderData($data) {
759 if (!in_array($data, $this->headerData
)) {
760 $this->headerData
[] = $data;
767 * @param string $data free header data for HTML header
770 public function addFooterData($data) {
771 if (!in_array($data, $this->footerData
)) {
772 $this->footerData
[] = $data;
776 /* Javascript Files */
779 * Adds JS Library. JS Library block is rendered on top of the JS files.
781 * @param string $name
782 * @param string $file
783 * @param string $type
784 * @param boolean $compress flag if library should be compressed
785 * @param boolean $forceOnTop flag if added library should be inserted at begin of this block
786 * @param string $allWrap
789 public function addJsLibrary($name, $file, $type = 'text/javascript', $compress = FALSE, $forceOnTop = FALSE, $allWrap = '') {
791 $type = 'text/javascript';
793 if (!in_array(strtolower($name), $this->jsLibs
)) {
794 $this->jsLibs
[strtolower($name)] = array(
797 'section' => self
::PART_HEADER
,
798 'compress' => $compress,
799 'forceOnTop' => $forceOnTop,
800 'allWrap' => $allWrap
807 * Adds JS Library to Footer. JS Library block is rendered on top of the Footer JS files.
809 * @param string $name
810 * @param string $file
811 * @param string $type
812 * @param boolean $compress flag if library should be compressed
813 * @param boolean $forceOnTop flag if added library should be inserted at begin of this block
814 * @param string $allWrap
817 public function addJsFooterLibrary($name, $file, $type = 'text/javascript', $compress = FALSE, $forceOnTop = FALSE, $allWrap = '') {
819 $type = 'text/javascript';
821 if (!in_array(strtolower($name), $this->jsLibs
)) {
822 $this->jsLibs
[strtolower($name)] = array(
825 'section' => self
::PART_FOOTER
,
826 'compress' => $compress,
827 'forceOnTop' => $forceOnTop,
828 'allWrap' => $allWrap
837 * @param string $file
838 * @param string $type
839 * @param boolean $compress
840 * @param boolean $forceOnTop
841 * @param string $allWrap
844 public function addJsFile($file, $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '') {
846 $type = 'text/javascript';
848 if (!isset($this->jsFiles
[$file])) {
849 $this->jsFiles
[$file] = array(
851 'section' => self
::PART_HEADER
,
852 'compress' => $compress,
853 'forceOnTop' => $forceOnTop,
854 'allWrap' => $allWrap
860 * Adds JS file to footer
862 * @param string $file
863 * @param string $type
864 * @param boolean $compress
865 * @param boolean $forceOnTop
868 public function addJsFooterFile($file, $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '') {
870 $type = 'text/javascript';
872 if (!isset($this->jsFiles
[$file])) {
873 $this->jsFiles
[$file] = array(
875 'section' => self
::PART_FOOTER
,
876 'compress' => $compress,
877 'forceOnTop' => $forceOnTop,
878 'allWrap' => $allWrap
883 /*Javascript Inline Blocks */
886 * Adds JS inline code
888 * @param string $name
889 * @param string $block
890 * @param boolean $compress
891 * @param boolean $forceOnTop
894 public function addJsInlineCode($name, $block, $compress = TRUE, $forceOnTop = FALSE) {
895 if (!isset($this->jsInline
[$name]) && !empty($block)) {
896 $this->jsInline
[$name] = array(
897 'code' => $block . LF
,
898 'section' => self
::PART_HEADER
,
899 'compress' => $compress,
900 'forceOnTop' => $forceOnTop
906 * Adds JS inline code to footer
908 * @param string $name
909 * @param string $block
910 * @param boolean $compress
911 * @param boolean $forceOnTop
914 public function addJsFooterInlineCode($name, $block, $compress = TRUE, $forceOnTop = FALSE) {
915 if (!isset($this->jsInline
[$name]) && !empty($block)) {
916 $this->jsInline
[$name] = array(
917 'code' => $block . LF
,
918 'section' => self
::PART_FOOTER
,
919 'compress' => $compress,
920 'forceOnTop' => $forceOnTop
926 * Adds Ext.onready code, which will be wrapped in Ext.onReady(function() {...});
928 * @param string $block javascript code
929 * @param boolean $forceOnTop position of the javascript code (TRUE for putting it on top, default is FALSE = bottom)
932 public function addExtOnReadyCode($block, $forceOnTop = FALSE) {
933 if (!in_array($block, $this->extOnReadyCode
)) {
935 array_unshift($this->extOnReadyCode
, $block);
937 $this->extOnReadyCode
[] = $block;
943 * Adds the ExtDirect code
947 public function addExtDirectCode() {
949 if (TYPO3_MODE
=== 'BE') {
950 $formprotection = t3lib_formprotection_Factory
::get();
951 $token = $formprotection->generateToken('extDirect');
954 // Note: we need to iterate thru the object, because the addProvider method
955 // does this only with multiple arguments
956 $this->addExtOnReadyCode('
958 TYPO3.ExtDirectToken = "' . $token . '";
959 for (var api in Ext.app.ExtDirectAPI) {
960 var provider = Ext.Direct.addProvider(Ext.app.ExtDirectAPI[api]);
961 provider.on("beforecall", function(provider, transaction, meta) {
962 if (transaction.data) {
963 transaction.data[transaction.data.length] = TYPO3.ExtDirectToken;
965 transaction.data = [TYPO3.ExtDirectToken];
969 provider.on("call", function(provider, transaction, meta) {
970 if (transaction.isForm) {
971 transaction.params.securityToken = TYPO3.ExtDirectToken;
977 var extDirectDebug = function(message, header, group) {
978 var TYPO3ViewportInstance = null;
980 if (top && top.TYPO3 && typeof top.TYPO3.Backend === "object") {
981 TYPO3ViewportInstance = top.TYPO3.Backend;
982 } else if (typeof TYPO3 === "object" && typeof TYPO3.Backend === "object") {
983 TYPO3ViewportInstance = TYPO3.Backend;
986 if (TYPO3ViewportInstance !== null) {
987 TYPO3ViewportInstance.DebugConsole.addTab(message, header, group);
988 } else if (typeof console === "object") {
989 console.log(message);
991 document.write(message);
995 Ext.Direct.on("exception", function(event) {
996 if (event.code === Ext.Direct.exceptions.TRANSPORT && !event.where) {
997 TYPO3.Flashmessage.display(
998 TYPO3.Severity.error,
999 TYPO3.LLL.extDirect.timeoutHeader,
1000 TYPO3.LLL.extDirect.timeoutMessage,
1006 backtrace = "<p style=\"margin-top: 20px;\">" +
1007 "<strong>Backtrace:<\/strong><br \/>" +
1008 event.where.replace(/#/g, "<br \/>#") +
1013 "<p>" + event.message + "<\/p>" + backtrace,
1015 "ExtDirect - Exception"
1020 Ext.Direct.on("event", function(event, provider) {
1021 if (typeof event.debug !== "undefined" && event.debug !== "") {
1022 extDirectDebug(event.debug, event.method, "ExtDirect - Debug");
1035 * @param string $file
1036 * @param string $rel
1037 * @param string $media
1038 * @param string $title
1039 * @param boolean $compress
1040 * @param boolean $forceOnTop
1043 public function addCssFile($file, $rel = 'stylesheet', $media = 'all', $title = '', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '') {
1044 if (!isset($this->cssFiles
[$file])) {
1045 $this->cssFiles
[$file] = array(
1049 'compress' => $compress,
1050 'forceOnTop' => $forceOnTop,
1051 'allWrap' => $allWrap
1056 /*CSS Inline Blocks */
1059 * Adds CSS inline code
1061 * @param string $name
1062 * @param string $block
1063 * @param boolean $compress
1064 * @param boolean $forceOnTop
1067 public function addCssInlineBlock($name, $block, $compress = FALSE, $forceOnTop = FALSE) {
1068 if (!isset($this->cssInline
[$name]) && !empty($block)) {
1069 $this->cssInline
[$name] = array(
1071 'compress' => $compress,
1072 'forceOnTop' => $forceOnTop
1080 * call function if you need the prototype library
1084 public function loadPrototype() {
1085 $this->addPrototype
= TRUE;
1089 * call function if you need the Scriptaculous library
1091 * @param string $modules add modules you need. use "all" if you need complete modules
1094 public function loadScriptaculous($modules = 'all') {
1095 // Scriptaculous require prototype, so load prototype too.
1096 $this->addPrototype
= TRUE;
1097 $this->addScriptaculous
= TRUE;
1099 if ($modules == 'all') {
1100 foreach ($this->addScriptaculousModules
as $key => $value) {
1101 $this->addScriptaculousModules
[$key] = TRUE;
1104 $mods = t3lib_div
::trimExplode(',', $modules);
1105 foreach ($mods as $mod) {
1106 if (isset($this->addScriptaculousModules
[strtolower($mod)])) {
1107 $this->addScriptaculousModules
[strtolower($mod)] = TRUE;
1115 * call this function if you need the extJS library
1117 * @param boolean $css flag, if set the ext-css will be loaded
1118 * @param boolean $theme flag, if set the ext-theme "grey" will be loaded
1119 * @param string $adapter choose alternative adapter, possible values: yui, prototype, jquery
1122 public function loadExtJS($css = TRUE, $theme = TRUE, $adapter = '') {
1124 // empty $adapter will always load the ext adapter
1125 switch (t3lib_div
::strtolower(trim($adapter))) {
1126 case self
::EXTJS_ADAPTER_YUI
:
1127 $this->extJSadapter
= 'yui/ext-yui-adapter.js';
1129 case self
::EXTJS_ADAPTER_PROTOTYPE
:
1130 $this->extJSadapter
= 'prototype/ext-prototype-adapter.js';
1132 case self
::EXTJS_ADAPTER_JQUERY
:
1133 $this->extJSadapter
= 'jquery/ext-jquery-adapter.js';
1137 $this->addExtJS
= TRUE;
1138 $this->extJStheme
= $theme;
1139 $this->extJScss
= $css;
1144 * Enables ExtJs QuickTips
1150 public function enableExtJSQuickTips() {
1151 $this->enableExtJSQuickTips
= TRUE;
1156 * call function if you need the ExtCore library
1160 public function loadExtCore() {
1161 $this->addExtCore
= TRUE;
1165 * call function if you need the SVG library
1169 public function loadSvg() {
1170 $this->addSvg
= TRUE;
1174 * call this function to load debug version of ExtJS. Use this for development only
1177 public function enableSvgDebug() {
1178 $this->enableSvgDebug
= TRUE;
1182 * call this function to force flash usage with SVG library
1185 public function svgForceFlash() {
1186 $this->addMetaTag('<meta name="svg.render.forceflash" content="true" />');
1190 * call this function to load debug version of ExtJS. Use this for development only
1193 public function enableExtJsDebug() {
1194 $this->enableExtJsDebug
= TRUE;
1198 * call this function to load debug version of ExtCore. Use this for development only
1202 public function enableExtCoreDebug() {
1203 $this->enableExtCoreDebug
= TRUE;
1207 * Adds Javascript Inline Label. This will occur in TYPO3.lang - object
1208 * The label can be used in scripts with TYPO3.lang.<key>
1211 * @param string $key
1212 * @param string $value
1215 public function addInlineLanguageLabel($key, $value) {
1216 $this->inlineLanguageLabels
[$key] = $value;
1220 * Adds Javascript Inline Label Array. This will occur in TYPO3.lang - object
1221 * The label can be used in scripts with TYPO3.lang.<key>
1222 * Array will be merged with existing array.
1225 * @param array $array
1228 public function addInlineLanguageLabelArray(array $array) {
1229 $this->inlineLanguageLabels
= array_merge($this->inlineLanguageLabels
, $array);
1233 * Gets labels to be used in JavaScript fetched from a locallang file.
1235 * @param string Input is a file-reference (see t3lib_div::getFileAbsFileName). That file is expected to be a 'locallang.xml' file containing a valid XML TYPO3 language structure.
1236 * @param string $selectionPrefix: Prefix to select the correct labels (default: '')
1237 * @param string $stripFromSelectionName: Sub-prefix to be removed from label names in the result (default: '')
1238 * @param integer Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception
1241 public function addInlineLanguageLabelFile($fileRef, $selectionPrefix = '', $stripFromSelectionName = '', $errorMode = 0) {
1242 $index = md5($fileRef . $selectionPrefix . $stripFromSelectionName);
1243 if ($fileRef && !isset($this->inlineLanguageLabelFiles
[$index])) {
1244 $this->inlineLanguageLabelFiles
[$index] = array(
1245 'fileRef' => $fileRef,
1246 'selectionPrefix' => $selectionPrefix,
1247 'stripFromSelectionName' => $stripFromSelectionName,
1248 'errorMode' => $errorMode
1255 * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
1256 * The label can be used in scripts with TYPO3.setting.<key>
1259 * @param string $namespace
1260 * @param string $key
1261 * @param string $value
1264 public function addInlineSetting($namespace, $key, $value) {
1266 if (strpos($namespace, '.')) {
1267 $parts = explode('.', $namespace);
1268 $a = &$this->inlineSettings
;
1269 foreach ($parts as $part) {
1274 $this->inlineSettings
[$namespace][$key] = $value;
1277 $this->inlineSettings
[$key] = $value;
1282 * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
1283 * The label can be used in scripts with TYPO3.setting.<key>
1284 * Array will be merged with existing array.
1287 * @param string $namespace
1288 * @param array $array
1291 public function addInlineSettingArray($namespace, array $array) {
1293 if (strpos($namespace, '.')) {
1294 $parts = explode('.', $namespace);
1295 $a = &$this->inlineSettings
;
1296 foreach ($parts as $part) {
1299 $a = array_merge((array) $a, $array);
1301 $this->inlineSettings
[$namespace] = array_merge((array) $this->inlineSettings
[$namespace], $array);
1304 $this->inlineSettings
= array_merge($this->inlineSettings
, $array);
1309 * Adds content to body content
1311 * @param string $content
1314 public function addBodyContent($content) {
1315 $this->bodyContent
.= $content;
1318 /*****************************************************/
1320 /* Render Functions */
1323 /*****************************************************/
1326 * render the section (Header or Footer)
1328 * @param int $part section which should be rendered: self::PART_COMPLETE, self::PART_HEADER or self::PART_FOOTER
1329 * @return string content of rendered section
1331 public function render($part = self
::PART_COMPLETE
) {
1337 $jsFooterInline = '';
1339 $jsFooterFiles = '';
1341 // preRenderHook for possible manuipulation
1342 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'])) {
1344 'jsLibs' => &$this->jsLibs
,
1345 'jsFooterLibs' => &$this->jsFooterLibs
,
1346 'jsFiles' => &$this->jsFiles
,
1347 'jsFooterFiles' => &$this->jsFooterFiles
,
1348 'cssFiles' => &$this->cssFiles
,
1349 'headerData' => &$this->headerData
,
1350 'footerData' => &$this->footerData
,
1351 'jsInline' => &$this->jsInline
,
1352 'jsFooterInline' => &$this->jsFooterInline
,
1353 'cssInline' => &$this->cssInline
,
1355 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'] as $hook) {
1356 t3lib_div
::callUserFunction($hook, $params, $this);
1360 $jsLibs = $this->renderJsLibraries();
1362 if ($this->concatenateFiles
) {
1363 // do the file concatenation
1364 $this->doConcatenate();
1366 if ($this->compressCss ||
$this->compressJavascript
) {
1367 // do the file compression
1368 $this->doCompress();
1371 $metaTags = implode(LF
, $this->metaTags
);
1373 // remove ending slashes from static header block
1374 // if the page is beeing rendered as html (not xhtml)
1375 // and define variable $endingSlash for further use
1376 if ($this->getRenderXhtml()) {
1377 $endingSlash = ' /';
1379 $this->metaCharsetTag
= str_replace(' />', '>', $this->metaCharsetTag
);
1380 $this->baseUrlTag
= str_replace(' />', '>', $this->baseUrlTag
);
1381 $this->shortcutTag
= str_replace(' />', '>', $this->shortcutTag
);
1385 if (count($this->cssFiles
)) {
1386 foreach ($this->cssFiles
as $file => $properties) {
1387 $file = t3lib_div
::resolveBackPath($file);
1388 $file = t3lib_div
::createVersionNumberedFilename($file);
1389 $tag = '<link rel="' . htmlspecialchars($properties['rel']) . '" type="text/css" href="' .
1390 htmlspecialchars($file) . '" media="' . htmlspecialchars($properties['media']) . '"' .
1391 ($properties['title'] ?
' title="' . htmlspecialchars($properties['title']) . '"' : '') .
1393 if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
1394 $tag = str_replace('|', $tag, $properties['allWrap']);
1396 if ($properties['forceOnTop']) {
1397 $cssFiles = $tag . LF
. $cssFiles;
1399 $cssFiles .= LF
. $tag;
1404 if (count($this->cssInline
)) {
1405 foreach ($this->cssInline
as $name => $properties) {
1406 if ($properties['forceOnTop']) {
1407 $cssInline = '/*' . htmlspecialchars($name) . '*/' . LF
. $properties['code'] . LF
. $cssInline;
1409 $cssInline .= '/*' . htmlspecialchars($name) . '*/' . LF
. $properties['code'] . LF
;
1412 $cssInline = $this->inlineCssWrap
[0] . $cssInline . $this->inlineCssWrap
[1];
1415 if (count($this->jsLibs
)) {
1416 foreach ($this->jsLibs
as $name => $properties) {
1417 $properties['file'] = t3lib_div
::resolveBackPath($properties['file']);
1418 $properties['file'] = t3lib_div
::createVersionNumberedFilename($properties['file']);
1419 $tag = '<script src="' . htmlspecialchars($properties['file']) . '" type="' . htmlspecialchars($properties['type']) . '"></script>';
1420 if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
1421 $tag = str_replace('|', $tag, $properties['allWrap']);
1423 if ($properties['forceOnTop']) {
1424 if ($properties['section'] === self
::PART_HEADER
) {
1425 $jsLibs = $tag . LF
. $jsLibs;
1427 $jsFooterLibs = $tag . LF
. $jsFooterLibs;
1430 if ($properties['section'] === self
::PART_HEADER
) {
1431 $jsLibs .= LF
. $tag;
1433 $jsFooterLibs .= LF
. $tag;
1439 if (count($this->jsFiles
)) {
1440 foreach ($this->jsFiles
as $file => $properties) {
1441 $file = t3lib_div
::resolveBackPath($file);
1442 $file = t3lib_div
::createVersionNumberedFilename($file);
1443 $tag = '<script src="' . htmlspecialchars($file) . '" type="' . htmlspecialchars($properties['type']) . '"></script>';
1444 if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
1445 $tag = str_replace('|', $tag, $properties['allWrap']);
1447 if ($properties['forceOnTop']) {
1448 if ($properties['section'] === self
::PART_HEADER
) {
1449 $jsFiles = $tag . LF
. $jsFiles;
1451 $jsFooterFiles = $tag . LF
. $jsFooterFiles;
1454 if ($properties['section'] === self
::PART_HEADER
) {
1455 $jsFiles .= LF
. $tag;
1457 $jsFooterFiles .= LF
. $tag;
1463 if (count($this->jsInline
)) {
1464 foreach ($this->jsInline
as $name => $properties) {
1465 if ($properties['forceOnTop']) {
1466 if ($properties['section'] === self
::PART_HEADER
) {
1467 $jsInline = '/*' . htmlspecialchars($name) . '*/' . LF
. $properties['code'] . LF
. $jsInline;
1469 $jsFooterInline = '/*' . htmlspecialchars($name) . '*/' . LF
. $properties['code'] . LF
. $jsFooterInline;
1472 if ($properties['section'] === self
::PART_HEADER
) {
1473 $jsInline .= '/*' . htmlspecialchars($name) . '*/' . LF
. $properties['code'] . LF
;
1475 $jsFooterInline .= '/*' . htmlspecialchars($name) . '*/' . LF
. $properties['code'] . LF
;
1483 $jsInline = $this->inlineJavascriptWrap
[0] . $jsInline . $this->inlineJavascriptWrap
[1];
1486 if ($jsFooterInline) {
1487 $jsFooterInline = $this->inlineJavascriptWrap
[0] . $jsFooterInline . $this->inlineJavascriptWrap
[1];
1492 $templateFile = t3lib_div
::getFileAbsFileName($this->templateFile
, TRUE);
1493 $template = t3lib_div
::getURL($templateFile);
1495 if ($this->removeLineBreaksFromTemplate
) {
1496 $template = strtr($template, array(LF
=> '', CR
=> ''));
1498 if ($part != self
::PART_COMPLETE
) {
1499 $templatePart = explode('###BODY###', $template);
1500 $template = $templatePart[$part - 1];
1503 if ($this->moveJsFromHeaderToFooter
) {
1504 $jsFooterLibs = $jsLibs . LF
. $jsFooterLibs;
1506 $jsFooterFiles = $jsFiles . LF
. $jsFooterFiles;
1508 $jsFooterInline = $jsInline . LF
. $jsFooterInline;
1512 // postRenderHook for possible manipulation
1513 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess'])) {
1515 'jsLibs' => &$jsLibs,
1516 'jsFiles' => &$jsFiles,
1517 'jsFooterFiles' => &$jsFooterFiles,
1518 'cssFiles' => &$cssFiles,
1519 'headerData' => &$this->headerData
,
1520 'footerData' => &$this->footerData
,
1521 'jsInline' => &$jsInline,
1522 'cssInline' => &$cssInline,
1523 'xmlPrologAndDocType' => &$this->xmlPrologAndDocType
,
1524 'htmlTag' => &$this->htmlTag
,
1525 'headTag' => &$this->headTag
,
1526 'charSet' => &$this->charSet
,
1527 'metaCharsetTag' => &$this->metaCharsetTag
,
1528 'shortcutTag' => &$this->shortcutTag
,
1529 'inlineComments' => &$this->inlineComments
,
1530 'baseUrl' => &$this->baseUrl
,
1531 'baseUrlTag' => &$this->baseUrlTag
,
1532 'favIcon' => &$this->favIcon
,
1533 'iconMimeType' => &$this->iconMimeType
,
1534 'titleTag' => &$this->titleTag
,
1535 'title' => &$this->title
,
1536 'metaTags' => &$metaTags,
1537 'jsFooterInline' => &$jsFooterInline,
1538 'jsFooterLibs' => &$jsFooterLibs,
1539 'bodyContent' => &$this->bodyContent
,
1541 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess'] as $hook) {
1542 t3lib_div
::callUserFunction($hook, $params, $this);
1546 $markerArray = array(
1547 'XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType
,
1548 'HTMLTAG' => $this->htmlTag
,
1549 'HEADTAG' => $this->headTag
,
1550 'METACHARSET' => $this->charSet ?
str_replace('|', htmlspecialchars($this->charSet
), $this->metaCharsetTag
) : '',
1551 'INLINECOMMENT' => $this->inlineComments ? LF
. LF
. '<!-- ' . LF
. implode(LF
, $this->inlineComments
) . '-->' . LF
. LF
: '',
1552 'BASEURL' => $this->baseUrl ?
str_replace('|', $this->baseUrl
, $this->baseUrlTag
) : '',
1553 'SHORTCUT' => $this->favIcon ?
sprintf($this->shortcutTag
, htmlspecialchars($this->favIcon
), $this->iconMimeType
) : '',
1554 'CSS_INCLUDE' => $cssFiles,
1555 'CSS_INLINE' => $cssInline,
1556 'JS_INLINE' => $jsInline,
1557 'JS_INCLUDE' => $jsFiles,
1558 'JS_LIBS' => $jsLibs,
1559 'TITLE' => $this->title ?
str_replace('|', htmlspecialchars($this->title
), $this->titleTag
) : '',
1560 'META' => $metaTags,
1561 'HEADERDATA' => $this->headerData ?
implode(LF
, $this->headerData
) : '',
1562 'FOOTERDATA' => $this->footerData ?
implode(LF
, $this->footerData
) : '',
1563 'JS_LIBS_FOOTER' => $jsFooterLibs,
1564 'JS_INCLUDE_FOOTER' => $jsFooterFiles,
1565 'JS_INLINE_FOOTER' => $jsFooterInline,
1566 'BODY' => $this->bodyContent
,
1569 $markerArray = array_map('trim', $markerArray);
1572 return trim(t3lib_parsehtml
::substituteMarkerArray($template, $markerArray, '###|###'));
1576 * helper function for render the javascript libraries
1578 * @return string content with javascript libraries
1580 protected function renderJsLibraries() {
1583 if ($this->addSvg
) {
1584 $out .= '<script src="' . $this->processJsFile($this->backPath
. $this->svgPath
. 'svg.js') .
1585 '" data-path="' . $this->backPath
. $this->svgPath
.
1586 '"' . ($this->enableSvgDebug ?
' data-debug="true"' : '') . '></script>';
1589 if ($this->addPrototype
) {
1590 $out .= '<script src="' . $this->processJsFile($this->backPath
. $this->prototypePath
. 'prototype.js') .
1591 '" type="text/javascript"></script>' . LF
;
1592 unset($this->jsFiles
[$this->backPath
. $this->prototypePath
. 'prototype.js']);
1595 if ($this->addScriptaculous
) {
1597 foreach ($this->addScriptaculousModules
as $key => $value) {
1598 if ($this->addScriptaculousModules
[$key]) {
1602 // resolve dependencies
1603 if (in_array('dragdrop', $mods) ||
in_array('controls', $mods)) {
1604 $mods = array_merge(array('effects'), $mods);
1608 foreach ($mods as $module) {
1609 $out .= '<script src="' . $this->processJsFile($this->backPath
.
1610 $this->scriptaculousPath
. $module . '.js') . '" type="text/javascript"></script>' . LF
;
1611 unset($this->jsFiles
[$this->backPath
. $this->scriptaculousPath
. $module . '.js']);
1614 $out .= '<script src="' . $this->processJsFile($this->backPath
. $this->scriptaculousPath
.
1615 'scriptaculous.js') . '" type="text/javascript"></script>' . LF
;
1616 unset($this->jsFiles
[$this->backPath
. $this->scriptaculousPath
. 'scriptaculous.js']);
1620 if ($this->addExtCore
) {
1621 $out .= '<script src="' . $this->processJsFile($this->backPath
.
1622 $this->extCorePath
. 'ext-core' . ($this->enableExtCoreDebug ?
'-debug' : '') . '.js') .
1623 '" type="text/javascript"></script>' . LF
;
1624 unset($this->jsFiles
[$this->backPath
. $this->extCorePath
. 'ext-core' . ($this->enableExtCoreDebug ?
'-debug' : '') . '.js']);
1628 if ($this->addExtJS
) {
1629 // use the base adapter all the time
1630 $out .= '<script src="' . $this->processJsFile($this->backPath
. $this->extJsPath
.
1631 'adapter/' . ($this->enableExtJsDebug ?
1632 str_replace('.js', '-debug.js', $this->extJSadapter
) : $this->extJSadapter
)) .
1633 '" type="text/javascript"></script>' . LF
;
1634 $out .= '<script src="' . $this->processJsFile($this->backPath
. $this->extJsPath
.
1635 'ext-all' . ($this->enableExtJsDebug ?
'-debug' : '') . '.js') .
1636 '" type="text/javascript"></script>' . LF
;
1638 // add extJS localization
1639 $localeMap = $this->csConvObj
->isoArray
; // load standard ISO mapping and modify for use with ExtJS
1640 $localeMap[''] = 'en';
1641 $localeMap['default'] = 'en';
1642 $localeMap['gr'] = 'el_GR'; // Greek
1643 $localeMap['no'] = 'no_BO'; // Norwegian Bokmaal
1644 $localeMap['se'] = 'se_SV'; // Swedish
1647 $extJsLang = isset($localeMap[$this->lang
]) ?
$localeMap[$this->lang
] : $this->lang
;
1648 // TODO autoconvert file from UTF8 to current BE charset if necessary!!!!
1649 $extJsLocaleFile = $this->extJsPath
. 'locale/ext-lang-' . $extJsLang . '.js';
1650 if (file_exists(PATH_typo3
. $extJsLocaleFile)) {
1651 $out .= '<script src="' . $this->processJsFile($this->backPath
.
1652 $extJsLocaleFile) . '" type="text/javascript" charset="utf-8"></script>' . LF
;
1656 // remove extjs from JScodeLibArray
1658 $this->jsFiles
[$this->backPath
. $this->extJsPath
. 'ext-all.js'],
1659 $this->jsFiles
[$this->backPath
. $this->extJsPath
. 'ext-all-debug.js']
1663 if (count($this->inlineLanguageLabelFiles
)) {
1664 foreach ($this->inlineLanguageLabelFiles
as $languageLabelFile) {
1665 $this->includeLanguageFileForInline(
1666 $languageLabelFile['fileRef'],
1667 $languageLabelFile['selectionPrefix'],
1668 $languageLabelFile['stripFromSelectionName'],
1669 $languageLabelFile['$errorMode']
1673 unset($this->inlineLanguageLabelFiles
);
1675 // Convert labels/settings back to UTF-8 since json_encode() only works with UTF-8:
1676 if ($this->getCharSet() !== 'utf-8') {
1677 if ($this->inlineLanguageLabels
) {
1678 $this->csConvObj
->convArray($this->inlineLanguageLabels
, $this->getCharSet(), 'utf-8');
1680 if ($this->inlineSettings
) {
1681 $this->csConvObj
->convArray($this->inlineSettings
, $this->getCharSet(), 'utf-8');
1685 $inlineSettings = $this->inlineLanguageLabels ?
'TYPO3.lang = ' . json_encode($this->inlineLanguageLabels
) . ';' : '';
1686 $inlineSettings .= $this->inlineSettings ?
'TYPO3.settings = ' . json_encode($this->inlineSettings
) . ';' : '';
1688 if ($this->addExtCore ||
$this->addExtJS
) {
1689 // set clear.gif, move it on top, add handler code
1691 if (count($this->extOnReadyCode
)) {
1692 foreach ($this->extOnReadyCode
as $block) {
1697 $out .= $this->inlineJavascriptWrap
[0] . '
1699 Ext.BLANK_IMAGE_URL = "' . htmlspecialchars(t3lib_div
::locationHeaderUrl($this->backPath
. 'gfx/clear.gif')) . '";' . LF
.
1701 'Ext.onReady(function() {' .
1702 ($this->enableExtJSQuickTips ?
'Ext.QuickTips.init();' . LF
: '') . $code .
1703 ' });' . $this->inlineJavascriptWrap
[1];
1704 unset ($this->extOnReadyCode
);
1706 if ($this->extJStheme
) {
1707 if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
1708 $this->addCssFile($this->backPath
. $GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'all', '', TRUE, TRUE);
1710 $this->addCssFile($this->backPath
. $this->extJsPath
. 'resources/css/xtheme-blue.css', 'stylesheet', 'all', '', TRUE, TRUE);
1713 if ($this->extJScss
) {
1714 if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
1715 $this->addCssFile($this->backPath
. $GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'all', '', TRUE, TRUE);
1717 $this->addCssFile($this->backPath
. $this->extJsPath
. 'resources/css/ext-all-notheme.css', 'stylesheet', 'all', '', TRUE, TRUE);
1721 if ($inlineSettings) {
1722 $out .= $this->inlineJavascriptWrap
[0] . $inlineSettings . $this->inlineJavascriptWrap
[1];
1729 protected function includeLanguageFileForInline($fileRef, $selectionPrefix = '', $stripFromSelectionName = '', $errorMode = 0) {
1730 if (!isset($this->lang
) ||
!isset($this->charSet
)) {
1731 throw new RuntimeException('Language and character encoding are not set.', 1284906026);
1734 $labelsFromFile = array();
1735 $allLabels = t3lib_div
::readLLfile($fileRef, $this->lang
, $this->charSet
, $errorMode);
1737 // Regular expression to strip the selection prefix and possibly something from the label name:
1738 $labelPattern = '#^' . preg_quote($selectionPrefix, '#') . '(' . preg_quote($stripFromSelectionName, '#') . ')?#';
1740 if ($allLabels !== FALSE) {
1741 // Merge language specific translations:
1742 if ($this->lang
!== 'default' && isset($allLabels[$this->lang
])) {
1743 $labels = array_merge($allLabels['default'], $allLabels[$this->lang
]);
1745 $labels = $allLabels['default'];
1748 // Iterate through all locallang labels:
1749 foreach ($labels as $label => $value) {
1750 if ($selectionPrefix === '') {
1751 $labelsFromFile[$label] = $value;
1752 } elseif (strpos($label, $selectionPrefix) === 0) {
1753 $key = preg_replace($labelPattern, '', $label);
1754 $labelsFromFile[$label] = $value;
1758 $this->inlineLanguageLabels
= array_merge($this->inlineLanguageLabels
, $labelsFromFile);
1762 /*****************************************************/
1767 /*****************************************************/
1770 * concatenate files into one file
1771 * registered handler
1775 protected function doConcatenate() {
1776 // traverse the arrays, concatenate in one file
1777 // then remove concatenated files from array and add the concatenated file
1779 if ($this->concatenateFiles
) {
1781 'jsLibs' => &$this->jsLibs
,
1782 'jsFiles' => &$this->jsFiles
,
1783 'jsFooterFiles' => &$this->jsFooterFiles
,
1784 'cssFiles' => &$this->cssFiles
,
1785 'headerData' => &$this->headerData
,
1786 'footerData' => &$this->footerData
,
1789 if ($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['concatenateHandler']) {
1790 // use extern concatenate routine
1791 t3lib_div
::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['concatenateHandler'], $params, $this);
1792 } elseif (TYPO3_MODE
=== 'BE') {
1793 $cssOptions = array('baseDirectories' => $GLOBALS['TBE_TEMPLATE']->getSkinStylesheetDirectories());
1794 $this->cssFiles
= $this->getCompressor()->concatenateCssFiles($this->cssFiles
, $cssOptions);
1800 * compress inline code
1804 protected function doCompress() {
1806 if ($this->compressJavascript
&& $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['jsCompressHandler']) {
1807 // use extern compress routine
1809 'jsInline' => &$this->jsInline
,
1810 'jsFooterInline' => &$this->jsFooterInline
,
1811 'jsLibs' => &$this->jsLibs
,
1812 'jsFiles' => &$this->jsFiles
,
1813 'jsFooterFiles' => &$this->jsFooterFiles
,
1814 'headerData' => &$this->headerData
,
1815 'footerData' => &$this->footerData
,
1817 t3lib_div
::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['jsCompressHandler'], $params, $this);
1819 // traverse the arrays, compress files
1821 if ($this->compressJavascript
) {
1822 if (count($this->jsInline
)) {
1823 foreach ($this->jsInline
as $name => $properties) {
1824 if ($properties['compress']) {
1826 $this->jsInline
[$name]['code'] = t3lib_div
::minifyJavaScript($properties['code'], $error);
1828 $this->compressError
.= 'Error with minify JS Inline Block "' . $name . '": ' . $error . LF
;
1833 if (TYPO3_MODE
=== 'BE') {
1834 $this->jsFiles
= $this->getCompressor()->compressJsFiles($this->jsFiles
);
1835 $this->jsFooterFiles
= $this->getCompressor()->compressJsFiles($this->jsFooterFiles
);
1839 if ($this->compressCss
) {
1840 // use extern compress routine
1842 'cssInline' => &$this->cssInline
,
1843 'cssFiles' => &$this->cssFiles
,
1844 'headerData' => &$this->headerData
,
1845 'footerData' => &$this->footerData
,
1848 if ($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['cssCompressHandler']) {
1849 // use extern concatenate routine
1850 t3lib_div
::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['cssCompressHandler'], $params, $this);
1851 } elseif (TYPO3_MODE
=== 'BE') {
1852 $this->cssFiles
= $this->getCompressor()->compressCssFiles($this->cssFiles
);
1858 * Returns instance of t3lib_Compressor
1860 * @return t3lib_Compressor Instance of t3lib_Compressor
1862 protected function getCompressor() {
1863 if ($this->compressor
=== NULL) {
1864 $this->compressor
= t3lib_div
::makeInstance('t3lib_Compressor');
1866 return $this->compressor
;
1870 * Processes a Javascript file dependent on the current context
1872 * Adds the version number for Frontend, compresses the file for Backend
1874 * @param string $filename Filename
1875 * @return string new filename
1877 protected function processJsFile($filename) {
1878 switch (TYPO3_MODE
) {
1880 $filename = t3lib_div
::createVersionNumberedFilename($filename);
1883 if ($this->compressJavascript
) {
1884 $filename = $this->getCompressor()->compressJsFile($filename);
1893 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_pagerenderer.php'])) {
1894 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_pagerenderer.php']);