From 8a160d3613afa1854b214af953bd68bbd48a4f7e Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 1 Jul 2020 12:53:09 +0000 Subject: [PATCH] wip #3751 @1 --- fluidbook/compile/hybrid/index.html | 22 ++++++++++++++++++- inc/ws/DAO/class.ws.dao.book.php | 10 +++++++-- .../html5/master/class.ws.html5.compiler.php | 8 +++++-- .../Util/html5/master/class.ws.html5.seo.php | 3 +++ .../Util/packager/class.ws.packager.html.php | 8 ++++++- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/fluidbook/compile/hybrid/index.html b/fluidbook/compile/hybrid/index.html index a5e457fad..5b705d066 100644 --- a/fluidbook/compile/hybrid/index.html +++ b/fluidbook/compile/hybrid/index.html @@ -1,7 +1,26 @@ + $titre + + $description + $opengraph + $twittercard + - + + \ No newline at end of file diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 426baa213..fe2989144 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -5,6 +5,9 @@ class wsDAOBook extends commonDAO public static $pagesOfBookCache = array(); + /** @var wsHTML5Compiler */ + public static $lastHTML5Compiler = null; + /** * wsDAOBook::singleton() * @@ -880,7 +883,7 @@ class wsDAOBook extends commonDAO $numerotation = array(); $nb_pages = 0; foreach ($pages as $p) { - if($setNumerotation) { + if ($setNumerotation) { $numerotation[] = $p->virtual; } $nb_pages++; @@ -892,7 +895,7 @@ class wsDAOBook extends commonDAO $c = $this->con->openCursor('books'); $c->parametres = serialize($parametres); - if($setNumerotation) { + if ($setNumerotation) { $c->numerotation = implode(',', $numerotation); } $c->changedate = TIME; @@ -1789,6 +1792,9 @@ class wsDAOBook extends commonDAO $htmlCompiler = wsHTML5::compilerFactory($book_id, $version, false, 'latest', null, false, false, false, $book); $htmlCompiler->compile($delete); + + self::$lastHTML5Compiler = $htmlCompiler; + } /* public function indexPDF($book, $pages) { 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 b67d73196..eee4f8efc 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -731,7 +731,7 @@ class wsHTML5Compiler $text = str_replace(array_keys($replace), array_values($replace), $text); - if( $this->book->parametres->audiodescriptionVoice) { + if ($this->book->parametres->audiodescriptionVoice) { $hash = hash('sha256', $this->book->parametres->audiodescriptionVoice . '_^_' . $text); $fname = $hash . '.mp3'; $dir = WS_BOOKS . '/audiodescription/'; @@ -892,6 +892,10 @@ class wsHTML5Compiler $socialImageWidth = $dim[0]; $socialImageHeight = $dim[1]; + $titre = $this->book->parametres->title; + + $description = ''; + $twittercard = ' @@ -973,7 +977,7 @@ class wsHTML5Compiler if ($this->phonegap) { $csp = "securityPolicyWhitelist)) . "; img-src * data:\">"; } - $vars = array('credits', 'style', 'script', 'pagesContents', 'print', 'hiddenContents', 'splash', 'splashstyles', 'cache', 'bgcolor', 'message', 'favicon', 'svg', 'beginbody', 'csp', 'opengraph', 'twittercard'); + $vars = array('titre', 'credits', 'style', 'script', 'pagesContents', 'print', 'hiddenContents', 'splash', 'splashstyles', 'cache', 'bgcolor', 'message', 'favicon', 'svg', 'beginbody', 'csp', 'opengraph', 'twittercard', 'description'); $res = []; foreach ($vars as $v) { diff --git a/inc/ws/Util/html5/master/class.ws.html5.seo.php b/inc/ws/Util/html5/master/class.ws.html5.seo.php index de9a7caab..a682ec7ff 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.seo.php +++ b/inc/ws/Util/html5/master/class.ws.html5.seo.php @@ -6,6 +6,9 @@ class wsHTML5Seo * @var wsHTML5Compiler */ public $compiler; + /** + * @var wsHTML5SeoPage[] + */ public $pages; public $html; protected $_nav = null; diff --git a/inc/ws/Util/packager/class.ws.packager.html.php b/inc/ws/Util/packager/class.ws.packager.html.php index c19c81eee..dd6fbb5d1 100644 --- a/inc/ws/Util/packager/class.ws.packager.html.php +++ b/inc/ws/Util/packager/class.ws.packager.html.php @@ -252,12 +252,18 @@ class wsPackagerHTML extends wsPackager if ($mfid != '' && (int)$mfid > 0) { $mfbook = $this->daoBook->selectById($mfid); $this->_compileHTML5($this->book_id, $this->book, $dest . '/d'); + $vars = wsDAOBook::$lastHTML5Compiler->getIndexVars(); $this->_compileHTML5($mfid, $mfbook, $dest . '/mf'); $hybrid = file_get_contents(WS_COMPILE_ASSETS . '/hybrid/index.html'); $replace = [ + 'titre' => $vars[''], 'breakpoint' => $this->book->parametres->mobilefirstBreakpoint . 'px', - 'bgcolor' => $this->theme->parametres->loadingBackColor + 'bgcolor' => $this->theme->parametres->loadingBackColor, + 'description' => $vars[''], + 'twittercard' => $vars[''], + 'opengraph' => $vars[''], + 'credits' => $vars[''], ]; foreach ($replace as $var => $value) { $hybrid = str_replace('$' . $var, $value, $hybrid); -- 2.39.5