]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7112 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 1 Oct 2024 17:04:53 +0000 (19:04 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 1 Oct 2024 17:04:53 +0000 (19:04 +0200)
app/Fluidbook/Compiler/Compiler.php
app/Fluidbook/Packager/Download.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php
app/Models/Traits/PublicationSettings.php

index aef9062f68767fa7bf7b2365efecf9e9397b3ca9..5ff82878d6192899724d19e0852ff960e6059ff1 100644 (file)
@@ -1503,6 +1503,9 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
             }
         }
 
+        // Loadbalancer
+        $this->config->hosting_loadbalancer_ignore = Text::explodeNewLines($this->config->hosting_loadbalancer_ignore);
+
         $this->config->content_lock = $this->content_lock;
     }
 
index 914ea654986c34d357458da632c6e484fb5608a1..cc92348a9110d2125d39545af022cc3eaa9f8051 100644 (file)
@@ -91,66 +91,69 @@ class Download extends DownloadBase
     {
         App::setLocale($this->user->preferredLocale());
         $res = [];
-  //      try {
-            $url = $this->_compileandpackage();
-            $translateVariables = ['title' => $this->_title(), 'nb' => $this->_id()];
-
-            $subject = __($this->_subject, $translateVariables);
-            $text = __($this->_text, $translateVariables);
-            $showTextIfNotEmail = false;
-            $actions = [];
-            if ($this->action === 'download' || $this->action === 'scormcloud') {
-                $actions = [__('Télécharger') => $url];
-                $res[] = $url;
-
-                if ($this->action === 'scormcloud') {
-                    try {
-                        $scormURL = ScormCloud::send($url, env('SCORM_CLOUD_PREFIX', 'toolbox_') . $this->type . '_' . $this->_id());
-                        $actions[__('Tester sur SCORM Cloud')] = $scormURL;
-                        $res[] = $url;
-                    } catch (\Exception $e) {
-                        Log::error($e);
-                        $text .= "\n\n" . __('Une erreur s\'est produite lors de l\'envoi sur SCORM Cloud (App ID :appid) : :error', ['error' => $e->getMessage(), 'appid' => env('SCORM_CLOUD_APP_ID')]);
-                        $showTextIfNotEmail = true;
-                    }
-                }
-            } else if ($this->action === 'install') {
-                $s = $this->entry->install_online;
-                $dest = Driver::cleanInstallDir($s['path']);
-                /** @var FluidbookExternalInstallServer $server */
-                $server = FluidbookExternalInstallServer::find($s['server']);
-                if (!$server) {
-                    throw new \Exception('No valid server defined for external installation');
-                }
-                if (!$dest && !$server->allows_root) {
-                    throw new \Exception('No path defined for external server installation : this server does not allow installing on root');
+        //      try {
+        $url = $this->_compileandpackage();
+        $translateVariables = ['title' => $this->_title(), 'nb' => $this->_id()];
+
+        $subject = __($this->_subject, $translateVariables);
+        $text = __($this->_text, $translateVariables);
+        $showTextIfNotEmail = false;
+        $actions = [];
+        if ($this->action === 'download' || $this->action === 'scormcloud') {
+            $actions = [__('Télécharger') => $url];
+            $res[] = $url;
+
+            if ($this->action === 'scormcloud') {
+                try {
+                    $scormURL = ScormCloud::send($url, env('SCORM_CLOUD_PREFIX', 'toolbox_') . $this->type . '_' . $this->_id());
+                    $actions[__('Tester sur SCORM Cloud')] = $scormURL;
+                    $res[] = $url;
+                } catch (\Exception $e) {
+                    Log::error($e);
+                    $text .= "\n\n" . __('Une erreur s\'est produite lors de l\'envoi sur SCORM Cloud (App ID :appid) : :error', ['error' => $e->getMessage(), 'appid' => env('SCORM_CLOUD_APP_ID')]);
+                    $showTextIfNotEmail = true;
                 }
+            }
+        } else if ($this->action === 'install') {
+            $s = $this->entry->install_online;
+            $dest = Driver::cleanInstallDir($s['path']);
+            /** @var FluidbookExternalInstallServer $server */
+            $server = FluidbookExternalInstallServer::find($s['server']);
+            if (!$server) {
+                throw new \Exception('No valid server defined for external installation');
+            }
+            if (!$dest && !$server->allows_root) {
+                throw new \Exception('No path defined for external server installation : this server does not allow installing on root');
+            }
 
-                $translateVariables['server'] = $server->name;
-                $subject = __($this->_installSubject, $translateVariables);
-                $text = __($this->_installText, $translateVariables);
-                $path = $this->_compileandpackage(false);
+            $translateVariables['server'] = $server->name;
+            $subject = __($this->_installSubject, $translateVariables);
+            $text = __($this->_installText, $translateVariables);
+            $path = $this->_compileandpackage(false);
 
-                /** @var Local $driver */
-                $driver = $server->getTransferDriver();
-                $driver->copy($path, $dest, false, false);
+            /** @var Local $driver */
+            $driver = $server->getTransferDriver();
+            $driver->copy($path, $dest, false, false);
 
-                $url = $server->makeURL($dest);
-                if (null !== $url) {
-                    $actions = [__('Voir sur :server', ['server' => $server->name]) => $url];
-                }
-                $res[] = $url;
-            } else if ($this->action === 'loadbalancer') {
-                $path = $this->_compileandpackage(false);
-                $dest = $this->entry->protected_path('fluidbookpublication/loadbalancer/' . $this->entry->id . '_' . $this->entry->hash . '/');
+            $url = $server->makeURL($dest);
+            if (null !== $url) {
+                $actions = [__('Voir sur :server', ['server' => $server->name]) => $url];
+            }
+            $res[] = $url;
+            if ($this->entry->hosting_loadbalancer) {
+                Download::dispatch($this->entry, $this->version, 'loadbalancer', $this->user, $this->_params);
+            }
+        } else if ($this->action === 'loadbalancer') {
+            $path = $this->_compileandpackage(false);
+            $dest = $this->entry->protected_path('fluidbookpublication/loadbalancer/' . $this->entry->id . '_' . $this->entry->hash . '/');
 
-                $rsync = new Rsync($path, $dest, true);
-                $rsync->execute();
-                $rsync->debug();
+            $rsync = new Rsync($path, $dest, true);
+            $rsync->execute();
+            $rsync->debug();
 
-                $subject = __($this->_loadbalancerSubject, $translateVariables);
-                $text = __($this->_loadbalancerText, $translateVariables);
-            }
+            $subject = __($this->_loadbalancerSubject, $translateVariables);
+            $text = __($this->_loadbalancerText, $translateVariables);
+        }
 //        } catch (\Exception $e) {
 //            $subject = __('Erreur lors de la compilation du :type :nb', ['nb' => $this->_id(), 'type' => $this->type]);
 //            $text = __('Détails de l\'erreur :message', ['message' => $e->getMessage() . ' at line ' . $e->getLine() . ' of ' . $e->getFile()]);
@@ -167,8 +170,8 @@ class Download extends DownloadBase
 
     protected function _compileandpackage($zip = true)
     {
-       // if ($this->entry->version == 3) {
-            $packager = Packager::package($this->entry->id, $this->version, $zip, true, $this->_params);
+        // if ($this->entry->version == 3) {
+        $packager = Packager::package($this->entry->id, $this->version, $zip, true, $this->_params);
 //        } else {
 //            $packager = new WorkshopPackager($this->entry->id, $this->version, null, $this->_params);
 //            $packager->zipPackage = $zip;
index 38b61ead386e004b03b8118f6e32e5030c1b08f7..64e1079abd7d771598eaa3936700b5cefc7a1fb6 100644 (file)
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Admin\Operations\FluidbookPublication;
 
 use App\Fluidbook\Packager\Download;
 use App\Http\Middleware\CheckIfAdmin;
-use App\Jobs\FluidbookSettingsExport;
 use App\Jobs\GenerateDeliveryThumbnailsPreview;
 use App\Models\FluidbookPublication;
 use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
index a049f478eff9a8fe45c9a00bc330ecfd4738b71c..0c0de8422ab38e028a87e238a20ddfebf5baaed6 100644 (file)
@@ -1995,6 +1995,7 @@ trait PublicationSettings
         $this->addSettingField('section_downloads', FormSection::class, $this->__('Versions disponibles au téléchargement'));
 
         $this->addSettingField('hosting_loadbalancer', Checkbox::class, $this->__('Hébergement "Load balancer"'));
+        $this->addSettingField('hosting_loadbalancer_ignore', Textarea::class, __('Ne pas charger ces éléments via le load balancer'), ['when' => ['hosting_loadbalancer' => 1], 'hint' => __('Certains contenus doivent accéder ne doivent pas se trouver sur un autre domaine pour fonctionner')]);
 
         foreach (self::getDownloadVersions() as $name => $downloadVersion) {
             $this->addSettingField('download_' . $name, Checkbox::class, $downloadVersion['label'], [