From 4c6f04f73ca589e57aa7261733fe2387d8fca4f3 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 13 Jan 2023 13:47:44 +0100 Subject: [PATCH] wip #5397 @3 --- app/Console/Kernel.php | 4 +- app/Fluidbook/Links.php | 2 +- app/Fluidbook/PDF.php | 2 +- app/Models/Traits/PublicationSettings.php | 99 ++++++------------- .../fluidbook_publication/download.blade.php | 25 ++++- 5 files changed, 55 insertions(+), 77 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 2106f1a8b..0be0d13be 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -24,13 +24,13 @@ class Kernel extends \Cubist\Backpack\Console\Kernel */ protected function schedule(Schedule $schedule) { - parent::schedule($schedule); + $schedule->command('cubist:magic:precache')->everyFiveMinutes(); $schedule->command('job:dispatch ProcessTotals')->everyTwoHours(); $schedule->command('fluidbook:farm:ping')->everyMinute(); $schedule->command('fluidbook:player:updatesources')->everyTwoHours(); - + $schedule->command('ws:migrate --publications=v2 --documents=missing')->dailyAt('1:00'); } /** diff --git a/app/Fluidbook/Links.php b/app/Fluidbook/Links.php index e63e59307..8943c5a84 100644 --- a/app/Fluidbook/Links.php +++ b/app/Fluidbook/Links.php @@ -142,7 +142,7 @@ class Links } $dir = self::getLinksDir($book_id); - $file = $dir . '/' . $time . '.links3.gz'; + $file = Files::firstThatExists($dir . '/' . $time . '.links3.gz', $dir . '/' . $time . '.links.gz'); if ($time === 'latest' && !file_exists($file)) { $versions = self::getLinksVersions($book_id); foreach ($versions as $version => $m) { diff --git a/app/Fluidbook/PDF.php b/app/Fluidbook/PDF.php index 36a1bc2b0..8a1523061 100644 --- a/app/Fluidbook/PDF.php +++ b/app/Fluidbook/PDF.php @@ -172,7 +172,7 @@ class PDF $pdftk = new CommandLine('pdftk'); $pdftk->setManualArg($args); $pdftk->execute(); - self::copy($normalPDF, $cached, false); + self::copy($originalPDF, $cached, false); } } } diff --git a/app/Models/Traits/PublicationSettings.php b/app/Models/Traits/PublicationSettings.php index 1f7322c7a..88b9b76ef 100644 --- a/app/Models/Traits/PublicationSettings.php +++ b/app/Models/Traits/PublicationSettings.php @@ -24,6 +24,25 @@ use Cubist\Backpack\Magic\Fields\Textarea; */ trait PublicationSettings { + /** + * @return array[] + */ + public static function getDownloadVersions() + { + return [ + 'online' => ['label' => __('Version online - Version par défaut'), 'default' => true], + 'sharepoint' => ['label' => __('Version Sharepoint - Version par défaut'), 'default' => false], + 'scorm' => ['label' => __('Version SCORM - Version par défaut'), 'default' => false], + 'win_inss_html' => ['label' => __('Version offline - Executable Windows'), 'default' => false], + 'win_ins_html' => ['label' => __('Version offline - Installeur Auto-executable Windows'), 'default' => false], + 'win_exe_html' => ['label' => __('Version offline - ZIP Windows'), 'default' => false], + 'mac_exe_html' => ['label' => __('Version offline - Exécutable Mac OS X'), 'default' => false], + 'win_cd_html' => ['label' => __('Version offline - CD-ROM / Clé USB'), 'default' => false], + 'win_html' => ['label' => __('Version offline - HTML (Non adaptée à l\'installation sur un serveur web)'), 'default' => false], + 'precompiled' => ['label' => __('Version precompilée'), 'default' => false], + ]; + } + public function setSettingsFields() { $acceptImages = ['.svg', '.jpg', '.jpeg', '.png', '.gif']; @@ -2953,76 +2972,16 @@ L,index', ]); $this->addField('section_downloads', FormSection::class, $this->__('Versions disponibles au téléchargement')); - $this->addField('download_online', Checkbox::class, $this->__('Version online - Version par défaut'), [ - 'v2' => '{"type":"boolean","editable":true,"default":true,"label":"\\u00a7!\\u00a7Version online - Version par d\\u00e9faut!\\u00a7!","grade":3}', - 'default' => true, - 'fake' => true, - 'store_in' => 'settings', - 'translatable' => false, - ]); - $this->addField('download_sharepoint', Checkbox::class, $this->__('Version Sharepoint - Version par défaut'), [ - 'v2' => '{"type":"boolean","editable":true,"default":false,"label":"\\u00a7!\\u00a7Version Sharepoint - Version par d\\u00e9faut!\\u00a7!","grade":3}', - 'default' => false, - 'fake' => true, - 'store_in' => 'settings', - 'translatable' => false, - ]); - $this->addField('download_scorm', Checkbox::class, $this->__('Version SCORM - Version par défaut'), [ - 'v2' => '{"type":"boolean","editable":true,"default":false,"label":"\\u00a7!\\u00a7Version SCORM - Version par d\\u00e9faut!\\u00a7!","grade":3}', - 'default' => false, - 'fake' => true, - 'store_in' => 'settings', - 'translatable' => false, - ]); - $this->addField('download_win_inss_html', Checkbox::class, $this->__('Version offline - Executable Windows'), [ - 'v2' => '{"type":"boolean","editable":true,"default":false,"label":"\\u00a7!\\u00a7Version offline - Executable Windows!\\u00a7!","grade":3}', - 'default' => false, - 'fake' => true, - 'store_in' => 'settings', - 'translatable' => false, - ]); - $this->addField('download_win_ins_html', Checkbox::class, $this->__('Version offline - Installeur Auto-executable Windows'), [ - 'v2' => '{"type":"boolean","editable":true,"default":false,"label":"\\u00a7!\\u00a7Version offline - Installeur Auto-executable Windows!\\u00a7!","grade":3}', - 'default' => false, - 'fake' => true, - 'store_in' => 'settings', - 'translatable' => false, - ]); - $this->addField('download_win_exe_html', Checkbox::class, $this->__('Version offline - ZIP Windows'), [ - 'v2' => '{"type":"boolean","editable":true,"default":false,"label":"\\u00a7!\\u00a7Version offline - ZIP Windows!\\u00a7!","grade":3}', - 'default' => false, - 'fake' => true, - 'store_in' => 'settings', - 'translatable' => false, - ]); - $this->addField('download_mac_exe_html', Checkbox::class, $this->__('Version offline - Exécutable Mac OS X'), [ - 'v2' => '{"type":"boolean","editable":true,"default":false,"label":"\\u00a7!\\u00a7Version offline - Ex\\u00e9cutable Mac OS X!\\u00a7!","grade":3}', - 'default' => false, - 'fake' => true, - 'store_in' => 'settings', - 'translatable' => false, - ]); - $this->addField('download_win_cd_html', Checkbox::class, $this->__('Version offline - CD-ROM / Clé USB'), [ - 'v2' => '{"type":"boolean","editable":true,"default":false,"label":"\\u00a7!\\u00a7Version offline - CD-ROM \\/ Cl\\u00e9 USB!\\u00a7!","grade":3}', - 'default' => false, - 'fake' => true, - 'store_in' => 'settings', - 'translatable' => false, - ]); - $this->addField('download_win_html', Checkbox::class, $this->__('Version offline - HTML (Non adaptée à l\'installation sur un serveur web)'), [ - 'v2' => '{"type":"boolean","editable":true,"default":false,"label":"\\u00a7!\\u00a7Version offline - HTML (Non adapt\\u00e9e \\u00e0 l\'installation sur un serveur web)!\\u00a7!","grade":3}', - 'default' => false, - 'fake' => true, - 'store_in' => 'settings', - 'translatable' => false, - ]); - $this->addField('download_precompiled', Checkbox::class, $this->__('Version precompilée'), [ - 'v2' => '{"type":"boolean","editable":true,"default":false,"label":"\\u00a7!\\u00a7Version precompil\\u00e9e!\\u00a7!","grade":3}', - 'default' => false, - 'fake' => true, - 'store_in' => 'settings', - 'translatable' => false, - ]); + + foreach (self::getDownloadVersions() as $name=>$downloadVersion) { + $this->addField('download_'.$name, Checkbox::class, $downloadVersion['label'], [ + 'v2' => json_encode(['type'=>'boolean','editable'=>true,'default'=>$downloadVersion['default'],'label'=>$downloadVersion['label'],'grade'=>3]), + 'default' => $downloadVersion['default'], + 'fake' => true, + 'store_in' => 'settings', + 'translatable' => false, + ]); + } $this->addField('section_elearning', FormSuperSection::class, __('E-Learning')); $this->addField('section_gamify', FormSection::class, $this->__('Gamification')); diff --git a/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php b/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php index 06d54e4fb..33e1e9fe3 100644 --- a/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php +++ b/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php @@ -1,4 +1,23 @@ - + [ + 'label'=>__('Page de téléchargement'), + 'url'=>$crud->route.'/delivery/'.$entry->id.'_'.$entry->hash, + ], + ]; + foreach (\App\Models\FluidbookPublication::getDownloadVersions() as $k=>$v) { + if(can('fluidbook-publication:download:all-versions') || $entry->{'download_'.$k}){ + $actions['download_'.$k]=['label'=>$v['label'],'url'=>$crud->route.'/download/'.$entry->id.'/'.$k]; + } + } + +@endphp + + {{__('Télécharger')}} - + title="{{__('Télécharger la publication')}}" + data-context-actions="{{json_encode($actions)}}" + data-context-route="{{$crud->route}}/$id/edit/$action" + data-context-id="{{$entry->getKey()}}" +> {{__('Télécharger')}} -- 2.39.5