From: Vincent Vanwaelscappel Date: Mon, 14 Jun 2021 16:57:25 +0000 (+0200) Subject: wip #4216 @35 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=6991dc7283adb8b3ee7d12b7b1561874131dce4e;p=fluidbook-toolbox.git wip #4216 @35 --- diff --git a/app/Console/Commands/WorkshopMigration.php b/app/Console/Commands/WorkshopMigration.php index 3c04c27e7..b760e4fa7 100644 --- a/app/Console/Commands/WorkshopMigration.php +++ b/app/Console/Commands/WorkshopMigration.php @@ -77,6 +77,7 @@ class WorkshopMigration extends CubistCommand $ignore = ['extraXSpace', 'extraYSpace']; + FluidbookTheme::$updateWS2ViewOnChange = false; foreach (FluidbookTheme::all() as $theme) { $theme->delete(); } @@ -115,6 +116,7 @@ class WorkshopMigration extends CubistCommand } $c->save(); } + FluidbookTheme::$updateWS2ViewOnChange = true; $this->themeCompatTable(); } diff --git a/app/Http/Controllers/API/FluidbookThemeAPIController.php b/app/Http/Controllers/API/FluidbookThemeAPIController.php index 9ba355f9f..42bc4618c 100644 --- a/app/Http/Controllers/API/FluidbookThemeAPIController.php +++ b/app/Http/Controllers/API/FluidbookThemeAPIController.php @@ -52,7 +52,6 @@ class FluidbookThemeAPIController extends Controller } - return $theme; } @@ -67,7 +66,18 @@ class FluidbookThemeAPIController extends Controller foreach ($data['parametres'] as $k => $v) { $field = $theme->getField($k); if ($field instanceof Files) { + if (!$v) { + continue; + } $path = $oldRoot . $v; + if (!file_exists($path)) { + $opath = str_replace('.svg', '.o.svg', $path); + if (file_exists($opath)) { + copy($opath, $path); + } else { + continue; + } + } $media = $theme->getMediaInField($k); $upload = false; @@ -77,7 +87,7 @@ class FluidbookThemeAPIController extends Controller /** @var Media $m */ $m = $media->get(0); - if ($media->getAttribute('file_name') !== $k) { + if ($m->getAttribute('file_name') !== $k) { $upload = true; } else { $mpath = $m->getPath(); @@ -90,7 +100,13 @@ class FluidbookThemeAPIController extends Controller if (!$upload) { continue; } - $theme->addMediaToField($k, $path); + $s = storage_path('themes/' . $theme->getAttribute('id')); + if (!file_exists($s)) { + mkdir($s); + } + $f = $s . '/' . $v; + copy($path, $f); + $theme->addMediaToField($k, $f); } } } diff --git a/app/Models/FluidbookTheme.php b/app/Models/FluidbookTheme.php index 69e08085d..6fba762e9 100644 --- a/app/Models/FluidbookTheme.php +++ b/app/Models/FluidbookTheme.php @@ -23,6 +23,8 @@ class FluidbookTheme extends CubistMagicAbstractModel protected static $_colorAlphaToWS2Cache = []; protected $_oldRoot = '/home/extranet/www/fluidbook/'; + public static $updateWS2ViewOnChange = true; + public function setFields() { parent::setFields(); @@ -865,7 +867,6 @@ class FluidbookTheme extends CubistMagicAbstractModel public function updateWS2Table() { - return; $fileFields = []; $colorFields = []; $colorAlphaFields = []; @@ -893,18 +894,20 @@ class FluidbookTheme extends CubistMagicAbstractModel continue; } $v = $theme->$k; - if (null === $v) { - continue; - } + if (in_array($k, $colorAlphaFields)) { $v = self::_colorAlphaToWS2($v); } else if (in_array($k, $colorFields)) { $v = self::_colorToWS2($v); } else if (in_array($k, $fileFields)) { - /** @var Media $media */ - $media = $theme->getMedia($v)->get(0); - if (null !== $media) { - $v = $media->getAttribute('file_name'); + if (null === $v) { + $v = ''; + } else { + /** @var Media $media */ + $media = $theme->getMedia($v)->get(0); + if (null !== $media) { + $v = $media->getAttribute('file_name'); + } } } if (null === $v) { @@ -1001,13 +1004,17 @@ class FluidbookTheme extends CubistMagicAbstractModel public function postSave() { parent::postSave(); - $this->updateWS2Table(); + if (self::$updateWS2ViewOnChange) { + $this->updateWS2Table(); + } } public function postDelete() { parent::postDelete(); - $this->updateWS2Table(); + if (self::$updateWS2ViewOnChange) { + $this->updateWS2Table(); + } } public function fromWS2($data) diff --git a/composer.lock b/composer.lock index 1fd7f3a57..00aadca6a 100644 --- a/composer.lock +++ b/composer.lock @@ -12,18 +12,19 @@ "source": { "type": "git", "url": "https://github.com/EnhydraV/lucy.git", - "reference": "ca0a21bfa43e92d41b11b897f641043c6540b676" + "reference": "551d90e6ee4eedd380d494aebfc8c5ee424fd785" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/EnhydraV/lucy/zipball/ca0a21bfa43e92d41b11b897f641043c6540b676", - "reference": "ca0a21bfa43e92d41b11b897f641043c6540b676", + "url": "https://api.github.com/repos/EnhydraV/lucy/zipball/551d90e6ee4eedd380d494aebfc8c5ee424fd785", + "reference": "551d90e6ee4eedd380d494aebfc8c5ee424fd785", "shasum": "" }, "require": { "geoip2/geoip2": "^2.0", "jenssegers/agent": "^v2.6", - "nesbot/carbon": "^2.0" + "nesbot/carbon": "^2.0", + "php": "^7.0" }, "require-dev": { "phpunit/phpunit": "^8.0" @@ -40,7 +41,7 @@ "support": { "source": "https://github.com/EnhydraV/lucy/tree/master" }, - "time": "2021-06-09T16:39:23+00:00" + "time": "2021-06-09T19:11:40+00:00" }, { "name": "alchemy/binary-driver", @@ -177,16 +178,16 @@ }, { "name": "backpack/crud", - "version": "4.1.46", + "version": "4.1.47", "source": { "type": "git", "url": "https://github.com/Laravel-Backpack/CRUD.git", - "reference": "4bb96f8e34289b858e482ad9c9bf3ea51cb8b7c0" + "reference": "b2325eedd661adb75c23683aa6ee1d291b3578e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Laravel-Backpack/CRUD/zipball/4bb96f8e34289b858e482ad9c9bf3ea51cb8b7c0", - "reference": "4bb96f8e34289b858e482ad9c9bf3ea51cb8b7c0", + "url": "https://api.github.com/repos/Laravel-Backpack/CRUD/zipball/b2325eedd661adb75c23683aa6ee1d291b3578e7", + "reference": "b2325eedd661adb75c23683aa6ee1d291b3578e7", "shasum": "" }, "require": { @@ -241,7 +242,7 @@ "role": "Creator & Maintainer" } ], - "description": "Quickly build an admin interfaces using Laravel 7, CoreUI, Boostrap 4 and jQuery.", + "description": "Quickly build an admin interfaces using Laravel, CoreUI, Bootstrap and jQuery.", "homepage": "https://github.com/laravel-backpack/CRUD", "keywords": [ "Admin Interface", @@ -264,9 +265,9 @@ ], "support": { "issues": "https://github.com/Laravel-Backpack/CRUD/issues", - "source": "https://github.com/Laravel-Backpack/CRUD/tree/4.1.46" + "source": "https://github.com/Laravel-Backpack/CRUD/tree/4.1.47" }, - "time": "2021-05-27T09:23:32+00:00" + "time": "2021-06-14T08:42:33+00:00" }, { "name": "backpack/logmanager", @@ -10392,16 +10393,16 @@ }, { "name": "facade/ignition", - "version": "2.10.1", + "version": "2.10.2", "source": { "type": "git", "url": "https://github.com/facade/ignition.git", - "reference": "508d80f91de953617977e5666f8953669b6e81f2" + "reference": "43688227bbf27c43bc1ad83af224f135b6ef0ff4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/facade/ignition/zipball/508d80f91de953617977e5666f8953669b6e81f2", - "reference": "508d80f91de953617977e5666f8953669b6e81f2", + "url": "https://api.github.com/repos/facade/ignition/zipball/43688227bbf27c43bc1ad83af224f135b6ef0ff4", + "reference": "43688227bbf27c43bc1ad83af224f135b6ef0ff4", "shasum": "" }, "require": { @@ -10465,7 +10466,7 @@ "issues": "https://github.com/facade/ignition/issues", "source": "https://github.com/facade/ignition" }, - "time": "2021-06-03T21:41:42+00:00" + "time": "2021-06-11T06:57:25+00:00" }, { "name": "facade/ignition-contracts",