From: Vincent Vanwaelscappel Date: Thu, 11 Jul 2024 09:04:52 +0000 (+0200) Subject: wip #6998 @3 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=d648030c5371ff8c44a5cc965d82bf04d4bd2631;p=fluidbook-toolbox.git wip #6998 @3 --- diff --git a/.docker/fluidbook-workshop/config/httpd.conf b/.docker/fluidbook-workshop/config/httpd.conf new file mode 100644 index 000000000..93e53508a --- /dev/null +++ b/.docker/fluidbook-workshop/config/httpd.conf @@ -0,0 +1,10 @@ +LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so + + + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + +User #1004 +Group #33 diff --git a/.docker/fluidbook-workshop/docker-compose.yml b/.docker/fluidbook-workshop/docker-compose.yml new file mode 100644 index 000000000..521053fd7 --- /dev/null +++ b/.docker/fluidbook-workshop/docker-compose.yml @@ -0,0 +1,18 @@ +services: + webserver: + container_name: fluidbook-workshop + image: php:apache + volumes: + - './html:/var/www/html' + - './config/httpd.conf:/etc/apache2/conf-enabled/99-config.conf' + environment: + VIRTUAL_HOST: workshop.fluidbook.com,exe.workshop.fluidbook.com,ws.fluidbook.com + LETSENCRYPT_HOST: workshop.fluidbook.com,exe.workshop.fluidbook.com,ws.fluidbook.com + networks: + - fluidbook-workshop + restart: unless-stopped + +networks: + fluidbook-workshop: + external: + name: fluidbook-workshop diff --git a/.docker/fluidbook-workshop/html/.htaccess b/.docker/fluidbook-workshop/html/.htaccess new file mode 100644 index 000000000..bfc83ca5e --- /dev/null +++ b/.docker/fluidbook-workshop/html/.htaccess @@ -0,0 +1,22 @@ +Options +FollowSymlinks + + + RewriteEngine on + RewriteBase / + + RewriteRule ^viewerh/(.+)$ https://toolbox.fluidbook.com/fluidbook-publication/preview/$1 [R=308,L] + RewriteRule ^viewers/(.+)$ https://toolbox.fluidbook.com/fluidbook-publication/preview/scorm/$1 [R=308,L] + + RewriteRule ^publications$ https://toolbox.fluidbook.com/fluidbook-publication/ [R=308,L] + RewriteRule ^fichiers$ https://toolbox.fluidbook.com/file/ [R=308,L] + RewriteRule ^dashboard$ https://toolbox.fluidbook.com/ [R=308,L] + + # Ignore static files or directories + RewriteCond %{REQUEST_FILENAME} -s [OR] + RewriteCond %{REQUEST_FILENAME} -l [OR] + RewriteCond %{REQUEST_FILENAME} -d + RewriteRule ^.*$ - [NC,L] + + RewriteRule ^([-,_a-zA-Z0-9\./\%\@]+)$ index.php/$1 [L] + + diff --git a/.docker/fluidbook-workshop/html/index.php b/.docker/fluidbook-workshop/html/index.php new file mode 100644 index 000000000..5e973bd30 --- /dev/null +++ b/.docker/fluidbook-workshop/html/index.php @@ -0,0 +1,3 @@ +table('books')->where('version', "3")->delete(); - - $inserts = []; - $ids = []; - - foreach (FluidbookPublication::withoutGlobalScopes()->where('created_ok', '1')->where('version', 3)->orderBy('id', 'ASC')->get() as $fb) { - /** @var $fb FluidbookPublication */ - $i = ['book_id' => $fb->id, - 'version' => 3, - 'nom' => $fb->c_title, - 'lang' => $fb->locale, - 'region' => $fb->region, - 'theme' => $fb->theme, - 'proprietaire' => $fb->owner, - 'status' => $fb->status, - 'tache' => $fb->extranet_task ?? 0, - 'date' => (new \DateTime($fb->created_at))->getTimestamp(), - 'changedate' => (new \DateTime($fb->updated_at))->getTimestamp(), - 'numerotation' => $fb->page_numbers??'', - 'parametres' => $fb->settings, - 'hash' => $fb->hash, - 'cid' => $fb->cid, - ]; - $inserts[] = $i; - $ids[] = $fb->id; - } - - DB::connection('extranet')->table('books')->whereIn('book_id', $ids)->delete(); - foreach ($inserts as $insert) { - DB::connection('extranet')->table('books')->insert($insert); - } - } -} diff --git a/app/Console/Commands/ToolboxToWorkshop.php b/app/Console/Commands/ToolboxToWorkshop.php deleted file mode 100644 index 7fde1dade..000000000 --- a/app/Console/Commands/ToolboxToWorkshop.php +++ /dev/null @@ -1,47 +0,0 @@ -argument('id')); - $map = WorkshopMigration::mapNames(true); - $mapValues = WorkshopMigration::mapValues(true); - - $data = []; - foreach ($source->getAttributes() as $k => $v) { - if ($k === 'settings' || $k === 'id' || !isset($map[$k])) { - continue; - } - $key = isset($map[$k]) ? $map[$k] : $k; - - if (stristr($key, 'date')) { - $date = new \DateTime($v); - $v = $date->getTimestamp(); - } - $data[$key] = $v; - - } - $targetid = $this->argument('targetid'); - if ($targetid === 'new') { - $res = DB::select(DB::raw('SELECT MAX(book_id)+1 AS book_id FROM ' . self::$_wstable)); - $data['book_id'] = $res[0]->book_id; - - DB::table(self::$_wstable)->insert($data); - } else { - DB::table(self::$_wstable)->where('book_id', $targetid)->update($data); - } - } -} diff --git a/app/Console/Commands/WorkshopMigration.php b/app/Console/Commands/WorkshopMigration.php deleted file mode 100644 index 118018c25..000000000 --- a/app/Console/Commands/WorkshopMigration.php +++ /dev/null @@ -1,384 +0,0 @@ -_lock = Cache::lock('ws2_migrate', 3600); - - if (!$this->option('force') && !$this->_lock->get()) { - $this->line('Migration is locked. Use --force to remove lock'); - return; - } - - $actions = [ - //'Backup current database' => 'backup', - 'Migrate magic models' => 'migrate', - 'Import documents' => 'importDocuments', - 'Import publications' => 'importPublications', - 'Clean caches' => 'cleanCache' - ]; - - if ($this->option('quick')) { - $actions = ['Import publications' => 'importPublications']; - } - - $this->progressBar = $this->output->createProgressBar(count($actions)); - - $this->line(' Data migration, please wait'); - $this->progressBar->start(); - - try { - foreach ($actions as $comment => $action) { - $this->line($comment); - $this->$action(); - $this->progressBar->advance(); - } - - $this->line('End of import'); - } finally { - $this->_lock->release(); - } - } - - protected function migrate() - { - Artisan::call('cubist:magic:generate'); - Artisan::call('cubist:magic:migrate'); - } - - protected function backup() - { - Artisan::call('backup:run'); - } - - protected function cleanCache() - { - Artisan::call('optimize:clear'); - } - - protected function importDocuments() - { - if ($this->option('documents') === 'none') { - return; - } - - PHP::neverStop(); - - $q = DB::table(self::OLD_DB . '.documents')->orderBy('document_id', 'desc'); - - if ($this->option('documents') === 'missing') { - $maxID = FluidbookDocument::withoutGlobalScopes()->where('id', '<', self::WS3_DOC_ID)->orderBy('id', 'DESC')->first()->id; - $q = DB::table(self::OLD_DB . '.documents')->where('document_id', '>', $maxID)->orderBy('document_id', 'desc'); - - } else if ($this->option('documents') === 'v2') { - DB::update('DELETE FROM fluidbook_document WHERE id<' . self::WS3_DOC_ID); - } else { - $range = ArrayUtil::parseRange($this->option('documents')); - FluidbookDocument::withoutGlobalScopes()->whereIn('id', $range)->forceDelete(); - $q->whereIn('document_id', $range); - } - - - foreach ($q->get() as $e) { - $this->line('Import ' . $e->document_id); - $c = new FluidbookDocument(); - $c->setIncrementing(false); - $c->id = $e->document_id; - $date = new \DateTime(); - $date->setTimestamp($e->date); - $c->created_at = $c->updated_at = $date; - $c->file = $e->file; - $c->owner = $e->proprietaire; - $c->pages = $e->pages; - - $c->pdf_data = $this->_unserialize($e->generalInfos); - $c->file_data = $this->_unserialize($e->localInfos); - $c->bookmarks = $this->_migrateBookmarks($e->bookmarks); - $c->saveWithoutFlushingCache(); - } - - } - - protected function _migrateBookmarks($bookmarks, $default = []) - { - $bookmarks = $this->_unserialize($bookmarks, $default); - $res = []; - foreach ($bookmarks as $bookmark) { - if (isset($bookmark['titre'])) { - $bookmark['title'] = $bookmark['titre']; - unset($bookmark['titre']); - } else { - $bookmark['title'] = ''; - } - $res[] = $bookmark; - } - return $res; - } - - protected function _unserialize($s, $default = []) - { - return ObjectUtil::safeUnserialize($s, $default); - } - - protected function _unserializeAndJSON($s, $default = []) - { - return json_encode($this->_unserialize($s, $default)); - } - - public static function mapNames($flip = false) - { - $res = ['book_id' => 'id', - 'nom' => 'name', - 'proprietaire' => 'owner', - 'date' => 'created_at', - 'lang' => 'locale', - 'compteur_visites' => 'visits_counter', - 'date_status' => 'status_date', - 'traductions' => 'translations', - 'numerotation' => 'page_numbers', - 'tache' => 'extranet_task', - 'changedate' => 'updated_at', - 'compiledate' => 'compilation_date', - 'composition_update' => 'composition_updated_at', - 'exportdatas' => 'export_data', - ]; - if ($flip) { - $res = array_flip($res); - } - return $res; - } - - public static function mapValues($flip = false) - { - $res = ['Open Sans (police du Fluidbook)' => 'OpenSans']; - if ($flip) { - $res = array_flip($res); - } - return $res; - } - - protected function importPublications() - { - if ($this->option('publications') === 'none') { - return; - } - - PHP::neverStop(); - - $map = self::mapNames(); - $mapValues = self::mapValues(); - - $v3 = FluidbookPublication::withoutGlobalScopes()->where('version', 3)->pluck('id')->toArray(); - - $ignore = []; - - $this->line('Begin publications migration'); - - FluidbookTheme::$updateWS2ViewOnChange = false; - - $q = DB::table(self::OLD_DB . '.books')->orderBy('book_id', 'asc'); - - if ($this->option('publications') === 'v2') { - DB::update('DELETE FROM fluidbook_publication WHERE version <= 2 AND id<' . self::WS3_BOOK_ID); - } else if ($this->option('publications') === 'missing') { - // Get highest fluidbook on toolbox with a number less thant WS3_BOOK_ID - $f = FluidbookPublication::withoutGlobalScopes()->where('id', '<', self::WS3_BOOK_ID)->orderBy('id', 'DESC')->first(); - $q->where('book_id', '>', $f->id); - } else { - $range = ArrayUtil::parseRange($this->option('publications')); - FluidbookPublication::withoutGlobalScopes()->where('version', '<=', 2)->whereIn('id', $range)->forceDelete(); - $q->whereIn('book_id', $range); - } - - foreach ($q->get() as $e) { - $this->line('Import ' . $e->book_id); - if (in_array($e->book_id, $v3)) { - continue; - } - $c = new FluidbookPublication(); - $c->setIncrementing(false); - $c->id = $e->book_id; - $e->compiledate = max($e->compiledate, $e->compile1date, $e->compilehtml5date); - $e->version = 2; - foreach ($e as $k => $v) { - $new = $map[$k] ?? $k; - if (!$c->hasField($new)) { - continue; - } - if ($new == 'visits_counter' && $v == 20) { - $v = 0; - } - if ($new == 'status') { - $v++; - } - if ($c->getField($new) instanceof Datetime) { - $date = new \DateTime(); - $date->setTimestamp($v); - $v = $date; - } else if ($k == 'chapters') { - $v = $this->_normalizeChapters($v); - } else if ($new == 'translations') { - $v = $this->_normalizeTranslations($v, $e->lang); - } else if (Json::isJson($v)) { - $v = json_decode($v, true); - } else if ($new === 'locale') { - $v = $this->_normalizeLang($v); - } - $c->setAttribute($new, $v); - } - - $s = $this->_unserialize($e->parametres); - - foreach ($s->datas as $k => $data) { - if (in_array($k, $ignore)) { - continue; - } - if ($k === 'pages') { - $c->setAttribute('c_pages', max($data, count(explode(',', $e->numerotation)))); - } - if (!$c->hasField($k)) { - continue; - } - $f = $c->getField($k); - - if ($f instanceof Color) { - $data = FluidbookTheme::_colorToWS3($data); - } else if ($f instanceof Datetime) { - $date = new \DateTime(); - $date->setTimestamp($data); - $data = $date; - } else if (Json::isJson($data)) { - $data = json_decode($data, true); - } - if (is_scalar($data) && isset($mapValues[$data])) { - $data = $mapValues[$data]; - } - - $c->setAttribute($k, $data); - if ($k === 'title') { - $c->setAttribute('c_title', $data); - } - - } - - // Composition - $composition = []; - foreach (DB::table(self::OLD_DB . '.book_pages')->where('book_id', $e->book_id)->get() as $p) { - $composition[$p->book_page] = [$p->document_id, $p->document_page]; - } - $c->setAttribute('composition', $composition); - - try { - $c->saveQuietlyWithoutFlushingCache(); - } catch (\Exception $e) { - dd($e); - } - } - - Artisan::call('fluidbook:document:setregion'); - } - - protected function _normalizeLang($lang) - { - $e = preg_split('/[-_]+/', $lang); - if (count($e) === 1) { - return $lang; - } - return mb_strtolower($e[0]) . "_" . mb_strtoupper($e[1]); - } - - protected function _normalizeTranslations($value, $lang) - { - if (!is_string($value) || !Json::isJson($value)) { - return []; - } - $translations = json_decode($value); - $res = []; - - $l10n = FluidbookTranslate::getCompiledTranslations()[$this->_normalizeLang($lang)]; - - foreach ($translations as $base => $trans) { - if (!isset($l10n[$base]) || !$trans || $l10n[$base] === $trans) { - - } else { - $res[$base] = $trans; - } - } - - return $res; - } - - public function _normalizeChapters($value) - { - if (!$value) { - return $value; - } - if (is_string($value)) { - $v = json_decode($value, true); - } else { - $v = $value; - } - if (!$v) { - return $value; - } - $res = []; - foreach ($v as $k => $chapter) { - $chapter['decoration'] = 'regular'; - $chapter['label'] = trim($chapter['label']); - if ($chapter['label'] === '----') { - $chapter['label'] = ''; - $chapter['decoration'] = 'separator'; - } else if ($chapter['label'] === '--') { - $chapter['label'] = ''; - $chapter['decoration'] = 'forcecut'; - } else if ($chapter['label'] === '++') { - $chapter['label'] = ''; - $chapter['decoration'] = 'nocut'; - } else if (str_starts_with($chapter['label'], '!!!')) { - $chapter['label'] = substr($chapter['label'], 3); - $chapter['decoration'] = 'column_head'; - } - $res[$k] = $chapter; - } - return $res; - } - - public function __destruct() - { - - } -} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index f1b20289e..4e92c7a5d 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -38,11 +38,12 @@ class Kernel extends \Cubist\Backpack\Console\Kernel // Email config $schedule->command('job:dispatchNow Maintenance\\\\EmailServerRefresh')->twiceDailyAt(); // WS to Toolbox migration - $schedule->command('ws:migrate --publications=v2 --documents=missing')->dailyAt('1:00'); - $schedule->command('syncfluidbooksv3toworkshop')->dailyAt('3:15'); - $schedule->command('ws:migrate --publications=missing --documents=missing')->everyTwoHours(); + //$schedule->command('ws:migrate --publications=v2 --documents=missing')->dailyAt('1:00'); + //$schedule->command('syncfluidbooksv3toworkshop')->dailyAt('3:15'); + //$schedule->command('ws:migrate --publications=missing --documents=missing')->everyTwoHours(); + // Quotes $schedule->command('fluidbook:quote --reminder')->weekdays()->at('10:00'); - + // Mailjet $schedule->command('job:dispatchNow MailjetSyncList')->dailyAt('5:00'); } diff --git a/app/Fluidbook/Compiler/Compiler.php b/app/Fluidbook/Compiler/Compiler.php index 210016fdf..b2155919e 100644 --- a/app/Fluidbook/Compiler/Compiler.php +++ b/app/Fluidbook/Compiler/Compiler.php @@ -305,7 +305,7 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError $this->phonegapVersion = self::getPhonegapVersion($phonegapVersion); $this->appcache = $appcache; $this->multiApp = $this->home = $home; - $this->devversion = $this->getFluidbook()->version < 3 ? "dev" : $this->getFluidbook()->mobileLVersion; + $this->devversion = /*$this->getFluidbook()->version < 3 ? "dev" : */$this->getFluidbook()->mobileLVersion; $this->scormVariant = $scormVariant; $this->hybrid = $hybrid; diff --git a/app/Fluidbook/Packager/Download.php b/app/Fluidbook/Packager/Download.php index f35047edf..ee11d7a29 100644 --- a/app/Fluidbook/Packager/Download.php +++ b/app/Fluidbook/Packager/Download.php @@ -165,14 +165,14 @@ class Download extends DownloadBase protected function _compileandpackage($zip = true) { - if ($this->entry->version == 3) { + // if ($this->entry->version == 3) { $packager = Packager::package($this->entry->id, $this->version, $zip, true, $this->_params); - } else { - $packager = new WorkshopPackager($this->entry->id, $this->version, null, $this->_params); - $packager->zipPackage = $zip; - $packager->cleanOnDestruct = true; - $packager->setUser($this->getUser()); - } +// } else { +// $packager = new WorkshopPackager($this->entry->id, $this->version, null, $this->_params); +// $packager->zipPackage = $zip; +// $packager->cleanOnDestruct = true; +// $packager->setUser($this->getUser()); +// } $packager->makePackage($zip); $url = $packager->getFinalURL(); if ($url) { diff --git a/app/Jobs/FluidbookCollectionDownload.php b/app/Jobs/FluidbookCollectionDownload.php index a370c72ae..6747eb4e5 100644 --- a/app/Jobs/FluidbookCollectionDownload.php +++ b/app/Jobs/FluidbookCollectionDownload.php @@ -354,19 +354,9 @@ class FluidbookCollectionDownload extends DownloadBase { if ($compilerVersion === 'auto') { $fb = FluidbookPublication::withoutGlobalScopes()->find($id); - $compilerVersion = $fb->version; - } - /** @var $job FluidbookPackage */ - if ($compilerVersion == 2) { - $job = new FluidbookWS2Download(); - if (null === $this->user) { - $job->setCredentials(['api@fluidbook.com', 'Dxsm2nqsvbV4ubH8KUEMRpbfsRrsDZagJkCZV2Nvuy83oPqsSEKC6ircWdC2']); - } else { - $job->setCredentials([$this->user->email, $this->user->api_token]); - } - } else if ($compilerVersion == 3) { - $job = new FluidbookPackage(); } + + $job = new FluidbookPackage(); $job->setBookId($id); $job->setVersion($version); $job->setOptions($options); diff --git a/app/Jobs/FluidbookWS2Download.php b/app/Jobs/FluidbookWS2Download.php deleted file mode 100644 index 41e90845d..000000000 --- a/app/Jobs/FluidbookWS2Download.php +++ /dev/null @@ -1,62 +0,0 @@ -login($this->getCredentials()[0], $this->getCredentials()[1]); - if (in_array($this->getVersion(), ['win_ins_html', 'win_inss_html'])) { - $res = $ws->downloadBookExport($this->getBookId(), $this->getDestination(), $this->getOptions(), $this->getVersion(), $this->getTries()); - } else { - $res = $ws->installBook($this->getBookId(), $this->getDestination(), $this->getOptions(), $this->getVersion(), $this->getTries()); - } - $this->setResult($res); - } catch (\Exception $e) { - $this->setException($e); - } - $this->setDone(true); - } - - /** - * @return int - */ - public function getTries(): int - { - return $this->_tries; - } - - /** - * @param int $tries - */ - public function setTries(int $tries): void - { - $this->_tries = $tries; - } - - /** - * @return array - */ - public function getCredentials(): array - { - return $this->_credentials; - } - - /** - * @param array $credentials - */ - public function setCredentials(array $credentials): void - { - $this->_credentials = $credentials; - } - -} diff --git a/app/Jobs/HostingUpdate.php b/app/Jobs/HostingUpdate.php index a1c7f3498..6f12bbbe2 100644 --- a/app/Jobs/HostingUpdate.php +++ b/app/Jobs/HostingUpdate.php @@ -12,8 +12,8 @@ use Cubist\Util\Text; class HostingUpdate extends Base { protected static $_data = [ - 'hosting' => ['host' => 'godzilla.cubedesigners.com', 'basepath' => '/data/fluidbook/hosting'], - 'hosting2' => ['host' => 'godzilla.cubedesigners.com', 'basepath' => '/data/fluidbook/hosting2'], + 'hosting' => ['host' => 'cloudatlas.cubedesigners.com', 'basepath' => '/home/fluidbook/hosting'], + 'hosting2' => ['host' => 'cloudatlas.cubedesigners.com', 'basepath' => '/home/fluidbook/hosting2'], 'ushosting' => ['host' => 'kingkong.cubedesigners.com', 'basepath' => '/home/fluidbook/data/hosting'], ]; diff --git a/app/Jobs/UpdateWS2ThemeTable.php b/app/Jobs/UpdateWS2ThemeTable.php deleted file mode 100644 index d6d48d15a..000000000 --- a/app/Jobs/UpdateWS2ThemeTable.php +++ /dev/null @@ -1,211 +0,0 @@ -id = $id; - } - - public function uniqueId() - { - return 'updatews2themetable_' . $this->id; - } - - /** - * Execute the job. - * - * @return void - */ - public function handle() - { - $lock = Cache::lock('job_' . $this->uniqueId(), 10); - if ($lock->get()) { - $theme = new FluidbookTheme(); - - foreach ($theme->getFields() as $field) { - $name = $field->getAttribute('name'); - $this->_allFields[] = $name; - if ($field instanceof Files) { - $this->_fileFields[] = $name; - } else if ($field instanceof Color) { - if ($field->getAttribute('allows_alpha')) { - $this->_colorAlphaFields[] = $name; - } else { - $this->_colorFields[] = $name; - } - } - } - $this->_ignore = ['id', 'name', 'owner', 'created_at', 'deleted_at', 'updated_at', 'slug', 'signature']; - - $data = []; - $t = DB::table('extranet_clean.ws3_themes'); - if ($this->id === 'all') { - foreach (FluidbookTheme::where('created_ok', 1)->get() as $theme) { - $data[] = $this->_handleTheme($theme); - } - $t->truncate(); - } else { - $theme = FluidbookTheme::find($this->id); - $data[] = $this->_handleTheme($theme); - $t->where('theme_id', '=', $this->id)->delete(); - } - try { - $t->insert($data); - } catch (Exception|UniqueConstraintViolationException $e) { - - } - $lock->release(); - } - } - - protected function _handleTheme($theme) - { - $res = $this->_getThemeData($theme); - $dest = $this->_t3dir . '/' . $theme->id . '.jpg'; - - $preview = storage_path('themes/' . $theme->id . '.jpg'); - \Cubist\Util\Files\Files::copyFile($preview, $dest, false, true, false); - - return $res; - } - - protected function _getThemeData($theme) - { - $settings = []; - foreach ($this->_allFields as $k) { - if (in_array($k, $this->_ignore)) { - continue; - } - $v = (string)$theme->$k; - - if (in_array($k, $this->_colorAlphaFields)) { - $v = self::colorAlphaToWS2($v); - } else if (in_array($k, $this->_colorFields)) { - $v = self::colorToWS2($v); - } else if (in_array($k, $this->_fileFields)) { - if (null === $v) { - $v = ''; - } else { - /** @var Media $media */ - $media = $theme->getMedia($v)->get(0); - if (null !== $media) { - $v = $media->getAttribute('file_name'); - $dir = $this->_t3dir . $theme->id; - \Cubist\Util\Files\Files::mkdir($dir); - $dest = $dir . '/' . $v; - $path = $media->getPath(); - - \Cubist\Util\Files\Files::copyFile($path, $dest); - - if (stristr($v, '.svg')) { - $png = str_replace('.svg', '.png', $dest); - if (!file_exists($png) || filemtime($png) < filemtime($path)) { - $im = new Imagemagick(); - $im->setDest($png); - $im->setSrc($dest); - $im->setManualArg('-background none'); - $im->execute(); - } - } - } else { - $v = ''; - } - } - } - if (null === $v) { - continue; - } - $settings[$k] = $v; - } - return ['theme_id' => $theme->id, 'nom' => $theme->name, 'proprietaire' => $theme->owner, 'icones' => $theme->iconSet, 'date' => strtotime($theme->updated_at), 'parametres' => json_encode($settings)]; - } - - - public static function colorAlphaToWS2($data) - { - if ($data === '') { - return null; - } - if (!isset(self::$_colorAlphaToWS2Cache[$data])) { - self::$_colorAlphaToWS2Cache[$data] = self::_colorToWS2($data, true); - } - return self::$_colorAlphaToWS2Cache[$data]; - } - - public static function colorToWS2($data) - { - if ($data === '') { - return ''; - } - if (!isset(self::$_colorToWS2Cache[$data])) { - self::$_colorToWS2Cache[$data] = self::_colorToWS2($data, false); - } - return self::$_colorToWS2Cache[$data]; - } - - protected static function _colorToWS2($data, $alpha): string - { - $data = trim($data, '# '); - if (strlen($data) < 6) { - $res = str_repeat('0', 6 - mb_strlen($data)) . $data; - } else if (strlen($data) === 6) { - $res = $data; - } else if ($data === 'transparent') { - $res = '00000000'; - } else if (preg_match('/rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(\s*,\s*([0-9.]*))?\)/', $data, $matches)) { - $res = self::dechex($matches[1]) . self::dechex($matches[2]) . self::dechex($matches[3]); - if (isset($matches[5])) { - $res = self::dechex($matches[5] * 255) . $res; - } - } else { - $res = $data; - } - if ($alpha && strlen($res) === 6) { - $res = 'ff' . $res; - } - return $res; - } - - public static function dechex($e) - { - if ($e == 0) { - $res = '00'; - } else { - $res = dechex(round($e)); - if (strlen($res) == 1) { - $res = '0' . $res; - } - } - return $res; - } - -} diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index 2f02eea06..98ee5ce36 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -722,9 +722,9 @@ class FluidbookPublication extends ToolboxStatusModel if (!parent::allowsDelete()) { return false; } - if ($this->version < 3) { - return false; - } +// if ($this->version < 3) { +// return false; +// } return true; } @@ -734,9 +734,9 @@ class FluidbookPublication extends ToolboxStatusModel if (!parent::allowsUpdate()) { return false; } - if ($this->version < 3) { - return false; - } +// if ($this->version < 3) { +// return false; +// } return true; } @@ -746,7 +746,8 @@ class FluidbookPublication extends ToolboxStatusModel if (!can(static::$_permissionBase . ':write')) { return false; } - if ($this->version >= 3) { + + if (true || $this->version >= 3) { return false; } return true; @@ -839,11 +840,12 @@ class FluidbookPublication extends ToolboxStatusModel public function syncFromWorkshop() { - if ($this->version >= 3) { - return false; - } - Artisan::call('ws:migrate --publications=' . $this->id . ' --documents=missing --quick'); - return true; + return false; +// if ($this->version >= 3) { +// return false; +// } +// Artisan::call('ws:migrate --publications=' . $this->id . ' --documents=missing --quick'); +// return true; } /** @@ -852,6 +854,7 @@ class FluidbookPublication extends ToolboxStatusModel */ public static function syncPublicationFromWorkshop($id) { + return; /** @var FluidbookPublication $fb */ $fb = FluidbookPublication::withoutGlobalScopes()->find($id); $fb?->syncFromWorkshop(); @@ -1114,6 +1117,7 @@ class FluidbookPublication extends ToolboxStatusModel public function upgrade($version = "latest") { + return; if ($version === 'latest') { $version = 3; } @@ -1203,9 +1207,9 @@ class FluidbookPublication extends ToolboxStatusModel public function allowsChangeStatus() { - if ($this->version < 3) { - return false; - } +// if ($this->version < 3) { +// return false; +// } return parent::allowsChangeStatus(); } diff --git a/app/Models/FluidbookTheme.php b/app/Models/FluidbookTheme.php index 395201f22..96ca7e21c 100644 --- a/app/Models/FluidbookTheme.php +++ b/app/Models/FluidbookTheme.php @@ -675,7 +675,6 @@ class FluidbookTheme extends ToolboxModel public function onSaved(): bool { $res = parent::onSaved(); - self::updateWS2Table($this->id); $this->_generateThemePreview(); return $res; } @@ -688,64 +687,9 @@ class FluidbookTheme extends ToolboxModel public function onDeleted(): bool { $res = parent::onDeleted(); - self::updateWS2Table(); return $res; } - public static function updateWS2Table($id = null) - { - - if (self::$updateWS2ViewOnChange) { - if (null !== $id) { - dispatch_sync(new UpdateWS2ThemeTable($id)); - } - dispatch(new UpdateWS2ThemeTable('all'))->onQueue('theme'); - } - } - - public function fromWS2($data) - { - $map = ['theme_id' => 'id', - 'nom' => 'name', - 'proprietaire' => 'owner', - 'date' => 'created_at',]; - - $ignore = ['extraXSpace', 'extraYSpace']; - - $oldRoot = $this->_oldRoot . 'themes/' . $data->theme_id . '/'; - - foreach ($map as $old => $new) { - $v = $data->$old; - if ($old === 'date') { - $date = new \DateTime(); - $date->setTimestamp($v); - $v = $date; - } - $this->setAttribute($new, $v); - } - $this->save(); - - - $s = self::_unserialize($data->parametres); - - foreach ($s->datas as $k => $v) { - if (in_array($k, $ignore)) { - continue; - } - $f = $this->getField($k); - if ($f instanceof Files) { - $this->_handleWS2File($f, $v, $oldRoot); - } else { - if ($f instanceof Color) { - $data = self::_colorToWS3($data); - } - $this->setAttribute($k, $v); - } - } - $this->save(); - return $this; - } - /** * @param array $a * @return FluidbookTheme diff --git a/bin/mount.sh b/bin/mount.sh index 54bd5a271..e661fbc10 100644 --- a/bin/mount.sh +++ b/bin/mount.sh @@ -5,7 +5,7 @@ if mountpoint -q "/mnt/hosting"; then else echo "mount /mnt/hosting" umount -l -q /mnt/hosting - sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 -o uid=1001 -o gid=33 -o allow_other fluidbook@godzilla.cubedesigners.com:/data/fluidbook/hosting /mnt/hosting + sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 -o uid=1001 -o gid=33 -o allow_other fluidbook@cloudatlas.cubedesigners.com:/home/fluidbook/hosting /mnt/hosting fi mkdir -p /mnt/hosting2 @@ -14,7 +14,7 @@ if mountpoint -q "/mnt/hosting2"; then else echo "mount /mnt/hosting2" umount -l -q /mnt/hosting2 - sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 -o uid=1001 -o gid=33 -o allow_other fluidbook@godzilla.cubedesigners.com:/data/fluidbook/hosting2 /mnt/hosting2 + sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 -o uid=1001 -o gid=33 -o allow_other fluidbook@cloudatlas.cubedesigners.com:/home/fluidbook/hosting2 /mnt/hosting2 fi mkdir -p /application/usstorage diff --git a/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php b/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php index 2c25fb7f3..8b46d4144 100644 --- a/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php +++ b/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php @@ -2,15 +2,15 @@ @php $actions=[]; $suffixv3=''; - if($entry->version==2){ - $actions['compilev2']=['label'=>''.__('Compilateur V2').'','disabled'=>true,'url'=>'#']; - $actions['preview_v2'] = ['label'=>__('Version online'),'url'=>'https://workshop.fluidbook.com/viewerh/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank']; - if($entry->isSCORMEnabled()){ - $actions['scorm_v2'] = ['label'=>__('Version SCORM'),'url'=>'https://workshop.fluidbook.com/viewers/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank']; - } - $actions['sep']='---------'; - $actions['testv3']=['label'=>''.__('Tester le compilateur V3').'','disabled'=>true,'url'=>'#']; - } +// if($entry->version==2){ +// $actions['compilev2']=['label'=>''.__('Compilateur V2').'','disabled'=>true,'url'=>'#']; +// $actions['preview_v2'] = ['label'=>__('Version online'),'url'=>'https://workshop.fluidbook.com/viewerh/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank']; +// if($entry->isSCORMEnabled()){ +// $actions['scorm_v2'] = ['label'=>__('Version SCORM'),'url'=>'https://workshop.fluidbook.com/viewers/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank']; +// } +// $actions['sep']='---------'; +// $actions['testv3']=['label'=>''.__('Tester le compilateur V3').'','disabled'=>true,'url'=>'#']; +// } $actions['preview']=['label'=>__('Version online'),'url'=>$crud->route.'/preview/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank']; if($entry->isSCORMEnabled()){ $actions['scorm']=['label'=>__('Version SCORM'),'url'=>$crud->route.'/preview/scorm/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank'];