]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5456 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 24 Feb 2023 11:03:56 +0000 (12:03 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 24 Feb 2023 11:03:56 +0000 (12:03 +0100)
app/Fluidbook/Links.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/CloneOperation.php
app/Models/FluidbookPublication.php

index 44c16e8618a9e0be48442d7b6c389b0af3dc4cab..0f76aa7e5de1d1900fddca2cca3ba6b350b0d60b 100644 (file)
@@ -37,7 +37,7 @@ class Links
             'video_loop' => __('Video : boucle'), 'video_auto_start' => __('Video : démarrage automatique'), 'video_controls' => __('Vidéo : afficher les contrôles'), 'video_sound_on' => __('Vidéo : activer le son'),
             'inline' => __('Vidéo : afficher dans la page'), 'video_width' => __('Vidéo : Largeur du popup'), 'video_height' => __('Vidéo : Hauteur du popup'),
             'interactive' => __('Interactivité'), 'video_service' => __('Webvideo : service'),
-            'close_button'=>__('Bouton de fermeture'),
+            'close_button' => __('Bouton de fermeture'),
             'extra' => __('Paramètre supplémentaire'),
             'alternative' => __('Alternative'),
             'read_mode' => __('Mode de lecture'),
@@ -483,4 +483,10 @@ class Links
         }
         return $randstring;
     }
+
+    public static function copy($source, $dest, $sourceVersion = 'latest')
+    {
+        self::getLinksAndRulers($source, $links, $rulers, $sourceVersion);
+        self::saveLinksInFile($dest, backpack_user()->id, __('Copier les liens à partir du fluidbook :fluidbook', ['fluidbook' => $source]), $links, $rulers);
+    }
 }
index 85b2cab8575acf6e4e30621ceab92b7d4e333ad4..f14ed6d65699497e8b7d1b1b1f2b305c4e43b9f4 100644 (file)
@@ -15,7 +15,7 @@ trait CloneOperation
      */
     protected function setupCloneRoutes($segment, $routeName, $controller)
     {
-        Route::post($segment . '/{id}/clone/{action}', [
+        Route::get($segment . '/{id}/clone/{action}', [
             'as' => $routeName . '.clone',
             'uses' => $controller . '@clone',
             'operation' => 'clone',
index d081e98a3fa02461e4b4118146a1a78b0229dd58..73d33263300868fef72bddf395bcca5787b11ff3 100644 (file)
@@ -34,6 +34,7 @@ use Cubist\Util\Files\Files;
 use Cubist\Util\Graphics\Image;
 use Cubist\Util\Json;
 use Datetime;
+
 // __('!!Paramètres des fluidbooks')
 class FluidbookPublication extends ToolboxSettingsModel
 {
@@ -464,7 +465,7 @@ class FluidbookPublication extends ToolboxSettingsModel
         return true;
     }
 
-    public function replicate(array $except = null)
+    protected function _baseReplicate(array $except = null)
     {
         $new = parent::replicate($except);
         if (backpack_user()) {
@@ -473,38 +474,42 @@ class FluidbookPublication extends ToolboxSettingsModel
         $new->status = -1;
         $new->title = __('Copie de :title', ['title' => $new->title]);
         $new->visits_counter = 0;
+        return $new;
+    }
+
+    public function replicate(array $except = null)
+    {
+        $new = $this->_baseReplicate($except);
         $new->save();
 
-        // Todo copy links
+        // Copy links & assets
+        Links::copy($this->id, $new->id);
+        $this->_replicateMedia($new->id);
 
         return $new;
     }
 
     public function replicateSettings(array $except = null)
     {
-        $new = parent::replicate($except);
-        if (backpack_user()) {
-            $new->owner = backpack_user()->id;
-        }
-        $new->status = -1;
-        $new->title = __('Copie de :title', ['title' => $new->title]);
+        $new = $this->_baseReplicate($except);
         $new->composition = [];
-        $new->visits_counter = 0;
         $new->save();
 
-        // Todo copy assets
+        // Copy assets
+        $this->_replicateMedia($new->id);
 
         return $new;
     }
 
+
     protected function _replicateMedia($newId)
     {
-        $from = protected_path('fluidbookpublication/working/' . $this->id . '/') . '*';
+        $from = protected_path('fluidbookpublication/working/' . $this->id . '/');
         if (!file_exists($from)) {
             return;
         }
         $to = Files::mkdir(protected_path('fluidbookpublication/working/' . $newId . '/'));
-        `cp -r $from $to`;
+        `cp -Rs $from* $to`;
     }
 
     public function incrementPreviewVisit()