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