]> _ Git - cubeextranet.git/commitdiff
wip #4592 @5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 13 Jul 2021 18:54:15 +0000 (18:54 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 13 Jul 2021 18:54:15 +0000 (18:54 +0000)
.htaccess
inc/ws/Controlleur/class.ws.url.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Util/html5/class.ws.html5.php
inc/ws/Util/html5/icon-bar/class.ws.html5.compiler.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 312b13fd3428c6445c81603f9107671913e915b1..fdeca4e41c6025bc6c1d3ab597e7b077df340e5f 100644 (file)
--- 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]\r
        RewriteRule ^telechargerr/([0-9a-fA-F]+)/([0-9]+)/(.*)$ index.php/telechargerr/$1/$2/$3 [L]\r
 \r
-       RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ viewer/$1_$2_$3/index [L]\r
-       RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.swf$ fluidbook/compile/index.swf [L]\r
-       RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/player.swf$ fluidbook/compile/player.swf [L]\r
-       RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/fluidbook.js$ fluidbook/compile/fluidbook.js [L]\r
-       RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/final/$1/$4 [L]\r
-\r
-       RewriteRule ^viewerh/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L]\r
-       RewriteRule ^viewers/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L]\r
+       RewriteRule ^viewerh/([0-9\-]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L]\r
+       RewriteRule ^viewers/([0-9\-]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L]\r
 \r
        RewriteRule ^fluidbook - [L]\r
 \r
index c70675b220c4db1af036627375d26fcb2ea36c50..90a5772f041201d569281081b9e337624821e0ac 100644 (file)
@@ -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) {
index d053c1233cd60b1f7f22fdaadd145b5f7c32a5bd..ae86af0d01a199c1550d5cffc32ebb436d4a7692 100644 (file)
@@ -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;
index b8ded0a56830bed8c4fe0670e03da7110a1242cd..a6c7d6f6babfe020eee8624ad766128b1a1b46b4 100644 (file)
@@ -16,7 +16,7 @@ class wsHTML5
      * @param null $book\r
      * @return wsHTML5Compiler\r
      */\r
-    public static function compilerFactory($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, $book = null)\r
+    public static function compilerFactory($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, $book = null,$forceTheme=false)\r
     {\r
         if (is_null($version)) {\r
             global $core;\r
@@ -46,7 +46,7 @@ class wsHTML5
             }\r
         }\r
 \r
-        return new wsHTML5Compiler($book_id, $version, $phonegap, $phonegapVersion, $dir, $standalone, $appcache, $home, $book);\r
+        return new wsHTML5Compiler($book_id, $version, $phonegap, $phonegapVersion, $dir, $standalone, $appcache, $home, $book,$forceTheme);\r
     }\r
 \r
     public static function getPhonegapVersion($v = 'latest')\r
index ad538e166f603a7c9e7eef961dad8eed92ca54a7..4bae88e04e52c108e5fe08570f8e514d878877a1 100644 (file)
@@ -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;
 
index e70193ebe7095e49a6b3a747aa4e8132f972253f..700573092d09fb8025923d38eb6c82774a7fd745 100644 (file)
@@ -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();