]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6188 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 25 Sep 2023 14:05:58 +0000 (16:05 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 25 Sep 2023 14:05:58 +0000 (16:05 +0200)
app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php
resources/views/fields/fluidbook_composition.blade.php

index dc2e1af1444ef2c414145e7dfe2dc6de58f234eb..25e530cdb3cd921e55f8dc3ddfe13bc7ceb96c03 100644 (file)
@@ -24,24 +24,28 @@ trait CompositionOperation
         Route::match(['post'], $segment . '/uploaddocument', $controller . '@upload');
         Route::match(['get'], $segment . '/uploadProgress/{uploadID}', $controller . '@uploadProgress');
         Route::match(['get'], $segment . '/docInfos/{doc_id}', $controller . '@docInfos');
-        Route::match(['get'], $segment . '/{fluidbook_id}/{type}/{page}.txt', $controller . '@getPageText');
+        Route::match(['get'], $segment . '/{fluidbook_id}/{type}/{page}.{ext}', $controller . '@getPageAsset');
     }
 
     protected function setupCompositionDefaults()
     {
     }
 
-    protected function getPageText($fluidbook_id, $type, $page)
+    protected function getPageAsset($fluidbook_id, $type, $page, $ext)
     {
-        $types = ['texts' => FluidbookDocument::TEXT_PLAIN, 'index' => FluidbookDocument::TEXT_INDEX, 'layout' => FluidbookDocument::TEXT_LAYOUT];
-        if (!isset($types[$type])) {
-            abort(404, 'Text type not found');
-        }
         if (!FluidbookPublication::hasPermission($fluidbook_id)) {
             abort(401);
         }
         /** @var FluidbookPublication $fb */
         $fb = FluidbookPublication::withoutGlobalScopes()->find($fluidbook_id);
+        if ($type === 'originalpdf') {
+            $doc = $fb->getDocument($page);
+            return XSendFileController::sendfile(protected_path('fluidbookpublication/docs/' . $doc->id . '/original.pdf'), 86400, ['Content-Disposition', 'attachment; filename="' . $doc->id . '.pdf"']);
+        }
+        $types = ['texts' => FluidbookDocument::TEXT_PLAIN, 'index' => FluidbookDocument::TEXT_INDEX, 'layout' => FluidbookDocument::TEXT_LAYOUT];
+        if (!isset($types[$type])) {
+            abort(404, 'Text type not found');
+        }
         $contentType = 'text/plain';
         if ($type == FluidbookDocument::TEXT_LAYOUT) {
             $path = $fb->getHightlightFile($page);
index 896d0a88bbe910d6a4118d2d5c6ef72f03b1a8cc..88015880b38775343f45920d1a3774a765000e0c 100644 (file)
                         foldsee: {
                             name: "{{__('Visualiser')}}",
                             items: {
+                                originalpdf: {
+                                    name: "{{__('PDF Original')}}",
+                                    callback: function (key, opt) {
+                                        window.open('/fluidbook-publication/' + {{$entry->id}} + '/originalpdf/' + ($(opt.$trigger[0]).index() + 1) + '.pdf');
+                                    },
+                                },
                                 seetexts: {
                                     name: "{{__('Textes extraits')}}",
                                     callback: function (key, opt) {