MDL-55528 core_files: Create new fileconverter plugintype

This commit is contained in:
Andrew Nicols
2017-03-10 09:31:14 +08:00
parent 29ce005862
commit 34df779a95
19 changed files with 2411 additions and 20 deletions
+17
View File
@@ -291,6 +291,23 @@ abstract class core_filetypes {
);
}
/**
* Given a mimetype - return a valid file extension for it.
*
* @param $mimetype string
* @return string|bool False if the mimetype was not known, a string indicating a valid file extension otherwise. It may not
* be the only valid file extension - just the first one found.
*/
public static function get_file_extension($mimetype) {
$types = self::get_types();
foreach ($types as $extension => $info) {
if ($info['type'] == $mimetype) {
return $extension;
}
}
return false;
}
/**
* Gets all the current types.
*