]> _ Git - cubeextranet.git/commitdiff
wip #4600 @3
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 20 Jul 2021 09:38:55 +0000 (09:38 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 20 Jul 2021 09:38:55 +0000 (09:38 +0000)
.htaccess
inc/ws/Controlleur/class.ws.url.php
inc/ws/DAO/class.ws.dao.theme.php
inc/ws/Metier/class.ws.parametres.php
inc/ws/Metier/class.ws.theme.parametres.php
inc/ws/Metier/class.ws.theme.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index fdeca4e41c6025bc6c1d3ab597e7b077df340e5f..96e71e3bd99d6cda4521cde1292824d32bc5793c 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -75,8 +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 ^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-9a-f\-]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L]\r
+       RewriteRule ^viewers/([0-9a-f\-]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L]\r
 \r
        RewriteRule ^fluidbook - [L]\r
 \r
index e620449678e673d5dc8c6f24a9d4b1e4f96ed59e..a0fb9fd1147692b05aabe55dea7e616157fdc377 100644 (file)
@@ -1111,6 +1111,16 @@ html.tall{height:150%}' . "\n";
             $forceTheme = $ee[1];
             $book_id = $ee[0];
         }
+        if (isset($_GET['theme']) && $_GET['theme']!=='') {
+            $forceTheme = CubeIT_Util_Json::decode($_GET['theme'], true);
+        }
+
+        $forceThemeId = wsTheme::hashThemeArray($forceTheme);
+        $e[0] = $book_id;
+        if ($forceThemeId) {
+            $e[0] .= '-' . $forceThemeId;
+        }
+
         $hash = $e[1];
 
         $dao = new wsDAOBook($core->con);
