| 1 | <?php |
||
| 10 | class Mime |
||
| 11 | { |
||
| 12 | const JSON = 'application/json'; |
||
| 13 | const XML = 'application/xml'; |
||
| 14 | const XHTML = 'application/html+xml'; |
||
| 15 | const FORM = 'application/x-www-form-urlencoded'; |
||
| 16 | const UPLOAD = 'multipart/form-data'; |
||
| 17 | const PLAIN = 'text/plain'; |
||
| 18 | const JS = 'text/javascript'; |
||
| 19 | const HTML = 'text/html'; |
||
| 20 | const YAML = 'application/x-yaml'; |
||
| 21 | const CSV = 'text/csv'; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Map short name for a mime type |
||
| 25 | * to a full proper mime type |
||
| 26 | */ |
||
| 27 | public static $mimes = array( |
||
| 28 | 'json' => self::JSON, |
||
| 29 | 'xml' => self::XML, |
||
| 30 | 'form' => self::FORM, |
||
| 31 | 'plain' => self::PLAIN, |
||
| 32 | 'text' => self::PLAIN, |
||
| 33 | 'upload' => self::UPLOAD, |
||
| 34 | 'html' => self::HTML, |
||
| 35 | 'xhtml' => self::XHTML, |
||
| 36 | 'js' => self::JS, |
||
| 37 | 'javascript'=> self::JS, |
||
| 38 | 'yaml' => self::YAML, |
||
| 39 | 'csv' => self::CSV, |
||
| 40 | ); |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Get the full Mime Type name from a "short name". |
||
| 44 | * Returns the short if no mapping was found. |
||
| 45 | * @param string $short_name common name for mime type (e.g. json) |
||
| 46 | * @return string full mime type (e.g. application/json) |
||
| 47 | */ |
||
| 48 | public static function getFullMime($short_name) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param string $short_name |
||
| 55 | * @return bool |
||
| 56 | */ |
||
| 57 | public static function supportsMimeType($short_name) |
||
| 61 | } |
||
| 62 |