From: vincent@cubedesigners.com Date: Mon, 11 Apr 2022 07:55:42 +0000 (+0000) Subject: wip #5220 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=a06d7e5724e72f2c6bc30af68c90095eef14e6d8;p=cubeextranet.git wip #5220 @0.5 --- diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 72ec397a2..940d2ff99 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -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() diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 449eac7cc..d413a4f85 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -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 { diff --git a/inc/ws/Metier/class.ws.book.php b/inc/ws/Metier/class.ws.book.php index a98f8130d..d04e2c5ba 100644 --- a/inc/ws/Metier/class.ws.book.php +++ b/inc/ws/Metier/class.ws.book.php @@ -126,4 +126,11 @@ class wsBook extends cubeMetier return $book->getAssetDir($sub); } + + public static function precompileImages($book_id){ + // Begin to generate files async + $url = 'https://workshop.fluidbook.com/maintenance/processBookPages/' . $book_id; + $ctx = stream_context_create(["http" => ["timeout" => 1]]); + file_get_contents($url, 0, $ctx); + } } \ No newline at end of file diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index 0fdd4e01f..14a2a3a20 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -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"> protected function writeWidget() { // Write widget html - if ($this->widget) { - $whtml = file_get_contents($this->assets . '/widget.html'); - $script = ''; - $script .= ''; - - $style = ''; - $vars = array('titre', 'style', 'script'); - foreach ($vars as $v) { - if (isset($$v)) { - $whtml = str_replace('', $$v, $whtml); - } else { - $whtml = str_replace('', '', $whtml); - } - } - $this->vdir->file_put_contents('widget.html', $whtml); - } +// if ($this->widget) { +// $whtml = file_get_contents($this->assets . '/widget.html'); +// $script = ''; +// $script .= ''; +// +// $style = ''; +// $vars = array('titre', 'style', 'script'); +// foreach ($vars as $v) { +// if (isset($$v)) { +// $whtml = str_replace('', $$v, $whtml); +// } else { +// $whtml = str_replace('', '', $whtml); +// } +// } +// $this->vdir->file_put_contents('widget.html', $whtml); +// } } function writeSEO() @@ -2625,6 +2626,7 @@ height="0" width="0" style="display:none;visibility:hidden"> { 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"> return $res; } + + } + + if (!function_exists('is_countable')) { function is_countable($c)