]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7821 @1:30
authorsoufiane <soufiane@cubedesigners.com>
Thu, 30 Oct 2025 17:12:07 +0000 (18:12 +0100)
committersoufiane <soufiane@cubedesigners.com>
Thu, 30 Oct 2025 17:12:07 +0000 (18:12 +0100)
app/Console/Commands/addFluidbookHemsleyToCollection.php [new file with mode: 0644]
app/Models/FluidbookCollection.php
app/Models/FluidbookPublication.php
app/SubForms/FluidbookAuditLinkButtons.php [new file with mode: 0644]

diff --git a/app/Console/Commands/addFluidbookHemsleyToCollection.php b/app/Console/Commands/addFluidbookHemsleyToCollection.php
new file mode 100644 (file)
index 0000000..6954e4a
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Console\Commands\Base\ToolboxCommand;
+use App\Models\FluidbookCollection;
+use App\Models\FluidbookAuditLink;
+use App\Models\FluidbookPublication;
+
+class addFluidbookHemsleyToCollection extends ToolboxCommand
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'fluidbook:fill-hemsley-collection {--sync}';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '';
+
+    /**
+     * Execute the console command.
+     */
+    public function handle()
+    {
+        //
+        //$f->generateThumbnailsPreview($this->option('sync', false));
+        $data = FluidbookPublication::getFluidbooksHemsley();
+        $instance = new FluidbookCollection();
+        $instance->updateHemsleyCollection($data);
+    }
+}
index 6b23c3a674d255c37b8f52c52009bcfe9f42c021..71d3df01c5689287581e00ff2d171d43a19926ef 100644 (file)
@@ -286,4 +286,22 @@ class FluidbookCollection extends ToolboxStatusModel
     {
         dispatch_sync(new AuditLink($this));
     }
+
+    public function updateHemsleyCollection($data) {
+        if($this->title === "Audit Hemsley") {
+            dd('ok');
+            $publications = json_decode($this->publications,true) ?? [];
+            foreach ($data as $fb) {
+                // Vérifier si le fluidbook n'existe pas déjà dans la collection
+                if(array_filter($publications, function($n) use($fb) { return $n['fluidbooks'] !== $fb; })) {
+                    $publications[] = [
+                        'fluidbook' => $fb,
+                        'export' => '',
+                    ];
+                }
+            }
+            $this->publications[] = json_encode($publications);
+            $this->save();
+        }
+    }
 }
index 3bf058f7ea80b5a2a1a16d81d21ef83dcd5b2311..735fc9c30e9294b20108996207afeaf6c71319f2 100644 (file)
@@ -1363,4 +1363,8 @@ class FluidbookPublication extends ToolboxStatusModel
             return FluidbookPublication::withoutGlobalScopes()->find($id)->protected_path($path);
         });
     }
+
+    public static function getFluidbooksHemsley() {
+        return static::where('c_title', 'LIKE', '%Hemsley Fraser -%')->pluck('id');
+    }
 }
diff --git a/app/SubForms/FluidbookAuditLinkButtons.php b/app/SubForms/FluidbookAuditLinkButtons.php
new file mode 100644 (file)
index 0000000..63fe0a2
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+namespace App\SubForms;
+
+use Cubist\Backpack\Magic\SubForm;
+use Cubist\Backpack\Magic\Fields\LinkButton;
+
+
+// __('!! e-Learning')
+class FluidbookAuditLinkButtons extends SubForm
+{
+    public function init()
+    {
+        parent::init();
+
+        $this->addField('download_audit', LinkButton::class, __('Télécharger l\'audit'), [
+            'when' => ["enable_audit" => 1],
+            'value' => backpack_url('/'),
+            'translatable' => false,
+            'attributes' => [ 'class' => 'form-control some-class'],
+        ]);
+        $this->addField('update_fluidbooks', LinkButton::class, __('Mettre à jour les publications'), [
+                'when' => ["enable_audit" => 1],
+                'value' => backpack_url('/'),
+                'translatable' => false]
+        );
+    }
+}