From: Vincent Vanwaelscappel Date: Fri, 24 Feb 2023 11:03:56 +0000 (+0100) Subject: wait #5456 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c2009dde53575b1f8cd5833102b559ca0dc68c65;p=fluidbook-toolbox.git wait #5456 @0.5 --- diff --git a/app/Fluidbook/Links.php b/app/Fluidbook/Links.php index 44c16e861..0f76aa7e5 100644 --- a/app/Fluidbook/Links.php +++ b/app/Fluidbook/Links.php @@ -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); + } } diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPublication/CloneOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPublication/CloneOperation.php index 85b2cab85..f14ed6d65 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPublication/CloneOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPublication/CloneOperation.php @@ -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', diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index d081e98a3..73d332633 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -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()