]> _ Git - cubeextranet.git/commitdiff
wip #5220 @0.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 11 Apr 2022 07:55:42 +0000 (07:55 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 11 Apr 2022 07:55:42 +0000 (07:55 +0000)
inc/ws/Controlleur/class.ws.flash.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Metier/class.ws.book.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 72ec397a21493b8d8f6aefc72bec8df2aeb0f23d..940d2ff994199904ed19f3da5165d80521832c18 100644 (file)
@@ -681,11 +681,11 @@ class wsFlash extends cubeFlashGateway
 
     protected function _addSpecialInfos($book, $theme, $param, $specialName)
     {
-        if ($specialName == 'archives' || $specialName==='slider') {
-            $inBook=true;
+        if ($specialName == 'archives' || $specialName === 'slider') {
+            $inBook = true;
             $p = $book->parametres;
         } else {
-            $inBook=false;
+            $inBook = false;
             $p = $theme->parametres;
         }
 
@@ -859,13 +859,7 @@ class wsFlash extends cubeFlashGateway
         $pages = json_decode($this->args['pages']);
         $dao->setComposition($this->args['book_id'], $pages);
 
-        // Begin to generate files async
-        $url = 'https://workshop.fluidbook.com/maintenance/processPage/' . $this->args['book_id'] . '/all/0';
-        $ctx = stream_context_create(["http" => ["timeout" => 1]]);
-        $it = max(4, min(12, ceil(count($pages) / 20)));
-        for ($i = 0; $i < $it; $i++) {
-            file_get_contents($url, 0, $ctx);
-        }
+        wsBook::precompileImages($this->args['book_id']);
     }
 
     public function getTexts()
index 449eac7cc9e7389b75a68f9bc11c62e1d04a5326..d413a4f85c4aafddec1330dfea1cb38211238917 100644 (file)
@@ -1556,21 +1556,20 @@ class wsMaintenance
         $page = $args[1];
         $force = !isset($args[2]) || $args[2] != '0';
 
-
         $daoBook = new wsDAOBook($core->con);
-        $book = $daoBook->selectById($book_id);
+        $book = $daoBook->selectById($book_id, true);
+        $resolutions = wsHTML5Compiler::getBookResolutions($book);
+        $format = $book->parametres->imageFormat;
 
-        $files = [
-            ['jpg', '300', true, true, 'html'],
-            ['jpg', '150', true, true, 'html'],
-            ['jpg', '150', false, true, 'html'],
-            ['jpg', '150', false, true, 'html'],
-            //['swf', '150', true, true, ''],
-            ['svg', '150', true, false, 'html'],
-            ['svg', '300', true, false, 'html'],
-            ['svg', '150', true, true, 'html'],
-            ['svg', '200', true, true, 'html'],
-        ];
+        $files = [[$format, 'thumb', true, true, '']];
+        foreach ($resolutions as $resolution) {
+            $files = array_merge($files, [
+                [$format, $resolution, true, true, 'html'],
+                [$format, $resolution, false, true, 'html'],
+                ['svg', $resolution, true, false, 'html'],
+                ['svg', $resolution, true, true, 'html'],
+            ]);
+        }
 
         if ($page == 'all') {
             $pages = range(1, $book->parametres->pages);
@@ -1587,6 +1586,25 @@ class wsMaintenance
         }
     }
 
+    public static function processBookPages($args)
+    {
+        CubeIT_Util_PHP::neverStop();
+
+        global $core;
+
+        $book_id = $args[0];
+
+        $dao = new wsDAOBook($core->con);
+        $book = $dao->selectById($book_id);
+
+        $url = 'https://workshop.fluidbook.com/maintenance/processPage/' . $book_id . '/all/0';
+        $ctx = stream_context_create(["http" => ["timeout" => 1]]);
+        $it = 2 * max(4, min(12, ceil(count($book->parametres->pages) / 20)));
+        for ($i = 0; $i < $it; $i++) {
+            file_get_contents($url, 0, $ctx);
+        }
+    }
+
 
     public static function getAdditionalSettingsMap(): array
     {
index a98f8130d6442c62e3f17d9edfce4628944b887f..d04e2c5baac272f669606b34e550f7c2a78fba92 100644 (file)
@@ -126,4 +126,11 @@ class wsBook extends cubeMetier
 \r
         return $book->getAssetDir($sub);\r
     }\r
