MediaFile loses dependency on PEAR::MIME

At the same time we remove the "filecommand" setting, since we will
likely not have use of it thanks to PECL fileinfo.

Also the "supported" list for attachment mime types has changed
format, so we can keep track of at least some known file extensions.
This commit is contained in:
Mikael Nordfeldth
2014-03-08 03:03:04 +01:00
parent 0eb38b8f84
commit 6faed0e451
5 changed files with 87 additions and 88 deletions

View File

@@ -1797,6 +1797,31 @@ function common_accept_to_prefs($accept, $def = '*/*')
return $prefs;
}
// Match by our supported file extensions
function common_supported_ext_to_mime($fileext)
{
// Accept a filename and take out the extension
if (strpos($fileext, '.') !== false) {
$fileext = substr(strrchr($fileext, '.'), 1);
}
$supported = common_config('attachments', 'supported');
foreach($supported as $type => $ext) {
if ($ext === $fileext) {
return $type;
}
}
return false;
}
// The MIME "media" is the part before the slash (video in video/webm)
function common_get_mime_media($type)
{
$tmp = explode('/', $type);
return strtolower($tmp[0]);
}
function common_mime_type_match($type, $avail)
{
if(array_key_exists($type, $avail)) {