From e293bbd9e697e02b1028a462ee9236ecc102a182 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 5 Mar 2024 16:30:32 +0100 Subject: [PATCH] wait #6769 @1 --- src/Links/ZoomLink.php | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/Links/ZoomLink.php b/src/Links/ZoomLink.php index 267d4c0..0f06aca 100644 --- a/src/Links/ZoomLink.php +++ b/src/Links/ZoomLink.php @@ -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 = []; -- 2.39.5