2010-05-19 16:09:32 +00:00
|
|
|
#!/usr/bin/php -q
|
|
|
|
<?php
|
|
|
|
require_once '../www/includecss.php';
|
|
|
|
require_once '../www/includejs.php';
|
|
|
|
|
|
|
|
require_once '../includes/lib/jsminplus/jsminplus.php';
|
|
|
|
require_once '../includes/lib/jsmin/jsmin.php';
|
|
|
|
|
|
|
|
/*
|
|
|
|
if(isset($tabStyles) && count($tabStyles)>0){
|
|
|
|
foreach($tabStyles as $name => $group){
|
|
|
|
foreach($group['list'] as $style){
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
define('PATH_JS', realpath(dirname(__FILE__).'/../www/js'));
|
|
|
|
define('PATH_JSMIN', realpath(dirname(__FILE__).'/../www/js/min'));
|
|
|
|
define('PATH_JSGROUP', realpath(dirname(__FILE__).'/../www/js/combine'));
|
|
|
|
|
|
|
|
define('USE_ENCODER', 'jsmin');
|
|
|
|
define('USE_FILEMIN', true);
|
|
|
|
|
|
|
|
echo "Minify JS\n";
|
|
|
|
if(isset($tabScripts) && count($tabScripts)>0){
|
|
|
|
foreach($tabScripts as $name => $group){
|
|
|
|
echo "\nGroup $name : ";
|
|
|
|
if( file_exists(PATH_JSGROUP.'/'.$name.'.js') ){
|
|
|
|
unlink(PATH_JSGROUP.'/'.$name.'.js');
|
|
|
|
}
|
|
|
|
foreach($group['list'] as $script){
|
|
|
|
echo "$script ";
|
|
|
|
$filejs = PATH_JS.'/'.$script;
|
|
|
|
$filemin = PATH_JSGROUP.'/'.str_replace('.js', '.min.js', $script);
|
|
|
|
if (USE_FILEMIN && file_exists($filemin)){
|
|
|
|
$minified = file_get_contents($filemin);
|
|
|
|
} else {
|
|
|
|
$js = file_get_contents($filejs);
|
|
|
|
switch(USE_ENCODER){
|
|
|
|
case 'jsminplus':
|
|
|
|
$minified = JSMinPlus::minify($js, $filejs.'-report');
|
|
|
|
break;
|
|
|
|
case 'jsmin':
|
|
|
|
default:
|
|
|
|
$minified = JSMin::minify($js);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
file_put_contents(PATH_JSGROUP.'/'.$name.'.js', $minified, FILE_APPEND);
|
|
|
|
}
|
|
|
|
|
2010-05-28 08:45:47 +00:00
|
|
|
/*
|
2010-05-19 16:09:32 +00:00
|
|
|
echo "\nGzip : $name\n";
|
|
|
|
if( file_exists(PATH_JSGROUP.'/'.$name.'.js.gz') ){
|
|
|
|
unlink(PATH_JSGROUP.'/'.$name.'.js.gz');
|
|
|
|
}
|
|
|
|
$content = file_get_contents(PATH_JSGROUP.'/'.$name.'.js');
|
|
|
|
$compressionLevel = 9;
|
|
|
|
$encodeMethod = 'gzip';
|
|
|
|
if ($encodeMethod === 'deflate') {
|
|
|
|
$encoded = gzdeflate($content, $compressionLevel);
|
|
|
|
} elseif ($encodeMethod === 'gzip') {
|
|
|
|
$encoded = gzencode($content, $compressionLevel);
|
|
|
|
} else {
|
|
|
|
$encoded = gzcompress($content, $compressionLevel);
|
|
|
|
}
|
|
|
|
file_put_contents(PATH_JSGROUP.'/'.$name.'.js.gz', $encoded);
|
2010-05-28 08:45:47 +00:00
|
|
|
*/
|
2010-05-19 16:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|