]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6088 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 27 Jun 2023 11:55:13 +0000 (13:55 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 27 Jun 2023 11:55:13 +0000 (13:55 +0200)
app/Jobs/FluidbookCollectionDownload.php

index 809cf6694dbc00ed6f18e5753aacb67195806967..548b76c733a370e0c39a6826bc50329bb9fdf39d 100644 (file)
@@ -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;
     }