]> source.dussan.org Git - nextcloud-server.git/commitdiff
improve unknown backend
authorGeorg Ehrke <developer@georgehrke.com>
Thu, 15 Aug 2013 11:20:31 +0000 (13:20 +0200)
committerGeorg Ehrke <developer@georgehrke.com>
Thu, 15 Aug 2013 11:22:04 +0000 (13:22 +0200)
lib/helper.php
lib/preview/unknown.php

index b74e4c4512e7c3b34bef3f1d40e3cf7b556311a4..6552bcce70359c2c8662f683a80fa3821b870810 100644 (file)
@@ -188,7 +188,38 @@ class OC_Helper {
         * Returns the path to the image of this file type.
         */
        public static function mimetypeIcon($mimetype) {
-               $alias = array('application/xml' => 'code/xml');
+               $alias = array(
+                       'application/xml' => 'code/xml',
+                       '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/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/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',
+               );
+
                if (isset($alias[$mimetype])) {
                        $mimetype = $alias[$mimetype];
                }
index ba13ca35d6641625b8c9eb79690220b4235c82a1..9e6cd68d401bae46ac24c38af26b8e9de56d0ee8 100644 (file)
@@ -16,27 +16,11 @@ class Unknown extends Provider {
 
        public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
                $mimetype = $fileview->getMimeType($path);
-               if(substr_count($mimetype, '/')) {
-                       list($type, $subtype) = explode('/', $mimetype);
-               }
 
-               $iconsRoot = \OC::$SERVERROOT . '/core/img/filetypes/';
+               $path = \OC_Helper::mimetypeIcon($mimetype);
+               $path = \OC::$SERVERROOT . substr($path, strlen(\OC::$WEBROOT));
 
-               if(isset($type)){
-                       $icons = array($mimetype, $type, 'text');
-               }else{
-                       $icons = array($mimetype, 'text');
-               }
-               foreach($icons as $icon) {
-                       $icon = str_replace('/', '-', $icon);
-
-                       $iconPath = $iconsRoot . $icon . '.png';
-
-                       if(file_exists($iconPath)) {
-                               return new \OC_Image($iconPath);
-                       }
-               }
-               return false;
+               return new \OC_Image($path);
        }
 }