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