]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7600 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 3 Jul 2025 11:40:20 +0000 (13:40 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 3 Jul 2025 11:40:20 +0000 (13:40 +0200)
app/Models/ELearningMedia.php

index 0fdf3b9629e3207e0f227ba705848919303b717e..cdcd4c8b8ed2b9c64e7e024df3a7058ed531c777 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace App\Models;
 
+use App\Fields\ElearningLocale;
 use App\Fields\SCORMVersion;
 use App\Http\Controllers\Admin\Operations\ChangeownerOperation;
 use App\Http\Controllers\Admin\Operations\ELearningMedia\ImportOperation;
@@ -47,6 +48,7 @@ class ELearningMedia extends ToolboxModel
 
         $this->addHashField();
 
+
         $this->addField(['name' => 'client',
             'label' => __('Nom du client'),
             'type' => 'Text',
@@ -61,6 +63,13 @@ class ELearningMedia extends ToolboxModel
             'column_label' => __('Projet')
         ]);
 
+        $this->addField(['name' => 'locale',
+            'label' => __('Langue'),
+            'type' => ElearningLocale::class,
+            'default' => 'en',
+            'column' => true,
+            'column_label' => '<i class="fa fa-language"></i>']);
+
         $this->addField('type', Hidden::class, __('Type'), ['column' => true]);
         $this->addField('title', Text::class, __('Titre'), ['column' => true]);
         $this->addField(['name' => 'scorm_version',
@@ -81,14 +90,14 @@ class ELearningMedia extends ToolboxModel
         $this->addField('complete_pct', Percent::class, __('Marquer terminé quand ce pourcentage est lu'), ['default' => 75, 'when' => ['complete_button' => 0, 'type' => ['logical_operator' => 'OR', 'values' => ['video', 'audio']]]]);
     }
 
-    public function preSave()
+    public function onSaving(): bool
     {
         $file = $this->getMediaInField('file')->first();
         if ($file !== null) {
             $spl = new \SplFileInfo($file->getPath());
             $this->setAttribute('type', self::getType($spl->getExtension()));
         }
-        return parent::preSave();
+        return parent::onSaving();
     }
 
     public static function getType($ext)
@@ -149,7 +158,7 @@ class ELearningMedia extends ToolboxModel
             $vdir->file_put_contents('pdfjs/web/viewer.css', $css);
         }
         $vdir->copy($file, 'media.' . $ext);
-        $vdir->file_put_contents('index.html', view('elearningmedia.index', ['complete_pct' => $complete_pct,'title' => $title, 'type' => $type]));
+        $vdir->file_put_contents('index.html', view('elearningmedia.index', ['complete_pct' => $complete_pct, 'title' => $title, 'type' => $type]));
         $vdir->sync(true);
         return $title;
     }