+\r
+    public static function precompileImages($book_id){\r
+        // Begin to generate files async\r
+        $url = 'https://workshop.fluidbook.com/maintenance/processBookPages/' . $book_id;\r
+        $ctx = stream_context_create(["http" => ["timeout" => 1]]);\r
+        file_get_contents($url, 0, $ctx);\r
+    }\r
 }
\ No newline at end of file
index 0fdd4e01f9f4bc4d4e5298d7dbf0841d7c4fc8f1..14a2a3a20db3a780c453fe3bd4ad4e471b861f2b 100644 (file)
@@ -895,16 +895,17 @@ class wsHTML5Compiler
 
     public function getResolutions()
     {
-        $res = [];
+        return self::getBookResolutions($this->book);
+    }
 
-        if ($this->maxRes == 300) {
+    public static function getBookResolutions($book)
+    {
+        $maxRes = min(300, $book->parametres->maxResolution);
+        $res = [];
+        if ($maxRes == 300) {
             $res = [150, 300];
-        } else if ($this->maxRes <= 150) {
-            $res = [$this->maxRes];
-        }
-
-        if ($this->widget) {
-            $res = array_merge(array(36), $res);
+        } else if ($maxRes <= 150) {
+            $res = [$maxRes];
         }
         return $res;
     }
@@ -1681,22 +1682,22 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
     protected function writeWidget()
     {
         // Write widget html
-        if ($this->widget) {
-            $whtml = file_get_contents($this->assets . '/widget.html');
-            $script = '<script type="text/javascript" charset="utf-8" src="data/datas.js"></script>';
-            $script .= '<script type="text/javascript" charset="utf-8" src="data/widget.js"></script>';
-
-            $style = '<link type="text/css" rel="stylesheet" href="style/widget.css">';
-            $vars = array('titre', 'style', 'script');
-            foreach ($vars as $v) {
-                if (isset($$v)) {
-                    $whtml = str_replace('<!-- $' . $v . ' -->', $$v, $whtml);
-                } else {
-                    $whtml = str_replace('<!-- $' . $v . ' -->', '', $whtml);
-                }
-            }
-            $this->vdir->file_put_contents('widget.html', $whtml);
-        }
+//        if ($this->widget) {
+//            $whtml = file_get_contents($this->assets . '/widget.html');
+//            $script = '<script type="text/javascript" charset="utf-8" src="data/datas.js"></script>';
+//            $script .= '<script type="text/javascript" charset="utf-8" src="data/widget.js"></script>';
+//
+//            $style = '<link type="text/css" rel="stylesheet" href="style/widget.css">';
+//            $vars = array('titre', 'style', 'script');
+//            foreach ($vars as $v) {
+//                if (isset($$v)) {
+//                    $whtml = str_replace('<!-- $' . $v . ' -->', $$v, $whtml);
+//                } else {
+//                    $whtml = str_replace('<!-- $' . $v . ' -->', '', $whtml);
+//                }
+//            }
+//            $this->vdir->file_put_contents('widget.html', $whtml);
+//        }
     }
 
     function writeSEO()
@@ -2625,6 +2626,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
     {
         global $core;
 
+        wsBook::precompileImages($this->book_id);
 
         switch ($this->book->parametres->mobileVersion) {
             case 'html5-desktop':
@@ -3690,9 +3692,13 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
         return $res;
     }
 
+
+
 }
 
 
+
+
 if (!function_exists('is_countable')) {
 
     function is_countable($c)