]> _ Git - cubeextranet.git/commitdiff
wait #5993 @0.75
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 5 Jun 2023 13:46:20 +0000 (13:46 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 5 Jun 2023 13:46:20 +0000 (13:46 +0000)
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Metier/class.ws.book.php
inc/ws/Metier/class.ws.document.php
inc/ws/Util/html5/master/class.ws.html5.links.php

index 28649b6c4c3b9c5210d9de6cdd9ac9d2bc5e2093..afb8301830328f5f4e82c00378cf3aabd6ffdd9c 100644 (file)
@@ -1761,7 +1761,7 @@ class wsMaintenance
 
         foreach ($files as $file) {
             echo '<h2>' . json_encode($file) . '</h2>';
-            $path = $doc->getFile($page, $file[0], $file[1], $file[2], $file[3], $file[4], true);
+            $path = $doc->getFile($page, $file[0], $file[1],85, $file[2], $file[3], $file[4], true);
             echo '<p>' . $path . '</p>';
             $path = str_replace('/data1/extranet/www/', 'https://workshop.fluidbook.com/', $path);
             $path = str_replace('/home/extranet/www/', 'https://workshop.fluidbook.com/', $path);
index 4f8ed212b1e62af98185274ffd6fc7159d68563e..df1157b2d25c11d8da3afd1838ff5f574eb92497 100644 (file)
@@ -91,16 +91,13 @@ class wsBook extends cubeMetier
             $dao = new wsDAODocument($core->con);\r
             $this->_docs[$p['document_id']] = $dao->selectById($p['document_id']);\r
         }\r
-        if ($format === 'jpg') {\r
-            $q = $this->parametres->JPEGQuality ?? 85;\r
-        } else {\r
-            $q = 85;\r
-        }\r
-        if ($q != 85) {\r
-            $resolution .= '-' . $q;\r
-        }\r
+        $q = $this->parametres->JPEGQuality ?: 85;\r
+\r
+\r
         $doc = $this->_docs[$p['document_id']];\r
-        return $doc->getFile($p['document_page'], $format, $resolution, $withText, $withGraphics, $version, $force);\r
+        $res= $doc->getFile($p['document_page'], $format, $resolution, $q, $withText, $withGraphics, $version, $force);\r
+\r
+        return $res;\r
     }\r
 \r
     public function getThumbFile($page, $format)\r
@@ -152,7 +149,7 @@ class wsBook extends cubeMetier
 \r
     public static function getDir($id, $dir, $addSlash = true, $onlyroot = false)\r
     {\r
-        $res = self::getRegionDir($id,false);\r
+        $res = self::getRegionDir($id, false);\r
         $res .= $dir . '/';\r
         if (!$onlyroot) {\r
             $res .= $id . '/';\r
index 891db1d686fe7b7c7bf4549ffd958a90dcb634fc..fec0cc9b59ab9018aba3b95182074a27b963a62d 100644 (file)
@@ -435,12 +435,13 @@ class wsDocument extends cubeMetier
         return $this->filesdata;
     }
 
-    public function getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $force = false)
+    public function getFile($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $force = false)
     {
         $this->getFilesData();
-        $cacheKey = md5($page . '||' . $format . '//' . $resolution . '""' . ($withText ? '1' : '0') . '---' . ($withGraphics ? '1' : '0') . '%%' . $version);
+        $cacheKey = md5($page . '||' . $format . '$$' . $quality . '//' . $resolution . '""' . ($withText ? '1' : '0') . '---' . ($withGraphics ? '1' : '0') . '%%' . $version);
         if ($force || !isset($this->filesdata[$cacheKey]) || !$this->filesdata[$cacheKey]) {
-            $this->filesdata[$cacheKey] = $this->_getFile($page, $format, $resolution, $withText, $withGraphics, $version, $force);
+            $res=$this->_getFile($page, $format, $resolution, $quality, $withText, $withGraphics, $version, $force);
+            $this->filesdata[$cacheKey] = $res;
         }
         return $this->filesdata[$cacheKey];
     }
@@ -506,12 +507,12 @@ class wsDocument extends cubeMetier
         return trim($response->getBody());
     }
 
-    public function _getFileFarm($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $force = false)
+    public function _getFileFarm($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $force = false)
     {
         $start = microtime(true);
         $farmer = self::pickOneFarmServer($this->region);
 
-        $params = ['page' => $page, 'format' => $format, 'resolution' => $resolution, 'withText' => $withText, 'withGraphics' => $withGraphics, 'version' => $version, 'force' => $force, 'out' => $this->out, 'resolutionRatio' => $this->getResolutionRatio(), 'mobileRatio' => $this->getMobileFirstRatio()];
+        $params = ['page' => $page, 'format' => $format, 'resolution' => $resolution, 'quality' => $quality, 'withText' => $withText, 'withGraphics' => $withGraphics, 'version' => $version, 'force' => $force, 'out' => $this->out, 'resolutionRatio' => $this->getResolutionRatio(), 'mobileRatio' => $this->getMobileFirstRatio()];
         try {
             $output = self::sendRequest($farmer, 'process.php', $params);
             if (preg_match('|/data1/extranet/www/[^\s]+|', $output, $matches)) {
@@ -532,7 +533,7 @@ class wsDocument extends cubeMetier
         }
 
         $time = round(microtime(true) - $start, 4);
-        $log = '[' . $farmer['name'] . ']' . "\t" . date('Y-m-d H:i:s') . "\t\t\t\t" . $time . "\t\t\t\t$page|$format|$resolution|$withText|$withGraphics|$version\t\t\t\t$res\t\t\t\t$output\n";
+        $log = '[' . $farmer['name'] . ']' . "\t" . date('Y-m-d H:i:s') . "\t\t\t\t" . $time . "\t\t\t\t$page|$format|$resolution|$quality|$withText|$withGraphics|$version\t\t\t\t$res\t\t\t\t$output\n";
 
         $fp = fopen(wsDocument::getDir($this->document_id) . 'farm.log', 'a+');
         fwrite($fp, $log);
@@ -541,18 +542,7 @@ class wsDocument extends cubeMetier
         return $res;
     }
 
-    public static function isFarmUser()
-    {
-        global $core;
-        return true;
-        $farmTesters = [1, 2, 3, 5, 446, 4135];
-        if (!$core->user) {
-            return false;
-        }
-        return in_array($core->user->utilisateur_id, $farmTesters);
-    }
-
-    public function _getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $force = false)
+    public function _getFile($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $force = false)
     {
         global $core;
 
@@ -571,7 +561,6 @@ class wsDocument extends cubeMetier
             $version = '';
         }
 
