Fixed bug #15383: [Unit tests] Add tests for t3lib_div::validEmail
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_pagerenderer.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2010 Steffen Kamper (info@sk-typo3.de)
6 * All rights reserved
7 *
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.
13 *
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.
18 *
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * TYPO3 pageRender class (new in TYPO3 4.3.0)
30 * This class render the HTML of a webpage, usable for BE and FE
31 *
32 * @author Steffen Kamper <info@sk-typo3.de>
33 * @package TYPO3
34 * @subpackage t3lib
35 * $Id$
36 */
37 class t3lib_PageRenderer implements t3lib_Singleton {
38
39 protected $compressJavascript = FALSE;
40 protected $compressCss = FALSE;
41 protected $removeLineBreaksFromTemplate = FALSE;
42
43 protected $concatenateFiles = FALSE;
44
45 protected $moveJsFromHeaderToFooter = FALSE;
46
47 protected $csConvObj;
48 protected $lang;
49
50 /* @var t3lib_Compressor Instance of t3lib_Compressor */
51 protected $compressor;
52
53 // static array containing associative array for the included files
54 protected static $jsFiles = array ();
55 protected static $jsFooterFiles = array ();
56 protected static $jsLibs = array ();
57 protected static $jsFooterLibs = array ();
58 protected static $cssFiles = array ();
59
60 protected $title;
61 protected $charSet;
62 protected $favIcon;
63 protected $baseUrl;
64
65 protected $renderXhtml = TRUE;
66
67 // static header blocks
68 protected $xmlPrologAndDocType = '';
69 protected $metaTags = array ();
70 protected $inlineComments = array ();
71 protected $headerData = array ();
72 protected $footerData = array ();
73 protected $titleTag = '<title>|</title>';
74 protected $metaCharsetTag = '<meta http-equiv="Content-Type" content="text/html; charset=|" />';
75 protected $htmlTag = '<html>';
76 protected $headTag = '<head>';
77 protected $baseUrlTag = '<base href="|" />';
78 protected $iconMimeType = '';
79 protected $shortcutTag = '<link rel="shortcut icon" href="%1$s"%2$s />
80 <link rel="icon" href="%1$s"%2$s />';
81
82 // static inline code blocks
83 protected $jsInline = array ();
84 protected $extOnReadyCode = array ();
85 protected $cssInline = array ();
86
87 protected $bodyContent;
88
89 protected $templateFile;
90
91 protected $jsLibraryNames = array ('prototype', 'scriptaculous', 'extjs');
92
93 const PART_COMPLETE = 0;
94 const PART_HEADER = 1;
95 const PART_FOOTER = 2;
96
97 // paths to contibuted libraries
98 protected $prototypePath = 'contrib/prototype/';
99 protected $scriptaculousPath = 'contrib/scriptaculous/';
100 protected $extCorePath = 'contrib/extjs/';
101 protected $extJsPath = 'contrib/extjs/';
102
103
104 // internal flags for JS-libraries
105 protected $addPrototype = FALSE;
106 protected $addScriptaculous = FALSE;
107 protected $addScriptaculousModules = array ('builder' => FALSE, 'effects' => FALSE, 'dragdrop' => FALSE, 'controls' => FALSE, 'slider' => FALSE);
108 protected $addExtJS = FALSE;
109 protected $addExtCore = FALSE;
110 protected $extJSadapter = 'ext/ext-base.js';
111
112 protected $enableExtJsDebug = FALSE;
113 protected $enableExtCoreDebug = FALSE;
114
115 // available adapters for extJs
116 const EXTJS_ADAPTER_JQUERY = 'jquery';
117 const EXTJS_ADAPTER_PROTOTYPE = 'prototype';
118 const EXTJS_ADAPTER_YUI = 'yui';
119
120 protected $extJStheme = TRUE;
121 protected $extJScss = TRUE;
122
123 protected $enableExtJSQuickTips = false;
124
125 protected $inlineLanguageLabels = array ();
126 protected $inlineSettings = array ();
127
128 protected $inlineJavascriptWrap = array ();
129
130 // used by BE modules
131 public $backPath;
132
133 /**
134 * Constructor
135 *
136 * @param string $templateFile declare the used template file. Omit this parameter will use default template
137 * @param string $backPath relative path to typo3-folder. It varies for BE modules, in FE it will be typo3/
138 * @return void
139 */
140 public function __construct($templateFile = '', $backPath = NULL) {
141
142 $this->reset();
143 $this->csConvObj = t3lib_div::makeInstance('t3lib_cs');
144
145 if (strlen($templateFile)) {
146 $this->templateFile = $templateFile;
147 }
148 $this->backPath = isset($backPath) ? $backPath : $GLOBALS['BACK_PATH'];
149
150 $this->inlineJavascriptWrap = array(
151 '<script type="text/javascript">' . LF . '/*<![CDATA[*/' . LF . '<!-- ' . LF,
152 '// -->' . LF . '/*]]>*/' . LF . '</script>' . LF
153 );
154 $this->inlineCssWrap = array(
155 '<style type="text/css">' . LF . '/*<![CDATA[*/' . LF . '<!-- ' . LF,
156 '-->' . LF . '/*]]>*/' . LF . '</style>' . LF
157 );
158
159 }
160
161 /**
162 * reset all vars to initial values
163 *
164 * @return void
165 */
166 protected function reset() {
167 $this->templateFile = TYPO3_mainDir . 'templates/template_page_backend.html';
168 $this->jsFiles = array ();
169 $this->jsFooterFiles = array ();
170 $this->jsInline = array ();
171 $this->jsFooterInline = array ();
172 $this->jsLibs = array ();
173 $this->cssFiles = array ();
174 $this->cssInline = array ();
175 $this->metaTags = array ();
176 $this->inlineComments = array ();
177 $this->headerData = array ();
178 $this->footerData = array ();
179 $this->extOnReadyCode = array ();
180 }
181 /*****************************************************/
182 /* */
183 /* Public Setters */
184 /* */
185 /* */
186 /*****************************************************/
187
188 /**
189 * Sets the title
190 *
191 * @param string $title title of webpage
192 * @return void
193 */
194 public function setTitle($title) {
195 $this->title = $title;
196 }
197
198
199 /**
200 * Enables/disables rendering of XHTML code
201 *
202 * @param boolean $enable Enable XHTML
203 * @return void
204 */
205 public function setRenderXhtml($enable) {
206 $this->renderXhtml = $enable;
207 }
208
209 /**
210 * Sets xml prolog and docType
211 *
212 * @param string $xmlPrologAndDocType complete tags for xml prolog and docType
213 * @return void
214 */
215 public function setXmlPrologAndDocType($xmlPrologAndDocType) {
216 $this->xmlPrologAndDocType = $xmlPrologAndDocType;
217 }
218
219 /**
220 * Sets meta charset
221 *
222 * @param string $charSet used charset
223 * @return void
224 */
225 public function setCharSet($charSet) {
226 $this->charSet = $charSet;
227 }
228
229 /**
230 * Sets language
231 *
232 * @param string $lang used language
233 * @return void
234 */
235 public function setLanguage($lang) {
236 $this->lang = $lang;
237 }
238
239 /**
240 * Sets html tag
241 *
242 * @param string $htmlTag html tag
243 * @return void
244 */
245 public function setHtmlTag($htmlTag) {
246 $this->htmlTag = $htmlTag;
247 }
248
249 /**
250 * Sets head tag
251 *
252 * @param string $tag head tag
253 * @return void
254 */
255 public function setHeadTag($headTag) {
256 $this->headTag = $headTag;
257 }
258
259 /**
260 * Sets favicon
261 *
262 * @param string $favIcon
263 * @return void
264 */
265 public function setFavIcon($favIcon) {
266 $this->favIcon = $favIcon;
267 }
268
269 /**
270 * Sets icon mime type
271 *
272 * @param string $iconMimeType
273 * @return void
274 */
275 public function setIconMimeType($iconMimeType) {
276 $this->iconMimeType = $iconMimeType;
277 }
278
279 /**
280 * Sets base url
281 *
282 * @param string $url
283 * @return void
284 */
285 public function setBaseUrl($baseUrl) {
286 $this->baseUrl = $baseUrl;
287 }
288
289 /**
290 * Sets template file
291 *
292 * @param string $file
293 * @return void
294 */
295 public function setTemplateFile($file) {
296 $this->templateFile = $file;
297 }
298
299 /**
300 * Sets back path
301 *
302 * @param string $backPath
303 * @return void
304 */
305 public function setBackPath($backPath) {
306 $this->backPath = $backPath;
307 }
308
309 /**
310 * Sets Content for Body
311 *
312 * @param string $content
313 * @return void
314 */
315 public function setBodyContent($content) {
316 $this->bodyContent = $content;
317 }
318
319 /**
320 * Sets Path for prototype library (relative to typo3 directory)
321 *
322 * @param string path
323 * @return void
324 */
325 public function setPrototypePath($path) {
326 $this->prototypePath = $path;
327 }
328
329 /**
330 * Sets Path for scriptaculous library (relative to typo3 directory)
331 *
332 * @param string $path
333 * @return void
334 */
335 public function setScriptaculousPath($path) {
336 $this->scriptaculousPath = $path;
337 }
338
339 /**
340 * Sets Path for Ext Core library (relative to typo3 directory)
341 *
342 * @param string $path
343 * @return void
344 */
345 public function setExtCorePath($path) {
346 $this->extCorePath = $path;
347 }
348
349 /**
350 * Sets Path for ExtJs library (relative to typo3 directory)
351 *
352 * @param string $path
353 * @return void
354 */
355 public function setExtJsPath($path) {
356 $this->extJsPath = $path;
357 }
358
359 /*****************************************************/
360 /* */
361 /* Public Enablers / Disablers */
362 /* */
363 /* */
364 /*****************************************************/
365
366 /**
367 * Enables MoveJsFromHeaderToFooter
368 *
369 * @param void
370 * @return void
371 */
372 public function enableMoveJsFromHeaderToFooter() {
373 $this->moveJsFromHeaderToFooter = TRUE;
374 }
375
376 /**
377 * Disables MoveJsFromHeaderToFooter
378 *
379 * @param void
380 * @return void
381 */
382 public function disableMoveJsFromHeaderToFooter() {
383 $this->moveJsFromHeaderToFooter = FALSE;
384 }
385
386 /**
387 * Enables compression of javascript
388 *
389 * @param void
390 * @return void
391 */
392 public function enableCompressJavascript() {
393 $this->compressJavascript = TRUE;
394 }
395
396 /**
397 * Disables compression of javascript
398 *
399 * @param void
400 * @return void
401 */
402 public function disableCompressJavascript() {
403 $this->compressJavascript = FALSE;
404 }
405
406 /**
407 * Enables compression of css
408 *
409 * @param void
410 * @return void
411 */
412 public function enableCompressCss() {
413 $this->compressCss = TRUE;
414 }
415
416 /**
417 * Disables compression of css
418 *
419 * @param void
420 * @return void
421 */
422 public function disableCompressCss() {
423 $this->compressCss = FALSE;
424 }
425
426 /**
427 * Enables concatenation of js/css files
428 *
429 * @param void
430 * @return void
431 */
432 public function enableConcatenateFiles() {
433 $this->concatenateFiles = TRUE;
434 }
435
436 /**
437 * Disables concatenation of js/css files
438 *
439 * @param void
440 * @return void
441 */
442 public function disableConcatenateFiles() {
443 $this->concatenateFiles = FALSE;
444 }
445
446 /**
447 * Sets removal of all line breaks in template
448 *
449 * @param void
450 * @return void
451 */
452 public function enableRemoveLineBreaksFromTemplate() {
453 $this->removeLineBreaksFromTemplate = TRUE;
454 }
455
456 /**
457 * Unsets removal of all line breaks in template
458 *
459 * @param void
460 * @return void
461 */
462 public function disableRemoveLineBreaksFromTemplate() {
463 $this->removeLineBreaksFromTemplate = FALSE;
464 }
465
466 /**
467 * Enables Debug Mode
468 * This is a shortcut to switch off all compress/concatenate features to enable easier debug
469 *
470 * @param void
471 * @return void
472 */
473 public function enableDebugMode() {
474 $this->compressJavascript = FALSE;
475 $this->compressCss = FALSE;
476 $this->concatenateFiles = FALSE;
477 $this->removeLineBreaksFromTemplate = FALSE;
478 }
479
480 /*****************************************************/
481 /* */
482 /* Public Getters */
483 /* */
484 /* */
485 /*****************************************************/
486
487 /**
488 * Gets the title
489 *
490 * @return string $title title of webpage
491 */
492 public function getTitle() {
493 return $this->title;
494 }
495
496 /**
497 * Gets the charSet
498 *
499 * @return string $charSet
500 */
501 public function getCharSet() {
502 return $this->charSet;
503 }
504
505 /**
506 * Gets the language
507 *
508 * @return string $lang
509 */
510 public function getLanguage() {
511 return $this->lang;
512 }
513
514 /**
515 * Returns rendering mode XHTML or HTML
516 *
517 * @return boolean TRUE if XHTML, FALSE if HTML
518 */
519 public function getRenderXhtml() {
520 return $this->renderXhtml;
521 }
522
523 /**
524 * Gets html tag
525 *
526 * @return string $htmlTag html tag
527 */
528 public function getHtmlTag() {
529 return $this->htmlTag;
530 }
531
532 /**
533 * Gets head tag
534 *
535 * @return string $tag head tag
536 */
537 public function getHeadTag() {
538 return $this->headTag;
539 }
540
541 /**
542 * Gets favicon
543 *
544 * @return string $favIcon
545 */
546 public function getFavIcon() {
547 return $this->favIcon;
548 }
549
550 /**
551 * Gets icon mime type
552 *
553 * @return string $iconMimeType
554 */
555 public function getIconMimeType() {
556 return $this->iconMimeType;
557 }
558
559 /**
560 * Gets base url
561 *
562 * @return string $url
563 */
564 public function getBaseUrl() {
565 return $this->baseUrl;
566 }
567
568 /**
569 * Gets template file
570 *
571 * @return string $file
572 */
573 public function getTemplateFile($file) {
574 return $this->templateFile;
575 }
576
577 /**
578 * Gets MoveJsFromHeaderToFooter
579 *
580 * @return boolean
581 */
582 public function getMoveJsFromHeaderToFooter() {
583 return $this->moveJsFromHeaderToFooter;
584 }
585
586 /**
587 * Gets compress of javascript
588 *
589 * @return boolean
590 */
591 public function getCompressJavascript() {
592 return $this->compressJavascript;
593 }
594
595 /**
596 * Gets compress of css
597 *
598 * @return boolean
599 */
600 public function getCompressCss() {
601 return $this->compressCss;
602 }
603
604 /**
605 * Gets concatenate of files
606 *
607 * @return boolean
608 */
609 public function getConcatenateFiles() {
610 return $this->concatenateFiles;
611 }
612
613 /**
614 * Gets remove of empty lines from template
615 *
616 * @return boolean
617 */
618 public function getRemoveLineBreaksFromTemplate() {
619 return $this->removeLineBreaksFromTemplate;
620 }
621
622 /**
623 * Gets content for body
624 *
625 * @return string
626 */
627 public function getBodyContent() {
628 return $this->bodyContent;
629 }
630
631 /**
632 * Gets Path for prototype library (relative to typo3 directory)
633 *
634 * @return string
635 */
636 public function getPrototypePath() {
637 return $this->prototypePath;
638 }
639
640 /**
641 * Gets Path for scriptaculous library (relative to typo3 directory)
642 *
643 * @return string
644 */
645 public function getScriptaculousPath() {
646 return $this->scriptaculousPath;
647 }
648
649 /**
650 * Gets Path for Ext Core library (relative to typo3 directory)
651 *
652 * @return string
653 */
654 public function getExtCorePath() {
655 return $this->extCorePath;
656 }
657
658 /**
659 * Gets Path for ExtJs library (relative to typo3 directory)
660 *
661 * @return string
662 */
663 public function getExtJsPath() {
664 return $this->extJsPath;
665 }
666
667 /*****************************************************/
668 /* */
669 /* Public Function to add Data */
670 /* */
671 /* */
672 /*****************************************************/
673
674 /**
675 * Adds meta data
676 *
677 * @param string $meta meta data (complete metatag)
678 * @return void
679 */
680 public function addMetaTag($meta) {
681 if (!in_array($meta, $this->metaTags)) {
682 $this->metaTags[] = $meta;
683 }
684 }
685
686 /**
687 * Adds inline HTML comment
688 *
689 * @param string $comment
690 * @return void
691 */
692 public function addInlineComment($comment) {
693 if (!in_array($comment, $this->inlineComments)) {
694 $this->inlineComments[] = $comment;
695 }
696 }
697
698 /**
699 * Adds header data
700 *
701 * @param string $data free header data for HTML header
702 * @return void
703 */
704 public function addHeaderData($data) {
705 if (!in_array($data, $this->headerData)) {
706 $this->headerData[] = $data;
707 }
708 }
709
710 /**
711 * Adds footer data
712 *
713 * @param string $data free header data for HTML header
714 * @return void
715 */
716 public function addFooterData($data) {
717 if (!in_array($data, $this->footerData)) {
718 $this->footerData[] = $data;
719 }
720 }
721
722 /* Javascript Files */
723
724 /**
725 * Adds JS Library. JS Library block is rendered on top of the JS files.
726 *
727 * @param string $name
728 * @param string $file
729 * @param string $type
730 * @param boolean $compress flag if library should be compressed
731 * @param boolean $forceOnTop flag if added library should be inserted at begin of this block
732 * @param string $allWrap
733 * @return void
734 */
735 public function addJsLibrary($name, $file, $type = 'text/javascript', $compress = FALSE, $forceOnTop = FALSE, $allWrap = '') {
736 if (!in_array(strtolower($name), $this->jsLibs)) {
737 $this->jsLibs[strtolower($name)] = array (
738 'file' => $file,
739 'type' => $type,
740 'section' => self::PART_HEADER,
741 'compress' => $compress,
742 'forceOnTop' => $forceOnTop,
743 'allWrap' => $allWrap
744 );
745 }
746
747 }
748
749 /**
750 * Adds JS Library to Footer. JS Library block is rendered on top of the Footer JS files.
751 *
752 * @param string $name
753 * @param string $file
754 * @param string $type
755 * @param boolean $compress flag if library should be compressed
756 * @param boolean $forceOnTop flag if added library should be inserted at begin of this block
757 * @param string $allWrap
758 * @return void
759 */
760 public function addJsFooterLibrary($name, $file, $type = 'text/javascript', $compress = FALSE, $forceOnTop = FALSE, $allWrap = '') {
761 if (!in_array(strtolower($name), $this->jsLibs)) {
762 $this->jsLibs[strtolower($name)] = array (
763 'file' => $file,
764 'type' => $type,
765 'section' => self::PART_FOOTER,
766 'compress' => $compress,
767 'forceOnTop' => $forceOnTop,
768 'allWrap' => $allWrap
769 );
770 }
771
772 }
773
774 /**
775 * Adds JS file
776 *
777 * @param string $file
778 * @param string $type
779 * @param boolean $compress
780 * @param boolean $forceOnTop
781 * @param string $allWrap
782 * @return void
783 */
784 public function addJsFile($file, $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '') {
785 if (!isset($this->jsFiles[$file])) {
786 $this->jsFiles[$file] = array (
787 'type' => $type,
788 'section' => self::PART_HEADER,
789 'compress' => $compress,
790 'forceOnTop' => $forceOnTop,
791 'allWrap' => $allWrap
792 );
793 }
794 }
795
796 /**
797 * Adds JS file to footer
798 *
799 * @param string $file
800 * @param string $type
801 * @param boolean $compress
802 * @param boolean $forceOnTop
803 * @return void
804 */
805 public function addJsFooterFile($file, $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '') {
806 if (!isset($this->jsFiles[$file])) {
807 $this->jsFiles[$file] = array (
808 'type' => $type,
809 'section' => self::PART_FOOTER,
810 'compress' => $compress,
811 'forceOnTop' => $forceOnTop,
812 'allWrap' => $allWrap
813 );
814 }
815 }
816
817 /*Javascript Inline Blocks */
818
819 /**
820 * Adds JS inline code
821 *
822 * @param string $name
823 * @param string $block
824 * @param boolean $compress
825 * @param boolean $forceOnTop
826 * @return void
827 */
828 public function addJsInlineCode($name, $block, $compress = TRUE, $forceOnTop = FALSE) {
829 if (!isset($this->jsInline[$name]) && !empty($block)) {
830 $this->jsInline[$name] = array (
831 'code' => $block . LF,
832 'section' => self::PART_HEADER,
833 'compress' => $compress,
834 'forceOnTop' => $forceOnTop
835 );
836 }
837 }
838
839 /**
840 * Adds JS inline code to footer
841 *
842 * @param string $name
843 * @param string $block
844 * @param boolean $compress
845 * @param boolean $forceOnTop
846 * @return void
847 */
848 public function addJsFooterInlineCode($name, $block, $compress = TRUE, $forceOnTop = FALSE) {
849 if (!isset($this->jsInline[$name]) && !empty($block)) {
850 $this->jsInline[$name] = array (
851 'code' => $block . LF,
852 'section' => self::PART_FOOTER,
853 'compress' => $compress,
854 'forceOnTop' => $forceOnTop
855 );
856 }
857 }
858
859 /**
860 * Adds Ext.onready code, which will be wrapped in Ext.onReady(function() {...});
861 *
862 * @param string $block javascript code
863 * @param boolean $forceOnTop position of the javascript code (TRUE for putting it on top, default is FALSE = bottom)
864 * @return void
865 */
866 public function addExtOnReadyCode($block, $forceOnTop = FALSE) {
867 if (!in_array($block, $this->extOnReadyCode)) {
868 if ($forceOnTop) {
869 array_unshift($this->extOnReadyCode, $block);
870 } else {
871 $this->extOnReadyCode[] = $block;
872 }
873 }
874 }
875
876 /* CSS Files */
877
878 /**
879 * Adds CSS file
880 *
881 * @param string $file
882 * @param string $rel
883 * @param string $media
884 * @param string $title
885 * @param boolean $compress
886 * @param boolean $forceOnTop
887 * @return void
888 */
889 public function addCssFile($file, $rel = 'stylesheet', $media = 'all', $title = '', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '') {
890 if (!isset($this->cssFiles[$file])) {
891 $this->cssFiles[$file] = array (
892 'rel' => $rel,
893 'media' => $media,
894 'title' => $title,
895 'compress' => $compress,
896 'forceOnTop' => $forceOnTop,
897 'allWrap' => $allWrap
898 );
899 }
900 }
901
902 /*CSS Inline Blocks */
903
904 /**
905 * Adds CSS inline code
906 *
907 * @param string $name
908 * @param string $block
909 * @param boolean $compress
910 * @param boolean $forceOnTop
911 * @return void
912 */
913 public function addCssInlineBlock($name, $block, $compressed = FALSE, $forceOnTop = FALSE) {
914 if (!isset($this->cssInline[$name]) && !empty($block)) {
915 $this->cssInline[$name] = array (
916 'code' => $block,
917 'compress' => $compress,
918 'forceOnTop' => $forceOnTop
919 );
920 }
921 }
922
923 /* JS Libraries */
924
925 /**
926 * call function if you need the prototype library
927 *
928 * @return void
929 */
930 public function loadPrototype() {
931 $this->addPrototype = TRUE;
932 }
933
934 /**
935 * call function if you need the Scriptaculous library
936 *
937 * @param string $modules add modules you need. use "all" if you need complete modules
938 * @return void
939 */
940 public function loadScriptaculous($modules = 'all') {
941 // Scriptaculous require prototype, so load prototype too.
942 $this->addPrototype = TRUE;
943 $this->addScriptaculous = TRUE;
944 if ($modules) {
945 if ($modules == 'all') {
946 foreach ($this->addScriptaculousModules as $key => $value) {
947 $this->addScriptaculousModules[$key] = TRUE;
948 }
949 } else {
950 $mods = t3lib_div::trimExplode(',', $modules);
951 foreach ($mods as $mod) {
952 if (isset($this->addScriptaculousModules[strtolower($mod)])) {
953 $this->addScriptaculousModules[strtolower($mod)] = TRUE;
954 }
955 }
956 }
957 }
958 }
959
960 /**
961 * call this function if you need the extJS library
962 *
963 * @param boolean $css flag, if set the ext-css will be loaded
964 * @param boolean $theme flag, if set the ext-theme "grey" will be loaded
965 * @param string $adapter choose alternative adapter, possible values: yui, prototype, jquery
966 * @return void
967 */
968 public function loadExtJS($css = TRUE, $theme = TRUE, $adapter = '') {
969 if ($adapter) {
970 // empty $adapter will always load the ext adapter
971 switch (t3lib_div::strtolower(trim($adapter))) {
972 case self::EXTJS_ADAPTER_YUI :
973 $this->extJSadapter = 'yui/ext-yui-adapter.js';
974 break;
975 case self::EXTJS_ADAPTER_PROTOTYPE :
976 $this->extJSadapter = 'prototype/ext-prototype-adapter.js';
977 break;
978 case self::EXTJS_ADAPTER_JQUERY :
979 $this->extJSadapter = 'jquery/ext-jquery-adapter.js';
980 break;
981 }
982 }
983 $this->addExtJS = TRUE;
984 $this->extJStheme = $theme;
985 $this->extJScss = $css;
986
987 }
988
989 /**
990 * Enables ExtJs QuickTips
991 * Need extJs loaded
992 *
993 * @return void
994 *
995 */
996 public function enableExtJSQuickTips() {
997 $this->enableExtJSQuickTips = TRUE;
998 }
999
1000
1001 /**
1002 * call function if you need the ExtCore library
1003 *
1004 * @return void
1005 */
1006 public function loadExtCore() {
1007 $this->addExtCore = TRUE;
1008 }
1009
1010 /**
1011 * call this function to load debug version of ExtJS. Use this for development only
1012 *
1013 */
1014 public function enableExtJsDebug() {
1015 $this->enableExtJsDebug = TRUE;
1016 }
1017
1018 /**
1019 * call this function to load debug version of ExtCore. Use this for development only
1020 *
1021 * @return void
1022 */
1023 public function enableExtCoreDebug() {
1024 $this->enableExtCoreDebug = TRUE;
1025 }
1026
1027 /**
1028 * Adds Javascript Inline Label. This will occur in TYPO3.lang - object
1029 * The label can be used in scripts with TYPO3.lang.<key>
1030 * Need extJs loaded
1031 *
1032 * @param string $key
1033 * @param string $value
1034 * @return void
1035 */
1036 public function addInlineLanguageLabel($key, $value) {
1037 $this->inlineLanguageLabels[$key] = $value;
1038 }
1039
1040 /**
1041 * Adds Javascript Inline Label Array. This will occur in TYPO3.lang - object
1042 * The label can be used in scripts with TYPO3.lang.<key>
1043 * Array will be merged with existing array.
1044 * Need extJs loaded
1045 *
1046 * @param array $array
1047 * @return void
1048 */
1049 public function addInlineLanguageLabelArray(array $array) {
1050 $this->inlineLanguageLabels = array_merge($this->inlineLanguageLabels, $array);
1051 }
1052
1053 /**
1054 * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
1055 * The label can be used in scripts with TYPO3.setting.<key>
1056 * Need extJs loaded
1057 *
1058 * @param string $namespace
1059 * @param string $key
1060 * @param string $value
1061 * @return void
1062 */
1063 public function addInlineSetting($namespace, $key, $value) {
1064 if ($namespace) {
1065 if (strpos($namespace, '.')) {
1066 $parts = explode('.', $namespace);
1067 $a = &$this->inlineSettings;
1068 foreach ($parts as $part) {
1069 $a = &$a[$part];
1070 }
1071 $a[$key] = $value;
1072 } else {
1073 $this->inlineSettings[$namespace][$key] = $value;
1074 }
1075 } else {
1076 $this->inlineSettings[$key] = $value;
1077 }
1078 }
1079
1080 /**
1081 * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
1082 * The label can be used in scripts with TYPO3.setting.<key>
1083 * Array will be merged with existing array.
1084 * Need extJs loaded
1085 *
1086 * @param string $namespace
1087 * @param array $array
1088 * @return void
1089 */
1090 public function addInlineSettingArray($namespace, array $array) {
1091 if ($namespace) {
1092 if (strpos($namespace, '.')) {
1093 $parts = explode('.', $namespace);
1094 $a = &$this->inlineSettings;
1095 foreach ($parts as $part) {
1096 $a = &$a[$part];
1097 }
1098 $a = array_merge((array) $a, $array);
1099 } else {
1100 $this->inlineSettings[$namespace] = array_merge((array) $this->inlineSettings[$namespace], $array);
1101 }
1102 } else {
1103 $this->inlineSettings = array_merge($this->inlineSettings, $array);
1104 }
1105 }
1106
1107 /**
1108 * Adds content to body content
1109 *
1110 * @param string $content
1111 * @return void
1112 */
1113 public function addBodyContent($content) {
1114 $this->bodyContent .= $content;
1115 }
1116
1117 /*****************************************************/
1118 /* */
1119 /* Render Functions */
1120 /* */
1121 /* */
1122 /*****************************************************/
1123
1124 /**
1125 * render the section (Header or Footer)
1126 *
1127 * @param int $part section which should be rendered: self::PART_COMPLETE, self::PART_HEADER or self::PART_FOOTER
1128 * @return string content of rendered section
1129 */
1130 public function render($part = self::PART_COMPLETE) {
1131
1132 $jsFiles = '';
1133 $cssFiles = '';
1134 $cssInline = '';
1135 $jsInline = '';
1136 $jsFooterInline = '';
1137 $jsFooterLibs = '';
1138 $jsFooterFiles = '';
1139 $noJS = FALSE;
1140
1141 // preRenderHook for possible manuipulation
1142 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'])) {
1143 $params = array (
1144 'jsLibs' => &$this->jsLibs,
1145 'jsFiles' => &$this->jsFiles,
1146 'jsFooterFiles' => &$this->jsFooterFiles,
1147 'cssFiles' => &$this->cssFiles,
1148 'headerData' => &$this->headerData,
1149 'footerData' => &$this->footerData,
1150 'jsInline' => &$this->jsInline,
1151 'cssInline' => &$this->cssInline,
1152 );
1153 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'] as $hook) {
1154 t3lib_div::callUserFunction($hook, $params, $this);
1155 }
1156 }
1157
1158 $jsLibs = $this->renderJsLibraries();
1159
1160 if ($this->concatenateFiles) {
1161 // do the file concatenation
1162 $this->doConcatenate();
1163 }
1164 if ($this->compressCss || $this->compressJavascript) {
1165 // do the file compression
1166 $this->doCompress();
1167 }
1168
1169 $metaTags = implode(LF, $this->metaTags);
1170
1171 // remove ending slashes from static header block
1172 // if the page is beeing rendered as html (not xhtml)
1173 // and define variable $endingSlash for further use
1174 if ($this->getRenderXhtml()) {
1175 $endingSlash = ' /';
1176 } else {
1177 $this->metaCharsetTag = str_replace(' />', '>', $this->metaCharsetTag);
1178 $this->baseUrlTag = str_replace(' />', '>', $this->baseUrlTag);
1179 $this->shortcutTag = str_replace(' />', '>', $this->shortcutTag);
1180 $endingSlash = '';
1181 }
1182
1183 if (count($this->cssFiles)) {
1184 foreach ($this->cssFiles as $file => $properties) {
1185 $file = t3lib_div::resolveBackPath($file);
1186 $file = t3lib_div::createVersionNumberedFilename($file);
1187 $tag = '<link rel="' . $properties['rel'] . '" type="text/css" href="' .
1188 htmlspecialchars($file) . '" media="' . $properties['media'] . '"' .
1189 ($properties['title'] ? ' title="' . $properties['title'] . '"' : '') .
1190 $endingSlash . '>';
1191 if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
1192 $tag = str_replace('|', $tag, $properties['allWrap']);
1193 }
1194 if ($properties['forceOnTop']) {
1195 $cssFiles = $tag . LF . $cssFiles;
1196 } else {
1197 $cssFiles .= LF . $tag;
1198 }
1199 }
1200 }
1201
1202 if (count($this->cssInline)) {
1203 foreach ($this->cssInline as $name => $properties) {
1204 if ($properties['forceOnTop']) {
1205 $cssInline = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF . $cssInline;
1206 } else {
1207 $cssInline .= '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF;
1208 }
1209 }
1210 $cssInline = $this->inlineCssWrap[0] . $cssInline . $this->inlineCssWrap[1];
1211 }
1212
1213 if (count($this->jsLibs)) {
1214 foreach ($this->jsLibs as $name => $properties) {
1215 $properties['file'] = t3lib_div::resolveBackPath($properties['file']);
1216 $properties['file'] = t3lib_div::createVersionNumberedFilename($properties['file']);
1217 $tag = '<script src="' . htmlspecialchars($properties['file']) . '" type="' . $properties['type'] . '"></script>';
1218 if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
1219 $tag = str_replace('|', $tag, $properties['allWrap']);
1220 }
1221 if ($properties['forceOnTop']) {
1222 if ($properties['section'] === self::PART_HEADER) {
1223 $jsLibs = $tag . LF . $jsLibs;
1224 } else {
1225 $jsFooterLibs = $tag . LF . $jsFooterLibs;
1226 }
1227 } else {
1228 if ($properties['section'] === self::PART_HEADER) {
1229 $jsLibs .= LF . $tag;
1230 } else {
1231 $jsFooterLibs .= LF . $tag;
1232 }
1233 }
1234 }
1235 }
1236
1237 if (count($this->jsFiles)) {
1238 foreach ($this->jsFiles as $file => $properties) {
1239 $file = t3lib_div::resolveBackPath($file);
1240 $file = t3lib_div::createVersionNumberedFilename($file);
1241 $tag = '<script src="' . htmlspecialchars($file) . '" type="' . $properties['type'] . '"></script>';
1242 if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
1243 $tag = str_replace('|', $tag, $properties['allWrap']);
1244 }
1245 if ($properties['forceOnTop']) {
1246 if ($properties['section'] === self::PART_HEADER) {
1247 $jsFiles = $tag . LF . $jsFiles;
1248 } else {
1249 $jsFooterFiles = $tag . LF . $jsFooterFiles;
1250 }
1251 } else {
1252 if ($properties['section'] === self::PART_HEADER) {
1253 $jsFiles .= LF . $tag;
1254 } else {
1255 $jsFooterFiles .= LF . $tag;
1256 }
1257 }
1258 }
1259 }
1260
1261 if (count($this->jsInline)) {
1262 foreach ($this->jsInline as $name => $properties) {
1263 if ($properties['forceOnTop']) {
1264 if ($properties['section'] === self::PART_HEADER) {
1265 $jsInline = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF . $jsInline;
1266 } else {
1267 $jsFooterInline = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF . $jsFooterInline;
1268 }
1269 } else {
1270 if ($properties['section'] === self::PART_HEADER) {
1271 $jsInline .= '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF;
1272 } else {
1273 $jsFooterInline .= '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF;
1274 }
1275 }
1276 }
1277 }
1278
1279
1280 if ($jsInline) {
1281 $jsInline = $this->inlineJavascriptWrap[0] . $jsInline . $this->inlineJavascriptWrap[1];
1282 }
1283
1284 if ($jsFooterInline) {
1285 $jsFooterInline = $this->inlineJavascriptWrap[0] . $jsFooterInline . $this->inlineJavascriptWrap[1];
1286 }
1287
1288
1289 // get template
1290 $templateFile = t3lib_div::getFileAbsFileName($this->templateFile, TRUE);
1291 $template = t3lib_div::getURL($templateFile);
1292
1293 if ($this->removeEmptyLinesFromTemplate) {
1294 $template = strtr($template, array(LF => '', CR => ''));
1295 }
1296 if ($part != self::PART_COMPLETE) {
1297 $templatePart = explode('###BODY###', $template);
1298 $template = $templatePart[$part - 1];
1299 }
1300
1301 if ($this->moveJsFromHeaderToFooter) {
1302 $jsFooterLibs = $jsLibs . LF . $jsFooterLibs;
1303 $jsLibs = '';
1304 $jsFooterFiles = $jsFiles . LF . $jsFooterFiles;
1305 $jsFiles = '';
1306 $jsFooterInline = $jsInline . LF . $jsFooterInline;
1307 $jsInline = '';
1308 }
1309
1310 $markerArray = array(
1311 'XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType,
1312 'HTMLTAG' => $this->htmlTag,
1313 'HEADTAG' => $this->headTag,
1314 'METACHARSET' => $this->charSet ? str_replace('|', htmlspecialchars($this->charSet), $this->metaCharsetTag) : '',
1315 'INLINECOMMENT' => $this->inlineComments ? LF . LF . '<!-- ' . LF . implode(LF, $this->inlineComments) . '-->' . LF . LF : '',
1316 'BASEURL' => $this->baseUrl ? str_replace('|', $this->baseUrl, $this->baseUrlTag) : '',
1317 'SHORTCUT' => $this->favIcon ? sprintf($this->shortcutTag, htmlspecialchars($this->favIcon), $this->iconMimeType) : '',
1318 'CSS_INCLUDE' => $cssFiles,
1319 'CSS_INLINE' => $cssInline,
1320 'JS_INLINE' => $jsInline,
1321 'JS_INCLUDE' => $jsFiles,
1322 'JS_LIBS' => $jsLibs,
1323 'TITLE' => $this->title ? str_replace('|', htmlspecialchars($this->title), $this->titleTag) : '',
1324 'META' => $metaTags,
1325 'HEADERDATA' => $this->headerData ? implode(LF, $this->headerData) : '',
1326 'FOOTERDATA' => $this->footerData ? implode(LF, $this->footerData) : '',
1327 'JS_LIBS_FOOTER' => $jsFooterLibs,
1328 'JS_INCLUDE_FOOTER' => $jsFooterFiles,
1329 'JS_INLINE_FOOTER' => $jsFooterInline,
1330 'BODY' => $this->bodyContent,
1331 );
1332
1333 $markerArray = array_map('trim', $markerArray);
1334
1335 $this->reset();
1336 return trim(t3lib_parsehtml::substituteMarkerArray($template, $markerArray, '###|###'));
1337 }
1338
1339 /**
1340 * helper function for render the javascript libraries
1341 *
1342 * @return string content with javascript libraries
1343 */
1344 protected function renderJsLibraries() {
1345 $out = '';
1346
1347 if ($this->addPrototype) {
1348 $out .= '<script src="' . $this->processJsFile($this->backPath . $this->prototypePath . 'prototype.js') .
1349 '" type="text/javascript"></script>' . LF;
1350 unset($this->jsFiles[$this->backPath . $this->prototypePath .'prototype.js']);
1351 }
1352
1353 if ($this->addScriptaculous) {
1354 $mods = array ();
1355 foreach ($this->addScriptaculousModules as $key => $value) {
1356 if ($this->addScriptaculousModules[$key]) {
1357 $mods[] = $key;
1358 }
1359 }
1360 // resolve dependencies
1361 if (in_array('dragdrop', $mods) || in_array('controls', $mods)) {
1362 $mods = array_merge(array('effects'), $mods);
1363 }
1364
1365 if (count($mods)) {
1366 foreach ($mods as $module) {
1367 $out .= '<script src="' . $this->processJsFile($this->backPath .
1368 $this->scriptaculousPath . $module . '.js') . '" type="text/javascript"></script>' . LF;
1369 unset($this->jsFiles[$this->backPath . $this->scriptaculousPath . $module . '.js']);
1370 }
1371 }
1372 $out .= '<script src="' . $this->processJsFile($this->backPath . $this->scriptaculousPath .
1373 'scriptaculous.js') . '" type="text/javascript"></script>' . LF;
1374 unset($this->jsFiles[$this->backPath . $this->scriptaculousPath . 'scriptaculous.js']);
1375 }
1376
1377 // include extCore
1378 if ($this->addExtCore) {
1379 $out .= '<script src="' . $this->processJsFile($this->backPath .
1380 $this->extCorePath . 'ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js') .
1381 '" type="text/javascript"></script>' . LF;
1382 unset($this->jsFiles[$this->backPath . $this->extCorePath . 'ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js']);
1383 }
1384
1385 // include extJS
1386 if ($this->addExtJS) {
1387 // use the base adapter all the time
1388 $out .= '<script src="' . $this->processJsFile($this->backPath . $this->extJsPath .
1389 'adapter/' . ($this->enableExtJsDebug ?
1390 str_replace('.js', '-debug.js', $this->extJSadapter) : $this->extJSadapter)) .
1391 '" type="text/javascript"></script>' . LF;
1392 $out .= '<script src="' . $this->processJsFile($this->backPath . $this->extJsPath .
1393 'ext-all' . ($this->enableExtJsDebug ? '-debug' : '') . '.js') .
1394 '" type="text/javascript"></script>' . LF;
1395
1396 // add extJS localization
1397 $localeMap = $this->csConvObj->isoArray; // load standard ISO mapping and modify for use with ExtJS
1398 $localeMap[''] = 'en';
1399 $localeMap['default'] = 'en';
1400 $localeMap['gr'] = 'el_GR'; // Greek
1401 $localeMap['no'] = 'no_BO'; // Norwegian Bokmaal
1402 $localeMap['se'] = 'se_SV'; // Swedish
1403
1404
1405 $extJsLang = isset($localeMap[$this->lang]) ? $localeMap[$this->lang] : $this->lang;
1406 // TODO autoconvert file from UTF8 to current BE charset if necessary!!!!
1407 $extJsLocaleFile = $this->extJsPath . 'locale/ext-lang-' . $extJsLang . '.js';
1408 if (file_exists(PATH_typo3 . $extJsLocaleFile)) {
1409 $out .= '<script src="' . $this->processJsFile($this->backPath .
1410 $extJsLocaleFile) . '" type="text/javascript" charset="utf-8"></script>' . LF;
1411 }
1412
1413
1414 // remove extjs from JScodeLibArray
1415 unset(
1416 $this->jsFiles[$this->backPath . $this->extJsPath . 'ext-all.js'],
1417 $this->jsFiles[$this->backPath . $this->extJsPath . 'ext-all-debug.js']
1418 );
1419 }
1420
1421 // Convert labels/settings back to UTF-8 since json_encode() only works with UTF-8:
1422 if ($this->getCharSet() !== 'utf-8') {
1423 if ($this->inlineLanguageLabels) {
1424 $this->csConvObj->convArray($this->inlineLanguageLabels, $this->getCharSet(), 'utf-8');
1425 }
1426 if ($this->inlineSettings) {
1427 $this->csConvObj->convArray($this->inlineSettings, $this->getCharSet(), 'utf-8');
1428 }
1429 }
1430
1431 $inlineSettings = $this->inlineLanguageLabels ? 'TYPO3.lang = ' . json_encode($this->inlineLanguageLabels) . ';' : '';
1432 $inlineSettings .= $this->inlineSettings ? 'TYPO3.settings = ' . json_encode($this->inlineSettings) . ';' : '';
1433
1434 if ($this->addExtCore || $this->addExtJS) {
1435 // set clear.gif, move it on top, add handler code
1436 $code = '';
1437 if (count($this->extOnReadyCode)) {
1438 foreach ($this->extOnReadyCode as $block) {
1439 $code .= $block;
1440 }
1441 }
1442
1443 $out .= $this->inlineJavascriptWrap[0] . '
1444 Ext.ns("TYPO3");
1445 Ext.BLANK_IMAGE_URL = "' . htmlspecialchars(t3lib_div::locationHeaderUrl($this->backPath . 'gfx/clear.gif')) . '";' . LF .
1446 $inlineSettings .
1447 'Ext.onReady(function() {' .
1448 ($this->enableExtJSQuickTips ? 'Ext.QuickTips.init();' . LF : '') . $code .
1449 ' });' . $this->inlineJavascriptWrap[1];
1450 unset ($this->extOnReadyCode);
1451
1452 if ($this->extJStheme) {
1453 if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
1454 $this->addCssFile($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'all', '', TRUE, TRUE);
1455 } else {
1456 $this->addCssFile($this->backPath . $this->extJsPath . 'resources/css/xtheme-blue.css', 'stylesheet', 'all', '', TRUE, TRUE);
1457 }
1458 }
1459 if ($this->extJScss) {
1460 if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
1461 $this->addCssFile($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'all', '', TRUE, TRUE);
1462 } else {
1463 $this->addCssFile($this->backPath . $this->extJsPath . 'resources/css/ext-all-notheme.css', 'stylesheet', 'all', '', TRUE, TRUE);
1464 }
1465 }
1466 } else {
1467 if ($inlineSettings) {
1468 $out .= $this->inlineJavascriptWrap[0] . $inlineSettings . $this->inlineJavascriptWrap[1];
1469 }
1470 }
1471
1472 return $out;
1473 }
1474
1475 /*****************************************************/
1476 /* */
1477 /* Tools */
1478 /* */
1479 /* */
1480 /*****************************************************/
1481
1482 /**
1483 * concatenate files into one file
1484 * registered handler
1485 *
1486 * @return void
1487 */
1488 protected function doConcatenate() {
1489 // traverse the arrays, concatenate in one file
1490 // then remove concatenated files from array and add the concatenated file
1491
1492 if ($this->concatenateFiles) {
1493 $params = array (
1494 'jsLibs' => &$this->jsLibs,
1495 'jsFiles' => &$this->jsFiles,
1496 'jsFooterFiles' => &$this->jsFooterFiles,
1497 'cssFiles' => &$this->cssFiles,
1498 'headerData' => &$this->headerData,
1499 'footerData' => &$this->footerData,
1500 );
1501
1502 if ($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['concatenateHandler']) {
1503 // use extern concatenate routine
1504 t3lib_div::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['concatenateHandler'], $params, $this);
1505 } elseif (TYPO3_MODE === 'BE') {
1506 $cssOptions = array('baseDirectories' => $GLOBALS['TBE_TEMPLATE']->getSkinStylesheetDirectories());
1507 $this->cssFiles = $this->getCompressor()->concatenateCssFiles($this->cssFiles, $cssOptions);
1508 }
1509 }
1510 }
1511
1512 /**
1513 * compress inline code
1514 *
1515 * @return void
1516 */
1517 protected function doCompress() {
1518
1519 if ($this->compressJavascript && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler']) {
1520 // use extern compress routine
1521 $params = array (
1522 'jsInline' => &$this->jsInline,
1523 'jsFooterInline' => &$this->jsFooterInline,
1524 'jsLibs' => &$this->jsLibs,
1525 'jsFiles' => &$this->jsFiles,
1526 'jsFooterFiles' => &$this->jsFooterFiles,
1527 'headerData' => &$this->headerData,
1528 'footerData' => &$this->footerData,
1529 );
1530 t3lib_div::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler'], $params, $this);
1531 } else {
1532 // traverse the arrays, compress files
1533 $this->compressError = '';
1534
1535 if ($this->compressJavascript) {
1536 if (count($this->jsInline)) {
1537 foreach ($this->jsInline as $name => $properties) {
1538 if ($properties['compress']) {
1539 $error = '';
1540 $this->jsInline[$name]['code'] = t3lib_div::minifyJavaScript($properties['code'], $error);
1541 if ($error) {
1542 $this->compressError .= 'Error with minify JS Inline Block "' . $name . '": ' . $error . LF;
1543 }
1544 }
1545 }
1546 }
1547 if (TYPO3_MODE === 'BE') {
1548 $this->jsFiles = $this->getCompressor()->compressJsFiles($this->jsFiles);
1549 $this->jsFooterFiles = $this->getCompressor()->compressJsFiles($this->jsFooterFiles);
1550 }
1551 }
1552 }
1553 if ($this->compressCss) {
1554 // use extern compress routine
1555 $params = array (
1556 'cssInline' => &$this->cssInline,
1557 'cssFiles' => &$this->cssFiles,
1558 'headerData' => &$this->headerData,
1559 'footerData' => &$this->footerData,
1560 );
1561
1562 if ($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler']) {
1563 // use extern concatenate routine
1564 t3lib_div::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler'], $params, $this);
1565 } elseif (TYPO3_MODE === 'BE') {
1566 $this->cssFiles = $this->getCompressor()->compressCssFiles($this->cssFiles);
1567 }
1568 }
1569 }
1570
1571 /**
1572 * Returns instance of t3lib_Compressor
1573 *
1574 * @return t3lib_Compressor Instance of t3lib_Compressor
1575 */
1576 protected function getCompressor() {
1577 if ($this->compressor === NULL) {
1578 $this->compressor = t3lib_div::makeInstance('t3lib_Compressor');
1579 }
1580 return $this->compressor;
1581 }
1582
1583 /**
1584 * Processes a Javascript file dependent on the current context
1585 *
1586 * Adds the version number for Frontend, compresses the file for Backend
1587 *
1588 * @param string $filename Filename
1589 * @return string new filename
1590 */
1591 protected function processJsFile($filename) {
1592 switch (TYPO3_MODE) {
1593 case 'FE':
1594 $filename = t3lib_div::createVersionNumberedFilename($filename);
1595 break;
1596 case 'BE':
1597 if ($this->compressJavascript) {
1598 $filename = $this->getCompressor()->compressJsFile($filename);
1599 }
1600 break;
1601 }
1602 return $filename;
1603 }
1604 }
1605
1606 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_pagerenderer.php']) {
1607 include_once ($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_pagerenderer.php']);
1608 }
1609 ?>