]> _ Git - fluidbook_tools.git/commitdiff
wait #6769 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 5 Mar 2024 15:30:32 +0000 (16:30 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 5 Mar 2024 15:30:32 +0000 (16:30 +0100)
src/Links/ZoomLink.php

index 267d4c0202a6194a7c53891f2b5ec9600554cb1b..0f06aca7ac7d7494e99cb55377601764b78baa2f 100644 (file)
@@ -11,15 +11,18 @@ use Fluidbook\Tools\Compiler\CompilerInterface;
 use Fluidbook\Tools\SVG\SVGTools;
 use Illuminate\Support\Facades\Log;
 
-class ZoomLink extends NormalLink {
+class ZoomLink extends NormalLink
+{
     protected $maxzoom_default = 2;
     protected $_groups = null;
 
-    public function ignore() {
+    public function ignore()
+    {
         return parent::ignore() || $this->isOutsidePage();
     }
 
-    public function getGroups() {
+    public function getGroups()
+    {
         if (null === $this->_groups) {
             $this->_groups = [];
             $groups = explode(',', $this->group);
@@ -30,13 +33,15 @@ class ZoomLink extends NormalLink {
         return $this->_groups;
     }
 
-    public function init() {
+    public function init()
+    {
         $this->compiler->addJsLib('fluidbook-zoom', 'js/libs/fluidbook/links/fluidbook.links.zoom.js');
         $this->maxzoom_default = $this->compiler->getSetting('zoomAreaDefaultZoomLevel', 2);
         parent::init();
     }
 
-    public function getHTMLContainerClass() {
+    public function getHTMLContainerClass()
+    {
         $class = ' zoomarea';
 
         $groups = $this->getGroups();
@@ -50,11 +55,13 @@ class ZoomLink extends NormalLink {
         return parent::getHTMLContainerClass() . $class;
     }
 
-    public function getDefaultTooltip() {
+    public function getDefaultTooltip()
+    {
         return 'zoom in';
     }
 
-    public function getAdditionnalContent() {
+    public function getAdditionnalContent()
+    {
         $res = parent::getAdditionnalContent();
 
         $res .= ' id="' . $this->uid . '"';
@@ -74,7 +81,8 @@ class ZoomLink extends NormalLink {
         return $res;
     }
 
-    public function getZoomAttributes() {
+    public function getZoomAttributes()
+    {
         return [
             'id' => $this->uid,
             'page' => $this->page,
@@ -97,9 +105,13 @@ class ZoomLink extends NormalLink {
      * @param $save
      * @return string
      */
-    public static function generateImage($attributes, $compiler, $cachedir, $save, $trim = false,$copy=true) {
+    public static function generateImage($attributes, $compiler, $cachedir, $save, $trim = false, $copy = true)
+    {
 
         $maxzoom = $attributes['maxzoom']; // Max zoom level might not always be set in the link editor
+        if (!is_numeric($maxzoom)) {
+            $maxzoom = 4;
+        }
         $maxzoom = max(0, min($maxzoom, 20));
         if (!$maxzoom) {
             $maxzoom = 2;
@@ -161,7 +173,6 @@ class ZoomLink extends NormalLink {
         $cache = $compiler->getCacheDir("zoomarea/" . $cachedir);
 
 
-
         $leftHeight = min($h, $compiler->getHeightForLinks($attributes['page']) - $y);
         $leftWidth = min($w, $compiler->getWidthForLinks($attributes['page']) - $x);
 
@@ -231,14 +242,15 @@ class ZoomLink extends NormalLink {
             Log::error('Failed generate image ' . json_encode($attributes));
         }
         $dest = 'data/links/' . $save . '_' . $attributes['id'] . '.' . $ext;
-        if($copy) {
+        if ($copy) {
             $compiler->simpleCopyLinkFile($both, $dest);
         }
         return $both;
     }
 
 
-    public function getClasses() {
+    public function getClasses()
+    {
         // Assign CSS classes for all groups so we can match and group them via JS
         $groups = $this->getGroups();
         $group_classes = [];