mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
hardcode the list of supported mime types for edition with collabora
This commit is contained in:
parent
00a6ef0598
commit
d9bb18e042
@ -16,10 +16,102 @@ use Chill\DocStoreBundle\Entity\StoredObject;
|
|||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
use Twig\Extension\RuntimeExtensionInterface;
|
use Twig\Extension\RuntimeExtensionInterface;
|
||||||
|
|
||||||
use function array_key_exists;
|
use function in_array;
|
||||||
|
|
||||||
final class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface
|
final class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface
|
||||||
{
|
{
|
||||||
|
public const SUPPORTED_MIMES = [
|
||||||
|
'image/svg+xml',
|
||||||
|
'application/vnd.ms-powerpoint',
|
||||||
|
'application/vnd.ms-excel',
|
||||||
|
'application/vnd.sun.xml.writer',
|
||||||
|
'application/vnd.oasis.opendocument.text',
|
||||||
|
'application/vnd.oasis.opendocument.text-flat-xml',
|
||||||
|
'application/vnd.sun.xml.calc',
|
||||||
|
'application/vnd.oasis.opendocument.spreadsheet',
|
||||||
|
'application/vnd.oasis.opendocument.spreadsheet-flat-xml',
|
||||||
|
'application/vnd.sun.xml.impress',
|
||||||
|
'application/vnd.oasis.opendocument.presentation',
|
||||||
|
'application/vnd.oasis.opendocument.presentation-flat-xml',
|
||||||
|
'application/vnd.sun.xml.draw',
|
||||||
|
'application/vnd.oasis.opendocument.graphics',
|
||||||
|
'application/vnd.oasis.opendocument.graphics-flat-xml',
|
||||||
|
'application/vnd.oasis.opendocument.chart',
|
||||||
|
'application/vnd.sun.xml.writer.global',
|
||||||
|
'application/vnd.oasis.opendocument.text-master',
|
||||||
|
'application/vnd.sun.xml.writer.template',
|
||||||
|
'application/vnd.oasis.opendocument.text-template',
|
||||||
|
'application/vnd.oasis.opendocument.text-master-template',
|
||||||
|
'application/vnd.sun.xml.calc.template',
|
||||||
|
'application/vnd.oasis.opendocument.spreadsheet-template',
|
||||||
|
'application/vnd.sun.xml.impress.template',
|
||||||
|
'application/vnd.oasis.opendocument.presentation-template',
|
||||||
|
'application/vnd.sun.xml.draw.template',
|
||||||
|
'application/vnd.oasis.opendocument.graphics-template',
|
||||||
|
'application/msword',
|
||||||
|
'application/msword',
|
||||||
|
'application/vnd.ms-excel',
|
||||||
|
'application/vnd.ms-powerpoint',
|
||||||
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
|
'application/vnd.ms-word.document.macroEnabled.12',
|
||||||
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||||
|
'application/vnd.ms-word.template.macroEnabled.12',
|
||||||
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
|
||||||
|
'application/vnd.ms-excel.template.macroEnabled.12',
|
||||||
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
|
'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
|
||||||
|
'application/vnd.ms-excel.sheet.macroEnabled.12',
|
||||||
|
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||||
|
'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
|
||||||
|
'application/vnd.openxmlformats-officedocument.presentationml.template',
|
||||||
|
'application/vnd.ms-powerpoint.template.macroEnabled.12',
|
||||||
|
'application/vnd.wordperfect',
|
||||||
|
'application/x-aportisdoc',
|
||||||
|
'application/x-hwp',
|
||||||
|
'application/vnd.ms-works',
|
||||||
|
'application/x-mswrite',
|
||||||
|
'application/x-dif-document',
|
||||||
|
'text/spreadsheet',
|
||||||
|
'text/csv',
|
||||||
|
'application/x-dbase',
|
||||||
|
'application/vnd.lotus-1-2-3',
|
||||||
|
'image/cgm',
|
||||||
|
'image/vnd.dxf',
|
||||||
|
'image/x-emf',
|
||||||
|
'image/x-wmf',
|
||||||
|
'application/coreldraw',
|
||||||
|
'application/vnd.visio2013',
|
||||||
|
'application/vnd.visio',
|
||||||
|
'application/vnd.ms-visio.drawing',
|
||||||
|
'application/x-mspublisher',
|
||||||
|
'application/x-sony-bbeb',
|
||||||
|
'application/x-gnumeric',
|
||||||
|
'application/macwriteii',
|
||||||
|
'application/x-iwork-numbers-sffnumbers',
|
||||||
|
'application/vnd.oasis.opendocument.text-web',
|
||||||
|
'application/x-pagemaker',
|
||||||
|
'text/rtf',
|
||||||
|
'text/plain',
|
||||||
|
'application/x-fictionbook+xml',
|
||||||
|
'application/clarisworks',
|
||||||
|
'image/x-wpg',
|
||||||
|
'application/x-iwork-pages-sffpages',
|
||||||
|
'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
|
||||||
|
'application/x-iwork-keynote-sffkey',
|
||||||
|
|
||||||
|
'application/x-abiword',
|
||||||
|
'image/x-freehand',
|
||||||
|
'application/vnd.sun.xml.chart',
|
||||||
|
'application/x-t602',
|
||||||
|
'image/bmp',
|
||||||
|
'image/png',
|
||||||
|
'image/gif',
|
||||||
|
'image/tiff',
|
||||||
|
'image/jpg',
|
||||||
|
'image/jpeg',
|
||||||
|
'application/pdf',
|
||||||
|
];
|
||||||
|
|
||||||
private const TEMPLATE = '@ChillDocStore/Button/wopi_edit_document.html.twig';
|
private const TEMPLATE = '@ChillDocStore/Button/wopi_edit_document.html.twig';
|
||||||
|
|
||||||
private DiscoveryInterface $discovery;
|
private DiscoveryInterface $discovery;
|
||||||
@ -31,15 +123,7 @@ final class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface
|
|||||||
|
|
||||||
public function isEditable(StoredObject $document): bool
|
public function isEditable(StoredObject $document): bool
|
||||||
{
|
{
|
||||||
$mime_type = $this->discovery->discoverMimeType($document->getType());
|
return in_array($document->getType(), self::SUPPORTED_MIMES, true);
|
||||||
|
|
||||||
foreach ($mime_type as $item) {
|
|
||||||
if (array_key_exists('default', $item) && 'true' === $item['default']) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderEditButton(Environment $environment, StoredObject $document, ?array $options = null): string
|
public function renderEditButton(Environment $environment, StoredObject $document, ?array $options = null): string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user