Project

General

Profile

Bug #22247 » rfc13758-inlineJS_v3.diff

Administrator Admin, 2010-04-30 10:27

View differences:

typo3/sysext/cms/tslib/class.tslib_pagegen.php (Arbeitskopie)
$pageRenderer->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['minifyJS']);
}
} elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS'] === 'external') {
// put default and inlineJS in external file
/*
This would also remove inlineJS from *_INT Objects to external files.
Because at this very point *_INT Objects only have placeholder instead of "results",
moving such place holders to external file would
a, break the JS file (no correct syntax)
b, the JS needed would never get included to the page
Therefore *_INT InlineJS must not be moved to external file but kept internal
*/
$inlineJSint = '';
$inlineJs = stripIntObjectPlaceholder($inlineJs, $inlineJSint);
$pageRenderer->addJsInlineCode('TS_inlineJSint', $inlineJSint, $GLOBALS['TSFE']->config['config']['minifyJS']);
$pageRenderer->addJsFile(TSpagegen::inline2TempFile($scriptJsCode . $inlineJS, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['minifyJS']);
if ($inlineFooterJs) {
$inlineFooterJSint = '';
$inlineFooterJS = stripIntObjectPlaceholder($inlineFooterJS, $inlineFooterJSint);
$pageRenderer->addJsFooterInlineCode('TS_inlineFooterJSint', $inlineFooterJSint, $GLOBALS['TSFE']->config['config']['minifyJS']);
$pageRenderer->addJsFooterFile(TSpagegen::inline2TempFile($inlineFooterJs, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['minifyJS']);
}
} else {
......
* Remember: Calls internally must still be done on the non-instantiated class: TSpagegen::inline2TempFile()
*
*************************/
/**
* Searches for placeholder created from *_INT cObjects, removes them from
* $searchString and merges them to $intObjects
*
* @param string $searchString the String which should be cleaned from int-object markers
* @param string $intObjects the String the found int-placeholders are moved to (for further processing)
* @return string the searchstring cleaned from placeholders
*/
protected function stripIntObjectPlaceholder(&$searchString, &$intObjects) {
$tempArray = array();
preg_match_all('/\<\!--INT_SCRIPT.[a-z0-9]*--\>/', $searchString, $tempArray);
$searchString = preg_replace('/\<\!--INT_SCRIPT.[a-z0-9]*--\>/', '', $searchString);
$intObjects = implode('', $tempArray[0]);
return $searchString;
}
/**
* Writes string to a temporary file named after the md5-hash of the string
(2-2/4)