From 0b73459b235947b72987b8f852ba9a3a8819af9d Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 25 Apr 2017 16:59:14 +0000 Subject: [PATCH] wip #1363 @2 --- inc/ws/Util/html5/class.ws.html5.links.php | 62 +++++++++++++++------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/inc/ws/Util/html5/class.ws.html5.links.php b/inc/ws/Util/html5/class.ws.html5.links.php index 614da6d40..df326ab85 100644 --- a/inc/ws/Util/html5/class.ws.html5.links.php +++ b/inc/ws/Util/html5/class.ws.html5.links.php @@ -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 '
'; + } +} + 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 -- 2.39.5