add more and fix office mimetypes, migrate wrong mimetypes

This commit is contained in:
Jörn Friedrich Dreyer 2014-06-05 13:01:01 +02:00
parent c47d4ebbac
commit a59b5249d3
2 changed files with 77 additions and 2 deletions

View File

@ -6,3 +6,60 @@ if (version_compare(\OCP\Config::getSystemValue('version', '0.0.0'), '7.0.0', '<
\OCP\Config::deleteSystemValue('allowZipDownload');
\OCP\Config::deleteSystemValue('maxZipInputSize');
}
if (version_compare(\OCP\Config::getAppValue('files', 'installed_version'), '1.1.8', '<')) {
// update wrong mimetypes
$wrongMimetypes = array(
'application/mspowerpoint' => 'application/vnd.ms-powerpoint',
'application/msexcel' => 'application/vnd.ms-excel',
);
$stmt = OC_DB::prepare('
UPDATE `*PREFIX*mimetypes`
SET `mimetype` = ?
WHERE `mimetype` = ?
');
foreach ($wrongMimetypes as $wrong => $correct) {
OC_DB::executeAudited($stmt, array($wrong, $correct));
}
$updatedMimetypes = array(
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xlsx' => 'application/vnd.ms-excel',
'pptx' => 'application/vnd.ms-powerpoint',
);
// separate doc from docx etc
foreach ($updatedMimetypes as $extension => $mimetype ) {
$result = OC_DB::executeAudited('
SELECT count(`mimetype`)
FROM `*PREFIX*mimetypes`
WHERE `mimetype` = ?
', array($mimetype)
);
$exists = $result->fetchOne();
if ( ! $exists ) {
// insert mimetype
OC_DB::executeAudited('
INSERT INTO `*PREFIX*mimetypes` ( `mimetype` )
VALUES ( ? )
', array($mimetype)
);
}
// change mimetype for files with x extension
OC_DB::executeAudited('
UPDATE `*PREFIX*filecache`
SET `mimetype` = (
SELECT `id`
FROM `*PREFIX*mimetypes`
WHERE `mimetype` = ?
) WHERE `name` LIKE ?
', array($mimetype, '%.'.$extension)
);
}
}

View File

@ -52,6 +52,7 @@ return array(
'c++' => array('text/x-c++src', null),
'deb' => array('application/x-deb', null),
'doc' => array('application/msword', null),
'docm' => array('application/vnd.ms-word.document.macroEnabled.12', null),
'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', null),
'dot' => array('application/msword', null),
'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.template', null),
@ -91,6 +92,7 @@ return array(
'mpg' => array('video/mpeg', null),
'msi' => array('application/x-msi', null),
'numbers' => array('application/x-iwork-numbers-sffnumbers', null),
'odf' => array('application/vnd.oasis.opendocument.formula', null),
'odg' => array('application/vnd.oasis.opendocument.graphics', null),
'odp' => array('application/vnd.oasis.opendocument.presentation', null),
'ods' => array('application/vnd.oasis.opendocument.spreadsheet', null),
@ -104,7 +106,16 @@ return array(
'php' => array('application/x-php', null),
'pl' => array('application/x-perl', null),
'png' => array('image/png', null),
'ppt' => array('application/mspowerpoint', null),
'pot' => array('application/vnd.ms-powerpoint', null),
'potm' => array('application/vnd.ms-powerpoint.template.macroEnabled.12', null),
'potx' => array('application/vnd.openxmlformats-officedocument.presentationml.template', null),
'ppa' => array('application/vnd.ms-powerpoint', null),
'ppam' => array('application/vnd.ms-powerpoint.addin.macroEnabled.12', null),
'pps' => array('application/vnd.ms-powerpoint', null),
'ppsm' => array('application/vnd.ms-powerpoint.slideshow.macroEnabled.12', null),
'ppsx' => array('application/vnd.openxmlformats-officedocument.presentationml.slideshow', null),
'ppt' => array('application/vnd.ms-powerpoint', null),
'pptm' => array('application/vnd.ms-powerpoint.presentation.macroEnabled.12', null),
'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation', null),
'psd' => array('application/x-photoshop', null),
'py' => array('text/x-python', null),
@ -130,8 +141,15 @@ return array(
'woff' => array('application/font-woff', null),
'wmv' => array('video/x-ms-asf', null),
'xcf' => array('application/x-gimp', null),
'xls' => array('application/msexcel', null),
'xla' => array('application/vnd.ms-excel', null),
'xlam' => array('application/vnd.ms-excel.addin.macroEnabled.12', null),
'xls' => array('application/vnd.ms-excel', null),
'xlsb' => array('application/vnd.ms-excel.sheet.binary.macroEnabled.12', null),
'xlsm' => array('application/vnd.ms-excel.sheet.macroEnabled.12', null),
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', null),
'xlt' => array('application/vnd.ms-excel', null),
'xltm' => array('application/vnd.ms-excel.template.macroEnabled.12', null),
'xltx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.template', null),
'xml' => array('application/xml', 'text/plain'),
'zip' => array('application/zip', null),
);