]> _ Git - cubeextranet.git/commitdiff
wip #1363 @2
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 25 Apr 2017 16:59:14 +0000 (16:59 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 25 Apr 2017 16:59:14 +0000 (16:59 +0000)
inc/ws/Util/html5/class.ws.html5.links.php

index 614da6d405e6eaf82580a0ea939efd68dd1e1605..df326ab8566de5f9f436168298265234ed16fc1f 100644 (file)
@@ -129,6 +129,9 @@ class wsHTML5Link {
                        case 26:
                                $compiler->addPageLabel($init['page'], $init['to']);
                                break;
+                       case 27:
+                               return new eventOverlayLink($id, $init, $compiler);
+                               break;
                        default:
                                return null;
                }
@@ -412,6 +415,16 @@ class contentLink extends wsHTML5Link {
 
 }
 
+class eventOverlayLink extends wsHTML5Link {
+       public function getHTMLContainerClass() {
+               return parent::getHTMLContainerClass() . ' eventOverlayLink';
+       }
+
+       public function getHTMLContent() {
+               return '<div></div>';
+       }
+}
+
 class webLink extends normalLink {
        public function getURL() {
                $res = str_replace('"', '\'', wsHTML5Link::getUniversalLocation($this->to));
@@ -1082,29 +1095,42 @@ class zoomLink extends normalLink {
 
        public function __construct($id, $init, $compiler) {
                parent::__construct($id, $init, $compiler);
+       }
 
-               fb($id, 'ID');
-               fb($init, 'INIT');
-               fb($compiler, 'COMPILER');
+       public function getAdditionnalContent() {
+               $res = parent::getAdditionnalContent();
+
+               // Data attributes
+               $attributes = [
+                       'maxzoom' => $this->to,
+               ];
+
+               // Set data attributes
+               foreach ($attributes as $key => $val) {
+                       $res .= ' data-' . $key . '="' . $val . '"';
+               }
+
+               $this->generateImage();
+
+               return $res;
        }
 
-    public function getAdditionnalContent() {
-        $res  = parent::getAdditionnalContent();
+       public function generateImage() {
+               $left = CubeIT_Files::tempnam();
+
+               $p = wsDAOBook::getDocumentPage($this->compiler->book_id, $this->page);
+               $pdfpath = wsDocument::getDir($p['document_id']) . 'original.pdf';
 
-        // Data attributes
-        $attributes = [
-            'maxzoom' => $this->to,
-        ];
+               CubeIT_CommandLine_Poppler::extractArea($pdfpath,
+                       $this->page,
+                       array('x' => $this->left, 'y' => $this->top, 'width' => $this->width, 'height' => $this->height),
+                       $left);
 
-        // Set data attributes
-        foreach ($attributes as $key => $val) {
-            $res .= ' data-'.$key.'="'. $val .'"';
-        }
+               $this->compiler->simpleCopyLinkFile($left . '.png', 'data/links/zoom_' . $this->id . '.png');
+       }
 
-        return $res;
-    }
 
-    public function getClasses() {
-        return array_merge(['zoomPopup'], parent::getClasses());
-    }
+       public function getClasses() {
+               return array_merge(['zoomPopup'], parent::getClasses());
+       }
 }
\ No newline at end of file