]> _ Git - cubeextranet.git/commitdiff
wip #3741 @2.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 30 Jun 2020 17:47:46 +0000 (17:47 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 30 Jun 2020 17:47:46 +0000 (17:47 +0000)
inc/ws/Util/html5/master/class.ws.html5.links.php

index b48fb2457f5a6a526961fabe732532cfa8f3eda0..5354e0dcc8a2c66b509a4cabcdbdce7c383fe9a4 100644 (file)
@@ -38,6 +38,8 @@ class wsHTML5Link
     public $zindex = 4;
     public $rightClone = false;
     public $iframeType = "none";
+    public $border = 0;
+    public $borderColor = '#ffffff';
 
     protected $_init;
 
@@ -197,6 +199,47 @@ class wsHTML5Link
         }
     }
 
+    public static function parseExtras($extras)
+    {
+        $extras = trim($extras);
+        if ($extras === '') {
+            return [];
+        }
+        $res = [];
+        $lines = CubeIT_Text::splitLines($extras);
+        foreach ($lines as $line) {
+            $e = explode('=', $line);
+            if (count($e) < 2) {
+                continue;
+            }
+            $v = trim($e[1]);
+            // Handle values surronded by quotes
+            if (preg_match('|^\"([^\"]+)\"$|', $v, $matches)) {
+                $v = $matches[1];
+            }
+            $res[trim($e[0])] = $v;
+        }
+
+        return $res;
+    }
+
+    public static function parseAnimation($animation)
+    {
+        $extras = self::parseExtras($animation);
+        if (count($extras) > 0) {
+            if (!isset($extras['direction'])) {
+                $extras['direction'] = 'right';
+            }
+            if ($extras['direction'] === 'top') {
+                $extras['direction'] = 'up';
+            }
+            if ($extras['direction'] === 'bottom') {
+                $extras['direction'] = 'down';
+            }
+        }
+        return $extras;
+    }
+
     public static function replaceCustomURL($url)
     {
         $url = trim($url);
@@ -244,11 +287,17 @@ class wsHTML5Link
             if ($k == 'extra') {
                 if (CubeIT_Util_Json::isJson($v)) {
                     $v = CubeIT_Util_Json::decode($v);
-                } else if (stristr($v, '=')) {
+                } else if (stristr($v, '=') && stristr($v, '&')) {
                     $vv = $v;
                     $v = [];
                     parse_str($vv, $v);
                     $v = CubeIT_Util_Object::asObject($v);
+                } else {
+                    $extras = self::parseExtras($v);
+                    foreach ($extras as $extrak => $extrav) {
+                        $this->$extrak = $extrav;
+                    }
+                    continue;
                 }
             }
             $this->$k = $v;
@@ -703,37 +752,6 @@ class contentLink extends wsHTML5Link
         return $res;
     }
 
-    public static function parseAnimation($animation)
-    {
-        $animation = trim($animation);
-        $variables = [];
-        if ($animation != '') {
-            $lines = CubeIT_Text::splitLines($animation);
-            foreach ($lines as $line) {
-                $e = explode('=', $line);
-                if (count($e) < 2) {
-                    continue;
-                }
-                $v = trim($e[1]);
-                // Handle values surronded by quotes
-                if (preg_match('|^\"([^\"]+)\"$|', $v, $matches)) {
-                    $v = $matches[1];
-                }
-                $variables[trim($e[0])] = $v;
-            }
-            if (!isset($variables['direction'])) {
-                $variables['direction'] = 'right';
-            }
-            if ($variables['direction'] == 'top') {
-                $variables['direction'] = 'up';
-            }
-            if ($variables['direction'] == 'bottom') {
-                $variables['direction'] = 'down';
-            }
-        }
-        return $variables;
-    }
-
     public function getCSSZIndex()
     {
         if ($this->zindex === 0) {
@@ -1321,6 +1339,8 @@ class downloadPortionLink extends fileLink
             'x' => round($this->left),
             'y' => round($this->top),
             'pdf' => $pdf,
+            'border' => $this->border,
+            'borderColor' => $this->borderColor,
         ];
         return $res;
     }
@@ -1930,7 +1950,9 @@ class zoomLink extends normalLink
             'width' => round($this->width),
             'height' => round($this->height),
             'x' => round($this->left),
-            'y' => round($this->top)
+            'y' => round($this->top),
+            'border' => $this->border,
+            'borderColor' => $this->borderColor,
         ];
     }
 
@@ -1949,7 +1971,7 @@ class zoomLink extends normalLink
             // The Poppler::extractArea function accepts a resolution setting and uses that to determine the
             // scale factor on the extracted images. It does so by dividing by 72, so we can pass our own scale
             // factor by setting the resolution to 72 * $maxzoom
-            'resolution' => 72 * $maxzoom
+            'resolution' => 150 * $maxzoom
         ];
 
         // Round all link co-ordinates because there seems to be a problem with the the Workshop link editor
@@ -2001,6 +2023,13 @@ class zoomLink extends normalLink
             $both = $leftfile;
         }
 
+        if ($attributes['border'] > 0) {
+            $tmp = CubeIT_Files::tempnam() . '.jpg';
+            CubeIT_CommandLine_Imagemagick::addBorder($both, $tmp, $attributes['border'], $attributes['borderColor']);
+            $compiler->vdir->addTemp($both);
+            $both = $tmp;
+        }
+
         $compiler->simpleCopyLinkFile($both, 'data/links/' . $save . '_' . $attributes['id'] . '.jpg');
 
         // Perform tidy up and delete temporary files if they exist