]> _ Git - fluidbook_tools.git/commitdiff
wait #6076 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Sat, 24 Jun 2023 10:47:44 +0000 (12:47 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Sat, 24 Jun 2023 10:47:44 +0000 (12:47 +0200)
.idea/deployment.xml
src/Links/LayerLink.php
src/Links/ZoomLink.php

index ff7f409b9f5e5ad4eea579f0b1d4c4c796ade867..6f144a767c79d46a0afd5cd197ab13d864a0e9c9 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
-  <component name="PublishConfigData" autoUpload="Always" serverName="dev.toolbox.fluidbook.com" remoteFilesAllowedToDisappearOnAutoupload="false" confirmBeforeUploading="false" autoUploadExternalChanges="true" showAutoUploadSettingsWarning="false">
+  <component name="PublishConfigData" autoUpload="Always" serverName="toolbox.fluidbook.com" remoteFilesAllowedToDisappearOnAutoupload="false" confirmBeforeUploading="false" autoUploadExternalChanges="true" showAutoUploadSettingsWarning="false">
     <option name="confirmBeforeUploading" value="false" />
     <serverData>
       <paths name="alphaville.cubedesigners.com">
index 7646061a7db05afb480e0fb13001d57d71b6f6e0..cf9ad8f9a5e9250ff6ca79df6fc904ca704818a2 100644 (file)
@@ -23,11 +23,23 @@ class LayerLink extends ImageLink {
     }
 
     public function getImageUrl() {
-        return 'data/links/layer_' . $this->uid . '.jpg';
+        return 'data/links/layer_' . $this->uid . '.' . $this->_getExtension();
+    }
+
+    protected function _getExtension() {
+        if ($this->_getLayer() === 'text') {
+            return 'svg';
+        } else {
+            return 'jpg';
+        }
+    }
+
+    protected function _getLayer() {
+        return $this->to ?: 'both';
     }
 
     public function getZoomAttributes() {
-        $layer = $this->to ?: 'both';
+        $layer = $this->_getLayer();
         return [
             'id' => $this->uid,
             'page' => $this->page,
index 43291f71a903295b8366cefab7e1ef5f03dfc5d8..c10b8b2786d77f194d7076bf4e40eb531184eda1 100644 (file)
@@ -116,11 +116,18 @@ class ZoomLink extends NormalLink {
             unset($attributes['layer']);
         }
 
+        $bookwidth = $compiler->getWidthForLinks();
         $x = $attributes['x'];
         $y = $attributes['y'];
         $w = $attributes['width'];
         $h = $attributes['height'];
-        $bookwidth = $compiler->getWidthForLinks();
+
+        if ($attributes['page'] == 0) {
+            $diff = $bookwidth - $attributes['x'];
+            $attributes['page'] = 1;
+            $x = 0;
+            $w -= $diff;
+        }
 
         if (!isset($attributes['pdf']) || !$attributes['pdf']) {
             $pdfpath = $compiler->getPagePDFSource($attributes['page']);
@@ -130,8 +137,17 @@ class ZoomLink extends NormalLink {
             $extractPage = $attributes['page'];
         }
 
-        if (isset($attributes['layer']) && $attributes['layer'] === 'image') {
-            $extractOptions['texts'] = false;
+        $extractOptions['format'] = 'jpeg';
+        $ext = 'jpg';
+        if (isset($attributes['layer'])) {
+            if ($attributes['layer'] === 'image') {
+                $extractOptions['texts'] = false;
+                $extractOptions['background'] = true;
+            } else if ($attributes['layer'] === 'text') {
+                $extractOptions['texts'] = true;
+                $extractOptions['background'] = false;
+                $ext = $extractOptions['format'] = 'svg';
+            }
         }
 
         $cache = $compiler->getCacheDir("zoomarea/" . $cachedir);
@@ -161,7 +177,7 @@ class ZoomLink extends NormalLink {
                 throw new \Exception('Error generating right part ' . $rightfile);
             }
 
-            $both = $cache . hash('sha256', $leftfile . $rightfile) . '.jpg';
+            $both = $cache . hash('sha256', $leftfile . $rightfile) . '.' . $ext;
             if (!file_exists($both)) {
                 Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal');
             }
@@ -173,7 +189,7 @@ class ZoomLink extends NormalLink {
         }
 
         if ($trim) {
-            $trimmed = str_replace('.jpg', '.trim.jpg', $both);
+            $trimmed = str_replace('.jpg', '.trim.' . $ext, $both);
             if (!file_exists($trimmed) || filemtime($trimmed) < filemtime($both)) {
                 Imagemagick::trim($both, $trimmed);
             }
@@ -189,7 +205,7 @@ class ZoomLink extends NormalLink {
         //                dd($both);
 
 
-        $dest = 'data/links/' . $save . '_' . $attributes['id'] . '.jpg';
+        $dest = 'data/links/' . $save . '_' . $attributes['id'] . '.' . $ext;
         $compiler->simpleCopyLinkFile($both, $dest);
     }