From acffc06771ac3237c54a05459542b58f991cea25 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 27 Jun 2023 13:55:13 +0200 Subject: [PATCH] wait #6088 @0.5 --- app/Jobs/FluidbookCollectionDownload.php | 42 +++++++++++++++++------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/app/Jobs/FluidbookCollectionDownload.php b/app/Jobs/FluidbookCollectionDownload.php index 809cf6694..548b76c73 100644 --- a/app/Jobs/FluidbookCollectionDownload.php +++ b/app/Jobs/FluidbookCollectionDownload.php @@ -41,7 +41,16 @@ class FluidbookCollectionDownload extends DownloadBase $translateVariables['server'] = $server->name; $url = $this->install($dest, $server); - $this->sendNotification(__('Collection ":title" (#:nb) installée sur le serveur :server', $translateVariables), __('La collection ":title" a été installée sur le serveur :server', $translateVariables), [__('Voir sur :server', $translateVariables) => $url]); + if ($this->entry->type === 'export') { + $actions = []; + $paths = $this->getPublicationsPaths($this->entry->getPageData()); + foreach ($paths as $fbid => $path) { + $actions[$this->_getFluidbookTitle($fbid)] = $url . '/' . $path; + } + } else { + $actions = [__('Voir sur :server', $translateVariables) => $url]; + } + $this->sendNotification(__('Collection ":title" (#:nb) installée sur le serveur :server', $translateVariables), __('La collection ":title" a été installée sur le serveur :server', $translateVariables), $actions); } else if ($this->action === 'export' && in_array($this->entry->version, ['win_inss_html', 'win_ins_html'])) { $url = $this->downloadList($this->entry->getPageData()); $this->sendNotification(__($this->_subject, $translateVariables), __($this->_text, $translateVariables), [__('Télécharger') => $url]); @@ -286,26 +295,37 @@ class FluidbookCollectionDownload extends DownloadBase * @return void * @throws \Exception */ - protected function compileExport($data, $path) + protected function compileExport($data, $basePath) { $options = $this->getCollectionGlobalSettings(); - $zipmerge = in_array($data->version, ['online', 'scorm', 'sharepoint', 'precompiled', 'win_exe_html', 'win_html', 'win_cd_html', 'mac_exe_html']); + $jobs = []; + $paths = $this->getPublicationsPaths($data); + foreach ($paths as $fbid => $path) { + $dest = $basePath . $path; + $jobs[] = $this->_jobDownloadFluidbook($fbid, $data->version, $dest, $options); + } + + $this->_waitJobs($jobs); + } + + protected function getPublicationsPaths($data, $attr = 'dir') + { + $zipmerge = in_array($data->version, ['online', 'scorm', 'sharepoint', 'precompiled', 'win_exe_html', 'win_html', 'win_cd_html', 'mac_exe_html']); + $res = []; foreach ($data->publications as $publication) { $fbid = $publication['fluidbook']; - $dest = $path; - if ($publication['export']) { - $dest .= $publication['export']; + if ($publication[$attr]) { + $path = $publication[$attr]; } else { - $dest .= Str::slug($this->_getFluidbookTitle($fbid)); + $path = Str::slug($this->_getFluidbookTitle($fbid)); } if (!$zipmerge) { - $dest .= '.exe'; + $path .= '.exe'; } - - $jobs[] = $this->_jobDownloadFluidbook($fbid, $data->version, $dest, $options); + $res[$fbid] = $path; } - $this->_waitJobs($jobs); + return $res; } -- 2.39.5