You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

css.php 987B

1234567891011121314151617181920212223242526272829303132333435363738
  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. $webroot = (string) OC::$WEBROOT;
  9. foreach($files as $file_info) {
  10. $file = $file_info[0] . '/' . $file_info[2];
  11. $css_out .= '/* ' . $file . ' */' . "\n";
  12. $css = file_get_contents($file);
  13. $in_root = false;
  14. foreach(OC::$APPSROOTS as $app_root) {
  15. if(strpos($file, $app_root['path'].'/') === 0) {
  16. $in_root = rtrim($webroot.$app_root['url'], '/');
  17. break;
  18. }
  19. }
  20. if ($in_root !== false) {
  21. $css = str_replace('%appswebroot%', $in_root, $css);
  22. $css = str_replace('%webroot%', $webroot, $css);
  23. }
  24. $remote = $file_info[1];
  25. $remote .= '/';
  26. $remote .= dirname($file_info[2]);
  27. $css_out .= CSSMin::remap($css, dirname($file), $remote, true);
  28. }
  29. if (!defined('DEBUG') || !DEBUG) {
  30. $css_out = CSSMin::minify($css_out);
  31. }
  32. return $css_out;
  33. }
  34. }