css.php 855 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. require_once('mediawiki/CSSMin.php');
  3. class OC_Minimizer_CSS extends OC_Minimizer
  4. {
  5. protected $contentType = 'text/css';
  6. public function minimizeFiles($files) {
  7. $css_out = '';
  8. $appswebroot = (string) OC::$APPSWEBROOT;
  9. $webroot = (string) OC::$WEBROOT;
  10. foreach($files as $file_info) {
  11. $file = $file_info[0] . '/' . $file_info[2];
  12. $css_out .= '/* ' . $file . ' */' . "\n";
  13. $css = file_get_contents($file);
  14. if (strpos($file, OC::$APPSROOT) == 0) {
  15. $css = str_replace('%appswebroot%', $appswebroot, $css);
  16. $css = str_replace('%webroot%', $webroot, $css);
  17. }
  18. $remote = $file_info[1];
  19. $remote .= '/';
  20. $remote .= dirname($file_info[2]);
  21. $css_out .= CSSMin::remap($css, dirname($file), $remote, true);
  22. }
  23. if (!defined('DEBUG') || !DEBUG){
  24. $css_out = CSSMin::minify($css_out);
  25. }
  26. return $css_out;
  27. }
  28. }