From cd7c85930b9b502e763ccececc88c4b86ad67f21 Mon Sep 17 00:00:00 2001 From: Jeff Segars <jsegars@alumni.rice.edu> Date: Fri, 30 Apr 2010 16:19:34 +0000 Subject: [PATCH] Fixed bug #13758: page.jsInline / page.jsFooterInline may fail with config.removeDefaultJS=external (thanks to Steffen Ritter) git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7463 709f56b5-9817-0410-a4d7-c38de5d9e867 --- ChangeLog | 4 +++ .../sysext/cms/tslib/class.tslib_pagegen.php | 30 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 11601752ab72..dc1d6618588c 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-04-30 Jeff Segars <jeff@webempoweredchurch.org> + + * Fixed bug #13758: page.jsInline / page.jsFooterInline may fail with config.removeDefaultJS=external (thanks to Steffen Ritter) + 2010-04-30 Xavier Perseguers <typo3@perseguers.ch> * Fixed bug #14254: Fresh install does not redirect to Install Tool when mysql is not available diff --git a/typo3/sysext/cms/tslib/class.tslib_pagegen.php b/typo3/sysext/cms/tslib/class.tslib_pagegen.php index 5a5c9de82404..7b828ce6c5a1 100644 --- a/typo3/sysext/cms/tslib/class.tslib_pagegen.php +++ b/typo3/sysext/cms/tslib/class.tslib_pagegen.php @@ -925,9 +925,23 @@ See <a href="http://wiki.typo3.org/index.php/TYPO3_3.8.1" target="_blank">wiki.t $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 keeps inlineJS from *_INT Objects from being moved to external files. + At this point in frontend rendering *_INT Objects only have placeholders instead + of actual content so moving these placeholders to external files would + a) break the JS file (syntax errors due to the placeholders) + b) the needed JS would never get included to the page + Therefore inlineJS from *_INT Objects must not be moved to external files but + kept internal. + */ + $inlineJSint = ''; + self::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 = ''; + self::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 { @@ -1046,6 +1060,20 @@ See <a href="http://wiki.typo3.org/index.php/TYPO3_3.8.1" target="_blank">wiki.t * 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) + */ + protected static 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]); + } /** * Writes string to a temporary file named after the md5-hash of the string -- GitLab