From: vincent@cubedesigners.com Date: Tue, 20 Jul 2021 09:38:55 +0000 (+0000) Subject: wip #4600 @3 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=9ce1606b7e1d7fca0ab39f91de9b922ef81abfba;p=cubeextranet.git wip #4600 @3 --- diff --git a/.htaccess b/.htaccess index fdeca4e41..96e71e3bd 100644 --- 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] RewriteRule ^telechargerr/([0-9a-fA-F]+)/([0-9]+)/(.*)$ index.php/telechargerr/$1/$2/$3 [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-9a-f\-]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L] + RewriteRule ^viewers/([0-9a-f\-]+)_([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 e62044967..a0fb9fd11 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -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 = ''; @@ -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 .= ''; $res .= ''; $res .= ' - - + @@ -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; } diff --git a/inc/ws/DAO/class.ws.dao.theme.php b/inc/ws/DAO/class.ws.dao.theme.php index d88fa1c67..3cdcb832d 100644 --- a/inc/ws/DAO/class.ws.dao.theme.php +++ b/inc/ws/DAO/class.ws.dao.theme.php @@ -3,6 +3,20 @@ class wsDAOTheme extends commonDAO { + public function fromArray($a) + { + $theme = new wsTheme(); + $theme->theme_id = $a['id']; + $theme->nom = $a['name']; + $theme->date = time(); + $theme->proprietaire = $a['owner']; + $theme->signature = 0; + $theme->icones = 15; + $theme->parametres = new wsThemeParametres($theme); + $theme->parametres->initFromArray($a); + return $theme; + } + protected function singleton($r) { $theme = new wsTheme(); @@ -28,10 +42,10 @@ class wsDAOTheme extends commonDAO } $theme->signature = $r->signature; $theme->icones = $r->icones; - if(CubeIT_Util_Json::isJson($r->parametres)){ + if (CubeIT_Util_Json::isJson($r->parametres)) { $p = new wsThemeParametres($theme); $p->importFromJson($r->parametres); - }else { + } else { $p = unserialize($r->parametres); } if (!$p) { @@ -80,7 +94,7 @@ class wsDAOTheme extends commonDAO public function getAllThemes($user, $order = '', $demos = null) { if (wsDroits::admin(false)) { - $sql = 'SELECT * FROM '.$this->_table('themes_vue'); + $sql = 'SELECT * FROM ' . $this->_table('themes_vue'); } else { $or = ''; if (wsDroits::revendeur()) { @@ -89,7 +103,7 @@ class wsDAOTheme extends commonDAO } $or .= ') OR ( proprietaire IN(' . $user->ws_rights . ') '; } - $sql = 'SELECT * FROM '.$this->_table('themes_vue').' WHERE theme_id IN (SELECT theme FROM books WHERE proprietaire IN(' . $user->ws_rights . ') ' . $or . ')'; + $sql = 'SELECT * FROM ' . $this->_table('themes_vue') . ' WHERE theme_id IN (SELECT theme FROM books WHERE proprietaire IN(' . $user->ws_rights . ') ' . $or . ')'; } $sql .= ' ' . $order; diff --git a/inc/ws/Metier/class.ws.parametres.php b/inc/ws/Metier/class.ws.parametres.php index 58162c5d6..d643a6a24 100644 --- a/inc/ws/Metier/class.ws.parametres.php +++ b/inc/ws/Metier/class.ws.parametres.php @@ -25,6 +25,11 @@ class wsParametres extends cubeMetier implements Iterator $this->datas = $r->columns(); } + public function initFromArray($a) + { + $this->datas = $a; + } + public function importFromJson($jsonString) { $this->datas = json_decode($jsonString, true); @@ -187,7 +192,7 @@ class wsParametres extends cubeMetier implements Iterator return false; } if (!$this->_isset($varname)) { - $msg='You are getting an attribute (' . get_class($this) . '::' . $varname . ') which not exists'; + $msg = 'You are getting an attribute (' . get_class($this) . '::' . $varname . ') which not exists'; trigger_error($msg); throw new Exception($msg); } diff --git a/inc/ws/Metier/class.ws.theme.parametres.php b/inc/ws/Metier/class.ws.theme.parametres.php index 366231cc0..9094171a7 100644 --- a/inc/ws/Metier/class.ws.theme.parametres.php +++ b/inc/ws/Metier/class.ws.theme.parametres.php @@ -77,10 +77,8 @@ class wsThemeParametres extends wsParametres $this->fields['bookShadeColor'] = array('type' => 'couleurAlpha', 'default' => '66000000', 'editable' => true, 'label' => __("Couleur de l'ombre sous la publication")); $this->fields['shadeAlpha'] = array('type' => 'integer', 'default' => 100, 'editable' => true, - 'label' => __('Transparence des ombres et reflets sur les pages'), + 'label' => __('Transparence des ombres sur les pages'), 'min' => 0, 'max' => 100); - $this->fields['pageReflection'] = array('type' => 'boolean', 'default' => false, 'editable' => true, - 'label' => __("Afficher le reflet sur la page")); $this->fields['usePageEdges'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Afficher la bordure des pages")); $this->fields['displayPageNumber'] = array('type' => 'boolean', 'default' => true, 'editable' => true, @@ -107,7 +105,7 @@ class wsThemeParametres extends wsParametres 'label' => __("Couleur de l'étoile activée")); $this->forms['book'] = array('label' => __('Personnalisation de la publication'), - 'fieldsnames' => array('interfaceFont', 'interfaceFontUppercase', '|', 'pageReflection', 'shadeAlpha', + 'fieldsnames' => array('interfaceFont', 'interfaceFontUppercase', '|', 'shadeAlpha', '|', 'bookShadeColor', '|', 'displayPageNumber', 'colorPageNumber', '|', 'linksColor', 'videoBackgroundColor', @@ -120,8 +118,6 @@ class wsThemeParametres extends wsParametres $this->forms['credits'] = array('label' => __('Personnalisation des crédits'), 'fieldsnames' => array('creditsColor')); /* Background */ - $this->fields['transparentBackground'] = array('type' => 'boolean', 'default' => false, 'editable' => true, - 'label' => __('Fond transparent'), 'hint' => __("Si cette option est cochée, aucun fond ne sera pris en compte (ni l'image, ni la couleur)")); $this->fields['backgroundColor'] = array('type' => 'couleur', 'default' => 'ffffff', 'editable' => true, 'label' => __("Couleur du fond")); $this->fields['backgroundImage'] = array('type' => 'file', 'default' => 'backgroundImg.jpg', 'editable' => true, @@ -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")); $this->forms['background'] = array('label' => __('Personnalisation du fond'), - 'fieldsnames' => array('transparentBackground', '|', 'backgroundColor', '|', 'backgroundImage', + 'fieldsnames' => array('backgroundColor', '|', 'backgroundImage', 'repeat', 'backgroundHAlign', 'backgroundVAlign', '|', 'displayBackgroundDuringLoading')); /* Menu bar */ $this->fields['menuHeight'] = array('type' => 'integer', 'default' => 60, 'editable' => true, diff --git a/inc/ws/Metier/class.ws.theme.php b/inc/ws/Metier/class.ws.theme.php index 93953e307..70102aed9 100644 --- a/inc/ws/Metier/class.ws.theme.php +++ b/inc/ws/Metier/class.ws.theme.php @@ -1,27 +1,41 @@ 'backgroundImg.jpg', 'menu' => 'menu_back.png', 'logo' => 'menu_clientLogo.png', 'logoLoader' => 'logoLoader.png'); + const MIDDLE = 7; + const TOP = 8; + const BOTTOM = 9; - protected $theme_id; - protected $icones; - protected $proprietaire; - protected $signature; - protected $nom; - protected $date; - protected $parametres; - protected $proprietaire_nom; - protected $nbBooks = 0; + public static $files = array('background' => 'backgroundImg.jpg', 'menu' => 'menu_back.png', 'logo' => 'menu_clientLogo.png', 'logoLoader' => 'logoLoader.png'); + + protected $theme_id; + protected $icones; + protected $proprietaire; + protected $signature; + protected $nom; + protected $date; + protected $parametres; + protected $proprietaire_nom; + protected $nbBooks = 0; + + public static function hashThemeArray($a) + { + if (!$a) { + return ''; + } + if (!is_array($a)) { + return $a; + } + ksort($a); + return substr(sha1(json_encode($a)), 0, 8); + } } \ 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 1113c20ba..f65b7cf86 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -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"> } - 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"> 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"> } } + 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"> $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"> 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"> $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{';