Fixed a couple of warnings which happened if you accessed a course while
[moodle.git] / files / mimetypes.php
CommitLineData
4c48acf0 1<?php // $Id$
704d5956 2
3function mimeinfo($element, $filename) {
4 $mimeinfo = array (
5 "xxx" => array ("type"=>"document/unknown", "icon"=>"unknown.gif"),
602bde06 6 "3gp" => array ("type"=>"video/quicktime", "icon"=>"video.gif"),
704d5956 7 "ai" => array ("type"=>"application/postscript", "icon"=>"image.gif"),
8 "aif" => array ("type"=>"audio/x-aiff", "icon"=>"audio.gif"),
9 "aiff" => array ("type"=>"audio/x-aiff", "icon"=>"audio.gif"),
10 "aifc" => array ("type"=>"audio/x-aiff", "icon"=>"audio.gif"),
11 "applescript" => array ("type"=>"text/plain", "icon"=>"text.gif"),
12 "asc" => array ("type"=>"text/plain", "icon"=>"text.gif"),
13 "au" => array ("type"=>"audio/au", "icon"=>"audio.gif"),
14 "avi" => array ("type"=>"video/x-ms-wm", "icon"=>"avi.gif"),
15 "bmp" => array ("type"=>"image/bmp", "icon"=>"image.gif"),
16 "cs" => array ("type"=>"application/x-csh", "icon"=>"text.gif"),
17 "css" => array ("type"=>"text/css", "icon"=>"text.gif"),
18 "dv" => array ("type"=>"video/x-dv", "icon"=>"video.gif"),
19 "doc" => array ("type"=>"application/msword", "icon"=>"word.gif"),
20 "dif" => array ("type"=>"video/x-dv", "icon"=>"video.gif"),
21 "eps" => array ("type"=>"application/postscript", "icon"=>"image.gif"),
22 "gif" => array ("type"=>"image/gif", "icon"=>"image.gif"),
23 "gtar" => array ("type"=>"application/x-gtar", "icon"=>"zip.gif"),
7969713a 24 "gz" => array ("type"=>"application/g-zip", "icon"=>"zip.gif"),
704d5956 25 "gzip" => array ("type"=>"application/g-zip", "icon"=>"zip.gif"),
26 "h" => array ("type"=>"text/plain", "icon"=>"text.gif"),
27 "hqx" => array ("type"=>"application/mac-binhex40", "icon"=>"zip.gif"),
28 "html" => array ("type"=>"text/html", "icon"=>"html.gif"),
29 "htm" => array ("type"=>"text/html", "icon"=>"html.gif"),
30 "jpe" => array ("type"=>"image/jpeg", "icon"=>"image.gif"),
31 "jpeg" => array ("type"=>"image/jpeg", "icon"=>"image.gif"),
32 "jpg" => array ("type"=>"image/jpeg", "icon"=>"image.gif"),
33 "js" => array ("type"=>"application/x-javascript", "icon"=>"text.gif"),
34 "latex"=> array ("type"=>"application/x-latex", "icon"=>"text.gif"),
35 "m" => array ("type"=>"text/plain", "icon"=>"text.gif"),
36 "mov" => array ("type"=>"video/quicktime", "icon"=>"video.gif"),
37 "movie"=> array ("type"=>"video/x-sgi-movie", "icon"=>"video.gif"),
38 "m3u" => array ("type"=>"audio/x-mpegurl", "icon"=>"audio.gif"),
39 "mp3" => array ("type"=>"audio/mp3", "icon"=>"audio.gif"),
40 "mp4" => array ("type"=>"video/mp4", "icon"=>"video.gif"),
41 "mpeg" => array ("type"=>"video/mpeg", "icon"=>"video.gif"),
42 "mpe" => array ("type"=>"video/mpeg", "icon"=>"video.gif"),
43 "mpg" => array ("type"=>"video/mpeg", "icon"=>"video.gif"),
44 "pct" => array ("type"=>"image/pict", "icon"=>"image.gif"),
45 "pdf" => array ("type"=>"application/pdf", "icon"=>"pdf.gif"),
46 "php" => array ("type"=>"text/plain", "icon"=>"text.gif"),
47 "pic" => array ("type"=>"image/pict", "icon"=>"image.gif"),
48 "pict" => array ("type"=>"image/pict", "icon"=>"image.gif"),
49 "png" => array ("type"=>"image/png", "icon"=>"image.gif"),
50 "ppt" => array ("type"=>"application/vnd.ms-powerpoint", "icon"=>"powerpoint.gif"),
51 "ps" => array ("type"=>"application/postscript", "icon"=>"image.gif"),
52 "qt" => array ("type"=>"video/quicktime", "icon"=>"video.gif"),
53 "ra" => array ("type"=>"audio/x-realaudio", "icon"=>"audio.gif"),
54 "ram" => array ("type"=>"audio/x-pn-realaudio", "icon"=>"audio.gif"),
55 "rm" => array ("type"=>"audio/x-pn-realaudio", "icon"=>"audio.gif"),
56 "rtf" => array ("type"=>"text/rtf", "icon"=>"text.gif"),
57 "rtx" => array ("type"=>"text/richtext", "icon"=>"text.gif"),
58 "sh" => array ("type"=>"application/x-sh", "icon"=>"text.gif"),
59 "sit" => array ("type"=>"application/x-stuffit", "icon"=>"zip.gif"),
60 "smi" => array ("type"=>"application/smil", "icon"=>"text.gif"),
61 "smil" => array ("type"=>"application/smil", "icon"=>"text.gif"),
62 "swf" => array ("type"=>"application/x-shockwave-flash", "icon"=>"flash.gif"),
63 "tar" => array ("type"=>"application/x-tar", "icon"=>"zip.gif"),
64 "tif" => array ("type"=>"image/tiff", "icon"=>"image.gif"),
65 "tiff" => array ("type"=>"image/tiff", "icon"=>"image.gif"),
66 "tex" => array ("type"=>"application/x-tex", "icon"=>"text.gif"),
67 "texi" => array ("type"=>"application/x-texinfo", "icon"=>"text.gif"),
68 "texinfo" => array ("type"=>"application/x-texinfo", "icon"=>"text.gif"),
69 "tsv" => array ("type"=>"text/tab-separated-values", "icon"=>"text.gif"),
70 "txt" => array ("type"=>"text/plain", "icon"=>"text.gif"),
71 "wav" => array ("type"=>"audio/wav", "icon"=>"audio.gif"),
98a45cd7 72 "wmv" => array ("type"=>"video/x-ms-wmv", "icon"=>"avi.gif"),
393137e2 73 "asf" => array ("type"=>"video/x-ms-asf", "icon"=>"avi.gif"),
704d5956 74 "xls" => array ("type"=>"application/vnd.ms-excel", "icon"=>"excel.gif"),
75 "xml" => array ("type"=>"text/xml", "icon"=>"xml.gif"),
76 "xsl" => array ("type"=>"text/xml", "icon"=>"xml.gif"),
77 "zip" => array ("type"=>"application/zip", "icon"=>"zip.gif")
78 );
79
80 if (eregi("\.([a-z0-9]+)$", $filename, $match)) {
81 $result = $mimeinfo[strtolower($match[1])][$element];
82 }
83
84 if (!empty($result)) {
85 return $result;
86 } else {
87 return $mimeinfo["xxx"][$element]; // By default
88 }
89}
90
91?>