From: Vincent Vanwaelscappel Date: Wed, 2 Jul 2025 17:01:57 +0000 (+0200) Subject: wait #7627 @3 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=17244a64cc298972f8cb9eb0e23046fe8d1f8128;p=fluidbook-toolbox.git wait #7627 @3 --- diff --git a/app/Fluidbook/Compiler/Compiler.php b/app/Fluidbook/Compiler/Compiler.php index d33221f56..cfdef504b 100644 --- a/app/Fluidbook/Compiler/Compiler.php +++ b/app/Fluidbook/Compiler/Compiler.php @@ -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 '' . str_replace('> <', '><', Text::removeNewLines(implode('', $symbols))) . ''; diff --git a/app/Models/FluidbookIconset.php b/app/Models/FluidbookIconset.php index 8aa696ea2..6c5b8463c 100644 --- a/app/Models/FluidbookIconset.php +++ b/app/Models/FluidbookIconset.php @@ -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' => '']); } - 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; } } diff --git a/app/helpers.php b/app/helpers.php index d2679bbc9..89d02a397 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -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 = '')