From 47b17db4b15efcf84bd95dbf616093c190041139 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 13 Jul 2021 18:54:15 +0000 Subject: [PATCH] wip #4592 @5 --- .htaccess | 10 ++----- inc/ws/Controlleur/class.ws.url.php | 29 +++++++++++++++---- inc/ws/DAO/class.ws.dao.book.php | 8 ++--- inc/ws/Util/html5/class.ws.html5.php | 4 +-- .../icon-bar/class.ws.html5.compiler.php | 2 +- .../html5/master/class.ws.html5.compiler.php | 15 ++++++++-- 6 files changed, 44 insertions(+), 24 deletions(-) diff --git a/.htaccess b/.htaccess index 312b13fd3..fdeca4e41 100644 --- a/.htaccess +++ b/.htaccess @@ -75,14 +75,8 @@ AddCharset UTF-8 log RewriteRule ^telecharger/([0-9a-fA-F]+)/([0-9]+)/(.*)$ index.php/telecharger/$1/$2/$3 [L] RewriteRule ^telechargerr/([0-9a-fA-F]+)/([0-9]+)/(.*)$ index.php/telechargerr/$1/$2/$3 [L] - RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ viewer/$1_$2_$3/index [L] - RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.swf$ fluidbook/compile/index.swf [L] - RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/player.swf$ fluidbook/compile/player.swf [L] - RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/fluidbook.js$ fluidbook/compile/fluidbook.js [L] - RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/final/$1/$4 [L] - - RewriteRule ^viewerh/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L] - RewriteRule ^viewers/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L] + RewriteRule ^viewerh/([0-9\-]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L] + RewriteRule ^viewers/([0-9\-]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L] RewriteRule ^fluidbook - [L] diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index c70675b22..90a5772f0 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -1098,11 +1098,19 @@ html.tall{height:150%}' . "\n"; global $core; $nointerface = isset($_GET['nointerface']); + $args = cubePage::getArgs($args); $e = explode('_', $args[0]); $book_id = $e[0]; + $ee = explode('-', $book_id); + if (count($ee) === 1) { + $forceTheme = false; + } else { + $forceTheme = $ee[1]; + $book_id = $ee[0]; + } $hash = $e[1]; $dao = new wsDAOBook($core->con); @@ -1131,21 +1139,25 @@ html.tall{height:150%}' . "\n"; if (count($e) <= 2 || ($e[2] < $limit && !$nointerface)) { $e[2] = $time; $daoTheme = new wsDAOTheme($core->con); - $theme = $daoTheme->getThemeOfBook($book_id, true); + if ($forceTheme) { + $theme = $daoTheme->selectById($forceTheme, 'themes'); + } else { + $theme = $daoTheme->getThemeOfBook($book_id, true); + } self::loadingCompile(SITE_PATH . 'viewerh/' . implode('_', $e) . '/' . $q, $book, $theme); exit; } $CrawlerDetect = new Jaybizzle\CrawlerDetect\CrawlerDetect(); if (!isset($_GET['force']) && !$nointerface && !$CrawlerDetect->isCrawler()) { $book->parametres->scorm_enable = false; - $dao->compile($book_id, 'html5', false, false, false, $book, false); + $dao->compile($book_id, 'html5', false, false, false, $book, false, $forceTheme); wsMaintenance::_socialImage($book->cid); } $book_id = $e[0]; $hash = $e[1]; - self::commonHTML5Viewer($book_id, $hash); + self::commonHTML5Viewer($book_id, $hash, '', [], $forceTheme); } @@ -1201,7 +1213,7 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co echo $res; } - public static function commonHTML5Viewer($book_id, $hash, $version = '', $replace = []) + public static function commonHTML5Viewer($book_id, $hash, $version = '', $replace = [], $forceTheme = false) { global $core; self::checkDocumentVersionOfBook($book_id); @@ -1224,13 +1236,18 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co } } + $id = $book_id; + if ($forceTheme) { + $id .= '-' . $forceTheme; + } + self::logReferer($book_id); - $htmlFile = WS_BOOKS . '/html5' . $dir . '/' . $book_id . '/index' . $version . '.html'; + $htmlFile = WS_BOOKS . '/html5' . $dir . '/' . $id . '/index' . $version . '.html'; $html = ''; if (file_exists($htmlFile)) { $html = file_get_contents($htmlFile); } else { - $dao->compile($book_id, 'html5', false, false, false, $book, false); + $dao->compile($book_id, 'html5', false, false, false, $book, false, $forceTheme); $html = file_get_contents($htmlFile); } foreach ($replace as $from => $to) { diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index d053c1233..ae86af0d0 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -1191,7 +1191,7 @@ class wsDAOBook extends commonDAO } } - public function compile($book_id, $version = 'all', $complete = false, $force = false, $dev = false, $book = null, $delete = true) + public function compile($book_id, $version = 'all', $complete = false, $force = false, $dev = false, $book = null, $delete = true, $forceTheme = false) { if (is_null($book_id) || !$book_id) { @@ -1215,7 +1215,7 @@ class wsDAOBook extends commonDAO $res = ''; try { $this->compilePDF($book, $pages); - $res .= $this->compileHTML5($book_id, $book, $dev, $delete); + $res .= $this->compileHTML5($book_id, $book, $dev, $delete, $forceTheme); $this->touchCompile($book_id, 'html5'); } catch (Exception $e) { @@ -1252,14 +1252,14 @@ class wsDAOBook extends commonDAO return wsBook::getAssetDirOfBook($book_id, $dir) . $path; } - public function compileHTML5($book_id, $book, $dev = false, $delete = true) + public function compileHTML5($book_id, $book, $dev = false, $delete = true,$forceTheme=false) { $version = $book->parametres->mobileLVersion; if ($dev) { $version = 'dev'; } - $htmlCompiler = wsHTML5::compilerFactory($book_id, $version, false, 'latest', null, false, false, false, $book); + $htmlCompiler = wsHTML5::compilerFactory($book_id, $version, false, 'latest', null, false, false, false, $book,$forceTheme); $htmlCompiler->compile($delete); self::$lastHTML5Compiler = $htmlCompiler; diff --git a/inc/ws/Util/html5/class.ws.html5.php b/inc/ws/Util/html5/class.ws.html5.php index b8ded0a56..a6c7d6f6b 100644 --- a/inc/ws/Util/html5/class.ws.html5.php +++ b/inc/ws/Util/html5/class.ws.html5.php @@ -16,7 +16,7 @@ class wsHTML5 * @param null $book * @return wsHTML5Compiler */ - public static function compilerFactory($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, $book = null) + public static function compilerFactory($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, $book = null,$forceTheme=false) { if (is_null($version)) { global $core; @@ -46,7 +46,7 @@ class wsHTML5 } } - return new wsHTML5Compiler($book_id, $version, $phonegap, $phonegapVersion, $dir, $standalone, $appcache, $home, $book); + return new wsHTML5Compiler($book_id, $version, $phonegap, $phonegapVersion, $dir, $standalone, $appcache, $home, $book,$forceTheme); } public static function getPhonegapVersion($v = 'latest') diff --git a/inc/ws/Util/html5/icon-bar/class.ws.html5.compiler.php b/inc/ws/Util/html5/icon-bar/class.ws.html5.compiler.php index ad538e166..4bae88e04 100644 --- a/inc/ws/Util/html5/icon-bar/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/icon-bar/class.ws.html5.compiler.php @@ -215,7 +215,7 @@ class wsHTML5Compiler public $seo = null; - function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, $book = null) + function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, $book = null,$forceTheme=false) { global $core; 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 e70193ebe..700573092 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -233,7 +233,7 @@ class wsHTML5Compiler public $seo = null; - function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, $book = null) + function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, $book = null, $forceTheme = false) { global $core; @@ -266,7 +266,11 @@ class wsHTML5Compiler $this->log('Start compilation'); if (is_null($dir)) { - $this->dir = WS_BOOKS . '/html5/' . $book_id . '/'; + $id = $book_id; + if ($forceTheme) { + $id .= '-' . $forceTheme; + } + $this->dir = WS_BOOKS . '/html5/' . $id . '/'; } else { $this->dir = $dir; } @@ -288,9 +292,14 @@ class wsHTML5Compiler $this->maxRes = min(300, $this->book->parametres->maxResolution); $daoTheme = new wsDAOTheme($core->con); - $this->theme = $daoTheme->getThemeOfBook($book_id, true); + if ($forceTheme) { + $this->theme = $daoTheme->selectById($forceTheme, 'themes'); + } else { + $this->theme = $daoTheme->getThemeOfBook($book_id, true); + } $this->themeRoot = WS_THEMES . '/' . $this->theme->theme_id . '/'; + $daoDoc = new wsDAODocument($core->con); $firstDoc = $daoDoc->selectById($this->pages[1]['document_id']); $firstDoc->checkInfos(); -- 2.39.5