-        $isFarmUser = self::isFarmUser();
 
         $dir = rtrim($this->out . $version, '/') . '/';
         $minsize = 1;
@@ -582,18 +571,17 @@ class wsDocument extends cubeMetier
                 $file .= '-' . $resolution;
             }
             $file .= '.svg';
-            if ($isFarmUser) {
-                $reffile = $this->out . '/html/fp' . $page . '.svg';
-            } else {
-                $reffile = $this->makeSVGFile($page, $force);
-            }
+
+            $reffile = $this->out . '/html/fp' . $page . '.svg';
+
             $minsize = 100;
         } else if ($format === 'png' || $format === 'jpg') {
+            $q = ($format === 'jpg' && $quality != 85) ? $quality : '';
             $prefix = $withText ? 't' : 'h';
             if ($resolution === 'thumb') {
                 $file = $dir . 'p' . $page . '.' . $format;
             } else {
-                $file = $dir . $prefix . $page . '-' . $resolution . '.' . $format;
+                $file = $dir . $prefix . $page . '-' . $resolution . $q . '.' . $format;
             }
         } else if ($format === 'swf') {
             $file = $dir . 'p' . $page . '.' . $format;
@@ -613,11 +601,7 @@ class wsDocument extends cubeMetier
 
 
         if ($do || $force) {
-            if ($isFarmUser) {
-                return $this->_getFileFarm($page, $format, $resolution, $withText, $withGraphics, $version, $force);
-            } else {
-                $this->makeFile($file, $page, $format, $resolution, $withText, $withGraphics, $version);
-            }
+            return $this->_getFileFarm($page, $format, $resolution, $quality, $withText, $withGraphics, $version, $force);
         } else {
             touch($file);
         }
@@ -625,44 +609,6 @@ class wsDocument extends cubeMetier
         return $file;
     }
 
-    public function makeFile($file, $page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html')
-    {
-        $lock = $file . '.lock';
-        if (file_exists($lock) && filemtime($lock) > time() - 300) {
-            sleep(10);
-            return $this->getFile($page, $format, $resolution, $withText, $withGraphics, $version);
-        }
-        touch($lock);
-        if ($format === 'jpeg') {
-            $format = 'jpg';
-        }
-        if ($format === 'svg') {
-            if ($withGraphics) {
-                $this->makeOptimizedSVGFile($page, $resolution, $file);
-            } else {
-                $this->makeTextSVGFile($page, $file);
-            }
-        } else if ($format === 'png' || $format === 'jpg') {
-            $e = explode('-', $resolution);
-            if (count($e) > 1) {
-                $resolution = $e[0];
-                $quality = $e[1];
-            } else {
-                $quality = 85;
-            }
-
-            if ($resolution === 'thumb') {
-                wsPDFConvert::makeMiniShot($this->getSplittedPDFPage($page), $file, 1, $format);
-            } else {
-                $rr = $version === 'html' ? $this->getResolutionRatio() : $this->getMobileFirstRatio();
-                wsPDFConvert::makeShotPNM($this->getSplittedPDFPage($page), $file, 1, '', $resolution * $rr, $quality, 4, $withText, null, null, $format);
-            }
-        } else if ($format === 'swf') {
-            wsPDFConvert::makeSWF($this->getSplittedPDFPage($page), $file, 1, $resolution, 80);
-        }
-        unlink($lock);
-    }
-
     public function cutDocument($mode)
     {
         $fwstk = new cubeCommandLine('fwstk.sh');
@@ -690,9 +636,9 @@ class wsDocument extends cubeMetier
         if ($force) {
             $this->addToLog('Processing page #' . $page);
             // Thumb for composition panel
-            $this->getFile($page, 'jpg', 'thumb', true, true, '', true);
+            $this->getFile($page, 'jpg', 'thumb', 85, true, true, '', true);
             // Image for link editor
-            $this->getFile($page, 'jpg', 150, true, true, 'html', true);
+            $this->getFile($page, 'jpg', 150, 85, true, true, 'html', true);
             // Make SVG base file
             $this->makeSVGFile($page, true);
         }
index e490854611fede16949eaa24e8661e13651f3729..84051ac89c16ca648ac7529e70ae0ddfdc2c3013 100644 (file)
@@ -2961,7 +2961,6 @@ class zoomLink extends normalLink
         if (!file_exists($leftfile)) {
             die('Error generating left part ' . $leftfile);
         }
-
         if (($x + $w) > $bookwidth) {
             if (!isset($attributes['pdf']) || !$attributes['pdf']) {
                 $p = wsDAOBook::getDocumentPage($compiler->book_id, $attributes['page'] + 1);