]> _ Git - cubeextranet.git/commitdiff
fix #3367 @5.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 24 Jan 2020 17:07:13 +0000 (17:07 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 24 Jan 2020 17:07:13 +0000 (17:07 +0000)
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index ba4f73d8e9dfa6572e79142afe45d2c9ca536e5b..50d4a90eb4fbaa02fdcf44d7f72efad00923dfbf 100644 (file)
@@ -275,14 +275,14 @@ class wsHTML5Compiler
 
         $this->log('Got data from database');
 
-        $this->width = round($size[0], 3);
-        $this->height = round($size[1], 3);
+        $this->width = round($size[0], 8);
+        $this->height = round($size[1], 8);
 
         wsDocument::makeHTML5FilesIfNotExists($this->pages[1]['document_id'], $this->pages[1]['document_page']);
         $firstJpeg = wsDocument::getDir($this->pages[1]['document_id']) . 'html/h150-' . $this->pages[1]['document_page'] . '.jpg';
 
         $imagesize = CubeIT_Image::getimagesize($firstJpeg);
-        $this->pdf2htmlRatio = round(($imagesize[0] * 0.48) / $this->width, 8);
+        $this->pdf2htmlRatio = round(($imagesize[0] * 0.48) / $this->width, 12);
 
         $this->linkScale = $this->cssScale = $this->z * min($this->optimalWidth / $this->width, $this->optimalHeight / $this->height);
         $this->cssOneScale = $this->z * min(($this->optimalWidth * 2) / $this->width, $this->optimalHeight / $this->height);
@@ -300,7 +300,7 @@ class wsHTML5Compiler
 
         $this->numerotation = explode(',', $this->book->numerotation);
 
-        if ($this->book->parametres->mobileNavigationType === 'mobilefirst') {
+        if ($this->isMobileFirst()) {
             $this->cssScale = $this->cssOneScale = 480 / $this->width;
             $this->linkScale = $this->cssScale;
             $this->cssOneWidth = $this->cssWidth = $this->width * $this->cssScale;
@@ -308,7 +308,7 @@ class wsHTML5Compiler
             $this->initMobileFirst();
         }
 
-        if ($this->book->parametres->zoomMode == 1 || $this->book->parametres->mobileNavigationType === 'mobilefirst') {
+        if ($this->book->parametres->zoomMode == 1 || $this->isMobileFirst()) {
             $this->multiply = $this->pdf2htmlRatio * $this->scale * $this->cssOneScale;
         } else {
             $this->multiply = $this->pdf2htmlRatio * $this->scale * $this->cssScale;
@@ -318,6 +318,11 @@ class wsHTML5Compiler
         $this->log('Defined dimensions');
     }
 
+    public function isMobileFirst()
+    {
+        return $this->book->parametres->mobileNavigationType === 'mobilefirst';
+    }
+
     public function initMobileFirst()
     {
         $this->theme->parametres->usePageEdges = false;
@@ -1652,6 +1657,7 @@ class wsHTML5Compiler
     protected function writeImages()
     {
         global $core;
+        $daoDoc = new wsDAODocument($core->con);
 
         switch ($this->book->parametres->mobileVersion) {
             case 'html5-desktop':
@@ -1697,7 +1703,8 @@ class wsHTML5Compiler
                     }
                     $source = $docdir . $imdir . '/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg';
                     if ($r == 150 && file_exists($source)) {
-                        $d = getimagesize($source);
+                        $firstDoc = $daoDoc->selectById($infos['document_id']);
+                        $d = $firstDoc->generalInfos['page'][$infos['document_page']]['size'];
                         $this->config->pagesDimensions[$page] = array($this->cssWidth, $d[1] * ($this->cssWidth / $d[0]));
                     }
                     $ok = $this->vdir->copy($source, 'data/background/' . $r . '/' . $backgroundsPrefix . $page . '.jpg');
@@ -1859,7 +1866,7 @@ class wsHTML5Compiler
 
         $lessVariables['z'] = $this->z;
         $lessVariables['book-page-width'] = $w;
-        if ($this->book->parametres->correctCenter) {
+        if ($this->book->parametres->correctCenter && !$this->isMobileFirst()) {
             $lessVariables['book-page-correct-width'] = ceil($w) + 1;
             $lessVariables['book-page-correct-height'] = ceil($h) + 1;
         } else {
@@ -1879,6 +1886,8 @@ class wsHTML5Compiler
         $lessVariables['display-page-number'] = $this->_lessBoolean($this->theme->parametres->displayPageNumber);
         $lessVariables['page-transition-duration'] = $this->book->parametres->mobileTransitionDuration . 's';
 
+        $corrText = $this->isMobileFirst() ? 0 : 4;
+
         if ($this->cssSVGScale != 1) {
             $texts = '.texts{' . wsHTML5::writeCSSUA('transform-origin', 'top left') . ';';
             $texts .= wsHTML5::writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale * $this->cssSVGScale, 3) . ')') . ';';
@@ -1886,7 +1895,7 @@ class wsHTML5Compiler
             $texts .= 'height:' . ($hm / $this->cssSVGScale) . 'px; max-height:' . ($hm / $this->cssSVGScale) . 'px;';
             $texts .= '}';
         } else {
-            $texts = '.texts{width:' . floor(floatval($w) + 4) . 'px;height:' . floor(floatval($h) + 4) . 'px;}';
+            $texts = '.texts{width:' . floor(floatval($w) + $corrText) . 'px;height:' . floor(floatval($h) + $corrText) . 'px;}';
         }
         $res[] = $texts;