Bug #20804 ยป 0011612.patch
t3lib/class.t3lib_div.php (working copy) | ||
---|---|---|
return $script;
|
||
}
|
||
/**
|
||
* Minify a JavaScript file and store it as temporary file in "typo3temp/"
|
||
*
|
||
* The filename contains a fix prefix "javascript_" a value user defined prefix
|
||
* (normaly the extension key) and last a md5 hash from the filename.
|
||
*
|
||
* The file will be rewritten if the given files lastmodified tstamp is greater than the cached one.
|
||
*
|
||
* @param string $file Full path to a file
|
||
* @param string $prefix OPTIONAL Can be the filename of file to compress
|
||
* @param string $errorMessage OPTIONAL Error message
|
||
* @return string Full path to the minifyed tempfile
|
||
* @author Michael Klapper <michael.klapper@aoemedia.de>
|
||
*/
|
||
public static function minifyJS2TempFile($file, $prefix = '', $errorMessage = '') {
|
||
$absfile = t3lib_div::getFileAbsFileName($file);
|
||
$isValidFile = ( (t3lib_div::validPathStr($file) === true) && file_exists($absfile) && is_file($absfile) && is_readable($absfile) ) ? true : false;
|
||
$urlPrefix = $GLOBALS['TSFE']->absRefPrefix;
|
||
if ( $isValidFile ) {
|
||
$lastModified = fileatime($absfile);
|
||
$lastModifiedTempFile = 0;
|
||
// create filename / tags:
|
||
$tempFileName = 'typo3temp/javascript_' . $prefix . '_' . substr(md5($file), 0, 10) . '.js';
|
||
if ( file_exists($tempFileName) && is_file($tempFileName) && is_readable($tempFileName) ) {
|
||
$lastModifiedTempFile = fileatime($tempFileName);
|
||
}
|
||
if ( !file_exists(PATH_site . $tempFileName) || ($lastModified > $lastModifiedTempFile) ) {
|
||
$fileContent = t3lib_div::minifyJavaScript (
|
||
file_get_contents($absfile),
|
||
$errorMessage
|
||
);
|
||
t3lib_div::writeFileToTypo3tempDir(PATH_site . $tempFileName, $fileContent);
|
||
}
|
||
}
|
||
return $tempFileName;
|
||
}
|
||
/*************************
|
typo3/sysext/cms/tslib/class.tslib_pagegen.php (working copy) | ||
---|---|---|
if (!is_array($JSfile)) {
|
||
$ss = $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
|
||
if ($ss) {
|
||
if ($GLOBALS['TSFE']->pSetup['includeJS.'][$key.'.']['minify']) {
|
||
$ss = t3lib_div::minifyJS2TempFile($ss, basename($ss, ".js"));
|
||
}
|
||
|
||
$type = $GLOBALS['TSFE']->pSetup['includeJS.'][$key.'.']['type'];
|
||
if (!$type) $type = 'text/javascript';
|
||