]> _ Git - fluidbook-toolbox.git/commitdiff
wait #7627 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 2 Jul 2025 17:01:57 +0000 (19:01 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 2 Jul 2025 17:01:57 +0000 (19:01 +0200)
app/Fluidbook/Compiler/Compiler.php
app/Models/FluidbookIconset.php
app/helpers.php

index d33221f56314fac8e5f37a1f313d42fd32098dbc..cfdef504b472db625c0e5f2e3326636ad07ca114 100644 (file)
@@ -15,6 +15,7 @@ use App\Jobs\QuizDownload;
 use App\Models\ELearningMedia;
 use App\Models\ELearningPackage;
 use App\Models\FluidbookHealthIssues;
+use App\Models\FluidbookIconset;
 use App\Models\FluidbookPublication;
 use App\Models\FluidbookTheme;
 use App\Models\Quiz;
@@ -392,15 +393,18 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
             $this->initMobileFirst();
         }
 
+        $icons = FluidbookIconset::getSVGPath();
+
         $this->svgfiles = array_unique([$this->assets . '/images/symbols/interface.svg',
-            storage_path('icons/15.svg')]);
+            $icons . '15.svg',]);
         if ($this->themeSettings->iconSet > 15) {
-            $this->svgfiles[] = storage_path('icons/' . $this->themeSettings->iconSet . '.svg');
+            $this->svgfiles[] = $icons . $this->themeSettings->iconSet . '.svg';
         }
         if ($symbols = $this->themeAsset('symbols')) {
             $this->svgfiles[] = $symbols->getPathname();
         }
 
+
         if ($this->isMobileFirst()) {
             $this->multiply = $this->pdf2htmlRatio * $this->scale * $this->cssOneScale;
         } else {
@@ -1189,7 +1193,8 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
     {
         $symbols = [];
         foreach ($this->svgfiles as $svgfile) {
-            $symbols = array_merge($symbols, $this->_getSVGSymbols($svgfile));
+            $s = $this->_getSVGSymbols($svgfile);
+            $symbols = array_merge($symbols, $s);
         }
         $symbols = array_merge($symbols, $this->_svgSymbols);
         return '<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">' . str_replace('> <', '><', Text::removeNewLines(implode('', $symbols))) . '</svg>';
index 8aa696ea2191923d3fd6273efeae32516b28f55a..6c5b8463c76e010596de55e059eb34a0283534e2 100644 (file)
@@ -7,6 +7,7 @@ use Cubist\Backpack\Magic\Fields\Checkbox;
 use Cubist\Backpack\Magic\Fields\Code;
 use Cubist\Backpack\Magic\Fields\Text;
 use Cubist\Util\Files\Files;
+
 // __('!!Paramètres des fluidbooks')
 class FluidbookIconset extends ToolboxModel
 {
@@ -43,32 +44,38 @@ class FluidbookIconset extends ToolboxModel
             'default' => '<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"></svg>']);
     }
 
-    public function postSave()
+    public function onSaved(): bool
     {
-        parent::postSave();
-        self::updateWS2();
+        $res = parent::onSaved();
+        self::writeSVGFiles();
+        return $res;
     }
 
-    public static function updateWS2()
+    public static function writeSVGFiles()
     {
-        foreach (self::all() as $item) {
-            $dir = '/home/extranet/www/fluidbook/icones/' . $item->id;
-            Files::mkdir($dir);
-            file_put_contents($dir . '/interface.svg', $item->icons);
-            // For WS3
-            file_put_contents(Files::mkdir(storage_path('icons')) . '/' . $item->id . '.svg', $item->icons);
+        $icons = self::getSVGPath();
+        foreach (self::withoutGlobalScopes()->get() as $item) {
+            file_put_contents($icons . $item->id . '.svg', $item->icons);
         }
     }
 
-    public function postCreate()
+    public static function getSVGPath()
     {
-        parent::postCreate();
-        self::updateWS2();
+        return Files::mkdir(protected_path('fluidbookpublication/icons'));
+    }
+
+    public function onCreated(): bool
+    {
+
+        $res = parent::onCreated();
+        self::writeSVGFiles();
+        return $res;
     }
 
-    public function postDelete()
+    public function onDeleted(): bool
     {
-        parent::postDelete();
-        self::updateWS2();
+        $res = parent::onDeleted();
+        self::writeSVGFiles();
+        return $res;
     }
 }
index d2679bbc9e1bcc048e5bacc954bc6cc620119f8c..89d02a3979cc35a74ea22353c218f067f180c535 100644 (file)
@@ -11,6 +11,18 @@ if (!function_exists('dddd')) {
     }
 }
 
+if (!function_exists('dddump')) {
+    function dddump()
+    {
+        $devs = [5, 5908];
+        if (backpack_user() === null || !in_array(backpack_user()->id, $devs)) {
+            return;
+        }
+        return call_user_func_array('dump', func_get_args());
+    }
+}
+
+
 
 if (!function_exists('us_path')) {
     function us_path($path = '')