2012-05-14 19:57:43 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once('mediawiki/CSSMin.php');
|
|
|
|
|
|
|
|
class OC_Minimizer_CSS extends OC_Minimizer
|
|
|
|
{
|
|
|
|
protected $contentType = 'text/css';
|
|
|
|
|
|
|
|
public function minimizeFiles($files) {
|
|
|
|
$css_out = '';
|
|
|
|
$webroot = (string) OC::$WEBROOT;
|
|
|
|
foreach($files as $file_info) {
|
|
|
|
$file = $file_info[0] . '/' . $file_info[2];
|
|
|
|
$css_out .= '/* ' . $file . ' */' . "\n";
|
|
|
|
$css = file_get_contents($file);
|
2012-06-07 01:11:15 +04:00
|
|
|
|
|
|
|
$in_root = false;
|
|
|
|
foreach(OC::$APPSROOTS as $app_root) {
|
|
|
|
if(strpos($file, $app_root['path']) == 0) {
|
2012-06-22 15:12:03 +04:00
|
|
|
$in_root = $webroot.$app_root['url'];
|
2012-06-07 01:11:15 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($in_root !== false) {
|
|
|
|
$css = str_replace('%appswebroot%', $in_root, $css);
|
2012-05-14 19:57:43 +04:00
|
|
|
$css = str_replace('%webroot%', $webroot, $css);
|
|
|
|
}
|
|
|
|
$remote = $file_info[1];
|
2012-06-05 20:09:32 +04:00
|
|
|
$remote .= '/';
|
2012-05-14 19:57:43 +04:00
|
|
|
$remote .= dirname($file_info[2]);
|
|
|
|
$css_out .= CSSMin::remap($css, dirname($file), $remote, true);
|
|
|
|
}
|
2012-06-14 20:22:48 +04:00
|
|
|
if (!defined('DEBUG') || !DEBUG){
|
|
|
|
$css_out = CSSMin::minify($css_out);
|
|
|
|
}
|
2012-06-22 15:12:03 +04:00
|
|
|
// die();
|
2012-05-14 19:57:43 +04:00
|
|
|
return $css_out;
|
|
|
|
}
|
|
|
|
}
|