@@ -1139,7 +1149,9 @@ html.tall{height:150%}' . "\n";
         if (count($e) <= 2 || ($e[2] < $limit && !$nointerface)) {
             $e[2] = $time;
             $daoTheme = new wsDAOTheme($core->con);
-            if ($forceTheme) {
+            if (is_array($forceTheme)) {
+                $theme = $daoTheme->fromArray($forceTheme);
+            } elseif (is_numeric($forceTheme)) {
                 $theme = $daoTheme->selectById($forceTheme, 'themes');
             } else {
                 $theme = $daoTheme->getThemeOfBook($book_id, true);
@@ -1164,9 +1176,11 @@ html.tall{height:150%}' . "\n";
     public static function loadingCompile($url, $book, $theme)
     {
         global $core;
-        $tcolor = $theme->parametres->couleurL;
-        if ($tcolor == $theme->parametres->backgroundColor) {
-            $tcolor = $theme->parametres->loadingSecColor;
+        $bgcolor = wsHTML5::colorToCSS($theme->parametres->backgroundColor);
+        $scolor = wsHTML5::colorToCSS($theme->parametres->loadingSecColor);
+        $tcolor = $lcolor = wsHTML5::colorToCSS($theme->parametres->couleurL);
+        if ($tcolor == $bgcolor) {
+            $tcolor = $scolor;
         }
 
         $res = '<html>';
@@ -1182,8 +1196,8 @@ html.tall{height:150%}' . "\n";
   }
 }
 *{margin:0;padding:0;}
-html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-color:#' . $theme->parametres->backgroundColor . ';}';
-        $res .= 'h2,h3{text-align:center;color:#' . $tcolor . ';font-weight:400;position:relative;top:55%;}';
+html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-color:' . $bgcolor . ';}';
+        $res .= 'h2,h3{text-align:center;color:' . $tcolor . ';font-weight:400;position:relative;top:55%;}';
         $res .= 'h2{font-size:16px;}';
         $res .= 'h3{font-size:10px;}';
         $res .= 'svg{position:absolute;top:calc(50% - 24px);left:calc(50% - 24px);
@@ -1200,8 +1214,8 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co
         $res .= '</head>';
         $res .= '<body onload="load();">';
         $res .= '<svg width="48" height="48" id="interface-loader" viewBox="0 0 48 48">
-        <circle cx="24" cy="24" r="23" fill="#' . $theme->parametres->couleurL . '"></circle>
-        <circle class="animate" cx="24" cy="24" fill="none" stroke="#' . $theme->parametres->loadingSecColor . '" stroke-width="3" r="16"
+        <circle cx="24" cy="24" r="23" fill="' . $lcolor . '"></circle>
+        <circle class="animate" cx="24" cy="24" fill="none" stroke="' . $scolor . '" stroke-width="3" r="16"
                 stroke-dasharray="80 80"
                 transform="rotate(0 24 24)">
         </circle>
@@ -1221,6 +1235,7 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co
         $dao = new wsDAOBook($core->con);
         $dir = '';
 
+
         $book = $dao->selectById($book_id);
         if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {
             commonDroits::error();
@@ -1236,12 +1251,19 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co
             }
         }
 
+        if (strpos($book_id, '-') !== false) {
+            $e = explode('-', $book_id);
+            $book_id = $e[0];
+        }
         $id = $book_id;
-        if ($forceTheme && strpos($id, '-') === false) {
-            $id .= '-' . $forceTheme;
+        $forceThemeId = wsTheme::hashThemeArray($forceTheme);
+        if ($forceThemeId) {
+            $id .= '-' . $forceThemeId;
         }
 
-        self::logReferer($book_id);
+        if(!$forceTheme) {
+            self::logReferer($book_id);
+        }
         $htmlFile = WS_BOOKS . '/html5' . $dir . '/' . $id . '/index' . $version . '.html';
         $html = '';
         if (file_exists($htmlFile)) {
@@ -1254,6 +1276,7 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co
             $html = str_replace($from, $to, $html);
         }
 
+
         echo $html;
         exit;
     }
index d88fa1c6794d89522b84102d6a26ce0d6a6502b5..3cdcb832de634cd37aa43a463626d4bb8ef6d5c3 100644 (file)
@@ -3,6 +3,20 @@
 class wsDAOTheme extends commonDAO\r
 {\r
 \r
+    public function fromArray($a)\r
+    {\r
+        $theme = new wsTheme();\r
+        $theme->theme_id = $a['id'];\r
+        $theme->nom = $a['name'];\r
+        $theme->date = time();\r
+        $theme->proprietaire = $a['owner'];\r
+        $theme->signature = 0;\r
+        $theme->icones = 15;\r
+        $theme->parametres = new wsThemeParametres($theme);\r
+        $theme->parametres->initFromArray($a);\r
+        return $theme;\r
+    }\r
+\r
     protected function singleton($r)\r
     {\r
         $theme = new wsTheme();\r
@@ -28,10 +42,10 @@ class wsDAOTheme extends commonDAO
             }\r
             $theme->signature = $r->signature;\r
             $theme->icones = $r->icones;\r
-            if(CubeIT_Util_Json::isJson($r->parametres)){\r
+            if (CubeIT_Util_Json::isJson($r->parametres)) {\r
                 $p = new wsThemeParametres($theme);\r
                 $p->importFromJson($r->parametres);\r
-            }else {\r
+            } else {\r
                 $p = unserialize($r->parametres);\r
             }\r
             if (!$p) {\r
@@ -80,7 +94,7 @@ class wsDAOTheme extends commonDAO
     public function getAllThemes($user, $order = '', $demos = null)\r
     {\r
         if (wsDroits::admin(false)) {\r
-            $sql = 'SELECT * FROM '.$this->_table('themes_vue');\r
+            $sql = 'SELECT * FROM ' . $this->_table('themes_vue');\r
         } else {\r
             $or = '';\r
             if (wsDroits::revendeur()) {\r
@@ -89,7 +103,7 @@ class wsDAOTheme extends commonDAO
                 }\r
                 $or .= ') OR ( proprietaire IN(' . $user->ws_rights . ') ';\r
             }\r
-            $sql = 'SELECT * FROM '.$this->_table('themes_vue').' WHERE theme_id IN (SELECT theme FROM books WHERE proprietaire IN(' . $user->ws_rights . ') ' . $or . ')';\r
+            $sql = 'SELECT * FROM ' . $this->_table('themes_vue') . ' WHERE theme_id IN (SELECT theme FROM books WHERE proprietaire IN(' . $user->ws_rights . ') ' . $or . ')';\r
         }\r
         $sql .= ' ' . $order;\r
 \r
index 58162c5d6ae6b00bc9318fc73c44f4085f3474dc..d643a6a24356400870818702c67b16fa47cc1212 100644 (file)
@@ -25,6 +25,11 @@ class wsParametres extends cubeMetier implements Iterator
         $this->datas = $r->columns();\r
     }\r
 \r
+    public function initFromArray($a)\r
+    {\r
+        $this->datas = $a;\r
+    }\r
+\r
     public function importFromJson($jsonString)\r
     {\r
         $this->datas = json_decode($jsonString, true);\r
@@ -187,7 +192,7 @@ class wsParametres extends cubeMetier implements Iterator
             return false;\r
         }\r
         if (!$this->_isset($varname)) {\r
-            $msg='You are getting an attribute (' . get_class($this) . '::' . $varname . ') which not exists';\r
+            $msg = 'You are getting an attribute (' . get_class($this) . '::' . $varname . ') which not exists';\r
             trigger_error($msg);\r
             throw new Exception($msg);\r
         }\r
index 366231cc04868ee5bcd3a241b703e2b499c62a01..9094171a775d980304d2f6079dc579fd8e28d0dc 100644 (file)
@@ -77,10 +77,8 @@ class wsThemeParametres extends wsParametres
         $this->fields['bookShadeColor'] = array('type' => 'couleurAlpha', 'default' => '66000000', 'editable' => true,\r
             'label' => __("Couleur de l'ombre sous la publication"));\r
         $this->fields['shadeAlpha'] = array('type' => 'integer', 'default' => 100, 'editable' => true,\r
-            'label' => __('Transparence des ombres et reflets sur les pages'),\r
+            'label' => __('Transparence des ombres sur les pages'),\r
             'min' => 0, 'max' => 100);\r
-        $this->fields['pageReflection'] = array('type' => 'boolean', 'default' => false, 'editable' => true,\r
-            'label' => __("Afficher le reflet sur la page"));\r
         $this->fields['usePageEdges'] = array('type' => 'boolean', 'default' => true, 'editable' => true,\r
             'label' => __("Afficher la bordure des pages"));\r
         $this->fields['displayPageNumber'] = array('type' => 'boolean', 'default' => true, 'editable' => true,\r
@@ -107,7 +105,7 @@ class wsThemeParametres extends wsParametres
             'label' => __("Couleur de l'étoile activée"));\r
 \r
         $this->forms['book'] = array('label' => __('Personnalisation de la publication'),\r
-            'fieldsnames' => array('interfaceFont', 'interfaceFontUppercase', '|', 'pageReflection', 'shadeAlpha',\r
+            'fieldsnames' => array('interfaceFont', 'interfaceFontUppercase', '|',  'shadeAlpha',\r
                 '|', 'bookShadeColor',\r
                 '|', 'displayPageNumber', 'colorPageNumber',\r
                 '|', 'linksColor', 'videoBackgroundColor',\r
@@ -120,8 +118,6 @@ class wsThemeParametres extends wsParametres
         $this->forms['credits'] = array('label' => __('Personnalisation des crédits'),\r
             'fieldsnames' => array('creditsColor'));\r
         /* Background */\r
-        $this->fields['transparentBackground'] = array('type' => 'boolean', 'default' => false, 'editable' => true,\r
-            'label' => __('Fond transparent'), 'hint' => __("Si cette option est cochée, aucun fond ne sera pris en compte (ni l'image, ni la couleur)"));\r
         $this->fields['backgroundColor'] = array('type' => 'couleur', 'default' => 'ffffff', 'editable' => true,\r
             'label' => __("Couleur du fond"));\r
         $this->fields['backgroundImage'] = array('type' => 'file', 'default' => 'backgroundImg.jpg', 'editable' => true,\r
@@ -148,7 +144,7 @@ class wsThemeParametres extends wsParametres
             'label' => __('Afficher le fond pendant le chargement'), 'hint' => __("Si cette option est désactivée, le fond ne sera affiché qu'à la fin du chargement"));\r
 \r
         $this->forms['background'] = array('label' => __('Personnalisation du fond'),\r
-            'fieldsnames' => array('transparentBackground', '|', 'backgroundColor', '|', 'backgroundImage',\r
+            'fieldsnames' => array('backgroundColor', '|', 'backgroundImage',\r
                 'repeat', 'backgroundHAlign', 'backgroundVAlign', '|', 'displayBackgroundDuringLoading'));\r
         /* Menu bar */\r
         $this->fields['menuHeight'] = array('type' => 'integer', 'default' => 60, 'editable' => true,\r
index 93953e307e2ce61c89ae32daf5d6aaecfe13e5e5..70102aed97e1c01a7614da413ecee819744af561 100644 (file)
@@ -1,27 +1,41 @@
 <?php\r
-class wsTheme extends cubeMetier {\r
-       const NONE = 3;\r
-       const STRETCH = 0;\r
-       const RATIO = 2;\r
-       const REPEAT = 1;\r
 \r
-       const CENTER = 4;\r
-       const LEFT = 5;\r
-       const RIGHT = 6;\r
+class wsTheme extends cubeMetier\r
+{\r
+    const NONE = 3;\r
+    const STRETCH = 0;\r
+    const RATIO = 2;\r
+    const REPEAT = 1;\r
 \r
-       const MIDDLE = 7;\r
-       const TOP = 8;\r
-       const BOTTOM = 9;\r
+    const CENTER = 4;\r
+    const LEFT = 5;\r
+    const RIGHT = 6;\r
 \r
-       public static $files = array('background' => 'backgroundImg.jpg', 'menu' => 'menu_back.png', 'logo' => 'menu_clientLogo.png', 'logoLoader' => 'logoLoader.png');\r
+    const MIDDLE = 7;\r
+    const TOP = 8;\r
+    const BOTTOM = 9;\r
 \r
-       protected $theme_id;\r
-       protected $icones;\r
-       protected $proprietaire;\r
-       protected $signature;\r
-       protected $nom;\r
-       protected $date;\r
-       protected $parametres;\r
-       protected $proprietaire_nom;\r
-       protected $nbBooks = 0;\r
+    public static $files = array('background' => 'backgroundImg.jpg', 'menu' => 'menu_back.png', 'logo' => 'menu_clientLogo.png', 'logoLoader' => 'logoLoader.png');\r
+\r
+    protected $theme_id;\r
+    protected $icones;\r
+    protected $proprietaire;\r
+    protected $signature;\r
+    protected $nom;\r
+    protected $date;\r
+    protected $parametres;\r
+    protected $proprietaire_nom;\r
+    protected $nbBooks = 0;\r
+\r
+    public static function hashThemeArray($a)\r
+    {\r
+        if (!$a) {\r
+            return '';\r
+        }\r
+        if (!is_array($a)) {\r
+            return $a;\r
+        }\r
+        ksort($a);\r
+        return substr(sha1(json_encode($a)), 0, 8);\r
+    }\r
 }
\ No newline at end of file
index 1113c20bacceb0b8e79b57bbeb1f0cc2f42a5945..f65b7cf86f360616effcf502a3234c0fe6e50744 100644 (file)
@@ -243,7 +243,6 @@ class wsHTML5Compiler
         $this->version = $version;
 
 
-
         if ($version == 'stable') {
             $this->assets = WS_COMPILE_ASSETS . '/player/branches/master';
         } else if ($version == 'dev') {
@@ -267,10 +266,16 @@ class wsHTML5Compiler
         $this->book_id = $book_id;
         $this->log('Start compilation');
 
+        $forceThemeId = wsTheme::hashThemeArray($forceTheme);
+
         if (is_null($dir)) {
+            if (strpos($book_id, '-') !== false) {
+                $e = explode('-', $book_id);
+                $book_id = $e[0];
+            }
             $id = $book_id;
-            if ($forceTheme && strpos($id, '-') === false) {
-                $id .= '-' . $forceTheme;
+            if ($forceThemeId) {
+                $id .= '-' . $forceThemeId;
             }
             $this->dir = WS_BOOKS . '/html5/' . $id . '/';
         } else {
@@ -294,7 +299,9 @@ class wsHTML5Compiler
         $this->maxRes = min(300, $this->book->parametres->maxResolution);
 
         $daoTheme = new wsDAOTheme($core->con);
-        if ($forceTheme) {
+        if (is_array($forceTheme)) {
+            $this->theme = $daoTheme->fromArray($forceTheme);
+        } else if (is_numeric($forceTheme)) {
             $this->theme = $daoTheme->selectById($forceTheme, 'themes');
         } else {
             $this->theme = $daoTheme->getThemeOfBook($book_id, true);
@@ -2101,7 +2108,6 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                 }
 
 
-
                 if (file_exists($tmp) && filesize($tmp) > 0) {
                     if ($hasNonMin) {
                         $uglify = new CubeIT_CommandLine('/usr/local/bin/uglifyjs');
@@ -2280,7 +2286,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
 
     protected function _lessBoolean($val)
     {
-        return $val ? 'true' : 'false';
+        return $this->_themeBoolean($val) ? 'true' : 'false';
     }
 
     protected function _font($f)
@@ -2303,6 +2309,11 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
         }
     }
 
+    protected function _themeBoolean($v)
+    {
+        return !(null === $v || $v === '0' || $v === 0 || $v === false || !$v);
+    }
+
     protected function writeCSS($links)
     {
         $res = array();
@@ -2312,7 +2323,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
         $lessContents = '';
 
         $this->lessVariables['font'] = $this->_font($this->theme->parametres->interfaceFont);
-        $this->lessVariables['text-transform'] = $this->theme->parametres->interfaceFontUppercase ? 'uppercase' : 'inherit';
+        $this->lessVariables['text-transform'] = $this->_themeBoolean($this->theme->parametres->interfaceFontUppercase) ? 'uppercase' : 'inherit';
 
         $this->lessVariables['css-scale'] = $this->cssScale;
 
@@ -2491,7 +2502,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                 continue;
             }
             $color = trim($chapter->color, '#');
-            $lessContents .= '.mview.c_' . $color . '{.menu-color(#' . $color . ');}';
+            $lessContents .= '.mview.c_' . $color . '{.menu-color(' . wsHTML5::colorToCSS($color) . ');}';
         }
 
         // Archives
@@ -2622,10 +2633,10 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
         $body = '';
 
         if ($this->theme->parametres->displayBackgroundDuringLoading) {
-            $body .= '#background,#splash{background-color:#' . $this->theme->parametres->backgroundColor . ' !important;}';
+            $body .= '#background,#splash{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->backgroundColor) . ' !important;}';
         } else {
-            $body .= '#background{transition:500ms opacity;visibility:hidden;opacity:0;background-color:#' . $this->theme->parametres->backgroundColor . ' !important;}';
-            $body .= '#splash{background-color:' . $this->theme->parametres->loadingBackColor . ' !important;}';
+            $body .= '#background{transition:500ms opacity;visibility:hidden;opacity:0;background-color:' . wsHTML5::colorToCSS($this->theme->parametres->backgroundColor) . ' !important;}';
+            $body .= '#splash{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->loadingBackColor) . ' !important;}';
         }
 
         $body .= '#background,#splash{';