2 /***************************************************************
5 * (c) 2009 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
;
50 // static array containing associative array for the included files
51 protected static $jsFiles = array ();
52 protected static $jsFooterFiles = array ();
53 protected static $jsLibs = array ();
54 protected static $jsFooterLibs = array ();
55 protected static $cssFiles = array ();
62 // static header blocks
63 protected $xmlPrologAndDocType = '';
64 protected $metaTags = array ();
65 protected $inlineComments = array ();
66 protected $headerData = array ();
67 protected $footerData = array ();
68 protected $titleTag = '<title>|</title>';
69 protected $metaCharsetTag = '<meta http-equiv="Content-Type" content="text/html; charset=|" />';
70 protected $htmlTag = '<html>';
71 protected $headTag = '<head>';
72 protected $baseUrlTag = '<base href="|" />';
73 protected $iconMimeType = '';
74 protected $shortcutTag = '<link rel="shortcut icon" href="%1$s"%2$s />
75 <link rel="icon" href="%1$s"%2$s />';
77 // static inline code blocks
78 protected $jsInline = array ();
79 protected $extOnReadyCode = array ();
80 protected $cssInline = array ();
82 protected $bodyContent;
84 protected $templateFile;
86 protected $jsLibraryNames = array ('prototype', 'scriptaculous', 'extjs');
88 const PART_COMPLETE
= 0;
89 const PART_HEADER
= 1;
90 const PART_FOOTER
= 2;
92 // internal flags for JS-libraries
93 protected $addPrototype = FALSE
;
94 protected $addScriptaculous = FALSE
;
95 protected $addScriptaculousModules = array ('builder' => FALSE
, 'effects' => FALSE
, 'dragdrop' => FALSE
, 'controls' => FALSE
, 'slider' => FALSE
);
96 protected $addExtJS = FALSE
;
97 protected $addExtCore = FALSE
;
98 protected $extJSadapter = 'ext/ext-base.js';
100 protected $enableExtJsDebug = FALSE
;
101 protected $enableExtCoreDebug = FALSE
;
103 // available adapters for extJs
104 const EXTJS_ADAPTER_JQUERY
= 'jquery';
105 const EXTJS_ADAPTER_PROTOTYPE
= 'prototype';
106 const EXTJS_ADAPTER_YUI
= 'yui';
108 protected $enableExtJSQuickTips = false
;
110 protected $inlineLanguageLabels = array ();
111 protected $inlineSettings = array ();
113 protected $inlineJavascriptWrap = array ();
115 // used by BE modules
121 * @param string $templateFile declare the used template file. Omit this parameter will use default template
122 * @param string $backPath relative path to typo3-folder. It varies for BE modules, in FE it will be typo3/
125 public function __construct($templateFile = '', $backPath = '') {
129 if (strlen($templateFile)) {
130 $this->templateFile
= $templateFile;
132 $this->backPath
= $backPath;
134 $this->inlineJavascriptWrap
= array(
135 '<script type="text/javascript">' . chr(10) . '/*<![CDATA[*/' . chr(10) . '<!-- ' . chr(10),
136 '// -->' . chr(10) . '/*]]>*/' . chr(10) . '</script>' . chr(10)
138 $this->inlineCssWrap
= array(
139 '<style type="text/css">' . chr(10) . '/*<![CDATA[*/' . chr(10) . '<!-- ' . chr(10),
140 '-->' . chr(10) . '/*]]>*/' . chr(10) . '</style>' . chr(10)
146 * reset all vars to initial values
150 protected function reset() {
151 $this->templateFile
= TYPO3_mainDir
. 'templates/template_page_backend.html';
152 $this->jsFiles
= array ();
153 $this->jsFooterFiles
= array ();
154 $this->jsInline
= array ();
155 $this->jsFooterInline
= array ();
156 $this->jsLibs
= array ();
157 $this->cssFiles
= array ();
158 $this->cssInline
= array ();
159 $this->metaTags
= array ();
160 $this->inlineComments
= array ();
161 $this->headerData
= array ();
162 $this->footerData
= array ();
163 $this->extOnReadyCode
= array ();
165 /*****************************************************/
170 /*****************************************************/
175 * @param string $title title of webpage
178 public function setTitle($title) {
179 $this->title
= $title;
183 * Sets xml prolog and docType
185 * @param string $xmlPrologAndDocType complete tags for xml prolog and docType
188 public function setXmlPrologAndDocType($xmlPrologAndDocType) {
189 $this->xmlPrologAndDocType
= $xmlPrologAndDocType;
196 * @param string $charSet used charset
198 public function setCharSet($charSet) {
199 $this->charSet
= $charSet;
205 * @param string $htmlTag html tag
208 public function setHtmlTag($htmlTag) {
209 $this->htmlTag
= $htmlTag;
215 * @param string $tag head tag
218 public function setHeadTag($headTag) {
219 $this->headTag
= $headTag;
225 * @param string $favIcon
228 public function setFavIcon($favIcon) {
229 $this->favIcon
= $favIcon;
233 * Sets icon mime type
235 * @param string $iconMimeType
238 public function setIconMimeType($iconMimeType) {
239 $this->iconMimeType
= $iconMimeType;
248 public function setBaseUrl($baseUrl) {
249 $this->baseUrl
= $baseUrl;
255 * @param string $file
258 public function setTemplateFile($file) {
259 $this->templateFile
= $file;
265 * @param string $backPath
268 public function setBackPath($backPath) {
269 $this->backPath
= $backPath;
273 * Sets Content for Body
275 * @param string $content
278 public function setBodyContent($content) {
279 $this->bodyContent
= $content;
282 /*****************************************************/
284 /* Public Enablers */
287 /*****************************************************/
289 * Enables MoveJsFromHeaderToFooter
294 public function enableMoveJsFromHeaderToFooter() {
295 $this->moveJsFromHeaderToFooter
= TRUE
;
299 * Enables compression of javascript
304 public function enableCompressJavascript() {
305 $this->compressJavascript
= TRUE
;
309 * Enables compression of css
314 public function enableCompressCss() {
315 $this->compressCss
= TRUE
;
320 * Enables concatenation of js/css files
325 public function enableConcatenateFiles() {
326 $this->concatenateFiles
= TRUE
;
330 * Sets removal of all line breaks in template
335 public function enableRemoveLineBreaksFromTemplate() {
336 $this->removeLineBreaksFromTemplate
= TRUE
;
339 /*****************************************************/
344 /*****************************************************/
349 * @return string $title title of webpage
351 public function getTitle() {
358 * @return string $charSet
360 public function getCharSet() {
361 return $this->charSet
;
367 * @return string $htmlTag html tag
369 public function getHtmlTag() {
370 return $this->htmlTag
;
376 * @return string $tag head tag
378 public function getHeadTag() {
379 return $this->headTag
;
385 * @return string $favIcon
387 public function getFavIcon() {
388 return $this->favIcon
;
392 * Gets icon mime type
394 * @return string $iconMimeType
396 public function getIconMimeType() {
397 return $this->iconMimeType
;
403 * @return string $url
405 public function getBaseUrl() {
406 return $this->baseUrl
;
412 * @return string $file
414 public function getTemplateFile($file) {
415 return $this->templateFile
;
419 * Gets MoveJsFromHeaderToFooter
423 public function getMoveJsFromHeaderToFooter() {
424 return $this->moveJsFromHeaderToFooter
;
428 * Gets compress of javascript
432 public function getCompressJavascript() {
433 return $this->compressJavascript
;
437 * Gets compress of css
441 public function getCompressCss() {
442 return $this->compressCss
;
446 * Gets concatenate of files
450 public function getConcatenateFiles() {
451 return $this->concatenateFiles
;
455 * Gets remove of empty lines from template
459 public function getRemoveLineBreaksFromTemplate() {
460 return $this->removeLineBreaksFromTemplate
;
464 * Gets content for body
468 public function getBodyContent() {
469 return $this->bodyContent
;
472 /*****************************************************/
474 /* Public Function to add Data */
477 /*****************************************************/
482 * @param string $meta meta data (complete metatag)
485 public function addMetaTag($meta) {
486 if (!in_array($meta, $this->metaTags
)) {
487 $this->metaTags
[] = $meta;
492 * Adds inline HTML comment
494 * @param string $comment
497 public function addInlineComment($comment) {
498 if (!in_array($comment, $this->inlineComments
)) {
499 $this->inlineComments
[] = $comment;
506 * @param string $data free header data for HTML header
509 public function addHeaderData($data) {
510 if (!in_array($data, $this->headerData
)) {
511 $this->headerData
[] = $data;
518 * @param string $data free header data for HTML header
521 public function addFooterData($data) {
522 if (!in_array($data, $this->footerData
)) {
523 $this->footerData
[] = $data;
527 /* Javascript Files */
530 * Adds JS Library. JS Library block is rendered on top of the JS files.
532 * @param string $name
533 * @param string $file
534 * @param string $type
535 * @param boolean $compressed flag if library is compressed
536 * @param boolean $forceOnTop flag if added library should be inserted at begin of this block
537 * @param string $allWrap
540 public function addJsLibrary($name, $file, $type = 'text/javascript', $compressed = TRUE
, $forceOnTop = FALSE
, $allWrap = '') {
541 if (!in_array(strtolower($name), $this->jsLibs
)) {
542 $this->jsLibs
[strtolower($name)] = array (
545 'section' => self
::PART_HEADER
,
546 'compressed' => $compressed,
547 'forceOnTop' => $forceOnTop,
548 'allWrap' => $allWrap
555 * Adds JS Library to Footer. JS Library block is rendered on top of the Footer JS files.
557 * @param string $name
558 * @param string $file
559 * @param string $type
560 * @param boolean $compressed flag if library is compressed
561 * @param boolean $forceOnTop flag if added library should be inserted at begin of this block
562 * @param string $allWrap
565 public function addJsFooterLibrary($name, $file, $type = 'text/javascript', $compressed = TRUE
, $forceOnTop = FALSE
, $allWrap = '') {
566 if (!in_array(strtolower($name), $this->jsLibs
)) {
567 $this->jsLibs
[strtolower($name)] = array (
570 'section' => self
::PART_FOOTER
,
571 'compressed' => $compressed,
572 'forceOnTop' => $forceOnTop,
573 'allWrap' => $allWrap
582 * @param string $file
583 * @param string $type
584 * @param boolean $compressed
585 * @param boolean $forceOnTop
586 * @param string $allWrap
589 public function addJsFile($file, $type = 'text/javascript', $compressed = FALSE
, $forceOnTop = FALSE
, $allWrap = '') {
590 if (!isset($this->jsFiles
[$file])) {
591 $this->jsFiles
[$file] = array (
593 'section' => self
::PART_HEADER
,
594 'compressed' => $compressed,
595 'forceOnTop' => $forceOnTop,
596 'allWrap' => $allWrap
602 * Adds JS file to footer
604 * @param string $file
605 * @param string $type
606 * @param boolean $compressed
607 * @param boolean $forceOnTop
610 public function addJsFooterFile($file, $type = 'text/javascript', $compressed = FALSE
, $forceOnTop = FALSE
, $allWrap = '') {
611 if (!isset($this->jsFiles
[$file])) {
612 $this->jsFiles
[$file] = array (
614 'section' => self
::PART_FOOTER
,
615 'compressed' => $compressed,
616 'forceOnTop' => $forceOnTop,
617 'allWrap' => $allWrap
622 /*Javascript Inline Blocks */
625 * Adds JS inline code
627 * @param string $name
628 * @param string $block
629 * @param boolean $compressed
630 * @param boolean $forceOnTop
633 public function addJsInlineCode($name, $block, $compressed = FALSE
, $forceOnTop = FALSE
) {
634 if (!isset($this->jsInline
[$name])) {
635 $this->jsInline
[$name] = array (
636 'code' => $block . chr(10),
637 'section' => self
::PART_HEADER
,
638 'compressed' => $compressed,
639 'forceOnTop' => $forceOnTop
645 * Adds JS inline code to footer
647 * @param string $name
648 * @param string $block
649 * @param boolean $compressed
650 * @param boolean $forceOnTop
653 public function addJsFooterInlineCode($name, $block, $compressed = FALSE
, $forceOnTop = FALSE
) {
654 if (!isset($this->jsInline
[$name])) {
655 $this->jsInline
[$name] = array (
656 'code' => $block . chr(10),
657 'section' => self
::PART_FOOTER
,
658 'compressed' => $compressed,
659 'forceOnTop' => $forceOnTop
665 * Adds Ext.onready code, which will be wrapped in Ext.onReady(function() {...});
667 * @param string $block
670 public function addExtOnReadyCode($block) {
671 if (!in_array($block, $this->extOnReadyCode
)) {
672 $this->extOnReadyCode
[] = $block;
681 * @param string $file
683 * @param string $media
684 * @param string $title
685 * @param boolean $compressed
686 * @param boolean $forceOnTop
689 public function addCssFile($file, $rel = 'stylesheet', $media = 'screen', $title = '', $compressed = FALSE
, $forceOnTop = FALSE
, $allWrap = '') {
690 if (!isset($this->cssFiles
[$file])) {
691 $this->cssFiles
[$file] = array ('rel' => $rel, 'media' => $media, 'title' => $title, 'compressed' => $compressed, 'forceOnTop' => $forceOnTop, 'allWrap' => $allWrap);
695 /*CSS Inline Blocks */
698 * Adds CSS inline code
700 * @param string $name
701 * @param string $block
702 * @param boolean $compressed
703 * @param boolean $forceOnTop
706 public function addCssInlineBlock($name, $block, $compressed = FALSE
, $forceOnTop = FALSE
) {
707 if (!isset($this->cssInline
[$name])) {
708 $this->cssInline
[$name] = array ('code' => $block, 'compressed' => $compressed, 'forceOnTop' => $forceOnTop);
715 * call function if you need the prototype library
719 public function loadPrototype() {
720 $this->addPrototype
= TRUE
;
724 * call function if you need the Scriptaculous library
726 * @param string $modules add modules you need. use "all" if you need complete modules
729 public function loadScriptaculous($modules = '') {
730 // Scriptaculous require prototype, so load prototype too.
731 $this->addPrototype
= TRUE
;
732 $this->addScriptaculous
= TRUE
;
734 if ($modules == 'all') {
735 foreach ($this->addScriptaculousModules
as $key => $value) {
736 $this->addScriptaculousModules
[$key] = TRUE
;
739 $mods = t3lib_div
::trimExplode(',', $modules);
740 foreach ($mods as $mod) {
741 if (isset($this->addScriptaculousModules
[strtolower($mod)])) {
742 $this->addScriptaculousModules
[strtolower($mod)] = TRUE
;
750 * call this function if you need the extJS library
752 * @param boolean $css flag, if set the ext-css will be loaded
753 * @param boolean $theme flag, if set the ext-theme "grey" will be loaded
754 * @param string $adapter choose alternative adapter, possible values: yui, prototype, jquery
757 public function loadExtJS($css = TRUE
, $theme = TRUE
, $adapter = '') {
759 // empty $adapter will always load the ext adapter
760 switch (t3lib_div
::strtolower(trim($adapter))) {
761 case self
::EXTJS_ADAPTER_YUI
:
762 $this->extJSadapter
= 'yui/ext-yui-adapter.js';
764 case self
::EXTJS_ADAPTER_PROTOTYPE
:
765 $this->extJSadapter
= 'prototype/ext-prototype-adapter.js';
767 case self
::EXTJS_ADAPTER_JQUERY
:
768 $this->extJSadapter
= 'jquery/ext-jquery-adapter.js';
772 if (!$this->addExtJS
) {
773 $this->addExtJS
= TRUE
;
775 if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
776 $this->addCssFile($this->backPath
. $GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'screen', '', FALSE
, TRUE
);
778 $this->addCssFile($this->backPath
. 'contrib/extjs/resources/css/xtheme-blue.css', 'stylesheet', 'screen', '', FALSE
, TRUE
);
782 if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
783 $this->addCssFile($this->backPath
. $GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'screen', '', FALSE
, TRUE
);
785 $this->addCssFile($this->backPath
. 'contrib/extjs/resources/css/ext-all-notheme.css', 'stylesheet', 'screen', '', FALSE
, TRUE
);
793 * Enables ExtJs QuickTips
799 public function enableExtJSQuickTips() {
800 $this->enableExtJSQuickTips
= TRUE
;
805 * call function if you need the ExtCore library
809 public function loadExtCore() {
810 $this->addExtCore
= TRUE
;
814 * call this function to load debug version of ExtJS. Use this for development only
817 public function enableExtJsDebug() {
818 $this->enableExtJsDebug
= TRUE
;
822 * call this function to load debug version of ExtCore. Use this for development only
826 public function enableExtCoreDebug() {
827 $this->enableExtCoreDebug
= TRUE
;
831 * Adds Javascript Inline Label. This will occur in TYPO3.lang - object
832 * The label can be used in scripts with TYPO3.lang.<key>
836 * @param string $value
839 public function addInlineLanguageLabel($key, $value) {
840 $this->inlineLanguageLabels
[$key] = $value;
844 * Adds Javascript Inline Label Array. This will occur in TYPO3.lang - object
845 * The label can be used in scripts with TYPO3.lang.<key>
846 * Array will be merged with existing array.
849 * @param array $array
852 public function addInlineLanguageLabelArray(array $array) {
853 $this->inlineLanguageLabels
= array_merge($this->inlineLanguageLabels
, $array);
857 * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
858 * The label can be used in scripts with TYPO3.setting.<key>
861 * @param string $namespace
863 * @param string $value
866 public function addInlineSetting($namespace, $key, $value) {
868 if (strpos($namespace, '.')) {
869 $parts = explode('.', $namespace);
870 $a = &$this->inlineSettings
;
871 foreach ($parts as $part) {
876 $this->inlineSettings
[$namespace][$key] = $value;
879 $this->inlineSettings
[$key] = $value;
884 * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
885 * The label can be used in scripts with TYPO3.setting.<key>
886 * Array will be merged with existing array.
889 * @param string $namespace
890 * @param array $array
893 public function addInlineSettingArray($namespace, array $array) {
895 if (strpos($namespace, '.')) {
896 $parts = explode('.', $namespace);
897 $a = &$this->inlineSettings
;
898 foreach ($parts as $part) {
901 $a = array_merge((array) $a, $array);
903 $this->inlineSettings
[$namespace] = array_merge((array) $this->inlineSettings
[$namespace], $array);
906 $this->inlineSettings
= array_merge($this->inlineSettings
, $array);
911 * Adds content to body content
913 * @param string $content
916 public function addBodyContent($content) {
917 $this->bodyContent
.= $content;
920 /*****************************************************/
922 /* Render Functions */
925 /*****************************************************/
928 * render the section (Header or Footer)
930 * @param int $part section which should be rendered: self::PART_COMPLETE, self::PART_HEADER or self::PART_FOOTER
931 * @return string content of rendered section
933 public function render($part = self
::PART_COMPLETE
) {
939 $jsFooterInline = '';
944 $jsLibs = $this->renderJsLibraries();
946 if ($this->compressCss ||
$this->compressJavascript
) {
947 // do the file compression
950 if ($this->concatenateFiles
) {
951 // do the file concatenation
952 $this->doConcatenate();
955 $metaTags = implode(chr(10), $this->metaTags
);
957 if (count($this->cssFiles
)) {
958 foreach ($this->cssFiles
as $file => $properties) {
959 $tag = '<link rel="' . $properties['rel'] . '" type="text/css" href="' . $file . '" media="' . $properties['media'] . '"' . ($properties['title'] ?
' title="' . $properties['title'] . '"' : '') . ' />';
960 if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE
) {
961 $tag = str_replace('|', $tag, $properties['allWrap']);
963 if ($properties['forceOnTop']) {
964 $cssFiles = $tag . chr(10) . $cssFiles;
966 $cssFiles .= chr(10) . $tag;
971 if (count($this->cssInline
)) {
973 foreach ($this->cssInline
as $name => $properties) {
974 if ($properties['forceOnTop']) {
975 $cssInline = '/*' . htmlspecialchars($name) . '*/' . chr(10) . $properties['code'] . chr(10) . $cssInline;
977 $cssInline .= '/*' . htmlspecialchars($name) . '*/' . chr(10) . $properties['code'] . chr(10);
980 $cssInline = $this->inlineCssWrap
[0] . $cssInline . $this->inlineCssWrap
[1];
984 if (count($this->jsLibs
)) {
985 foreach ($this->jsLibs
as $name => $properties) {
986 $tag = '<script src="' . $properties['file'] . '" type="' . $properties['type'] . '"></script>';
987 if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE
) {
988 $tag = str_replace('|', $tag, $properties['allWrap']);
990 if ($properties['forceOnTop']) {
991 if ($properties['section'] === self
::PART_HEADER
) {
992 $jsLibs = $tag . chr(10) . $jsLibs;
994 $jsFooterLibs = $tag . chr(10) . $jsFooterLibs;
997 if ($properties['section'] === self
::PART_HEADER
) {
998 $jsLibs .= chr(10) . $tag;
1000 $jsFooterLibs .= chr(10) . $tag;
1007 if (count($this->jsFiles
)) {
1008 foreach ($this->jsFiles
as $file => $properties) {
1009 $tag = '<script src="' . $file . '" type="' . $properties['type'] . '"></script>';
1010 if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE
) {
1011 $tag = str_replace('|', $tag, $properties['allWrap']);
1013 if ($properties['forceOnTop']) {
1014 if ($properties['section'] === self
::PART_HEADER
) {
1015 $jsFiles = $tag . chr(10) . $jsFiles;
1017 $jsFooterFiles = $tag . chr(10) . $jsFooterFiles;
1020 if ($properties['section'] === self
::PART_HEADER
) {
1021 $jsFiles .= chr(10) . $tag;
1023 $jsFooterFiles .= chr(10) . $tag;
1029 if (count($this->jsInline
)) {
1030 foreach ($this->jsInline
as $name => $properties) {
1031 if ($properties['forceOnTop']) {
1032 if ($properties['section'] === self
::PART_HEADER
) {
1033 $jsInline = '/*' . htmlspecialchars($name) . '*/' . chr(10) . $properties['code'] . chr(10) . $jsInline;
1035 $jsFooterInline = '/*' . htmlspecialchars($name) . '*/' . chr(10) . $properties['code'] . chr(10) . $jsFooterInline;
1038 if ($properties['section'] === self
::PART_HEADER
) {
1039 $jsInline .= '/*' . htmlspecialchars($name) . '*/' . chr(10) . $properties['code'] . chr(10);
1041 $jsFooterInline .= '/*' . htmlspecialchars($name) . '*/' . chr(10) . $properties['code'] . chr(10);
1049 $jsInline = $this->inlineJavascriptWrap
[0] . $jsInline . $this->inlineJavascriptWrap
[1];
1052 if ($jsFooterInline) {
1053 $jsFooterInline = $this->inlineJavascriptWrap
[0] . $jsFooterInline . $this->inlineJavascriptWrap
[1];
1058 $templateFile = t3lib_div
::getFileAbsFileName($this->templateFile
, TRUE
);
1059 $template = t3lib_div
::getURL($templateFile);
1061 if ($this->removeEmptyLinesFromTemplate
) {
1062 $template = strtr($template, array(chr(10) => '', chr(13) => ''));
1064 if ($part != self
::PART_COMPLETE
) {
1065 $templatePart = explode('###BODY###', $template);
1066 $template = $templatePart[$part - 1];
1069 if ($this->moveJsFromHeaderToFooter
) {
1070 $jsFooterLibs = $jsLibs . chr(10) . $jsFooterLibs;
1072 $jsFooterFiles = $jsFiles . chr(10) . $jsFooterFiles;
1074 $jsFooterInline = $jsInline . chr(10) . $jsFooterInline;
1078 $markerArray = array(
1079 'XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType
,
1080 'HTMLTAG' => $this->htmlTag
,
1081 'HEADTAG' => $this->headTag
,
1082 'METACHARSET' => $this->charSet ?
str_replace('|', htmlspecialchars($this->charSet
), $this->metaCharsetTag
) : '',
1083 'INLINECOMMENT' => $this->inlineComments ?
chr(10) . chr(10) . '<!-- ' . chr(10) . implode(chr(10), $this->inlineComments
) . '-->' . chr(10) . chr(10) : '',
1084 'BASEURL' => $this->baseUrl ?
str_replace('|', $this->baseUrl
, $this->baseUrlTag
) : '',
1085 'SHORTCUT' => $this->favIcon ?
sprintf($this->shortcutTag
, htmlspecialchars($this->favIcon
), $this->iconMimeType
) : '',
1086 'CSS_INCLUDE' => $cssFiles,
1087 'CSS_INLINE' => $cssInline,
1088 'JS_INLINE' => $jsInline,
1089 'JS_INCLUDE' => $jsFiles,
1090 'JS_LIBS' => $jsLibs,
1091 'TITLE' => $this->title ?
str_replace('|', htmlspecialchars($this->title
), $this->titleTag
) : '',
1092 'META' => $metaTags,
1093 'HEADERDATA' => $this->headerData ?
implode(chr(10), $this->headerData
) : '',
1094 'FOOTERDATA' => $this->footerData ?
implode(chr(10), $this->footerData
) : '',
1095 'JS_LIBS_FOOTER' => $jsFooterLibs,
1096 'JS_INCLUDE_FOOTER' => $jsFooterFiles,
1097 'JS_INLINE_FOOTER' => $jsFooterInline,
1098 'BODY' => $this->bodyContent
,
1101 $markerArray = array_map('trim', $markerArray);
1104 return trim(t3lib_parsehtml
::substituteMarkerArray($template, $markerArray, '###|###'));
1108 * helper function for render the javascript libraries
1110 * @return string content with javascript libraries
1112 protected function renderJsLibraries() {
1115 if ($this->addPrototype
) {
1116 $out .= '<script src="' . $this->backPath
. 'contrib/prototype/prototype.js" type="text/javascript"></script>' . chr(10);
1117 unset($this->jsFiles
[$this->backPath
. 'contrib/prototype/prototype.js']);
1120 if ($this->addScriptaculous
) {
1122 foreach ($this->addScriptaculousModules
as $key => $value) {
1123 if ($this->addScriptaculousModules
[$key]) {
1127 // resolve dependencies
1128 if (in_array('dragdrop', $mods) ||
in_array('controls', $mods)) {
1129 $mods = array_merge(array('effects'), $mods);
1133 $moduleLoadString = '?load=' . implode(',', $mods);
1136 $out .= '<script src="' . $this->backPath
. 'contrib/scriptaculous/scriptaculous.js' . $moduleLoadString . '" type="text/javascript"></script>' . chr(10);
1137 unset($this->jsFiles
[$this->backPath
. 'contrib/scriptaculous/scriptaculous.js' . $moduleLoadString]);
1141 if ($this->addExtCore
) {
1142 $out .= '<script src="' . $this->backPath
. 'contrib/extjs/ext-core' . ($this->enableExtCoreDebug ?
'-debug' : '') . '.js" type="text/javascript"></script>' . chr(10);
1143 unset($this->jsFiles
[$this->backPath
. 'contrib/extjs/ext-core' . ($this->enableExtCoreDebug ?
'-debug' : '') . '.js']);
1147 if ($this->addExtJS
) {
1148 // use the base adapter all the time
1149 $out .= '<script src="' . $this->backPath
. 'contrib/extjs/adapter/' . $this->extJSadapter
. '" type="text/javascript"></script>' . chr(10);
1150 $out .= '<script src="' . $this->backPath
. 'contrib/extjs/ext-all' . ($this->enableExtJsDebug ?
'-debug' : '') . '.js" type="text/javascript"></script>' . chr(10);
1152 // add extJS localization
1153 $localeMap = $this->csConvObj
->isoArray
; // load standard ISO mapping and modify for use with ExtJS
1154 $localeMap[''] = 'en';
1155 $localeMap['default'] = 'en';
1156 $localeMap['gr'] = 'el_GR'; // Greek
1157 $localeMap['no'] = 'no_BO'; // Norwegian Bokmaal
1158 $localeMap['se'] = 'se_SV'; // Swedish
1161 $extJsLang = isset($localeMap[$this->lang
]) ?
$localeMap[$this->lang
] : $this->lang
;
1162 // TODO autoconvert file from UTF8 to current BE charset if necessary!!!!
1163 $extJsLocaleFile = 'contrib/extjs/locale/ext-lang-' . $extJsLang . '-min.js';
1164 if (file_exists(PATH_typo3
. $extJsLocaleFile)) {
1165 $out .= '<script src="' . $this->backPath
. $extJsLocaleFile . '" type="text/javascript"></script>' . chr(10);
1169 // remove extjs from JScodeLibArray
1171 $this->jsFiles
[$this->backPath
. 'contrib/extjs/ext-all.js'], $this->jsFiles
[$this->backPath
. 'contrib/extjs/ext-all-debug.js']
1174 if ($this->addExtCore ||
$this->addExtJS
) {
1175 // set clear.gif, move it on top, add handler code
1177 if (count($this->extOnReadyCode
)) {
1178 foreach ($this->extOnReadyCode
as $block) {
1183 $out .= $this->inlineJavascriptWrap
[0] . '
1185 Ext.BLANK_IMAGE_URL = "' . htmlspecialchars(t3lib_div
::locationHeaderUrl($this->backPath
. 'gfx/clear.gif')) . '";' . chr(10) .
1186 'TYPO3.lang = ' . json_encode($this->inlineLanguageLabels
) . ';' . 'TYPO3.settings = ' . json_encode($this->inlineSettings
) . ';' .
1187 'Ext.onReady(function() {' .
1188 ($this->enableExtJSQuickTips ?
'Ext.QuickTips.init();' . chr(10) : '') . $code .
1189 ' });' . $this->inlineJavascriptWrap
[1];
1190 unset ($this->extOnReadyCode
);
1196 /*****************************************************/
1201 /*****************************************************/
1204 * concatenate files into one file
1205 * registered handler
1206 * TODO: implement own method
1210 protected function doConcatenate() {
1211 // traverse the arrays, concatenate in one file
1212 // then remove concatenated files from array and add the concatenated file
1215 // extern concatination
1216 if ($this->concatenateFiles
&& $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['concatenateHandler']) {
1217 // use extern concatenate routine
1219 'jsLibs' => &$this->jsLibs
,
1220 'jsFiles' => &$this->jsFiles
,
1221 'jsFooterFiles' => &$this->jsFiles
,
1222 'cssFiles' => &$this->cssFiles
,
1224 t3lib_div
::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['concatenateHandler'], $params, $this);
1226 // own method, nothing implemented atm
1233 * compress inline code
1236 protected function doCompress() {
1238 if ($this->compressJavascript
&& $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['jsCompressHandler']) {
1239 // use extern compress routine
1241 'jsInline' => &$this->jsInline
,
1242 'jsFooterInline' => &$this->jsFooterInline
1244 t3lib_div
::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['jsCompressHandler'], $params, $this);
1246 // traverse the arrays, compress files
1247 $this->compressError
= '';
1249 if ($this->compressJavascript
) {
1250 if (count($this->jsInline
)) {
1251 foreach ($this->jsInline
as $name => $properties) {
1252 if (!$properties['compressed']) {
1254 $this->jsInline
[$name]['code'] = t3lib_div
::minifyJavaScript($properties['code'], $error);
1256 $this->compressError
.= 'Error with minify JS Inline Block "' . $name . '": ' . $error . chr(10);
1264 if ($this->compressCss
&& $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['cssCompressHandler']) {
1265 // use extern compress routine
1267 'cssInline' => &$this->cssInline
1269 t3lib_div
::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['cssCompressHandler'], $params, $this);
1271 if ($this->compressCss
) {
1272 // own method, nothing implemented atm
1279 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_pagerenderer.php']) {
1280 include_once ($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_pagerenderer.php']);