diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig index e01344be4..fe5558ad2 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig @@ -1,4 +1,5 @@ {% import "@ChillDocStore/Macro/macro.html.twig" as m %} +{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %}
+{{ document.description }}{% endif %} @@ -36,12 +38,14 @@ {{ m.download_button(document.object, document.title) }}- {% if not freezed %} - {{ document.object|chill_document_edit_button({'changeIcon': 'fa-unlock', 'title': document.title|e('html') }) }} - {% else %} - - {{ 'Update document'|trans }} - + {% if chill_document_is_editable(document.object) %} + {% if not freezed %} + {{ document.object|chill_document_edit_button({'title': document.title|e('html') }) }} + {% else %} + + {{ 'Update document'|trans }} + + {% endif %} {% endif %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig index 28f984e01..a43bc2cd2 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig @@ -14,7 +14,9 @@ {{ parent() }} {{ encore_entry_link_tags('mod_async_upload') }} {{ encore_entry_link_tags('mod_entity_workflow_pick') }} + {# {{ encore_entry_link_tags('mod_wopi_link') }} + #} {% endblock %} {% block content %} @@ -82,5 +84,7 @@ {{ parent() }} {{ encore_entry_script_tags('mod_async_upload') }} {{ encore_entry_script_tags('mod_entity_workflow_pick') }} + {# {{ encore_entry_script_tags('mod_wopi_link') }} + #} {% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/Macro/macro_mimeicon.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/Macro/macro_mimeicon.html.twig index ff5e533e4..a9bc07e2f 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/Macro/macro_mimeicon.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/Macro/macro_mimeicon.html.twig @@ -36,9 +36,9 @@ mime type and friendly name https://gist.github.com/rosskmurphy/3724501 #} {% set maptype = { - 'fa-file-word-o': 'document/texte', - 'fa-file-excel-o': 'document/tableur', - 'fa-file-powerpoint-o': 'document/presentation', + 'fa-file-word-o': 'office document/texte', + 'fa-file-excel-o': 'office document/tableur', + 'fa-file-powerpoint-o': 'office document/presentation', } %} {% set label = type %} diff --git a/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtension.php b/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtension.php index 600f3cbdd..94c354336 100644 --- a/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtension.php +++ b/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtension.php @@ -31,10 +31,7 @@ class WopiEditTwigExtension extends AbstractExtension public function getFunctions(): array { return [ - new TwigFunction('chill_document_is_editable', [WopiEditTwigExtensionRuntime::class, 'isEditable'], [ - 'needs_environment' => true, - 'is_safe' => ['html'], - ]), + new TwigFunction('chill_document_is_editable', [WopiEditTwigExtensionRuntime::class, 'isEditable']), ]; } diff --git a/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtensionRuntime.php b/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtensionRuntime.php index 552ed483e..e8937232e 100644 --- a/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtensionRuntime.php +++ b/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtensionRuntime.php @@ -36,18 +36,18 @@ class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface ]); } - public function isEditable(Environment $environment, StoredObject $document): bool + public function isEditable(StoredObject $document): bool { $mime_type = $this->discovery->discoverMimeType($document->getType()); - if (empty($mime_type)) { + if ([] === $mime_type) { return false; } - if (array_key_exists('default', $mime_type[0]) - && $mime_type[0]['default'] === 'true' - ) { - return true; + foreach ($mime_type as $item) { + if (array_key_exists('default', $item) && $item['default'] === 'true') { + return true; + } } return false;