improve unknown backend
This commit is contained in:
parent
2fd5178a00
commit
7fe9320ffe
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue