Mime.php 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Mime lookup
  4. *
  5. * @package Less
  6. * @subpackage node
  7. */
  8. class Less_Mime{
  9. // this map is intentionally incomplete
  10. // if you want more, install 'mime' dep
  11. static $_types = array(
  12. '.htm' => 'text/html',
  13. '.html'=> 'text/html',
  14. '.gif' => 'image/gif',
  15. '.jpg' => 'image/jpeg',
  16. '.jpeg'=> 'image/jpeg',
  17. '.png' => 'image/png',
  18. '.ttf' => 'application/x-font-ttf',
  19. '.otf' => 'application/x-font-otf',
  20. '.eot' => 'application/vnd.ms-fontobject',
  21. '.woff' => 'application/x-font-woff',
  22. '.svg' => 'image/svg+xml',
  23. );
  24. public static function lookup( $filepath ){
  25. $parts = explode('.',$filepath);
  26. $ext = '.'.strtolower(array_pop($parts));
  27. if( !isset(self::$_types[$ext]) ){
  28. return null;
  29. }
  30. return self::$_types[$ext];
  31. }
  32. public static function charsets_lookup( $type = null ){
  33. // assumes all text types are UTF-8
  34. return $type && preg_match('/^text\//',$type) ? 'UTF-8' : '';
  35. }
  36. }