diff --git a/lib/private/helper.php b/lib/private/helper.php index 4c2f1f509c..b7938416fb 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -54,77 +54,7 @@ class OC_Helper { private static $mimetypeDetector; private static $templateManager; /** @var string[] */ - private static $mimeTypeAlias = array( - 'application/octet-stream' => 'file', // use file icon as fallback - - 'application/illustrator' => 'image/vector', - 'application/postscript' => 'image/vector', - 'image/svg+xml' => 'image/vector', - - 'application/coreldraw' => 'image', - 'application/x-gimp' => 'image', - 'application/x-photoshop' => 'image', - 'application/x-dcraw' => 'image', - - 'application/font-sfnt' => 'font', - 'application/x-font' => 'font', - 'application/font-woff' => 'font', - 'application/vnd.ms-fontobject' => 'font', - - 'application/json' => 'text/code', - 'application/x-perl' => 'text/code', - 'application/x-php' => 'text/code', - 'text/x-shellscript' => 'text/code', - 'application/yaml' => 'text/code', - 'application/xml' => 'text/html', - 'text/css' => 'text/code', - 'application/x-tex' => 'text', - - 'application/x-compressed' => 'package/x-generic', - 'application/x-7z-compressed' => 'package/x-generic', - 'application/x-deb' => 'package/x-generic', - 'application/x-gzip' => 'package/x-generic', - 'application/x-rar-compressed' => 'package/x-generic', - 'application/x-tar' => 'package/x-generic', - 'application/vnd.android.package-archive' => 'package/x-generic', - 'application/zip' => 'package/x-generic', - - 'application/msword' => 'x-office/document', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'x-office/document', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'x-office/document', - 'application/vnd.ms-word.document.macroEnabled.12' => 'x-office/document', - 'application/vnd.ms-word.template.macroEnabled.12' => 'x-office/document', - 'application/vnd.oasis.opendocument.text' => 'x-office/document', - 'application/vnd.oasis.opendocument.text-template' => 'x-office/document', - 'application/vnd.oasis.opendocument.text-web' => 'x-office/document', - 'application/vnd.oasis.opendocument.text-master' => 'x-office/document', - - 'application/mspowerpoint' => 'x-office/presentation', - 'application/vnd.ms-powerpoint' => 'x-office/presentation', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'x-office/presentation', - 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'x-office/presentation', - 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'x-office/presentation', - 'application/vnd.ms-powerpoint.addin.macroEnabled.12' => 'x-office/presentation', - 'application/vnd.ms-powerpoint.presentation.macroEnabled.12' => 'x-office/presentation', - 'application/vnd.ms-powerpoint.template.macroEnabled.12' => 'x-office/presentation', - 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => 'x-office/presentation', - 'application/vnd.oasis.opendocument.presentation' => 'x-office/presentation', - 'application/vnd.oasis.opendocument.presentation-template' => 'x-office/presentation', - - 'application/msexcel' => 'x-office/spreadsheet', - 'application/vnd.ms-excel' => 'x-office/spreadsheet', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'x-office/spreadsheet', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'x-office/spreadsheet', - 'application/vnd.ms-excel.sheet.macroEnabled.12' => 'x-office/spreadsheet', - 'application/vnd.ms-excel.template.macroEnabled.12' => 'x-office/spreadsheet', - 'application/vnd.ms-excel.addin.macroEnabled.12' => 'x-office/spreadsheet', - 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => 'x-office/spreadsheet', - 'application/vnd.oasis.opendocument.spreadsheet' => 'x-office/spreadsheet', - 'application/vnd.oasis.opendocument.spreadsheet-template' => 'x-office/spreadsheet', - 'text/csv' => 'x-office/spreadsheet', - - 'application/msaccess' => 'database', - ); + private static $mimeTypeAlias = []; /** * Creates an url using a defined route @@ -256,6 +186,12 @@ class OC_Helper { */ public static function mimetypeIcon($mimetype) { + // On first access load the list of mimetype aliases + if (empty(self::$mimeTypeAlias)) { + $file = file_get_contents(OC::$SERVERROOT . '/config/mimetypealiases.json'); + self::$mimeTypeAlias = get_object_vars(json_decode($file)); + } + if (isset(self::$mimeTypeAlias[$mimetype])) { $mimetype = self::$mimeTypeAlias[$mimetype]; }