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
$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);
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);
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>';
}
}
*{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);
$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>
$dao = new wsDAOBook($core->con);
$dir = '';
+
$book = $dao->selectById($book_id);
if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {
commonDroits::error();
}
}
+ 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)) {
$html = str_replace($from, $to, $html);
}
+
echo $html;
exit;
}
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
}\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
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
}\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
$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
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
$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
'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
$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
'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
<?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
$this->version = $version;
-
if ($version == 'stable') {
$this->assets = WS_COMPILE_ASSETS . '/player/branches/master';
} else if ($version == 'dev') {
$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 {
$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);
}
-
if (file_exists($tmp) && filesize($tmp) > 0) {
if ($hasNonMin) {
$uglify = new CubeIT_CommandLine('/usr/local/bin/uglifyjs');
protected function _lessBoolean($val)
{
- return $val ? 'true' : 'false';
+ return $this->_themeBoolean($val) ? 'true' : 'false';
}
protected function _font($f)
}
}
+ protected function _themeBoolean($v)
+ {
+ return !(null === $v || $v === '0' || $v === 0 || $v === false || !$v);
+ }
+
protected function writeCSS($links)
{
$res = array();
$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;
continue;
}
$color = trim($chapter->color, '#');
- $lessContents .= '.mview.c_' . $color . '{.menu-color(#' . $color . ');}';
+ $lessContents .= '.mview.c_' . $color . '{.menu-color(' . wsHTML5::colorToCSS($color) . ');}';
}
// Archives
$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{';