068ebdd0ef852d77b03b65e8896433035b9f813d
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Page / PageGenerator.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Page;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Libraries for pagegen.php
31 * The script "pagegen.php" is included by "index_ts.php" when a page is not cached but needs to be rendered.
32 *
33 * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj
34 * XHTML compliant
35 *
36 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
37 */
38 /**
39 * Class for starting TypoScript page generation
40 *
41 * The class is not instantiated as an objects but called directly with the "::" operator.
42 * eg: TSpagegen::pagegenInit()
43 *
44 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
45 */
46 class PageGenerator {
47
48 /**
49 * Setting some vars in TSFE, primarily based on TypoScript config settings.
50 *
51 * @return void
52 */
53 static public function pagegenInit() {
54 if ($GLOBALS['TSFE']->page['content_from_pid'] > 0) {
55 // make REAL copy of TSFE object - not reference!
56 $temp_copy_TSFE = clone $GLOBALS['TSFE'];
57 // Set ->id to the content_from_pid value - we are going to evaluate this pid as was it a given id for a page-display!
58 $temp_copy_TSFE->id = $GLOBALS['TSFE']->page['content_from_pid'];
59 $temp_copy_TSFE->MP = '';
60 $temp_copy_TSFE->getPageAndRootlineWithDomain($GLOBALS['TSFE']->config['config']['content_from_pid_allowOutsideDomain'] ? 0 : $GLOBALS['TSFE']->domainStartPage);
61 $GLOBALS['TSFE']->contentPid = intval($temp_copy_TSFE->id);
62 unset($temp_copy_TSFE);
63 }
64 if ($GLOBALS['TSFE']->config['config']['MP_defaults']) {
65 $temp_parts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('|', $GLOBALS['TSFE']->config['config']['MP_defaults'], 1);
66 foreach ($temp_parts as $temp_p) {
67 list($temp_idP, $temp_MPp) = explode(':', $temp_p, 2);
68 $temp_ids = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $temp_idP);
69 foreach ($temp_ids as $temp_id) {
70 $GLOBALS['TSFE']->MP_defaults[$temp_id] = $temp_MPp;
71 }
72 }
73 }
74 // Global vars...
75 $GLOBALS['TSFE']->indexedDocTitle = $GLOBALS['TSFE']->page['title'];
76 $GLOBALS['TSFE']->debug = '' . $GLOBALS['TSFE']->config['config']['debug'];
77 // Base url:
78 if (isset($GLOBALS['TSFE']->config['config']['baseURL'])) {
79 $GLOBALS['TSFE']->baseUrl = $GLOBALS['TSFE']->config['config']['baseURL'];
80 $GLOBALS['TSFE']->anchorPrefix = substr(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), strlen(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL')));
81 }
82 // Internal and External target defaults
83 $GLOBALS['TSFE']->intTarget = '' . $GLOBALS['TSFE']->config['config']['intTarget'];
84 $GLOBALS['TSFE']->extTarget = '' . $GLOBALS['TSFE']->config['config']['extTarget'];
85 $GLOBALS['TSFE']->fileTarget = '' . $GLOBALS['TSFE']->config['config']['fileTarget'];
86 if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'] === 'ascii') {
87 $GLOBALS['TSFE']->spamProtectEmailAddresses = 'ascii';
88 } else {
89 $GLOBALS['TSFE']->spamProtectEmailAddresses = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'], -10, 10, 0);
90 }
91 $GLOBALS['TSFE']->absRefPrefix = $GLOBALS['TSFE']->config['config']['absRefPrefix'] ? trim($GLOBALS['TSFE']->config['config']['absRefPrefix']) : '';
92 if ($GLOBALS['TSFE']->type && $GLOBALS['TSFE']->config['config']['frameReloadIfNotInFrameset']) {
93 $tdlLD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, '_top', $GLOBALS['TSFE']->no_cache, '');
94 $GLOBALS['TSFE']->JSCode = 'if(!parent.' . trim($GLOBALS['TSFE']->sPre) . ' && !parent.view_frame) top.location.href="' . $GLOBALS['TSFE']->baseUrlWrap($tdlLD['totalURL']) . '"';
95 }
96 $GLOBALS['TSFE']->compensateFieldWidth = '' . $GLOBALS['TSFE']->config['config']['compensateFieldWidth'];
97 $GLOBALS['TSFE']->lockFilePath = '' . $GLOBALS['TSFE']->config['config']['lockFilePath'];
98 $GLOBALS['TSFE']->lockFilePath = $GLOBALS['TSFE']->lockFilePath ? $GLOBALS['TSFE']->lockFilePath : $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'];
99 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_noScaleUp'] = isset($GLOBALS['TSFE']->config['config']['noScaleUp']) ? '' . $GLOBALS['TSFE']->config['config']['noScaleUp'] : $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_noScaleUp'];
100 $GLOBALS['TSFE']->TYPO3_CONF_VARS['GFX']['im_noScaleUp'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_noScaleUp'];
101 $GLOBALS['TSFE']->ATagParams = trim($GLOBALS['TSFE']->config['config']['ATagParams']) ? ' ' . trim($GLOBALS['TSFE']->config['config']['ATagParams']) : '';
102 if ($GLOBALS['TSFE']->config['config']['setJS_mouseOver']) {
103 $GLOBALS['TSFE']->setJS('mouseOver');
104 }
105 if ($GLOBALS['TSFE']->config['config']['setJS_openPic']) {
106 $GLOBALS['TSFE']->setJS('openPic');
107 }
108 $GLOBALS['TSFE']->sWordRegEx = '';
109 $GLOBALS['TSFE']->sWordList = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('sword_list');
110 if (is_array($GLOBALS['TSFE']->sWordList)) {
111 $space = !empty($GLOBALS['TSFE']->config['config']['sword_standAlone']) ? '[[:space:]]' : '';
112 foreach ($GLOBALS['TSFE']->sWordList as $val) {
113 if (strlen(trim($val)) > 0) {
114 $GLOBALS['TSFE']->sWordRegEx .= $space . quotemeta($val) . $space . '|';
115 }
116 }
117 $GLOBALS['TSFE']->sWordRegEx = preg_replace('/\\|$/', '', $GLOBALS['TSFE']->sWordRegEx);
118 }
119 // linkVars
120 $GLOBALS['TSFE']->calculateLinkVars();
121 // dtdAllowsFrames indicates whether to use the target attribute in links
122 $GLOBALS['TSFE']->dtdAllowsFrames = FALSE;
123 if ($GLOBALS['TSFE']->config['config']['doctype']) {
124 if (in_array((string) $GLOBALS['TSFE']->config['config']['doctype'], array('xhtml_frames', 'html5'))) {
125 $GLOBALS['TSFE']->dtdAllowsFrames = TRUE;
126 }
127 } else {
128 $GLOBALS['TSFE']->dtdAllowsFrames = TRUE;
129 }
130 // Setting XHTML-doctype from doctype
131 if (!$GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
132 $GLOBALS['TSFE']->config['config']['xhtmlDoctype'] = $GLOBALS['TSFE']->config['config']['doctype'];
133 }
134 if ($GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
135 $GLOBALS['TSFE']->xhtmlDoctype = $GLOBALS['TSFE']->config['config']['xhtmlDoctype'];
136 // Checking XHTML-docytpe
137 switch ((string) $GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
138 case 'xhtml_trans':
139
140 case 'xhtml_strict':
141
142 case 'xhtml_frames':
143 $GLOBALS['TSFE']->xhtmlVersion = 100;
144 break;
145 case 'xhtml_basic':
146 $GLOBALS['TSFE']->xhtmlVersion = 105;
147 break;
148 case 'xhtml_11':
149
150 case 'xhtml+rdfa_10':
151 $GLOBALS['TSFE']->xhtmlVersion = 110;
152 break;
153 case 'xhtml_2':
154 $GLOBALS['TSFE']->xhtmlVersion = 200;
155 break;
156 default:
157 $GLOBALS['TSFE']->getPageRenderer()->setRenderXhtml(FALSE);
158 $GLOBALS['TSFE']->xhtmlDoctype = '';
159 $GLOBALS['TSFE']->xhtmlVersion = 0;
160 }
161 } else {
162 $GLOBALS['TSFE']->getPageRenderer()->setRenderXhtml(FALSE);
163 }
164 }
165
166 /**
167 * Returns an array with files to include. These files are the ones set up in TypoScript config.
168 *
169 * @return array Files to include. Paths are relative to PATH_site.
170 */
171 static public function getIncFiles() {
172 $incFilesArray = array();
173 // Get files from config.includeLibrary
174 $includeLibrary = trim('' . $GLOBALS['TSFE']->config['config']['includeLibrary']);
175 if ($includeLibrary) {
176 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($includeLibrary);
177 if ($incFile) {
178 $incFilesArray[] = $incFile;
179 }
180 }
181 if (is_array($GLOBALS['TSFE']->pSetup['includeLibs.'])) {
182 $incLibs = $GLOBALS['TSFE']->pSetup['includeLibs.'];
183 } else {
184 $incLibs = array();
185 }
186 if (is_array($GLOBALS['TSFE']->tmpl->setup['includeLibs.'])) {
187 // toplevel 'includeLibs' is added to the PAGE.includeLibs. In that way, PAGE-libs get first priority, because if the key already exist, it's not altered. (Due to investigation by me)
188 $incLibs += $GLOBALS['TSFE']->tmpl->setup['includeLibs.'];
189 }
190 if (count($incLibs)) {
191 foreach ($incLibs as $theLib) {
192 if (!is_array($theLib) && ($incFile = $GLOBALS['TSFE']->tmpl->getFileName($theLib))) {
193 $incFilesArray[] = $incFile;
194 }
195 }
196 }
197 return $incFilesArray;
198 }
199
200 /**
201 * Processing JavaScript handlers
202 *
203 * @return array Array with a) a JavaScript section with event handlers and variables set and b) an array with attributes for the body tag.
204 */
205 static public function JSeventFunctions() {
206 $functions = array();
207 $setEvents = array();
208 $setBody = array();
209 foreach ($GLOBALS['TSFE']->JSeventFuncCalls as $event => $handlers) {
210 if (count($handlers)) {
211 $functions[] = ' function T3_' . $event . 'Wrapper(e) { ' . implode(' ', $handlers) . ' }';
212 $setEvents[] = ' document.' . $event . '=T3_' . $event . 'Wrapper;';
213 if ($event == 'onload') {
214 // Dubiuos double setting breaks on some browser - do we need it?
215 $setBody[] = 'onload="T3_onloadWrapper();"';
216 }
217 }
218 }
219 return array(count($functions) ? implode(LF, $functions) . LF . implode(LF, $setEvents) : '', $setBody);
220 }
221
222 /**
223 * Rendering the page content
224 *
225 * @return void
226 */
227 static public function renderContent() {
228 // PAGE CONTENT
229 $GLOBALS['TT']->incStackPointer();
230 $GLOBALS['TT']->push($GLOBALS['TSFE']->sPre, 'PAGE');
231 $pageContent = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup);
232 if ($GLOBALS['TSFE']->pSetup['wrap']) {
233 $pageContent = $GLOBALS['TSFE']->cObj->wrap($pageContent, $GLOBALS['TSFE']->pSetup['wrap']);
234 }
235 if ($GLOBALS['TSFE']->pSetup['stdWrap.']) {
236 $pageContent = $GLOBALS['TSFE']->cObj->stdWrap($pageContent, $GLOBALS['TSFE']->pSetup['stdWrap.']);
237 }
238 // PAGE HEADER (after content - maybe JS is inserted!
239 // if 'disableAllHeaderCode' is set, all the header-code is discarded!
240 if ($GLOBALS['TSFE']->config['config']['disableAllHeaderCode']) {
241 $GLOBALS['TSFE']->content = $pageContent;
242 } else {
243 self::renderContentWithHeader($pageContent);
244 }
245 $GLOBALS['TT']->pull($GLOBALS['TT']->LR ? $GLOBALS['TSFE']->content : '');
246 $GLOBALS['TT']->decStackPointer();
247 }
248
249 /**
250 * Rendering normal HTML-page with header by wrapping the generated content ($pageContent) in body-tags and setting the header accordingly.
251 *
252 * @param string $pageContent The page content which TypoScript objects has generated
253 * @return void
254 */
255 static public function renderContentWithHeader($pageContent) {
256 // get instance of t3lib_PageRenderer
257 /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
258 $pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
259 if ($GLOBALS['TSFE']->config['config']['moveJsFromHeaderToFooter']) {
260 $pageRenderer->enableMoveJsFromHeaderToFooter();
261 }
262 if ($GLOBALS['TSFE']->config['config']['pageRendererTemplateFile']) {
263 $file = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->config['config']['pageRendererTemplateFile']);
264 if ($file) {
265 $pageRenderer->setTemplateFile($file);
266 }
267 }
268 $headerComment = $GLOBALS['TSFE']->config['config']['headerComment'];
269 if (trim($headerComment)) {
270 $pageRenderer->addInlineComment(TAB . str_replace(LF, (LF . TAB), trim($headerComment)) . LF);
271 }
272 // Setting charset:
273 $theCharset = $GLOBALS['TSFE']->metaCharset;
274 // Reset the content variables:
275 $GLOBALS['TSFE']->content = '';
276 $htmlTagAttributes = array();
277 $htmlLang = $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] ? $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] : 'en';
278 // Set content direction: (More info: http://www.tau.ac.il/~danon/Hebrew/HTML_and_Hebrew.html)
279 if ($GLOBALS['TSFE']->config['config']['htmlTag_dir']) {
280 $htmlTagAttributes['dir'] = htmlspecialchars($GLOBALS['TSFE']->config['config']['htmlTag_dir']);
281 }
282 // Setting document type:
283 $docTypeParts = array();
284 $xmlDocument = TRUE;
285 // Part 1: XML prologue
286 switch ((string) $GLOBALS['TSFE']->config['config']['xmlprologue']) {
287 case 'none':
288 $xmlDocument = FALSE;
289 $GLOBALS['TSFE']->config['config']['xhtml_cleaning'] = 'none';
290 break;
291 case 'xml_10':
292 $docTypeParts[] = '<?xml version="1.0" encoding="' . $theCharset . '"?>';
293 break;
294 case 'xml_11':
295 $docTypeParts[] = '<?xml version="1.1" encoding="' . $theCharset . '"?>';
296 break;
297 case '':
298 if ($GLOBALS['TSFE']->xhtmlVersion) {
299 $docTypeParts[] = '<?xml version="1.0" encoding="' . $theCharset . '"?>';
300 }
301 break;
302 default:
303 $docTypeParts[] = $GLOBALS['TSFE']->config['config']['xmlprologue'];
304 }
305 // Part 2: DTD
306 $doctype = $GLOBALS['TSFE']->config['config']['doctype'];
307 if ($doctype) {
308 switch ($doctype) {
309 case 'xhtml_trans':
310 $docTypeParts[] = '<!DOCTYPE html
311 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
312 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
313 break;
314 case 'xhtml_strict':
315 $docTypeParts[] = '<!DOCTYPE html
316 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
317 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
318 break;
319 case 'xhtml_frames':
320 $docTypeParts[] = '<!DOCTYPE html
321 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
322 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
323 break;
324 case 'xhtml_basic':
325 $docTypeParts[] = '<!DOCTYPE html
326 PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
327 "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">';
328 break;
329 case 'xhtml_11':
330 $docTypeParts[] = '<!DOCTYPE html
331 PUBLIC "-//W3C//DTD XHTML 1.1//EN"
332 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
333 break;
334 case 'xhtml_2':
335 $docTypeParts[] = '<!DOCTYPE html
336 PUBLIC "-//W3C//DTD XHTML 2.0//EN"
337 "http://www.w3.org/TR/xhtml2/DTD/xhtml2.dtd">';
338 break;
339 case 'xhtml+rdfa_10':
340 $docTypeParts[] = '<!DOCTYPE html
341 PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
342 "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">';
343 break;
344 case 'html5':
345 $docTypeParts[] = '<!DOCTYPE html>';
346 if ($xmlDocument) {
347 $pageRenderer->setMetaCharsetTag('<meta charset="|" />');
348 } else {
349 $pageRenderer->setMetaCharsetTag('<meta charset="|">');
350 }
351 break;
352 case 'none':
353 break;
354 default:
355 $docTypeParts[] = $doctype;
356 }
357 } else {
358 $docTypeParts[] = '<!DOCTYPE html>';
359 if ($xmlDocument){
360 $pageRenderer->setMetaCharsetTag('<meta charset="|" />');
361 } else {
362 $pageRenderer->setMetaCharsetTag('<meta charset="|">');
363 }
364 }
365 if ($GLOBALS['TSFE']->xhtmlVersion) {
366 $htmlTagAttributes['xml:lang'] = $htmlLang;
367 }
368 if ($GLOBALS['TSFE']->xhtmlVersion < 110 || $doctype === 'html5') {
369 $htmlTagAttributes['lang'] = $htmlLang;
370 }
371 if ($GLOBALS['TSFE']->xhtmlVersion || $doctype === 'html5' && $xmlDocument) {
372 // We add this to HTML5 to achieve a slightly better backwards compatibility
373 $htmlTagAttributes['xmlns'] = 'http://www.w3.org/1999/xhtml';
374 if (is_array($GLOBALS['TSFE']->config['config']['namespaces.'])) {
375 foreach ($GLOBALS['TSFE']->config['config']['namespaces.'] as $prefix => $uri) {
376 // $uri gets htmlspecialchared later
377 $htmlTagAttributes['xmlns:' . htmlspecialchars($prefix)] = $uri;
378 }
379 }
380 }
381 // Swap XML and doctype order around (for MSIE / Opera standards compliance)
382 if ($GLOBALS['TSFE']->config['config']['doctypeSwitch']) {
383 $docTypeParts = array_reverse($docTypeParts);
384 }
385 // Adding doctype parts:
386 if (count($docTypeParts)) {
387 $pageRenderer->setXmlPrologAndDocType(implode(LF, $docTypeParts));
388 }
389 // Begin header section:
390 if (strcmp($GLOBALS['TSFE']->config['config']['htmlTag_setParams'], 'none')) {
391 $_attr = $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] ? $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] : \TYPO3\CMS\Core\Utility\GeneralUtility::implodeAttributes($htmlTagAttributes);
392 } else {
393 $_attr = '';
394 }
395 $htmlTag = '<html' . ($_attr ? ' ' . $_attr : '') . '>';
396 if (isset($GLOBALS['TSFE']->config['config']['htmlTag_stdWrap.'])) {
397 $htmlTag = $GLOBALS['TSFE']->cObj->stdWrap($htmlTag, $GLOBALS['TSFE']->config['config']['htmlTag_stdWrap.']);
398 }
399 $pageRenderer->setHtmlTag($htmlTag);
400 // Head tag:
401 $headTag = $GLOBALS['TSFE']->pSetup['headTag'] ? $GLOBALS['TSFE']->pSetup['headTag'] : '<head>';
402 $pageRenderer->setHeadTag($headTag);
403 // Setting charset meta tag:
404 $pageRenderer->setCharSet($theCharset);
405 $pageRenderer->addInlineComment(' This website is powered by TYPO3 - inspiring people to share!
406 TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
407 TYPO3 is copyright ' . TYPO3_copyright_year . ' of Kasper Skaarhoj. Extensions are copyright of their respective owners.
408 Information and contribution at ' . TYPO3_URL_ORG . '
409 ');
410 if ($GLOBALS['TSFE']->baseUrl) {
411 $pageRenderer->setBaseUrl($GLOBALS['TSFE']->baseUrl);
412 }
413 if ($GLOBALS['TSFE']->pSetup['shortcutIcon']) {
414 $favIcon = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['shortcutIcon']);
415 $iconMimeType = '';
416 if (function_exists('finfo_open')) {
417 if ($finfo = @finfo_open(FILEINFO_MIME)) {
418 $iconMimeType = ' type="' . finfo_file($finfo, (PATH_site . $favIcon)) . '"';
419 finfo_close($finfo);
420 $pageRenderer->setIconMimeType($iconMimeType);
421 }
422 }
423 $pageRenderer->setFavIcon(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $favIcon);
424 }
425 // Including CSS files
426 if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'])) {
427 $temp_styleLines = array();
428 foreach ($GLOBALS['TSFE']->tmpl->setup['plugin.'] as $key => $iCSScode) {
429 if (is_array($iCSScode)) {
430 if ($iCSScode['_CSS_DEFAULT_STYLE'] && empty($GLOBALS['TSFE']->config['config']['removeDefaultCss'])) {
431 $temp_styleLines[] = '/* default styles for extension "' . substr($key, 0, -1) . '" */' . LF . $iCSScode['_CSS_DEFAULT_STYLE'];
432 }
433 if ($iCSScode['_CSS_PAGE_STYLE']) {
434 $temp_styleLines[] = '/* specific page styles for extension "' . substr($key, 0, -1) . '" */' . LF . implode(LF, $iCSScode['_CSS_PAGE_STYLE']);
435 }
436 }
437 }
438 if (count($temp_styleLines)) {
439 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
440 $pageRenderer->addCssFile(self::inline2TempFile(implode(LF, $temp_styleLines), 'css'));
441 } else {
442 $pageRenderer->addCssInlineBlock('TSFEinlineStyle', implode(LF, $temp_styleLines));
443 }
444 }
445 }
446 if ($GLOBALS['TSFE']->pSetup['stylesheet']) {
447 $ss = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['stylesheet']);
448 if ($ss) {
449 $pageRenderer->addCssFile($ss);
450 }
451 }
452 /**********************************************************************/
453 /* includeCSS
454 /* config.includeCSS {
455 /*
456 /* }
457 /**********************************************************************/
458 if (is_array($GLOBALS['TSFE']->pSetup['includeCSS.'])) {
459 foreach ($GLOBALS['TSFE']->pSetup['includeCSS.'] as $key => $CSSfile) {
460 if (!is_array($CSSfile)) {
461 $ss = $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['external'] ? $CSSfile : $GLOBALS['TSFE']->tmpl->getFileName($CSSfile);
462 if (isset($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['if.']) && !$GLOBALS['TSFE']->cObj->checkIf($GLOBALS['TSFE']->pSetup['includeCSS.'][($key . '.')]['if.'])) {
463 continue;
464 }
465 if ($ss) {
466 if ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['import']) {
467 if (!$GLOBALS['TSFE']->pSetup['includeCSS.'][($key . '.')]['external'] && substr($ss, 0, 1) != '/') {
468 // To fix MSIE 6 that cannot handle these as relative paths (according to Ben v Ende)
469 $ss = \TYPO3\CMS\Core\Utility\GeneralUtility::dirname(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('SCRIPT_NAME')) . '/' . $ss;
470 }
471 $pageRenderer->addCssInlineBlock('import_' . $key, '@import url("' . htmlspecialchars($ss) . '") ' . htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][($key . '.')]['media']) . ';', empty($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['disableCompression']), $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE, '');
472 } else {
473 $pageRenderer->addCssFile($ss, $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['alternate'] ? 'alternate stylesheet' : 'stylesheet', $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media'] : 'all', $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['title'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['title'] : '', empty($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['disableCompression']), $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE, $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['allWrap'], $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['excludeFromConcatenation'] ? TRUE : FALSE);
474 }
475 }
476 }
477 }
478 }
479 // Stylesheets
480 $style = '';
481 if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE']) {
482 $pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig();
483 $RTEclasses = $pageTSConfig['RTE.']['classes.'];
484 if (is_array($RTEclasses)) {
485 foreach ($RTEclasses as $RTEclassName => $RTEvalueArray) {
486 if ($RTEvalueArray['value']) {
487 $style .= '
488 .' . substr($RTEclassName, 0, -1) . ' {' . $RTEvalueArray['value'] . '}';
489 }
490 }
491 }
492 if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs'] && is_array($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'])) {
493 $mSOa_tList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', strtoupper($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs']), 1);
494 foreach ($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'] as $mSOa_key => $mSOa_value) {
495 if (!is_array($mSOa_value) && (in_array('*', $mSOa_tList) || in_array($mSOa_key, $mSOa_tList))) {
496 $style .= '
497 ' . $mSOa_key . ' {' . $mSOa_value . '}';
498 }
499 }
500 }
501 }
502 // Setting body tag margins in CSS:
503 if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins']) && $GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
504 $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
505 $style .= '
506 BODY {margin: ' . $margins . 'px ' . $margins . 'px ' . $margins . 'px ' . $margins . 'px;}';
507 }
508 if ($GLOBALS['TSFE']->pSetup['adminPanelStyles']) {
509 $style .= '
510
511 /* Default styles for the Admin Panel */
512 TABLE.typo3-adminPanel { border: 1px solid black; background-color: #F6F2E6; }
513 TABLE.typo3-adminPanel TR.typo3-adminPanel-hRow TD { background-color: #9BA1A8; }
514 TABLE.typo3-adminPanel TR.typo3-adminPanel-itemHRow TD { background-color: #ABBBB4; }
515 TABLE.typo3-adminPanel TABLE, TABLE.typo3-adminPanel TD { border: 0px; }
516 TABLE.typo3-adminPanel TD FONT { font-family: verdana; font-size: 10px; color: black; }
517 TABLE.typo3-adminPanel TD A FONT { font-family: verdana; font-size: 10px; color: black; }
518 TABLE.typo3-editPanel { border: 1px solid black; background-color: #F6F2E6; }
519 TABLE.typo3-editPanel TD { border: 0px; }
520 ';
521 }
522 // CSS_inlineStyle from TS
523 $style .= trim($GLOBALS['TSFE']->pSetup['CSS_inlineStyle']);
524 $style .= $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['cssInline.'], 'cssInline.');
525 if (trim($style)) {
526 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
527 $pageRenderer->addCssFile(self::inline2TempFile($style, 'css'));
528 } else {
529 $pageRenderer->addCssInlineBlock('additionalTSFEInlineStyle', $style);
530 }
531 }
532 // Javascript Libraries
533 if (is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.'])) {
534 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['SVG']) {
535 $pageRenderer->loadSvg();
536 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['SVG.']['debug']) {
537 $pageRenderer->enableSvgDebug();
538 }
539 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['SVG.']['forceFlash']) {
540 $pageRenderer->svgForceFlash();
541 }
542 }
543 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['Prototype']) {
544 $pageRenderer->loadPrototype();
545 }
546 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous']) {
547 $modules = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous.']['modules'] ? $GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous.']['modules'] : '';
548 $pageRenderer->loadScriptaculous($modules);
549 }
550 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtCore']) {
551 $pageRenderer->loadExtCore();
552 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtCore.']['debug']) {
553 $pageRenderer->enableExtCoreDebug();
554 }
555 }
556 // Include jQuery into the page renderer
557 if (!empty($GLOBALS['TSFE']->pSetup['javascriptLibs.']['jQuery'])) {
558 $jQueryTS = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['jQuery.'];
559 // Check if version / source is set, if not set variable to "NULL" to use the default of the page renderer
560 $version = isset($jQueryTS['version']) ? $jQueryTS['version'] : NULL;
561 $source = isset($jQueryTS['source']) ? $jQueryTS['source'] : NULL;
562 // When "noConflict" is not set or "1" enable the default jQuery noConflict mode, otherwise disable the namespace
563 if (!isset($jQueryTS['noConflict']) || !empty($jQueryTS['noConflict'])) {
564 // Set namespace to the "noConflict.namespace" value if "noConflict.namespace" has a value
565 if (!empty($jQueryTS['noConflict.']['namespace'])) {
566 $namespace = $jQueryTS['noConflict.']['namespace'];
567 } else {
568 $namespace = \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_NAMESPACE_DEFAULT_NOCONFLICT;
569 }
570 } else {
571 $namespace = \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_NAMESPACE_NONE;
572 }
573 $pageRenderer->loadJQuery($version, $source, $namespace);
574 }
575 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs']) {
576 $css = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['css'] ? TRUE : FALSE;
577 $theme = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['theme'] ? TRUE : FALSE;
578 $adapter = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['adapter'] ? $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['adapter'] : '';
579 $pageRenderer->loadExtJs($css, $theme, $adapter);
580 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['debug']) {
581 $pageRenderer->enableExtJsDebug();
582 }
583 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['quickTips']) {
584 $pageRenderer->enableExtJSQuickTips();
585 }
586 }
587 }
588 // JavaScript library files
589 if (is_array($GLOBALS['TSFE']->pSetup['includeJSlibs.'])) {
590 foreach ($GLOBALS['TSFE']->pSetup['includeJSlibs.'] as $key => $JSfile) {
591 if (!is_array($JSfile)) {
592 if (isset($GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['if.']) && !$GLOBALS['TSFE']->cObj->checkIf($GLOBALS['TSFE']->pSetup['includeJSlibs.'][($key . '.')]['if.'])) {
593 continue;
594 }
595 $ss = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
596 if ($ss) {
597 $type = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['type'];
598 if (!$type) {
599 $type = 'text/javascript';
600 }
601 $pageRenderer->addJsLibrary($key, $ss, $type, empty($GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['disableCompression']), $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['forceOnTop'] ? TRUE : FALSE, $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['allWrap'], $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['excludeFromConcatenation'] ? TRUE : FALSE);
602 }
603 }
604 }
605 }
606 if (is_array($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'])) {
607 foreach ($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'] as $key => $JSfile) {
608 if (!is_array($JSfile)) {
609 if (isset($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['if.']) && !$GLOBALS['TSFE']->cObj->checkIf($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][($key . '.')]['if.'])) {
610 continue;
611 }
612 $ss = $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
613 if ($ss) {
614 $type = $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['type'];
615 if (!$type) {
616 $type = 'text/javascript';
617 }
618 $pageRenderer->addJsFooterLibrary($key, $ss, $type, empty($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['disableCompression']), $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['forceOnTop'] ? TRUE : FALSE, $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['allWrap'], $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['excludeFromConcatenation'] ? TRUE : FALSE);
619 }
620 }
621 }
622 }
623 // JavaScript files
624 if (is_array($GLOBALS['TSFE']->pSetup['includeJS.'])) {
625 foreach ($GLOBALS['TSFE']->pSetup['includeJS.'] as $key => $JSfile) {
626 if (!is_array($JSfile)) {
627 if (isset($GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['if.']) && !$GLOBALS['TSFE']->cObj->checkIf($GLOBALS['TSFE']->pSetup['includeJS.'][($key . '.')]['if.'])) {
628 continue;
629 }
630 $ss = $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
631 if ($ss) {
632 $type = $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['type'];
633 if (!$type) {
634 $type = 'text/javascript';
635 }
636 $pageRenderer->addJsFile($ss, $type, empty($GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['disableCompression']), $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE, $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['allWrap'], $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['excludeFromConcatenation'] ? TRUE : FALSE);
637 }
638 }
639 }
640 }
641 if (is_array($GLOBALS['TSFE']->pSetup['includeJSFooter.'])) {
642 foreach ($GLOBALS['TSFE']->pSetup['includeJSFooter.'] as $key => $JSfile) {
643 if (!is_array($JSfile)) {
644 if (isset($GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['if.']) && !$GLOBALS['TSFE']->cObj->checkIf($GLOBALS['TSFE']->pSetup['includeJSFooter.'][($key . '.')]['if.'])) {
645 continue;
646 }
647 $ss = $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
648 if ($ss) {
649 $type = $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['type'];
650 if (!$type) {
651 $type = 'text/javascript';
652 }
653 $pageRenderer->addJsFooterFile($ss, $type, empty($GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['disableCompression']), $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['forceOnTop'] ? TRUE : FALSE, $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['allWrap'], $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['excludeFromConcatenation'] ? TRUE : FALSE);
654 }
655 }
656 }
657 }
658 // Headerdata
659 if (is_array($GLOBALS['TSFE']->pSetup['headerData.'])) {
660 $pageRenderer->addHeaderData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['headerData.'], 'headerData.'));
661 }
662 // Footerdata
663 if (is_array($GLOBALS['TSFE']->pSetup['footerData.'])) {
664 $pageRenderer->addFooterData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['footerData.'], 'footerData.'));
665 }
666 // Title
667 $titleTagContent = $GLOBALS['TSFE']->tmpl->printTitle($GLOBALS['TSFE']->altPageTitle ? $GLOBALS['TSFE']->altPageTitle : $GLOBALS['TSFE']->page['title'], $GLOBALS['TSFE']->config['config']['noPageTitle'], $GLOBALS['TSFE']->config['config']['pageTitleFirst']);
668 if ($GLOBALS['TSFE']->config['config']['titleTagFunction']) {
669 $titleTagContent = $GLOBALS['TSFE']->cObj->callUserFunction($GLOBALS['TSFE']->config['config']['titleTagFunction'], array(), $titleTagContent);
670 }
671 if (strlen($titleTagContent) && intval($GLOBALS['TSFE']->config['config']['noPageTitle']) !== 2) {
672 $pageRenderer->setTitle($titleTagContent);
673 }
674 // Add ending slash only to documents rendered as xhtml
675 $endingSlash = $GLOBALS['TSFE']->xhtmlVersion ? ' /' : '';
676 $pageRenderer->addMetaTag('<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS"' . $endingSlash . '>');
677 $conf = $GLOBALS['TSFE']->pSetup['meta.'];
678 if (is_array($conf)) {
679 foreach ($conf as $theKey => $theValue) {
680 // Only if 1) the property is set but not the value itself, 2) the value and/or any property
681 if (!strstr($theKey, '.') || !isset($conf[substr($theKey, 0, -1)])) {
682 if (strstr($theKey, '.')) {
683 $theKey = substr($theKey, 0, -1);
684 }
685 $val = $GLOBALS['TSFE']->cObj->stdWrap($conf[$theKey], $conf[$theKey . '.']);
686 $key = $theKey;
687 if (trim($val)) {
688 $a = 'name';
689 if (strtolower($key) === 'refresh' || !empty($conf[($theKey . '.')]['httpEquivalent'])) {
690 $a = 'http-equiv';
691 }
692 $pageRenderer->addMetaTag('<meta ' . $a . '="' . $key . '" content="' . htmlspecialchars(trim($val)) . '"' . $endingSlash . '>');
693 }
694 }
695 }
696 }
697 unset($GLOBALS['TSFE']->additionalHeaderData['JSCode']);
698 unset($GLOBALS['TSFE']->additionalHeaderData['JSImgCode']);
699 if (is_array($GLOBALS['TSFE']->config['INTincScript'])) {
700 // Storing the JSCode and JSImgCode vars...
701 $GLOBALS['TSFE']->additionalHeaderData['JSCode'] = $GLOBALS['TSFE']->JSCode;
702 $GLOBALS['TSFE']->additionalHeaderData['JSImgCode'] = $GLOBALS['TSFE']->JSImgCode;
703 $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] = $GLOBALS['TSFE']->uniqueHash();
704 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalHeaderData'] = $GLOBALS['TSFE']->additionalHeaderData;
705 // Storing the header-data array
706 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalFooterData'] = $GLOBALS['TSFE']->additionalFooterData;
707 // Storing the footer-data array
708 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalJavaScript'] = $GLOBALS['TSFE']->additionalJavaScript;
709 // Storing the JS-data array
710 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalCSS'] = $GLOBALS['TSFE']->additionalCSS;
711 // Storing the Style-data array
712 $GLOBALS['TSFE']->additionalHeaderData = array('<!--HD_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->');
713 // Clearing the array
714 $GLOBALS['TSFE']->additionalFooterData = array('<!--FD_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->');
715 // Clearing the array
716 $GLOBALS['TSFE']->divSection .= '<!--TDS_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->';
717 } else {
718 $GLOBALS['TSFE']->INTincScript_loadJSCode();
719 }
720 $JSef = self::JSeventFunctions();
721 // Adding default Java Script:
722 $scriptJsCode = '
723 var browserName = navigator.appName;
724 var browserVer = parseInt(navigator.appVersion);
725 var version = "";
726 var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
727 if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror" || browserName=="Opera") {version = "n3";} else {version = "n2";}
728 // Blurring links:
729 function blurLink(theObject) { //
730 if (msie4) {theObject.blur();}
731 }
732 ' . $JSef[0];
733 if ($GLOBALS['TSFE']->spamProtectEmailAddresses && $GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii') {
734 $scriptJsCode .= '
735 // decrypt helper function
736 function decryptCharcode(n,start,end,offset) {
737 n = n + offset;
738 if (offset > 0 && n > end) {
739 n = start + (n - end - 1);
740 } else if (offset < 0 && n < start) {
741 n = end - (start - n - 1);
742 }
743 return String.fromCharCode(n);
744 }
745 // decrypt string
746 function decryptString(enc,offset) {
747 var dec = "";
748 var len = enc.length;
749 for(var i=0; i < len; i++) {
750 var n = enc.charCodeAt(i);
751 if (n >= 0x2B && n <= 0x3A) {
752 dec += decryptCharcode(n,0x2B,0x3A,offset); // 0-9 . , - + / :
753 } else if (n >= 0x40 && n <= 0x5A) {
754 dec += decryptCharcode(n,0x40,0x5A,offset); // A-Z @
755 } else if (n >= 0x61 && n <= 0x7A) {
756 dec += decryptCharcode(n,0x61,0x7A,offset); // a-z
757 } else {
758 dec += enc.charAt(i);
759 }
760 }
761 return dec;
762 }
763 // decrypt spam-protected emails
764 function linkTo_UnCryptMailto(s) {
765 location.href = decryptString(s,' . $GLOBALS['TSFE']->spamProtectEmailAddresses * -1 . ');
766 }
767 ';
768 }
769 // Add inline JS
770 $inlineJS = '';
771 // defined in php
772 if (is_array($GLOBALS['TSFE']->inlineJS)) {
773 foreach ($GLOBALS['TSFE']->inlineJS as $key => $val) {
774 if (!is_array($val)) {
775 $inlineJS .= LF . $val . LF;
776 }
777 }
778 }
779 // defined in TS with page.inlineJS
780 // Javascript inline code
781 $inline = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsInline.'], 'jsInline.');
782 if ($inline) {
783 $inlineJS .= LF . $inline . LF;
784 }
785 // Javascript inline code for Footer
786 $inlineFooterJs = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsFooterInline.'], 'jsFooterInline.');
787 // Should minify?
788 if ($GLOBALS['TSFE']->config['config']['compressJs']) {
789 $pageRenderer->enableCompressJavascript();
790 $minifyErrorScript = ($minifyErrorInline = '');
791 $scriptJsCode = \TYPO3\CMS\Core\Utility\GeneralUtility::minifyJavaScript($scriptJsCode, $minifyErrorScript);
792 if ($minifyErrorScript) {
793 $GLOBALS['TT']->setTSlogMessage($minifyErrorScript, 3);
794 }
795 if ($inlineJS) {
796 $inlineJS = \TYPO3\CMS\Core\Utility\GeneralUtility::minifyJavaScript($inlineJS, $minifyErrorInline);
797 if ($minifyErrorInline) {
798 $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3);
799 }
800 }
801 if ($inlineFooterJs) {
802 $inlineFooterJs = \TYPO3\CMS\Core\Utility\GeneralUtility::minifyJavaScript($inlineFooterJs, $minifyErrorInline);
803 if ($minifyErrorInline) {
804 $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3);
805 }
806 }
807 }
808 if (!$GLOBALS['TSFE']->config['config']['removeDefaultJS']) {
809 // inlude default and inlineJS
810 if ($scriptJsCode) {
811 $pageRenderer->addJsInlineCode('_scriptCode', $scriptJsCode, $GLOBALS['TSFE']->config['config']['compressJs']);
812 }
813 if ($inlineJS) {
814 $pageRenderer->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['compressJs']);
815 }
816 if ($inlineFooterJs) {
817 $pageRenderer->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['compressJs']);
818 }
819 } elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS'] === 'external') {
820 /*
821 * This keeps inlineJS from *_INT Objects from being moved to external files.
822 * At this point in frontend rendering *_INT Objects only have placeholders instead
823 * of actual content so moving these placeholders to external files would
824 * a) break the JS file (syntax errors due to the placeholders)
825 * b) the needed JS would never get included to the page
826 * Therefore inlineJS from *_INT Objects must not be moved to external files but
827 * kept internal.
828 */
829 $inlineJSint = '';
830 self::stripIntObjectPlaceholder($inlineJS, $inlineJSint);
831 if ($inlineJSint) {
832 $pageRenderer->addJsInlineCode('TS_inlineJSint', $inlineJSint, $GLOBALS['TSFE']->config['config']['compressJs']);
833 }
834 $pageRenderer->addJsFile(self::inline2TempFile($scriptJsCode . $inlineJS, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['compressJs']);
835 if ($inlineFooterJs) {
836 $inlineFooterJSint = '';
837 self::stripIntObjectPlaceholder($inlineFooterJs, $inlineFooterJSint);
838 if ($inlineFooterJSint) {
839 $pageRenderer->addJsFooterInlineCode('TS_inlineFooterJSint', $inlineFooterJSint, $GLOBALS['TSFE']->config['config']['compressJs']);
840 }
841 $pageRenderer->addJsFooterFile(self::inline2TempFile($inlineFooterJs, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['compressJs']);
842 }
843 } else {
844 // Include only inlineJS
845 if ($inlineJS) {
846 $pageRenderer->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['compressJs']);
847 }
848 if ($inlineFooterJs) {
849 $pageRenderer->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['compressJs']);
850 }
851 }
852 // ExtJS specific code
853 if (is_array($GLOBALS['TSFE']->pSetup['inlineLanguageLabel.'])) {
854 $pageRenderer->addInlineLanguageLabelArray($GLOBALS['TSFE']->pSetup['inlineLanguageLabel.']);
855 }
856 if (is_array($GLOBALS['TSFE']->pSetup['inlineSettings.'])) {
857 $pageRenderer->addInlineSettingArray('TS', $GLOBALS['TSFE']->pSetup['inlineSettings.']);
858 }
859 if (is_array($GLOBALS['TSFE']->pSetup['extOnReady.'])) {
860 $pageRenderer->addExtOnReadyCode($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['extOnReady.'], 'extOnReady.'));
861 }
862 // Compression and concatenate settings
863 if ($GLOBALS['TSFE']->config['config']['compressCss']) {
864 $pageRenderer->enableCompressCss();
865 }
866 if ($GLOBALS['TSFE']->config['config']['compressJs']) {
867 $pageRenderer->enableCompressJavascript();
868 }
869 if ($GLOBALS['TSFE']->config['config']['concatenateCss']) {
870 $pageRenderer->enableConcatenateCss();
871 }
872 if ($GLOBALS['TSFE']->config['config']['concatenateJs']) {
873 $pageRenderer->enableConcatenateJavascript();
874 }
875 // Backward compatibility for old configuration
876 if ($GLOBALS['TSFE']->config['config']['concatenateJsAndCss']) {
877 $pageRenderer->enableConcatenateFiles();
878 }
879 // Add header data block
880 if ($GLOBALS['TSFE']->additionalHeaderData) {
881 $pageRenderer->addHeaderData(implode(LF, $GLOBALS['TSFE']->additionalHeaderData));
882 }
883 // Add footer data block
884 if ($GLOBALS['TSFE']->additionalFooterData) {
885 $pageRenderer->addFooterData(implode(LF, $GLOBALS['TSFE']->additionalFooterData));
886 }
887 // Header complete, now add content
888 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
889 $fs = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\FramesetRenderer');
890 $pageRenderer->addBodyContent($fs->make($GLOBALS['TSFE']->pSetup['frameSet.']));
891 $pageRenderer->addBodyContent(LF . '<noframes>' . LF);
892 }
893 // Bodytag:
894 $defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'], $GLOBALS['TSFE']->pSetup['bodyTagCObject.'], 'bodyTagCObject') : '';
895 if (!$defBT) {
896 $defBT = $GLOBALS['TSFE']->defaultBodyTag;
897 }
898 $bodyTag = $GLOBALS['TSFE']->pSetup['bodyTag'] ? $GLOBALS['TSFE']->pSetup['bodyTag'] : $defBT;
899 if ($bgImg = $GLOBALS['TSFE']->cObj->getImgResource($GLOBALS['TSFE']->pSetup['bgImg'], $GLOBALS['TSFE']->pSetup['bgImg.'])) {
900 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' background="' . $GLOBALS['TSFE']->absRefPrefix . $bgImg[3] . '">';
901 }
902 if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins'])) {
903 $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
904 if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
905
906 } else {
907 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' leftmargin="' . $margins . '" topmargin="' . $margins . '" marginwidth="' . $margins . '" marginheight="' . $margins . '">';
908 }
909 }
910 if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd'])) {
911 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']) . '>';
912 }
913 // Event functions
914 if (count($JSef[1])) {
915 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim(implode(' ', $JSef[1])) . '>';
916 }
917 $pageRenderer->addBodyContent(LF . $bodyTag);
918 // Div-sections
919 if ($GLOBALS['TSFE']->divSection) {
920 $pageRenderer->addBodyContent(LF . $GLOBALS['TSFE']->divSection);
921 }
922 // Page content
923 $pageRenderer->addBodyContent(LF . $pageContent);
924 if (!empty($GLOBALS['TSFE']->config['INTincScript']) && is_array($GLOBALS['TSFE']->config['INTincScript'])) {
925 // Store the serialized pageRenderer in configuration
926 $GLOBALS['TSFE']->config['INTincScript_ext']['pageRenderer'] = serialize($pageRenderer);
927 // Render complete page, keep placeholders for JavaScript and CSS
928 $GLOBALS['TSFE']->content = $pageRenderer->renderPageWithUncachedObjects($GLOBALS['TSFE']->config['INTincScript_ext']['divKey']);
929 } else {
930 // Render complete page
931 $GLOBALS['TSFE']->content = $pageRenderer->render();
932 }
933 // Ending page
934 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
935 $GLOBALS['TSFE']->content .= LF . '</noframes>';
936 }
937 }
938
939 /*************************
940 *
941 * Helper functions
942 * Remember: Calls internally must still be done on the non-instantiated class: TSpagegen::inline2TempFile()
943 *
944 *************************/
945 /**
946 * Searches for placeholder created from *_INT cObjects, removes them from
947 * $searchString and merges them to $intObjects
948 *
949 * @param string $searchString The String which should be cleaned from int-object markers
950 * @param string $intObjects The String the found int-placeholders are moved to (for further processing)
951 */
952 static protected function stripIntObjectPlaceholder(&$searchString, &$intObjects) {
953 $tempArray = array();
954 preg_match_all('/\\<\\!--INT_SCRIPT.[a-z0-9]*--\\>/', $searchString, $tempArray);
955 $searchString = preg_replace('/\\<\\!--INT_SCRIPT.[a-z0-9]*--\\>/', '', $searchString);
956 $intObjects = implode('', $tempArray[0]);
957 }
958
959 /**
960 * Writes string to a temporary file named after the md5-hash of the string
961 *
962 * @param string $str CSS styles / JavaScript to write to file.
963 * @param string $ext Extension: "css" or "js
964 * @return string <script> or <link> tag for the file.
965 */
966 static public function inline2TempFile($str, $ext) {
967 // Create filename / tags:
968 $script = '';
969 switch ($ext) {
970 case 'js':
971 $script = 'typo3temp/javascript_' . substr(md5($str), 0, 10) . '.js';
972 break;
973 case 'css':
974 $script = 'typo3temp/stylesheet_' . substr(md5($str), 0, 10) . '.css';
975 break;
976 }
977 // Write file:
978 if ($script) {
979 if (!@is_file((PATH_site . $script))) {
980 \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_site . $script, $str);
981 }
982 }
983 return $script;
984 }
985
986 /**
987 * Checks if the value defined in "config.linkVars" contains an allowed value. Otherwise, return FALSE which means the value will not be added to any links.
988 *
989 * @param string $haystack The string in which to find $needle
990 * @param string $needle The string to find in $haystack
991 * @return boolean Returns TRUE if $needle matches or is found in $haystack
992 */
993 static public function isAllowedLinkVarValue($haystack, $needle) {
994 $OK = FALSE;
995 // Integer
996 if ($needle == 'int' || $needle == 'integer') {
997 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($haystack)) {
998 $OK = TRUE;
999 }
1000 } elseif (preg_match('/^\\/.+\\/[imsxeADSUXu]*$/', $needle)) {
1001 // Regular expression, only "//" is allowed as delimiter
1002 if (@preg_match($needle, $haystack)) {
1003 $OK = TRUE;
1004 }
1005 } elseif (strstr($needle, '-')) {
1006 // Range
1007 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($haystack)) {
1008 $range = explode('-', $needle);
1009 if ($range[0] <= $haystack && $range[1] >= $haystack) {
1010 $OK = TRUE;
1011 }
1012 }
1013 } elseif (strstr($needle, '|')) {
1014 // List
1015 // Trim the input
1016 $haystack = str_replace(' ', '', $haystack);
1017 if (strstr('|' . $needle . '|', '|' . $haystack . '|')) {
1018 $OK = TRUE;
1019 }
1020 } elseif (!strcmp($needle, $haystack)) {
1021 // String comparison
1022 $OK = TRUE;
1023 }
1024 return $OK;
1025 }
1026
1027 }
1028
1029
1030 ?>