diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-19 08:40:25 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-19 08:40:25 +0100 |
commit | 4fcfedb03cb60fe60617fd8d7609d5d1397789a5 (patch) | |
tree | 4ae0abba4bb5804ae9ab3a7ef271b929f2b403c3 /lib | |
parent | 5b3ff7867f9a891ff2c68f0b4ca6c5be93c9c7a0 (diff) | |
parent | 309cc9a6caac2295be74bc04cbd10e6256103988 (diff) | |
download | nextcloud-server-4fcfedb03cb60fe60617fd8d7609d5d1397789a5.tar.gz nextcloud-server-4fcfedb03cb60fe60617fd8d7609d5d1397789a5.zip |
Merge pull request #13438 from owncloud/cache-the-array
Reuse the array key of mimetypes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/helper.php | 141 |
1 files changed, 71 insertions, 70 deletions
diff --git a/lib/private/helper.php b/lib/private/helper.php index 86cc0850bc3..6268bd3d42e 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -28,6 +28,75 @@ class OC_Helper { private static $mimetypeIcons = array(); 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-font-ttf' => '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/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', + ); /** * Creates an url using a defined route @@ -155,77 +224,9 @@ class OC_Helper { * Returns the path to the image of this file type. */ public static function mimetypeIcon($mimetype) { - $alias = 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-font-ttf' => '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/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', - ); - if (isset($alias[$mimetype])) { - $mimetype = $alias[$mimetype]; + if (isset(self::$mimeTypeAlias[$mimetype])) { + $mimetype = self::$mimeTypeAlias[$mimetype]; } if (isset(self::$mimetypeIcons[$mimetype])) { return self::$mimetypeIcons[$mimetype]; |