--- /dev/null
+<?php
+
+namespace App\Http\Controllers\Admin\Operations\FluidbookPublication;
+
+use Illuminate\Support\Facades\Route;
+
+trait CloneOperation
+{
+ /**
+ * Define which routes are needed for this operation.
+ *
+ * @param string $segment Name of the current entity (singular). Used as first URL segment.
+ * @param string $routeName Prefix of the route name.
+ * @param string $controller Name of the current CrudController.
+ */
+ protected function setupCloneRoutes($segment, $routeName, $controller)
+ {
+ Route::post($segment . '/{id}/clone/{action}', [
+ 'as' => $routeName . '.clone',
+ 'uses' => $controller . '@clone',
+ 'operation' => 'clone',
+ ]);
+ }
+
+ /**
+ * Add the default settings, buttons, etc that this operation needs.
+ */
+ protected function setupCloneDefaults()
+ {
+ $this->crud->allowAccess('clone');
+
+ $this->crud->operation('clone', function () {
+ $this->crud->loadDefaultOperationSettingsFromConfig();
+ });
+
+ $this->crud->operation(['list', 'show'], function () {
+ $this->crud->addButton('line', 'clone', 'view', 'crud::buttons.fluidbook_publication.clone', 'end');
+ });
+ }
+
+ /**
+ * Create a duplicate of the current entry in the datatabase.
+ *
+ * @param int $id
+ * @return Response
+ */
+ public function clone($id, $action)
+ {
+ $this->crud->hasAccessOrFail('clone');
+
+ $entry=$this->crud->model->findOrFail($id);
+ if ($action === 'complete') {
+ $clonedEntry = $entry->replicate();
+ } else {
+ $clonedEntry = $entry->replicateSettings();
+ }
+
+ return (string)$clonedEntry->push();
+ }
+}
$nointerface = !!request('nointerface', false);
$shortLoading = !!request('shortLoading', false);
+ self::_getFluidbookAndTheme($id, $hash, $fluidbook, $theme);
+
+
+
+ $check = $this->_checkDemoLinkAuth($fluidbook);
+ if ($check !== true) {
+ return $check;
+ }
+
if (null === $time || ((null === $path || $path === 'index.html') && $time < (time() - 60) && !$nointerface && !$shortLoading)) {
$v = ($version === 'online') ? '' : $version . '/';
$url = backpack_url($segment . '/preview/' . $v . $id . '_' . $hash . '_' . time()) . '/' . $q;
return $this->loadingCompile($url, $id, $hash);
}
- self::_getFluidbookAndTheme($id, $hash, $fluidbook, $theme);
- $check = $this->_checkDemoLinkAuth($fluidbook);
- if ($check !== true) {
- return $check;
- }
return $this->preview($version, $fluidbook, $theme, $path);
}
use App\Fields\User;
use App\Fluidbook\Farm;
use App\Fluidbook\Links;
+use App\Http\Controllers\Admin\Operations\FluidbookPublication\CloneOperation;
use App\Http\Controllers\Admin\Operations\FluidbookPublication\CompositionOperation;
use App\Http\Controllers\Admin\Operations\FluidbookPublication\DeletefbOperation;
use App\Http\Controllers\Admin\Operations\FluidbookPublication\DownloadOperation;
use App\Models\Traits\PublicationSettings;
use App\Models\Traits\SCORMVersionTrait;
use App\Slack\Slack;
-use Backpack\CRUD\app\Http\Controllers\Operations\CloneOperation;
use Backpack\CRUD\app\Library\Widget;
use Cubist\Backpack\Magic\Fields\FormBigSection;
use Cubist\Backpack\Magic\Fields\FormSuperSection;
use Cubist\Util\Files\Files;
use Cubist\Util\Graphics\Image;
use Cubist\Util\Json;
-use Cubist\Util\ObjectUtil;
use Datetime;
// __('!!Paramètres des fluidbooks')
class FluidbookPublication extends ToolboxSettingsModel
}
public function replicate(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->visits_counter = 0;
+ $new->save();
+
+ // Todo copy links
+
+ return $new;
+ }
+
+ public function replicateSettings(array $except = null)
{
$new = parent::replicate($except);
if (backpack_user()) {
$new->composition = [];
$new->visits_counter = 0;
$new->save();
+
+ // Todo copy assets
+
return $new;
}
--- /dev/null
+{{-- __('!! Paramètres des fluidbooks') --}}
+@php
+
+ $base=$crud->route.'/'.$entry->id;
+ $actions=[
+ 'settings'=>
+ [
+ 'label'=>__('Uniquement les paramètres et assets'),
+
+ ],
+ 'complete'=>
+ [
+ 'label'=>__('Pages, liens, paramètres et assets'),
+ ],
+ ];
+
+@endphp
+
+<a class="btn btn-sm btn-link" href="#"
+ data-toggle="tooltip"
+ title="{{__('Cloner la publication')}}"
+ data-context-actions="{{json_encode($actions)}}"
+ data-context-route="{{$crud->route}}/$id/clone/$action"
+ data-context-id="{{$entry->getKey()}}"
+><i class="la la-copy"></i> {{__('Cloner')}}</a>