From: Vincent Vanwaelscappel Date: Mon, 12 Dec 2022 18:14:28 +0000 (+0100) Subject: wip #5639 @3 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=79018d0b5d47834c4798a6a40024c608d175f37e;p=fluidbook-toolbox.git wip #5639 @3 --- diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index 8df95b100..bb03e38cf 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -13,6 +13,7 @@ services: - '/home/toolbox/www:/application' - '/home/toolbox/www/storage/app/public/:/application/public/storage/' - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/protected/fluidbookpublication/docs/' + - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/fluidbook/docs/' - '/data/extranet/www/fluidbook/books/working/:/application/protected/fluidbookpublication/working/' - '/home/extranet:/home/extranet' - '/data/extranet:/data/extranet' @@ -72,6 +73,7 @@ services: - '/home/toolbox/www:/application' - '/home/toolbox/www/storage/app/public/:/application/public/storage/' - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/protected/fluidbookpublication/docs/' + - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/fluidbook/docs/' - '/data/extranet/www/fluidbook/books/working/:/application/protected/fluidbookpublication/working/' - '/home/extranet:/home/extranet' - '/data/extranet:/data/extranet' diff --git a/app/Console/Commands/WorkshopMigration.php b/app/Console/Commands/WorkshopMigration.php index 7da8eef26..369f71870 100644 --- a/app/Console/Commands/WorkshopMigration.php +++ b/app/Console/Commands/WorkshopMigration.php @@ -20,7 +20,7 @@ use Illuminate\Support\Facades\DB; class WorkshopMigration extends CubistCommand { - protected $signature = 'ws:migrate {--publications=v2} {--documents=v2}'; + protected $signature = 'ws:migrate {--publications=v2} {--documents=missing}'; protected $description = 'Migrate data from Workshop V2'; protected $_wsRanks = []; protected $_oldDB = 'extranet_clean'; @@ -74,7 +74,7 @@ class WorkshopMigration extends CubistCommand protected function importDocuments() { - if($this->option('documents')==='none'){ + if ($this->option('documents') === 'none') { return; } @@ -84,7 +84,11 @@ class WorkshopMigration extends CubistCommand $q = DB::table($this->_oldDB . '.documents')->orderBy('document_id', 'desc'); - if ($this->option('documents') === 'v2') { + if ($this->option('documents') === 'missing') { + $maxID = FluidbookDocument::where('id', '<', $ws3step)->orderBy('id', 'DESC')->first()->id; + $q = DB::table($this->_oldDB . '.documents')->where('document_id', '>', $maxID)->orderBy('document_id', 'desc'); + + } else if ($this->option('documents') === 'v2') { DB::update('DELETE FROM fluidbook_document WHERE id<' . $ws3step); } else if ($this->option('documents') === 'all') { FluidbookDocument::truncate(); @@ -145,7 +149,7 @@ class WorkshopMigration extends CubistCommand protected function importPublications($reset = false) { - if($this->option('publications')==='none'){ + if ($this->option('publications') === 'none') { return; } diff --git a/app/Models/FluidbookDocument.php b/app/Models/FluidbookDocument.php index ded006f17..3ae438568 100644 --- a/app/Models/FluidbookDocument.php +++ b/app/Models/FluidbookDocument.php @@ -17,7 +17,7 @@ use Illuminate\Support\Facades\Cache; class FluidbookDocument extends ToolboxModel { - public const WS_DOCS = '/application/protected/fluidbookpublication/docs/'; + public const WS_DOCS = '/application/fluidbook/docs/'; protected $table = 'fluidbook_document'; protected $_options = ['name' => 'fluidbook-document', 'singular' => 'document', @@ -57,6 +57,11 @@ class FluidbookDocument extends ToolboxModel return sqrt($a4surface / $docSurface); } + public function getPageSize($page) + { + return $this->pdf_data['page'][$page]['size']; + } + public function processUpload($uploadID, $sync = false) { $this->processSync = $sync; @@ -324,7 +329,7 @@ class FluidbookDocument extends ToolboxModel public function _getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html') { if (!$this->hasFile($page, $format, $resolution, $withText, $withGraphics, $version)) { - return FluidbookFarm::getFile($page, $format, $resolution, $withText, $withGraphics, $version, $this->getResolutionRatio(), $this->getMobileFirstRatio(), $this->path() . '/'); + return FluidbookFarm::getFile($page, $format, $resolution, $withText, $withGraphics, $version, $this->getResolutionRatio(), $this->getMobileFirstRatio(), $this->path()); } $path = $this->_getPath($page, $format, $resolution, $withText, $withGraphics, $version); diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index 26f777d14..05bf5431d 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -153,6 +153,11 @@ class FluidbookPublication extends ToolboxSettingsModel { /** @var \App\Models\User $owner */ $owner = \App\Models\User::find($this->owner); + if (null === $owner) { + $this->owner = 1; + $this->saveQuietly(); + $owner = \App\Models\User::find(1); + } /** @var Company $company */ $company = Company::find($owner->company); @@ -295,8 +300,8 @@ class FluidbookPublication extends ToolboxSettingsModel public function getDocumentSize($page = 1) { - $sizes = $this->getDocumentSizes(); - return $sizes[$this->composition[$page][0]]; + $document=$this->getDocument($page); + return $document->getPageSize($this->composition[$page][1]); } public function getPageWidth($page = 1) diff --git a/resources/linkeditor/js/linkeditor.js b/resources/linkeditor/js/linkeditor.js index 7e1e3b13a..9d729d24d 100644 --- a/resources/linkeditor/js/linkeditor.js +++ b/resources/linkeditor/js/linkeditor.js @@ -332,6 +332,9 @@ LinkEditor.prototype = { this.loader.loadPage(this.currentPage + 1, 'right'); } $("#linkeditor-page-field input").val(this.currentPage); + if (this.mobileFirst) { + this.zoom.reset(); + } this.resize.resize(); this.loader.preloadPages(); }, diff --git a/resources/linkeditor/js/linkeditor.resize.js b/resources/linkeditor/js/linkeditor.resize.js index 2c6514443..516a9cde5 100644 --- a/resources/linkeditor/js/linkeditor.resize.js +++ b/resources/linkeditor/js/linkeditor.resize.js @@ -22,11 +22,11 @@ LinkeditorResize.prototype = { this.updateWindowDimensions(); this.resizeMain(); this.resizeCanvas(); - if(this.linkeditor.panels) { + if (this.linkeditor.panels) { this.linkeditor.panels.resize(this.ww); } this.linkeditor.rulers.updateRulers(); - if(this.linkeditor.popup){ + if (this.linkeditor.popup) { this.linkeditor.popup.resize(); } }, @@ -41,8 +41,16 @@ LinkeditorResize.prototype = { var aw = this.linkeditor.canvasRect.width - 30; var ah = this.linkeditor.canvasRect.height - 30; this.linkeditor.fs = Math.min(aw / this.linkeditor.fw, ah / this.linkeditor.fh); - var left = ((this.linkeditor.canvasRect.width * 2) - this.linkeditor.fw * this.linkeditor.fs) / 2; - var top = ((this.linkeditor.canvasRect.height * 2) - this.linkeditor.fh * this.linkeditor.fs) / 2; + + let left, top; + + if (!this.linkeditor.mobileFirst) { + left = ((this.linkeditor.canvasRect.width * 2) - this.linkeditor.fw * this.linkeditor.fs) / 2; + top = ((this.linkeditor.canvasRect.height * 2) - this.linkeditor.fh * this.linkeditor.fs) / 2; + } else { + left = (this.linkeditor.canvasRect.width - this.linkeditor.fw * this.linkeditor.fs) / 2; + top = 100; + } $("#linkeditor-fluidbook").css({left: left, top: top, transform: 'scale(' + this.linkeditor.fs + ')'}); }, }; diff --git a/resources/linkeditor/js/linkeditor.utils.js b/resources/linkeditor/js/linkeditor.utils.js index 25454c371..24fcc311e 100644 --- a/resources/linkeditor/js/linkeditor.utils.js +++ b/resources/linkeditor/js/linkeditor.utils.js @@ -8,6 +8,10 @@ LinkeditorUtils.prototype = { }, + maxPageHeight: function () { + + }, + normalizePage: function (page) { page = parseInt(page); if (page % 2 === 1 && !this.linkeditor.single) { diff --git a/resources/linkeditor/js/linkeditor.zoom.js b/resources/linkeditor/js/linkeditor.zoom.js index d08f1bfd4..1322740b7 100644 --- a/resources/linkeditor/js/linkeditor.zoom.js +++ b/resources/linkeditor/js/linkeditor.zoom.js @@ -10,25 +10,27 @@ LinkeditorZoom.prototype = { this.zoom = 1; this.zoomdragging = false; - $("#linkeditor-main").on('wheel', function (e) { - var step = $this.zoom >= 1 ? 0.25 : 0.1; - $this.linkeditor.setMouseCoordinates(e); - let delta = e.originalEvent.deltaY; - if (delta === 0) { - return true; - } - e.stopPropagation(); - e.stopImmediatePropagation(); - e.preventDefault(); - if (delta < 0) { - if ($this.setZoom($this.zoom + step)) { - $this.moveZoom(e); + if (!this.linkeditor.mobileFirst) { + $("#linkeditor-main").on('wheel', function (e) { + var step = $this.zoom >= 1 ? 0.25 : 0.1; + $this.linkeditor.setMouseCoordinates(e); + let delta = e.originalEvent.deltaY; + if (delta === 0) { + return true; } - } else { - $this.setZoom($this.zoom - step); - } - return false; - }); + e.stopPropagation(); + e.stopImmediatePropagation(); + e.preventDefault(); + if (delta < 0) { + if ($this.setZoom($this.zoom + step)) { + $this.moveZoom(e); + } + } else { + $this.setZoom($this.zoom - step); + } + return false; + }); + } }, mouseUp: function () { @@ -76,18 +78,27 @@ LinkeditorZoom.prototype = { }, setZoom: function (z, force) { + if (!this.linkeditor.mobileFirst) { + z = 1; + } let $this = this; z = this.normalizeZoom(z); - if (force !== true && z === this.zoom) { - return false; - } + this.zoom = z; - let cw2 = this.linkeditor.canvasRect.width * 2; - let ch2 = this.linkeditor.canvasRect.height * 2; - let zh = ch2; - if (this.zoom < 1) { - zh *= this.zoom; + + let cw2, ch2, zh; + if (this.linkeditor.mobileFirst) { + cw2 = this.linkeditor.canvasRect.width; + zh = parseFloat(FLUIDBOOK_DATA.pages_max_height) + 200; + } else { + cw2 = this.linkeditor.canvasRect.width * 2; + ch2 = this.linkeditor.canvasRect.height * 2; + zh = ch2; + if (this.zoom < 1) { + zh *= this.zoom; + } } + $("#linkeditor-canvas").attr('data-z', this.zoom); $("#linkeditor-zoom").css({ transform: 'scale(' + this.zoom + ')', overflow: 'visible', @@ -112,7 +123,8 @@ LinkeditorZoom.prototype = { reset: function () { this.setZoom(1); - $("#linkeditor-canvas").scrollTo({top: '50%', left: '50%'}); + var top = this.linkeditor.mobileFirst ? 0 : '50%'; + $("#linkeditor-canvas").scrollTo({top: top, left: '50%'}); this.resetZoomDrag(); }, }; diff --git a/resources/views/fluidbook_publication/link_editor.blade.php b/resources/views/fluidbook_publication/link_editor.blade.php index f79a9c1c1..d389f72c7 100644 --- a/resources/views/fluidbook_publication/link_editor.blade.php +++ b/resources/views/fluidbook_publication/link_editor.blade.php @@ -6,6 +6,12 @@ $fbdata['settings']['width']=$fbdata['width']=$fluidbook->getPageWidth(); $fbdata['settings']['height']=$fbdata['height']=$fluidbook->getPageHeight(); $fbdata['settings']['pages']=$fbdata['pages']=$fluidbook->getPagesNumber(); + $mh = 0; + for($i=1;$i<=$fbdata['pages'];$i++){ + $mh = max($mh, $fluidbook->getPageHeight($i)); + } + $fbdata['pages_max_height']=$mh; + $translations=[ 'success_save'=>__('Liens sauvegardés'), 'error_save'=>__('Une erreur s\'est produite lors de la sauvegarde des liens'), @@ -48,7 +54,9 @@