32e40a4dc77d0546455daac85a296407e9e3d9b4
[redakcja.git] / apps / filebrowser / media / filebrowser / uploadify / com / adobe / net / MimeTypeMap.as
1 /*
2   Copyright (c) 2008, Adobe Systems Incorporated
3   All rights reserved.
4
5   Redistribution and use in source and binary forms, with or without 
6   modification, are permitted provided that the following conditions are
7   met:
8
9   * Redistributions of source code must retain the above copyright notice, 
10     this list of conditions and the following disclaimer.
11   
12   * Redistributions in binary form must reproduce the above copyright
13     notice, this list of conditions and the following disclaimer in the 
14     documentation and/or other materials provided with the distribution.
15   
16   * Neither the name of Adobe Systems Incorporated nor the names of its 
17     contributors may be used to endorse or promote products derived from 
18     this software without specific prior written permission.
19
20   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21   IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
24   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 package com.adobe.net
33 {
34         public class MimeTypeMap
35         {
36                 private var types:Array = 
37                         [["application/andrew-inset","ez"],
38                         ["application/atom+xml","atom"],
39                         ["application/mac-binhex40","hqx"],
40                         ["application/mac-compactpro","cpt"],
41                         ["application/mathml+xml","mathml"],
42                         ["application/msword","doc"],
43                         ["application/octet-stream","bin","dms","lha","lzh","exe","class","so","dll","dmg"],
44                         ["application/oda","oda"],
45                         ["application/ogg","ogg"],
46                         ["application/pdf","pdf"],
47                         ["application/postscript","ai","eps","ps"],
48                         ["application/rdf+xml","rdf"],
49                         ["application/smil","smi","smil"],
50                         ["application/srgs","gram"],
51                         ["application/srgs+xml","grxml"],
52                         ["application/vnd.adobe.apollo-application-installer-package+zip","air"],
53                         ["application/vnd.mif","mif"],
54                         ["application/vnd.mozilla.xul+xml","xul"],
55                         ["application/vnd.ms-excel","xls"],
56                         ["application/vnd.ms-powerpoint","ppt"],
57                         ["application/vnd.rn-realmedia","rm"],
58                         ["application/vnd.wap.wbxml","wbxml"],
59                         ["application/vnd.wap.wmlc","wmlc"],
60                         ["application/vnd.wap.wmlscriptc","wmlsc"],
61                         ["application/voicexml+xml","vxml"],
62                         ["application/x-bcpio","bcpio"],
63                         ["application/x-cdlink","vcd"],
64                         ["application/x-chess-pgn","pgn"],
65                         ["application/x-cpio","cpio"],
66                         ["application/x-csh","csh"],
67                         ["application/x-director","dcr","dir","dxr"],
68                         ["application/x-dvi","dvi"],
69                         ["application/x-futuresplash","spl"],
70                         ["application/x-gtar","gtar"],
71                         ["application/x-hdf","hdf"],
72                         ["application/x-javascript","js"],
73                         ["application/x-koan","skp","skd","skt","skm"],
74                         ["application/x-latex","latex"],
75                         ["application/x-netcdf","nc","cdf"],
76                         ["application/x-sh","sh"],
77                         ["application/x-shar","shar"],
78                         ["application/x-shockwave-flash","swf"],
79                         ["application/x-stuffit","sit"],
80                         ["application/x-sv4cpio","sv4cpio"],
81                         ["application/x-sv4crc","sv4crc"],
82                         ["application/x-tar","tar"],
83                         ["application/x-tcl","tcl"],
84                         ["application/x-tex","tex"],
85                         ["application/x-texinfo","texinfo","texi"],
86                         ["application/x-troff","t","tr","roff"],
87                         ["application/x-troff-man","man"],
88                         ["application/x-troff-me","me"],
89                         ["application/x-troff-ms","ms"],
90                         ["application/x-ustar","ustar"],
91                         ["application/x-wais-source","src"],
92                         ["application/xhtml+xml","xhtml","xht"],
93                         ["application/xml","xml","xsl"],
94                         ["application/xml-dtd","dtd"],
95                         ["application/xslt+xml","xslt"],
96                         ["application/zip","zip"],
97                         ["audio/basic","au","snd"],
98                         ["audio/midi","mid","midi","kar"],
99                         ["audio/mpeg","mp3","mpga","mp2"],
100                         ["audio/x-aiff","aif","aiff","aifc"],
101                         ["audio/x-mpegurl","m3u"],
102                         ["audio/x-pn-realaudio","ram","ra"],
103                         ["audio/x-wav","wav"],
104                         ["chemical/x-pdb","pdb"],
105                         ["chemical/x-xyz","xyz"],
106                         ["image/bmp","bmp"],
107                         ["image/cgm","cgm"],
108                         ["image/gif","gif"],
109                         ["image/ief","ief"],
110                         ["image/jpeg","jpg","jpeg","jpe"],
111                         ["image/png","png"],
112                         ["image/svg+xml","svg"],
113                         ["image/tiff","tiff","tif"],
114                         ["image/vnd.djvu","djvu","djv"],
115                         ["image/vnd.wap.wbmp","wbmp"],
116                         ["image/x-cmu-raster","ras"],
117                         ["image/x-icon","ico"],
118                         ["image/x-portable-anymap","pnm"],
119                         ["image/x-portable-bitmap","pbm"],
120                         ["image/x-portable-graymap","pgm"],
121                         ["image/x-portable-pixmap","ppm"],
122                         ["image/x-rgb","rgb"],
123                         ["image/x-xbitmap","xbm"],
124                         ["image/x-xpixmap","xpm"],
125                         ["image/x-xwindowdump","xwd"],
126                         ["model/iges","igs","iges"],
127                         ["model/mesh","msh","mesh","silo"],
128                         ["model/vrml","wrl","vrml"],
129                         ["text/calendar","ics","ifb"],
130                         ["text/css","css"],
131                         ["text/html","html","htm"],
132                         ["text/plain","txt","asc"],
133                         ["text/richtext","rtx"],
134                         ["text/rtf","rtf"],
135                         ["text/sgml","sgml","sgm"],
136                         ["text/tab-separated-values","tsv"],
137                         ["text/vnd.wap.wml","wml"],
138                         ["text/vnd.wap.wmlscript","wmls"],
139                         ["text/x-setext","etx"],
140                         ["video/mpeg","mpg","mpeg","mpe"],
141                         ["video/quicktime","mov","qt"],
142                         ["video/vnd.mpegurl","m4u","mxu"],
143                         ["video/x-flv","flv"],
144                         ["video/x-msvideo","avi"],
145                         ["video/x-sgi-movie","movie"],
146                         ["x-conference/x-cooltalk","ice"]];
147                 
148                 /**
149                  * Returns the mimetype for the given extension.
150                  */
151                 public function getMimeType(extension:String):String
152                 {
153                         extension = extension.toLocaleLowerCase();
154                         for each (var a:Array in types)
155                         {
156                                 for each (var b:String in a)
157                                 {
158                                         if (b == extension)
159                                         {
160                                                 return a[0];
161                                         }
162                                 }
163                         }
164                         return null;
165                 }
166
167                 /**
168                  * Returns the prefered extension for the given mimetype.
169                  */
170                 public function getExtension(mimetype:String):String
171                 {
172                         mimetype = mimetype.toLocaleLowerCase();
173                         for each (var a:Array in types)
174                         {
175                                 if (a[0] == mimetype)
176                                 {
177                                         return a[1];
178                                 }
179                         }
180                         return null;
181                 }
182
183                 /**
184                  * Adds a mimetype to the map. The order of the extensions matters. The most preferred should come first.
185                  */
186                 public function addMimeType(mimetype:String, extensions:Array):void
187                 {
188                         var newType:Array = [mimetype];
189                         for each (var a:String in extensions)
190                         {
191                                 newType.push(a);
192                         }
193                         types.push(newType);
194                 }
195         }
196 }