From 4a6bac854692c3641fbed7ca9be8a037c57d3805 Mon Sep 17 00:00:00 2001 From: Mike Ng Date: Mon, 19 Mar 2018 17:52:57 +0400 Subject: [PATCH 1/2] wip write video chapters --- .../Controller/Prod/ToolsController.php | 26 +++++++++++++++++++ .../Phrasea/ControllerProvider/Prod/Tools.php | 4 +++ .../web/prod/actions/Tools/index.html.twig | 1 + 3 files changed, 31 insertions(+) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php index 34ddb7e84a..63b5cd0917 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php @@ -54,6 +54,7 @@ class ToolsController extends Controller /** @Ignore */ $JSFields[$meta->get_id()] = [ + 'id' => $meta->get_id(), 'name' => $meta->get_name(), '_value' => $record->getCaption([$meta->get_name()]), ]; @@ -442,4 +443,29 @@ class ToolsController extends Controller unset($media); $this->getFilesystem()->remove($fileName); } + + /** + * @param $request + * @return \Symfony\Component\HttpFoundation\JsonResponse + */ + public function saveMetasAction(Request $request) + { + $record = new \record_adapter($this->app, + (int)$request->request->get("databox_id"), + (int)$request->request->get("record_id")); + + $metadatas[0] = [ + 'meta_struct_id' => (int)$request->request->get("meta_struct_id"), + 'meta_id' => '', + 'value' => $request->request->get("value") + ]; + try { + $record->set_metadatas($metadatas); + } + catch (Exception $e) { + return $this->app->json(['success' => false, 'errorMessage' => $e->getMessage()]); + } + + return $this->app->json(['success' => true, 'errorMessage' => '']); + } } diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Prod/Tools.php b/lib/Alchemy/Phrasea/ControllerProvider/Prod/Tools.php index b49e8dda86..dfef3af2e6 100644 --- a/lib/Alchemy/Phrasea/ControllerProvider/Prod/Tools.php +++ b/lib/Alchemy/Phrasea/ControllerProvider/Prod/Tools.php @@ -69,6 +69,10 @@ class Tools implements ControllerProviderInterface, ServiceProviderInterface $controllers->post('/sharing-editor/{base_id}/{record_id}/', 'controller.prod.tools:editRecordSharing'); + $controllers->post('/metadata/save/', 'controller.prod.tools:saveMetasAction') + ->bind('prod_tools_metadata_save'); + + return $controllers; } } diff --git a/templates/web/prod/actions/Tools/index.html.twig b/templates/web/prod/actions/Tools/index.html.twig index f564f3d543..7ca006134e 100644 --- a/templates/web/prod/actions/Tools/index.html.twig +++ b/templates/web/prod/actions/Tools/index.html.twig @@ -358,6 +358,7 @@ var toolsConfig = { selectionLength: {{ selectionLength }}, databaseId: {% if selectionLength == 1%}{{record.get_base_id}}{% else %}0{% endif %}, + databoxId: {% if selectionLength == 1 %}{{ record.get_sbas_id() }}{% else %}0{% endif %}, recordId: {% if selectionLength == 1%}{{record.get_record_id}}{% else %}0{% endif %}, translations: { alertTitle: '{{ "alert" | trans }}', From 3cdaf5400febe9c7201daa9095d0fde951a9c7c3 Mon Sep 17 00:00:00 2001 From: Mike Ng Date: Tue, 20 Mar 2018 12:03:28 +0400 Subject: [PATCH 2/2] fix issue with video preview --- templates/web/common/thumbnail.html.twig | 9 ++++++--- templates/web/prod/actions/Tools/index.html.twig | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/templates/web/common/thumbnail.html.twig b/templates/web/common/thumbnail.html.twig index ba3d6c77cd..165e034046 100644 --- a/templates/web/common/thumbnail.html.twig +++ b/templates/web/common/thumbnail.html.twig @@ -13,7 +13,8 @@
+ data-kind="video" + data-src="{{ url('alchemy_embed_view', {url: url|trim, autoplay: autoplay|default('false') }) }}"> @@ -22,7 +23,8 @@
+ data-kind="document" + data-src="{{ url('alchemy_embed_view', {url: url|trim, autoplay: autoplay|default('false') }) }}"> @@ -31,7 +33,8 @@
+ data-kind="audio" + data-src="{{ url('alchemy_embed_view', {url: url|trim, autoplay: autoplay|default('false') }) }}"> diff --git a/templates/web/prod/actions/Tools/index.html.twig b/templates/web/prod/actions/Tools/index.html.twig index 7ca006134e..053fa20875 100644 --- a/templates/web/prod/actions/Tools/index.html.twig +++ b/templates/web/prod/actions/Tools/index.html.twig @@ -364,7 +364,8 @@ alertTitle: '{{ "alert" | trans }}', noImgSelected: '{{ "no image selected" | trans }}', processing: '{{ "processing" | trans }}', - thumbnailTitle: '{{ 'thumbnail validation' | trans }}' + thumbnailTitle: '{{ 'thumbnail validation' | trans }}', + updateTitle: '{{ 'Successful update' | trans }}' }, T_fields: {{ JSonFields|raw }}, videoEditorConfig: {% if videoEditorConfig is not null %}{{ videoEditorConfig|json_encode()|raw }}{% else %}{}{% endif %},