Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/helpers/minifiers/minify_helper.php
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||
return ''; | return ''; | ||||
} | } | ||||
$extension = pathinfo($files[0], PATHINFO_EXTENSION); | $extension = pathinfo($files[0], PATHINFO_EXTENSION); | ||||
$save_as = isset($params['save_as']) ? $params['save_as'] : false; | $save_as = isset($params['save_as']) ? $params['save_as'] : false; | ||||
$dst_file = $this->resourceFolder . DIRECTORY_SEPARATOR . ($this->debugMode ? 'd' : 'c') . '_'; | $dst_file = $this->resourceFolder . DIRECTORY_SEPARATOR . ($this->debugMode ? 'd' : 'c') . '_'; | ||||
/** @var FileHelper $file_helper */ | |||||
$file_helper = $this->Application->recallObject('FileHelper'); | |||||
if ( $save_as ) { | if ( $save_as ) { | ||||
$dst_file .= $save_as . ( strpos($save_as, '.') === false ? '.' . $extension : '' ); | $dst_file .= $save_as . ( strpos($save_as, '.') === false ? '.' . $extension : '' ); | ||||
} | } | ||||
else { | else { | ||||
$dst_file .= $this->_getHash($files) . '.' . $extension; | $dst_file .= $this->_getHash($file_helper->makeRelative($files)) . '.' . $extension; | ||||
} | } | ||||
$was_compressed = file_exists($dst_file); | $was_compressed = file_exists($dst_file); | ||||
if ( !$was_compressed || ($this->debugMode && filemtime($dst_file) < $this->_getMaxFileDate($files)) ) { | if ( !$was_compressed || ($this->debugMode && filemtime($dst_file) < $this->_getMaxFileDate($files)) ) { | ||||
$string = ''; | $string = ''; | ||||
$path_length = strlen(FULL_PATH) + 1; | $path_length = strlen(FULL_PATH) + 1; | ||||
Show All 27 Lines | |||||
// don't compress merged js/css file in debug mode to allow js/css debugging | // don't compress merged js/css file in debug mode to allow js/css debugging | ||||
$this->compressString($string, $extension); | $this->compressString($string, $extension); | ||||
} | } | ||||
// save compressed file | // save compressed file | ||||
file_put_contents($dst_file, $string); | file_put_contents($dst_file, $string); | ||||
} | } | ||||
$file_helper = $this->Application->recallObject('FileHelper'); | |||||
/* @var $file_helper FileHelper */ | |||||
return $file_helper->pathToUrl($dst_file) . '?ts=' . adodb_date('Y-m-d_H:i:s', filemtime($dst_file)); | return $file_helper->pathToUrl($dst_file) . '?ts=' . adodb_date('Y-m-d_H:i:s', filemtime($dst_file)); | ||||
} | } | ||||
/** | /** | ||||
* Returns maximal modification date across given files | * Returns maximal modification date across given files | ||||
* | * | ||||
* @param Array $files | * @param Array $files | ||||
* @return int | * @return int | ||||
Show All 25 Lines | |||||
if ($this->Application->isAdmin) { | if ($this->Application->isAdmin) { | ||||
array_unshift($hash, 'A:1'); | array_unshift($hash, 'A:1'); | ||||
} | } | ||||
else { | else { | ||||
array_unshift($hash, 'A:0;T:' . $this->Application->GetVar('m_theme')); | array_unshift($hash, 'A:0;T:' . $this->Application->GetVar('m_theme')); | ||||
} | } | ||||
return crc32( implode('|', $hash) ); | return kUtil::crc32(implode('|', $hash)); | ||||
} | } | ||||
/** | /** | ||||
* Deletes compression info file | * Deletes compression info file | ||||
* | * | ||||
* @todo also delete all listed there files | * @todo also delete all listed there files | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
$ret[] = $this->Application->TemplatesCache->GetRealFilename(str_replace('{module_path}', $module_prefix, $template)); | $ret[] = $this->Application->TemplatesCache->GetRealFilename(str_replace('{module_path}', $module_prefix, $template)); | ||||
$included[] = $module_prefix; | $included[] = $module_prefix; | ||||
} | } | ||||
return $ret; | return $ret; | ||||
} | } | ||||
} | } | ||||
No newline at end of file |