@@ -91,66 +91,54 @@ class Util {
91
91
510 => 'Not Extended '
92
92
];
93
93
94
- private static $ _mime_types = [
95
- 'txt ' => 'text/plain ' ,
96
- 'htm ' => 'text/html ' ,
97
- 'html ' => 'text/html ' ,
98
- 'php ' => 'text/html ' ,
99
- 'css ' => 'text/css ' ,
100
- 'js ' => 'application/javascript ' ,
101
- 'json ' => 'application/json ' ,
102
- 'xml ' => 'application/xml ' ,
103
- 'swf ' => 'application/x-shockwave-flash ' ,
104
- 'flv ' => 'video/x-flv ' ,
94
+ private static $ _mime_extensions = [
95
+ 'text/plain ' => 'txt ' ,
96
+ 'text/html ' => 'html ' ,
97
+ 'text/css ' => 'css ' ,
98
+ 'application/javascript ' => 'js ' ,
99
+ 'application/json ' => 'json ' ,
100
+ 'application/xml ' => 'xml ' ,
101
+ 'application/x-shockwave-flash ' => 'swf ' ,
102
+ 'video/x-flv ' => 'flv ' ,
105
103
106
104
// images
107
- 'png ' => 'image/png ' ,
108
- 'jpe ' => 'image/jpeg ' ,
109
- 'jpeg ' => 'image/jpeg ' ,
110
- 'jpg ' => 'image/jpeg ' ,
111
- 'gif ' => 'image/gif ' ,
112
- 'bmp ' => 'image/bmp ' ,
113
- 'ico ' => 'image/vnd.microsoft.icon ' ,
114
- 'tiff ' => 'image/tiff ' ,
115
- 'tif ' => 'image/tiff ' ,
116
- 'svg ' => 'image/svg+xml ' ,
117
- 'svgz ' => 'image/svg+xml ' ,
105
+ 'image/png ' => 'png ' ,
106
+ 'image/jpeg ' => 'jpg ' ,
107
+ 'image/gif ' => 'gif ' ,
108
+ 'image/bmp ' => 'bmp ' ,
109
+ 'image/vnd.microsoft.icon ' => 'ico ' ,
110
+ 'image/tiff ' => 'tiff ' ,
111
+ 'image/svg+xml ' => 'svg ' ,
118
112
119
113
// archives
120
- 'zip ' => 'application/zip ' ,
121
- 'rar ' => 'application/x-rar-compressed ' ,
122
- 'exe ' => 'application/x-msdownload ' ,
123
- 'msi ' => 'application/x-msdownload ' ,
124
- 'cab ' => 'application/vnd.ms-cab-compressed ' ,
114
+ 'application/zip ' => 'zip ' ,
115
+ 'application/x-rar-compressed ' => 'rar ' ,
116
+ 'application/x-msdownload ' => 'exe ' ,
117
+ 'application/vnd.ms-cab-compressed ' => 'cab ' ,
125
118
126
119
// audio/video
127
- 'mp3 ' => 'audio/mpeg ' ,
128
- 'qt ' => 'video/quicktime ' ,
129
- 'mov ' => 'video/quicktime ' ,
130
- 'wmv ' => 'video/x-ms-wmv ' ,
131
- 'mp4 ' => 'video/mp4 ' ,
132
- 'mp4a ' => 'audio/mp4 ' ,
133
- 'mpeg ' => 'video/mpeg ' ,
120
+ 'audio/mpeg ' => 'mp3 ' ,
121
+ 'video/quicktime ' => 'mov ' ,
122
+ 'video/x-ms-wmv ' => 'wmv ' ,
123
+ 'video/mp4 ' => 'mp4 ' ,
124
+ 'video/mpeg ' => 'mpeg ' ,
134
125
135
126
// adobe
136
- 'pdf ' => 'application/pdf ' ,
137
- 'psd ' => 'image/vnd.adobe.photoshop ' ,
138
- 'ai ' => 'application/postscript ' ,
139
- 'eps ' => 'application/postscript ' ,
140
- 'ps ' => 'application/postscript ' ,
141
- 'tiff ' => 'image/tiff ' ,
127
+ 'application/pdf ' => 'pdf ' ,
128
+ 'image/vnd.adobe.photoshop ' => 'psd ' ,
129
+ 'application/postscript ' => 'eps ' ,
142
130
143
131
// ms office
144
- 'doc ' => 'application/msword ' ,
145
- 'rtf ' => 'application/ rtf ' ,
146
- 'xls ' => ' application/vnd.ms-excel ' ,
147
- 'xlsx ' => ' application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ' ,
148
- 'docx ' => ' application/vnd.openxmlformats-officedocument.wordprocessingml.document ' ,
149
- 'ppt ' => ' application/vnd.ms-powerpoint ' ,
132
+ 'application/msword ' => 'doc ' ,
133
+ 'application/ rtf ' => 'rtf ' ,
134
+ 'application/vnd.ms-excel ' => ' xls ' ,
135
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ' => ' xlsx ' ,
136
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document ' => ' docx ' ,
137
+ 'application/vnd.ms-powerpoint ' => ' ppt ' ,
150
138
151
139
// open office
152
- 'odt ' => ' application/vnd.oasis.opendocument.text ' ,
153
- 'ods ' => ' application/vnd.oasis.opendocument.spreadsheet ' ,
140
+ 'application/vnd.oasis.opendocument.text ' => ' odt ' ,
141
+ 'application/vnd.oasis.opendocument.spreadsheet ' => ' ods ' ,
154
142
];
155
143
156
144
/**
@@ -170,7 +158,7 @@ public static function getHttpStatus($code) {
170
158
* @return string The extension
171
159
*/
172
160
public static function getExtension ($ mime_type ) {
173
- return array_search ( strtolower ( $ mime_type) , self ::$ _mime_types );
161
+ return self :: get ( $ mime_type , self ::$ _mime_extensions );
174
162
}
175
163
176
164
public static function get ($ field , $ source = null , $ default = null , $ possible_values = []) {
0 commit comments