]> _ Git - cubeextranet.git/commitdiff
wip #3497 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 23 Jun 2020 15:48:09 +0000 (15:48 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 23 Jun 2020 15:48:09 +0000 (15:48 +0000)
inc/ws/Util/html5/master/class.ws.html5.links.php

index 45cc713da2ee22a62ee6de8ed49892ed2a8059df..b48fb2457f5a6a526961fabe732532cfa8f3eda0 100644 (file)
@@ -1305,7 +1305,12 @@ class downloadPortionLink extends fileLink
 
     public function getZoomAttributes()
     {
-        return [
+        $pdf = $this->compiler->book->parametres->downloadPortionPDF;
+        if ($pdf !== '') {
+            $pdf = $this->compiler->wdir . '/' . $this->compiler->book->parametres->downloadPortionPDF;
+        }
+
+        $res = [
             'id' => $this->id,
             'page' => $this->page,
             'maxzoom' => $this->compiler->book->parametres->downloadPortionZoom,
@@ -1314,11 +1319,12 @@ class downloadPortionLink extends fileLink
             'width' => round($this->width),
             'height' => round($this->height),
             'x' => round($this->left),
-            'y' => round($this->top)
+            'y' => round($this->top),
+            'pdf' => $pdf,
         ];
+        return $res;
     }
 
-
     public function getAdditionnalContent()
     {
         $file = $this->to;
@@ -1957,22 +1963,35 @@ class zoomLink extends normalLink
 
         //error_log("--- Book Width: $bookwidth ---");
 
-        $p = wsDAOBook::getDocumentPage($compiler->book_id, $attributes['page']);
-        $pdfpath = wsDocument::getDir($p['document_id']) . '/pdf/p' . $p['document_page'] . '.pdf';
+        if (!isset($attributes['pdf']) || !$attributes['pdf']) {
+            $p = wsDAOBook::getDocumentPage($compiler->book_id, $attributes['page']);
+            $pdfpath = wsDocument::getDir($p['document_id']) . '/pdf/p' . $p['document_page'] . '.pdf';
+            $extractPage = 1;
+        } else {
+            $pdfpath = $attributes['pdf'];
+            $extractPage = $attributes['page'];
+        }
 
         $left = CubeIT_Files::tempnam();
         $leftfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
-            1,
+            $extractPage,
             array('x' => $x, 'y' => $y, 'width' => $w, 'height' => $h),
             $left, $extractOptions, WS_CACHE . '/' . $cachedir . '/' . $compiler->book_id . '/');
 
         if (($x + $w) > $bookwidth) {
-            $p = wsDAOBook::getDocumentPage($compiler->book_id, $attributes['page'] + 1);
-            $pdfpath = wsDocument::getDir($p['document_id']) . '/pdf/p' . $p['document_page'] . '.pdf';
+            if (!isset($attributes['pdf']) || !$attributes['pdf']) {
+                $p = wsDAOBook::getDocumentPage($compiler->book_id, $attributes['page'] + 1);
+                $pdfpath = wsDocument::getDir($p['document_id']) . '/pdf/p' . $p['document_page'] . '.pdf';
+                $extractPage = 1;
+            } else {
+                $pdfpath = $attributes['pdf'];
+                $extractPage = $attributes['page'] + 1;
+            }
+
             $diff = ($w + $x) - $bookwidth;
             $right = CubeIT_Files::tempnam();
             $rightfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
-                1,
+                $extractPage,
                 array('x' => 0, 'y' => $y, 'width' => $diff, 'height' => $h),
                 $right, $extractOptions, WS_CACHE . '/' . $cachedir . '/' . $compiler->book_id . '/');