00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 class t3lib_PageRenderer implements t3lib_Singleton {
00038
00039 protected $compressJavascript = FALSE;
00040 protected $compressCss = FALSE;
00041 protected $removeLineBreaksFromTemplate = FALSE;
00042
00043 protected $concatenateFiles = FALSE;
00044
00045 protected $moveJsFromHeaderToFooter = FALSE;
00046
00047 protected $csConvObj;
00048 protected $lang;
00049
00050
00051 protected $compressor;
00052
00053
00054 protected static $jsFiles = array ();
00055 protected static $jsFooterFiles = array ();
00056 protected static $jsLibs = array ();
00057 protected static $jsFooterLibs = array ();
00058 protected static $cssFiles = array ();
00059
00060 protected $title;
00061 protected $charSet;
00062 protected $favIcon;
00063 protected $baseUrl;
00064
00065 protected $renderXhtml = TRUE;
00066
00067
00068 protected $xmlPrologAndDocType = '';
00069 protected $metaTags = array ();
00070 protected $inlineComments = array ();
00071 protected $headerData = array ();
00072 protected $footerData = array ();
00073 protected $titleTag = '<title>|</title>';
00074 protected $metaCharsetTag = '<meta http-equiv="Content-Type" content="text/html; charset=|" />';
00075 protected $htmlTag = '<html>';
00076 protected $headTag = '<head>';
00077 protected $baseUrlTag = '<base href="|" />';
00078 protected $iconMimeType = '';
00079 protected $shortcutTag = '<link rel="shortcut icon" href="%1$s"%2$s />
00080 <link rel="icon" href="%1$s"%2$s />';
00081
00082
00083 protected $jsInline = array ();
00084 protected $extOnReadyCode = array ();
00085 protected $cssInline = array ();
00086
00087 protected $bodyContent;
00088
00089 protected $templateFile;
00090
00091 protected $jsLibraryNames = array ('prototype', 'scriptaculous', 'extjs');
00092
00093 const PART_COMPLETE = 0;
00094 const PART_HEADER = 1;
00095 const PART_FOOTER = 2;
00096
00097
00098 protected $addPrototype = FALSE;
00099 protected $addScriptaculous = FALSE;
00100 protected $addScriptaculousModules = array ('builder' => FALSE, 'effects' => FALSE, 'dragdrop' => FALSE, 'controls' => FALSE, 'slider' => FALSE);
00101 protected $addExtJS = FALSE;
00102 protected $addExtCore = FALSE;
00103 protected $extJSadapter = 'ext/ext-base.js';
00104
00105 protected $enableExtJsDebug = FALSE;
00106 protected $enableExtCoreDebug = FALSE;
00107
00108
00109 const EXTJS_ADAPTER_JQUERY = 'jquery';
00110 const EXTJS_ADAPTER_PROTOTYPE = 'prototype';
00111 const EXTJS_ADAPTER_YUI = 'yui';
00112
00113 protected $extJStheme = TRUE;
00114 protected $extJScss = TRUE;
00115
00116 protected $enableExtJSQuickTips = false;
00117
00118 protected $inlineLanguageLabels = array ();
00119 protected $inlineSettings = array ();
00120
00121 protected $inlineJavascriptWrap = array ();
00122
00123
00124 public $backPath;
00125
00126
00127
00128
00129
00130
00131
00132
00133 public function __construct($templateFile = '', $backPath = NULL) {
00134
00135 $this->reset();
00136 $this->csConvObj = t3lib_div::makeInstance('t3lib_cs');
00137
00138 if (strlen($templateFile)) {
00139 $this->templateFile = $templateFile;
00140 }
00141 $this->backPath = isset($backPath) ? $backPath : $GLOBALS['BACK_PATH'];
00142
00143 $this->inlineJavascriptWrap = array(
00144 '<script type="text/javascript">' . LF . '' . LF . '<!-- ' . LF,
00145 '
00146 );
00147 $this->inlineCssWrap = array(
00148 '<style type="text/css">' . LF . '' . LF . '<!-- ' . LF,
00149 '-->' . LF . '' . LF . '</style>' . LF
00150 );
00151
00152 }
00153
00154
00155
00156
00157
00158
00159 protected function reset() {
00160 $this->templateFile = TYPO3_mainDir . 'templates/template_page_backend.html';
00161 $this->jsFiles = array ();
00162 $this->jsFooterFiles = array ();
00163 $this->jsInline = array ();
00164 $this->jsFooterInline = array ();
00165 $this->jsLibs = array ();
00166 $this->cssFiles = array ();
00167 $this->cssInline = array ();
00168 $this->metaTags = array ();
00169 $this->inlineComments = array ();
00170 $this->headerData = array ();
00171 $this->footerData = array ();
00172 $this->extOnReadyCode = array ();
00173 }
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 public function setTitle($title) {
00188 $this->title = $title;
00189 }
00190
00191
00192
00193
00194
00195
00196
00197
00198 public function setRenderXhtml($enable) {
00199 $this->renderXhtml = $enable;
00200 }
00201
00202
00203
00204
00205
00206
00207
00208 public function setXmlPrologAndDocType($xmlPrologAndDocType) {
00209 $this->xmlPrologAndDocType = $xmlPrologAndDocType;
00210 }
00211
00212
00213
00214
00215
00216
00217
00218 public function setCharSet($charSet) {
00219 $this->charSet = $charSet;
00220 }
00221
00222
00223
00224
00225
00226
00227
00228 public function setLanguage($lang) {
00229 $this->lang = $lang;
00230 }
00231
00232
00233
00234
00235
00236
00237
00238 public function setHtmlTag($htmlTag) {
00239 $this->htmlTag = $htmlTag;
00240 }
00241
00242
00243
00244
00245
00246
00247
00248 public function setHeadTag($headTag) {
00249 $this->headTag = $headTag;
00250 }
00251
00252
00253
00254
00255
00256
00257
00258 public function setFavIcon($favIcon) {
00259 $this->favIcon = $favIcon;
00260 }
00261
00262
00263
00264
00265
00266
00267
00268 public function setIconMimeType($iconMimeType) {
00269 $this->iconMimeType = $iconMimeType;
00270 }
00271
00272
00273
00274
00275
00276
00277
00278 public function setBaseUrl($baseUrl) {
00279 $this->baseUrl = $baseUrl;
00280 }
00281
00282
00283
00284
00285
00286
00287
00288 public function setTemplateFile($file) {
00289 $this->templateFile = $file;
00290 }
00291
00292
00293
00294
00295
00296
00297
00298 public function setBackPath($backPath) {
00299 $this->backPath = $backPath;
00300 }
00301
00302
00303
00304
00305
00306
00307
00308 public function setBodyContent($content) {
00309 $this->bodyContent = $content;
00310 }
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325 public function enableMoveJsFromHeaderToFooter() {
00326 $this->moveJsFromHeaderToFooter = TRUE;
00327 }
00328
00329
00330
00331
00332
00333
00334
00335 public function disableMoveJsFromHeaderToFooter() {
00336 $this->moveJsFromHeaderToFooter = FALSE;
00337 }
00338
00339
00340
00341
00342
00343
00344
00345 public function enableCompressJavascript() {
00346 $this->compressJavascript = TRUE;
00347 }
00348
00349
00350
00351
00352
00353
00354
00355 public function disableCompressJavascript() {
00356 $this->compressJavascript = FALSE;
00357 }
00358
00359
00360
00361
00362
00363
00364
00365 public function enableCompressCss() {
00366 $this->compressCss = TRUE;
00367 }
00368
00369
00370
00371
00372
00373
00374
00375 public function disableCompressCss() {
00376 $this->compressCss = FALSE;
00377 }
00378
00379
00380
00381
00382
00383
00384
00385 public function enableConcatenateFiles() {
00386 $this->concatenateFiles = TRUE;
00387 }
00388
00389
00390
00391
00392
00393
00394
00395 public function disableConcatenateFiles() {
00396 $this->concatenateFiles = FALSE;
00397 }
00398
00399
00400
00401
00402
00403
00404
00405 public function enableRemoveLineBreaksFromTemplate() {
00406 $this->removeLineBreaksFromTemplate = TRUE;
00407 }
00408
00409
00410
00411
00412
00413
00414
00415 public function disableRemoveLineBreaksFromTemplate() {
00416 $this->removeLineBreaksFromTemplate = FALSE;
00417 }
00418
00419
00420
00421
00422
00423
00424
00425
00426 public function enableDebugMode() {
00427 $this->compressJavascript = FALSE;
00428 $this->compressCss = FALSE;
00429 $this->concatenateFiles = FALSE;
00430 $this->removeLineBreaksFromTemplate = FALSE;
00431 }
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445 public function getTitle() {
00446 return $this->title;
00447 }
00448
00449
00450
00451
00452
00453
00454 public function getCharSet() {
00455 return $this->charSet;
00456 }
00457
00458
00459
00460
00461
00462
00463 public function getLanguage() {
00464 return $this->lang;
00465 }
00466
00467
00468
00469
00470
00471
00472 public function getRenderXhtml() {
00473 return $this->renderXhtml;
00474 }
00475
00476
00477
00478
00479
00480
00481 public function getHtmlTag() {
00482 return $this->htmlTag;
00483 }
00484
00485
00486
00487
00488
00489
00490 public function getHeadTag() {
00491 return $this->headTag;
00492 }
00493
00494
00495
00496
00497
00498
00499 public function getFavIcon() {
00500 return $this->favIcon;
00501 }
00502
00503
00504
00505
00506
00507
00508 public function getIconMimeType() {
00509 return $this->iconMimeType;
00510 }
00511
00512
00513
00514
00515
00516
00517 public function getBaseUrl() {
00518 return $this->baseUrl;
00519 }
00520
00521
00522
00523
00524
00525
00526 public function getTemplateFile($file) {
00527 return $this->templateFile;
00528 }
00529
00530
00531
00532
00533
00534
00535 public function getMoveJsFromHeaderToFooter() {
00536 return $this->moveJsFromHeaderToFooter;
00537 }
00538
00539
00540
00541
00542
00543
00544 public function getCompressJavascript() {
00545 return $this->compressJavascript;
00546 }
00547
00548
00549
00550
00551
00552
00553 public function getCompressCss() {
00554 return $this->compressCss;
00555 }
00556
00557
00558
00559
00560
00561
00562 public function getConcatenateFiles() {
00563 return $this->concatenateFiles;
00564 }
00565
00566
00567
00568
00569
00570
00571 public function getRemoveLineBreaksFromTemplate() {
00572 return $this->removeLineBreaksFromTemplate;
00573 }
00574
00575
00576
00577
00578
00579
00580 public function getBodyContent() {
00581 return $this->bodyContent;
00582 }
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597 public function addMetaTag($meta) {
00598 if (!in_array($meta, $this->metaTags)) {
00599 $this->metaTags[] = $meta;
00600 }
00601 }
00602
00603
00604
00605
00606
00607
00608
00609 public function addInlineComment($comment) {
00610 if (!in_array($comment, $this->inlineComments)) {
00611 $this->inlineComments[] = $comment;
00612 }
00613 }
00614
00615
00616
00617
00618
00619
00620
00621 public function addHeaderData($data) {
00622 if (!in_array($data, $this->headerData)) {
00623 $this->headerData[] = $data;
00624 }
00625 }
00626
00627
00628
00629
00630
00631
00632
00633 public function addFooterData($data) {
00634 if (!in_array($data, $this->footerData)) {
00635 $this->footerData[] = $data;
00636 }
00637 }
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652 public function addJsLibrary($name, $file, $type = 'text/javascript', $compress = FALSE, $forceOnTop = FALSE, $allWrap = '') {
00653 if (!in_array(strtolower($name), $this->jsLibs)) {
00654 $this->jsLibs[strtolower($name)] = array (
00655 'file' => $file,
00656 'type' => $type,
00657 'section' => self::PART_HEADER,
00658 'compress' => $compress,
00659 'forceOnTop' => $forceOnTop,
00660 'allWrap' => $allWrap
00661 );
00662 }
00663
00664 }
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677 public function addJsFooterLibrary($name, $file, $type = 'text/javascript', $compress = FALSE, $forceOnTop = FALSE, $allWrap = '') {
00678 if (!in_array(strtolower($name), $this->jsLibs)) {
00679 $this->jsLibs[strtolower($name)] = array (
00680 'file' => $file,
00681 'type' => $type,
00682 'section' => self::PART_FOOTER,
00683 'compress' => $compress,
00684 'forceOnTop' => $forceOnTop,
00685 'allWrap' => $allWrap
00686 );
00687 }
00688
00689 }
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701 public function addJsFile($file, $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '') {
00702 if (!isset($this->jsFiles[$file])) {
00703 $this->jsFiles[$file] = array (
00704 'type' => $type,
00705 'section' => self::PART_HEADER,
00706 'compress' => $compress,
00707 'forceOnTop' => $forceOnTop,
00708 'allWrap' => $allWrap
00709 );
00710 }
00711 }
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722 public function addJsFooterFile($file, $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '') {
00723 if (!isset($this->jsFiles[$file])) {
00724 $this->jsFiles[$file] = array (
00725 'type' => $type,
00726 'section' => self::PART_FOOTER,
00727 'compress' => $compress,
00728 'forceOnTop' => $forceOnTop,
00729 'allWrap' => $allWrap
00730 );
00731 }
00732 }
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745 public function addJsInlineCode($name, $block, $compress = TRUE, $forceOnTop = FALSE) {
00746 if (!isset($this->jsInline[$name]) && !empty($block)) {
00747 $this->jsInline[$name] = array (
00748 'code' => $block . LF,
00749 'section' => self::PART_HEADER,
00750 'compress' => $compress,
00751 'forceOnTop' => $forceOnTop
00752 );
00753 }
00754 }
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765 public function addJsFooterInlineCode($name, $block, $compress = TRUE, $forceOnTop = FALSE) {
00766 if (!isset($this->jsInline[$name]) && !empty($block)) {
00767 $this->jsInline[$name] = array (
00768 'code' => $block . LF,
00769 'section' => self::PART_FOOTER,
00770 'compress' => $compress,
00771 'forceOnTop' => $forceOnTop
00772 );
00773 }
00774 }
00775
00776
00777
00778
00779
00780
00781
00782
00783 public function addExtOnReadyCode($block, $forceOnTop = FALSE) {
00784 if (!in_array($block, $this->extOnReadyCode)) {
00785 if ($forceOnTop) {
00786 array_unshift($this->extOnReadyCode, $block);
00787 } else {
00788 $this->extOnReadyCode[] = $block;
00789 }
00790 }
00791 }
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806 public function addCssFile($file, $rel = 'stylesheet', $media = 'all', $title = '', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '') {
00807 if (!isset($this->cssFiles[$file])) {
00808 $this->cssFiles[$file] = array (
00809 'rel' => $rel,
00810 'media' => $media,
00811 'title' => $title,
00812 'compress' => $compress,
00813 'forceOnTop' => $forceOnTop,
00814 'allWrap' => $allWrap
00815 );
00816 }
00817 }
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830 public function addCssInlineBlock($name, $block, $compressed = FALSE, $forceOnTop = FALSE) {
00831 if (!isset($this->cssInline[$name]) && !empty($block)) {
00832 $this->cssInline[$name] = array (
00833 'code' => $block,
00834 'compress' => $compress,
00835 'forceOnTop' => $forceOnTop
00836 );
00837 }
00838 }
00839
00840
00841
00842
00843
00844
00845
00846
00847 public function loadPrototype() {
00848 $this->addPrototype = TRUE;
00849 }
00850
00851
00852
00853
00854
00855
00856
00857 public function loadScriptaculous($modules = 'all') {
00858
00859 $this->addPrototype = TRUE;
00860 $this->addScriptaculous = TRUE;
00861 if ($modules) {
00862 if ($modules == 'all') {
00863 foreach ($this->addScriptaculousModules as $key => $value) {
00864 $this->addScriptaculousModules[$key] = TRUE;
00865 }
00866 } else {
00867 $mods = t3lib_div::trimExplode(',', $modules);
00868 foreach ($mods as $mod) {
00869 if (isset($this->addScriptaculousModules[strtolower($mod)])) {
00870 $this->addScriptaculousModules[strtolower($mod)] = TRUE;
00871 }
00872 }
00873 }
00874 }
00875 }
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885 public function loadExtJS($css = TRUE, $theme = TRUE, $adapter = '') {
00886 if ($adapter) {
00887
00888 switch (t3lib_div::strtolower(trim($adapter))) {
00889 case self::EXTJS_ADAPTER_YUI :
00890 $this->extJSadapter = 'yui/ext-yui-adapter.js';
00891 break;
00892 case self::EXTJS_ADAPTER_PROTOTYPE :
00893 $this->extJSadapter = 'prototype/ext-prototype-adapter.js';
00894 break;
00895 case self::EXTJS_ADAPTER_JQUERY :
00896 $this->extJSadapter = 'jquery/ext-jquery-adapter.js';
00897 break;
00898 }
00899 }
00900 $this->addExtJS = TRUE;
00901 $this->extJStheme = $theme;
00902 $this->extJScss = $css;
00903
00904 }
00905
00906
00907
00908
00909
00910
00911
00912
00913 public function enableExtJSQuickTips() {
00914 $this->enableExtJSQuickTips = TRUE;
00915 }
00916
00917
00918
00919
00920
00921
00922
00923 public function loadExtCore() {
00924 $this->addExtCore = TRUE;
00925 }
00926
00927
00928
00929
00930
00931 public function enableExtJsDebug() {
00932 $this->enableExtJsDebug = TRUE;
00933 }
00934
00935
00936
00937
00938
00939
00940 public function enableExtCoreDebug() {
00941 $this->enableExtCoreDebug = TRUE;
00942 }
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953 public function addInlineLanguageLabel($key, $value) {
00954 $this->inlineLanguageLabels[$key] = $value;
00955 }
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966 public function addInlineLanguageLabelArray(array $array) {
00967 $this->inlineLanguageLabels = array_merge($this->inlineLanguageLabels, $array);
00968 }
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980 public function addInlineSetting($namespace, $key, $value) {
00981 if ($namespace) {
00982 if (strpos($namespace, '.')) {
00983 $parts = explode('.', $namespace);
00984 $a = &$this->inlineSettings;
00985 foreach ($parts as $part) {
00986 $a = &$a[$part];
00987 }
00988 $a[$key] = $value;
00989 } else {
00990 $this->inlineSettings[$namespace][$key] = $value;
00991 }
00992 } else {
00993 $this->inlineSettings[$key] = $value;
00994 }
00995 }
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007 public function addInlineSettingArray($namespace, array $array) {
01008 if ($namespace) {
01009 if (strpos($namespace, '.')) {
01010 $parts = explode('.', $namespace);
01011 $a = &$this->inlineSettings;
01012 foreach ($parts as $part) {
01013 $a = &$a[$part];
01014 }
01015 $a = array_merge((array) $a, $array);
01016 } else {
01017 $this->inlineSettings[$namespace] = array_merge((array) $this->inlineSettings[$namespace], $array);
01018 }
01019 } else {
01020 $this->inlineSettings = array_merge($this->inlineSettings, $array);
01021 }
01022 }
01023
01024
01025
01026
01027
01028
01029
01030 public function addBodyContent($content) {
01031 $this->bodyContent .= $content;
01032 }
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047 public function render($part = self::PART_COMPLETE) {
01048
01049 $jsFiles = '';
01050 $cssFiles = '';
01051 $cssInline = '';
01052 $jsInline = '';
01053 $jsFooterInline = '';
01054 $jsFooterLibs = '';
01055 $jsFooterFiles = '';
01056 $noJS = FALSE;
01057
01058
01059 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'])) {
01060 $params = array (
01061 'jsLibs' => &$this->jsLibs,
01062 'jsFiles' => &$this->jsFiles,
01063 'jsFooterFiles' => &$this->jsFooterFiles,
01064 'cssFiles' => &$this->cssFiles,
01065 'headerData' => &$this->headerData,
01066 'footerData' => &$this->footerData,
01067 'jsInline' => &$this->jsInline,
01068 'cssInline' => &$this->cssInline,
01069 );
01070 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'] as $hook) {
01071 t3lib_div::callUserFunction($hook, $params, $this);
01072 }
01073 }
01074
01075 $jsLibs = $this->renderJsLibraries();
01076
01077 if ($this->concatenateFiles) {
01078
01079 $this->doConcatenate();
01080 }
01081 if ($this->compressCss || $this->compressJavascript) {
01082
01083 $this->doCompress();
01084 }
01085
01086 $metaTags = implode(LF, $this->metaTags);
01087
01088
01089
01090
01091 if ($this->getRenderXhtml()) {
01092 $endingSlash = ' /';
01093 } else {
01094 $this->metaCharsetTag = str_replace(' />', '>', $this->metaCharsetTag);
01095 $this->baseUrlTag = str_replace(' />', '>', $this->baseUrlTag);
01096 $this->shortcutTag = str_replace(' />', '>', $this->shortcutTag);
01097 $endingSlash = '';
01098 }
01099
01100 if (count($this->cssFiles)) {
01101 foreach ($this->cssFiles as $file => $properties) {
01102 $file = t3lib_div::resolveBackPath($file);
01103 $file = t3lib_div::createVersionNumberedFilename($file);
01104 $tag = '<link rel="' . $properties['rel'] . '" type="text/css" href="' .
01105 htmlspecialchars($file) . '" media="' . $properties['media'] . '"' .
01106 ($properties['title'] ? ' title="' . $properties['title'] . '"' : '') .
01107 $endingSlash . '>';
01108 if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
01109 $tag = str_replace('|', $tag, $properties['allWrap']);
01110 }
01111 if ($properties['forceOnTop']) {
01112 $cssFiles = $tag . LF . $cssFiles;
01113 } else {
01114 $cssFiles .= LF . $tag;
01115 }
01116 }
01117 }
01118
01119 if (count($this->cssInline)) {
01120 foreach ($this->cssInline as $name => $properties) {
01121 if ($properties['forceOnTop']) {
01122 $cssInline = '' . LF . $properties['code'] . LF . $cssInline;
01123 } else {
01124 $cssInline .= '' . LF . $properties['code'] . LF;
01125 }
01126 }
01127 $cssInline = $this->inlineCssWrap[0] . $cssInline . $this->inlineCssWrap[1];
01128 }
01129
01130 if (count($this->jsLibs)) {
01131 foreach ($this->jsLibs as $name => $properties) {
01132 $properties['file'] = t3lib_div::resolveBackPath($properties['file']);
01133 $properties['file'] = t3lib_div::createVersionNumberedFilename($properties['file']);
01134 $tag = '<script src="' . htmlspecialchars($properties['file']) . '" type="' . $properties['type'] . '"></script>';
01135 if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
01136 $tag = str_replace('|', $tag, $properties['allWrap']);
01137 }
01138 if ($properties['forceOnTop']) {
01139 if ($properties['section'] === self::PART_HEADER) {
01140 $jsLibs = $tag . LF . $jsLibs;
01141 } else {
01142 $jsFooterLibs = $tag . LF . $jsFooterLibs;
01143 }
01144 } else {
01145 if ($properties['section'] === self::PART_HEADER) {
01146 $jsLibs .= LF . $tag;
01147 } else {
01148 $jsFooterLibs .= LF . $tag;
01149 }
01150 }
01151 }
01152 }
01153
01154 if (count($this->jsFiles)) {
01155 foreach ($this->jsFiles as $file => $properties) {
01156 $file = t3lib_div::resolveBackPath($file);
01157 $file = t3lib_div::createVersionNumberedFilename($file);
01158 $tag = '<script src="' . htmlspecialchars($file) . '" type="' . $properties['type'] . '"></script>';
01159 if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
01160 $tag = str_replace('|', $tag, $properties['allWrap']);
01161 }
01162 if ($properties['forceOnTop']) {
01163 if ($properties['section'] === self::PART_HEADER) {
01164 $jsFiles = $tag . LF . $jsFiles;
01165 } else {
01166 $jsFooterFiles = $tag . LF . $jsFooterFiles;
01167 }
01168 } else {
01169 if ($properties['section'] === self::PART_HEADER) {
01170 $jsFiles .= LF . $tag;
01171 } else {
01172 $jsFooterFiles .= LF . $tag;
01173 }
01174 }
01175 }
01176 }
01177
01178 if (count($this->jsInline)) {
01179 foreach ($this->jsInline as $name => $properties) {
01180 if ($properties['forceOnTop']) {
01181 if ($properties['section'] === self::PART_HEADER) {
01182 $jsInline = '' . LF . $properties['code'] . LF . $jsInline;
01183 } else {
01184 $jsFooterInline = '' . LF . $properties['code'] . LF . $jsFooterInline;
01185 }
01186 } else {
01187 if ($properties['section'] === self::PART_HEADER) {
01188 $jsInline .= '' . LF . $properties['code'] . LF;
01189 } else {
01190 $jsFooterInline .= '' . LF . $properties['code'] . LF;
01191 }
01192 }
01193 }
01194 }
01195
01196
01197 if ($jsInline) {
01198 $jsInline = $this->inlineJavascriptWrap[0] . $jsInline . $this->inlineJavascriptWrap[1];
01199 }
01200
01201 if ($jsFooterInline) {
01202 $jsFooterInline = $this->inlineJavascriptWrap[0] . $jsFooterInline . $this->inlineJavascriptWrap[1];
01203 }
01204
01205
01206
01207 $templateFile = t3lib_div::getFileAbsFileName($this->templateFile, TRUE);
01208 $template = t3lib_div::getURL($templateFile);
01209
01210 if ($this->removeEmptyLinesFromTemplate) {
01211 $template = strtr($template, array(LF => '', CR => ''));
01212 }
01213 if ($part != self::PART_COMPLETE) {
01214 $templatePart = explode('###BODY###', $template);
01215 $template = $templatePart[$part - 1];
01216 }
01217
01218 if ($this->moveJsFromHeaderToFooter) {
01219 $jsFooterLibs = $jsLibs . LF . $jsFooterLibs;
01220 $jsLibs = '';
01221 $jsFooterFiles = $jsFiles . LF . $jsFooterFiles;
01222 $jsFiles = '';
01223 $jsFooterInline = $jsInline . LF . $jsFooterInline;
01224 $jsInline = '';
01225 }
01226
01227 $markerArray = array(
01228 'XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType,
01229 'HTMLTAG' => $this->htmlTag,
01230 'HEADTAG' => $this->headTag,
01231 'METACHARSET' => $this->charSet ? str_replace('|', htmlspecialchars($this->charSet), $this->metaCharsetTag) : '',
01232 'INLINECOMMENT' => $this->inlineComments ? LF . LF . '<!-- ' . LF . implode(LF, $this->inlineComments) . '-->' . LF . LF : '',
01233 'BASEURL' => $this->baseUrl ? str_replace('|', $this->baseUrl, $this->baseUrlTag) : '',
01234 'SHORTCUT' => $this->favIcon ? sprintf($this->shortcutTag, htmlspecialchars($this->favIcon), $this->iconMimeType) : '',
01235 'CSS_INCLUDE' => $cssFiles,
01236 'CSS_INLINE' => $cssInline,
01237 'JS_INLINE' => $jsInline,
01238 'JS_INCLUDE' => $jsFiles,
01239 'JS_LIBS' => $jsLibs,
01240 'TITLE' => $this->title ? str_replace('|', htmlspecialchars($this->title), $this->titleTag) : '',
01241 'META' => $metaTags,
01242 'HEADERDATA' => $this->headerData ? implode(LF, $this->headerData) : '',
01243 'FOOTERDATA' => $this->footerData ? implode(LF, $this->footerData) : '',
01244 'JS_LIBS_FOOTER' => $jsFooterLibs,
01245 'JS_INCLUDE_FOOTER' => $jsFooterFiles,
01246 'JS_INLINE_FOOTER' => $jsFooterInline,
01247 'BODY' => $this->bodyContent,
01248 );
01249
01250 $markerArray = array_map('trim', $markerArray);
01251
01252 $this->reset();
01253 return trim(t3lib_parsehtml::substituteMarkerArray($template, $markerArray, '###|###'));
01254 }
01255
01256
01257
01258
01259
01260
01261 protected function renderJsLibraries() {
01262 $out = '';
01263
01264 if ($this->addPrototype) {
01265 $out .= '<script src="' . $this->processJsFile($this->backPath . 'contrib/prototype/prototype.js') .
01266 '" type="text/javascript"></script>' . LF;
01267 unset($this->jsFiles[$this->backPath . 'contrib/prototype/prototype.js']);
01268 }
01269
01270 if ($this->addScriptaculous) {
01271 $mods = array ();
01272 foreach ($this->addScriptaculousModules as $key => $value) {
01273 if ($this->addScriptaculousModules[$key]) {
01274 $mods[] = $key;
01275 }
01276 }
01277
01278 if (in_array('dragdrop', $mods) || in_array('controls', $mods)) {
01279 $mods = array_merge(array('effects'), $mods);
01280 }
01281
01282 if (count($mods)) {
01283 foreach ($mods as $module) {
01284 $out .= '<script src="' . $this->processJsFile($this->backPath .
01285 'contrib/scriptaculous/' . $module . '.js') . '" type="text/javascript"></script>' . LF;
01286 unset($this->jsFiles[$this->backPath . 'contrib/scriptaculous/' . $module . '.js']);
01287 }
01288 }
01289 $out .= '<script src="' . $this->processJsFile($this->backPath .
01290 'contrib/scriptaculous/scriptaculous.js') . '" type="text/javascript"></script>' . LF;
01291 unset($this->jsFiles[$this->backPath . 'contrib/scriptaculous/scriptaculous.js']);
01292 }
01293
01294
01295 if ($this->addExtCore) {
01296 $out .= '<script src="' . $this->processJsFile($this->backPath .
01297 'contrib/extjs/ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js') .
01298 '" type="text/javascript"></script>' . LF;
01299 unset($this->jsFiles[$this->backPath . 'contrib/extjs/ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js']);
01300 }
01301
01302
01303 if ($this->addExtJS) {
01304
01305 $out .= '<script src="' . $this->processJsFile($this->backPath .
01306 'contrib/extjs/adapter/' . ($this->enableExtJsDebug ?
01307 str_replace('.js', '-debug.js', $this->extJSadapter) : $this->extJSadapter)) .
01308 '" type="text/javascript"></script>' . LF;
01309 $out .= '<script src="' . $this->processJsFile($this->backPath .
01310 'contrib/extjs/ext-all' . ($this->enableExtJsDebug ? '-debug' : '') . '.js') .
01311 '" type="text/javascript"></script>' . LF;
01312
01313
01314 $localeMap = $this->csConvObj->isoArray;
01315 $localeMap[''] = 'en';
01316 $localeMap['default'] = 'en';
01317 $localeMap['gr'] = 'el_GR';
01318 $localeMap['no'] = 'no_BO';
01319 $localeMap['se'] = 'se_SV';
01320
01321
01322 $extJsLang = isset($localeMap[$this->lang]) ? $localeMap[$this->lang] : $this->lang;
01323
01324 $extJsLocaleFile = 'contrib/extjs/locale/ext-lang-' . $extJsLang . '.js';
01325 if (file_exists(PATH_typo3 . $extJsLocaleFile)) {
01326 $out .= '<script src="' . $this->processJsFile($this->backPath .
01327 $extJsLocaleFile) . '" type="text/javascript" charset="utf-8"></script>' . LF;
01328 }
01329
01330
01331
01332 unset(
01333 $this->jsFiles[$this->backPath . 'contrib/extjs/ext-all.js'], $this->jsFiles[$this->backPath . 'contrib/extjs/ext-all-debug.js']
01334 );
01335 }
01336
01337
01338 if ($this->getCharSet() !== 'utf-8') {
01339 if ($this->inlineLanguageLabels) {
01340 $this->csConvObj->convArray($this->inlineLanguageLabels, $this->getCharSet(), 'utf-8');
01341 }
01342 if ($this->inlineSettings) {
01343 $this->csConvObj->convArray($this->inlineSettings, $this->getCharSet(), 'utf-8');
01344 }
01345 }
01346
01347 $inlineSettings = $this->inlineLanguageLabels ? 'TYPO3.lang = ' . json_encode($this->inlineLanguageLabels) . ';' : '';
01348 $inlineSettings .= $this->inlineSettings ? 'TYPO3.settings = ' . json_encode($this->inlineSettings) . ';' : '';
01349
01350 if ($this->addExtCore || $this->addExtJS) {
01351
01352 $code = '';
01353 if (count($this->extOnReadyCode)) {
01354 foreach ($this->extOnReadyCode as $block) {
01355 $code .= $block;
01356 }
01357 }
01358
01359 $out .= $this->inlineJavascriptWrap[0] . '
01360 Ext.ns("TYPO3");
01361 Ext.BLANK_IMAGE_URL = "' . htmlspecialchars(t3lib_div::locationHeaderUrl($this->backPath . 'gfx/clear.gif')) . '";' . LF .
01362 $inlineSettings .
01363 'Ext.onReady(function() {' .
01364 ($this->enableExtJSQuickTips ? 'Ext.QuickTips.init();' . LF : '') . $code .
01365 ' });' . $this->inlineJavascriptWrap[1];
01366 unset ($this->extOnReadyCode);
01367
01368 if ($this->extJStheme) {
01369 if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
01370 $this->addCssFile($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'all', '', TRUE, TRUE);
01371 } else {
01372 $this->addCssFile($this->backPath . 'contrib/extjs/resources/css/xtheme-blue.css', 'stylesheet', 'all', '', TRUE, TRUE);
01373 }
01374 }
01375 if ($this->extJScss) {
01376 if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
01377 $this->addCssFile($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'all', '', TRUE, TRUE);
01378 } else {
01379 $this->addCssFile($this->backPath . 'contrib/extjs/resources/css/ext-all-notheme.css', 'stylesheet', 'all', '', TRUE, TRUE);
01380 }
01381 }
01382 } else {
01383 if ($inlineSettings) {
01384 $out .= $this->inlineJavascriptWrap[0] . $inlineSettings . $this->inlineJavascriptWrap[1];
01385 }
01386 }
01387
01388 return $out;
01389 }
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404 protected function doConcatenate() {
01405
01406
01407
01408 if ($this->concatenateFiles) {
01409 $params = array (
01410 'jsLibs' => &$this->jsLibs,
01411 'jsFiles' => &$this->jsFiles,
01412 'jsFooterFiles' => &$this->jsFooterFiles,
01413 'cssFiles' => &$this->cssFiles,
01414 'headerData' => &$this->headerData,
01415 'footerData' => &$this->footerData,
01416 );
01417
01418 if ($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['concatenateHandler']) {
01419
01420 t3lib_div::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['concatenateHandler'], $params, $this);
01421 } elseif (TYPO3_MODE === 'BE') {
01422 $cssOptions = array('baseDirectories' => $GLOBALS['TBE_TEMPLATE']->getSkinStylesheetDirectories());
01423 $this->cssFiles = $this->getCompressor()->concatenateCssFiles($this->cssFiles, $cssOptions);
01424 }
01425 }
01426 }
01427
01428
01429
01430
01431
01432
01433 protected function doCompress() {
01434
01435 if ($this->compressJavascript && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler']) {
01436
01437 $params = array (
01438 'jsInline' => &$this->jsInline,
01439 'jsFooterInline' => &$this->jsFooterInline,
01440 'jsLibs' => &$this->jsLibs,
01441 'jsFiles' => &$this->jsFiles,
01442 'jsFooterFiles' => &$this->jsFooterFiles,
01443 'headerData' => &$this->headerData,
01444 'footerData' => &$this->footerData,
01445 );
01446 t3lib_div::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler'], $params, $this);
01447 } else {
01448
01449 $this->compressError = '';
01450
01451 if ($this->compressJavascript) {
01452 if (count($this->jsInline)) {
01453 foreach ($this->jsInline as $name => $properties) {
01454 if ($properties['compress']) {
01455 $error = '';
01456 $this->jsInline[$name]['code'] = t3lib_div::minifyJavaScript($properties['code'], $error);
01457 if ($error) {
01458 $this->compressError .= 'Error with minify JS Inline Block "' . $name . '": ' . $error . LF;
01459 }
01460 }
01461 }
01462 }
01463 if (TYPO3_MODE === 'BE') {
01464 $this->jsFiles = $this->getCompressor()->compressJsFiles($this->jsFiles);
01465 $this->jsFooterFiles = $this->getCompressor()->compressJsFiles($this->jsFooterFiles);
01466 }
01467 }
01468 }
01469 if ($this->compressCss) {
01470
01471 $params = array (
01472 'cssInline' => &$this->cssInline,
01473 'cssFiles' => &$this->cssFiles,
01474 'headerData' => &$this->headerData,
01475 'footerData' => &$this->footerData,
01476 );
01477
01478 if ($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler']) {
01479
01480 t3lib_div::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler'], $params, $this);
01481 } elseif (TYPO3_MODE === 'BE') {
01482 $this->cssFiles = $this->getCompressor()->compressCssFiles($this->cssFiles);
01483 }
01484 }
01485 }
01486
01487
01488
01489
01490
01491
01492 protected function getCompressor() {
01493 if ($this->compressor === NULL) {
01494 $this->compressor = t3lib_div::makeInstance('t3lib_Compressor');
01495 }
01496 return $this->compressor;
01497 }
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507 protected function processJsFile($filename) {
01508 switch (TYPO3_MODE) {
01509 case 'FE':
01510 $filename = t3lib_div::createVersionNumberedFilename($filename);
01511 break;
01512 case 'BE':
01513 if ($this->compressJavascript) {
01514 $filename = $this->getCompressor()->compressJsFile($filename);
01515 }
01516 break;
01517 }
01518 return $filename;
01519 }
01520 }
01521
01522 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_pagerenderer.php']) {
01523 include_once ($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_pagerenderer.php']);
01524 }
01525 ?>