From 9a33bbb83c9110f1bb2df31bac76e53a7412133a Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Thu, 29 Sep 2016 15:38:08 +0000 Subject: [PATCH] done #761 @1.5 --- inc/ws/Controlleur/class.ws.url.php | 10 +++---- .../Util/packager/class.ws.packager.html.php | 29 +++++++++++++------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 2706ddf3d..7b80e54b4 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -1308,11 +1308,11 @@ html{height:100%}' . "\n"; $res .= ''; $res .= ''; // Entêtes Facebook - $meta['og:title'] = ($book->parametres->facebook_title == '') ? $book->parametres->title : $book->parametres->facebook_title; - if ($book->parametres->facebook_description != '') { - $meta['og:description'] = $book->parametres->facebook_description; - } - $meta['og:image'] = 'https://workshop.fluidbook.com/services/facebook_thumbnail?id=' . $book->book_id . '&j=' . TIME; + $meta['og:title'] = ($book->parametres->facebook_title == '') ? $book->parametres->title : $book->parametres->facebook_title; + if ($book->parametres->facebook_description != '') { + $meta['og:description'] = $book->parametres->facebook_description; + } + $meta['og:image'] = 'https://workshop.fluidbook.com/services/facebook_thumbnail?id=' . $book->book_id . '&j=' . TIME; $redirectPDF = 'window.location="data/document.pdf"'; diff --git a/inc/ws/Util/packager/class.ws.packager.html.php b/inc/ws/Util/packager/class.ws.packager.html.php index d45f85201..d4444cf96 100644 --- a/inc/ws/Util/packager/class.ws.packager.html.php +++ b/inc/ws/Util/packager/class.ws.packager.html.php @@ -99,10 +99,6 @@ class wsPackagerHTML extends wsPackager { $robots = ''; } - $description = ''; - if ($this->book->parametres->seoDescription) { - $description = ''; - } $keywords = ''; if ($this->book->parametres->seoKeywords) { $keywords = ''; @@ -118,6 +114,7 @@ class wsPackagerHTML extends wsPackager { } $html5priority = CubeIT_Util_Bool::boolval($this->book->parametres->html5priority, false, true); + // Stuffs to replace in html $toReplace = array('lang' => strtolower($this->book->lang), 'ga' => $ga, @@ -126,7 +123,6 @@ class wsPackagerHTML extends wsPackager { 'redirectMobile' => $redirectMobile, 'redirectPDF' => $redirectPDF, 'junk' => TIME, - 'description' => $description, 'robots' => $robots, 'favicon' => $favicon, 'flashversion' => $this->getMinFlashVersion(), @@ -171,7 +167,6 @@ class wsPackagerHTML extends wsPackager { $html = CubeIT_Util_Gzip::file_get_contents($htmlfile); $alt .= "\n" . $html . "\n"; - if ($page == 1) { $alt .= $nav1; } else { @@ -179,7 +174,6 @@ class wsPackagerHTML extends wsPackager { } } - $alt .= $footer; $base = ''; @@ -187,6 +181,17 @@ class wsPackagerHTML extends wsPackager { $base = ''; } + if ($page == 1 && $this->book->parametres->seoDescription) { + $description = $this->book->parametres->seoDescription; + } else { + $textfile = wsDocument::getDir($infos['document_id']) . 'ph' . $infos['document_page'] . '.txt'; + if (file_exists($textfile)) { + $description = mb_substr(file_get_contents($textfile), 0, 150); + } else { + $description = ''; + } + } + $data = str_replace('$alt', $alt, $this->origHTML); $data = str_replace('$base', $base, $data); $data = str_replace('$pathToIndex', $pathToIndex, $data); @@ -195,6 +200,7 @@ class wsPackagerHTML extends wsPackager { $data = str_replace('$redirectScript', $redirectScript, $data); $data = str_replace('$sp', $sp, $data); $data = str_replace('$index_ext', $this->_ext, $data); + $data = str_replace('$description', '', $data); file_put_contents($this->vdir . $dest, $data); @@ -354,8 +360,13 @@ class wsPackagerHTML extends wsPackager { return 1; } - protected function escape($txt) { - return htmlentities($txt, ENT_COMPAT, 'UTF-8'); + protected function escape($txt, $replaceNewLines = false) { + $res = htmlentities($txt, ENT_COMPAT, 'UTF-8'); + if ($replaceNewLines) { + $res = str_replace("\n", ' ', $res); + $res = str_replace("\r", '', $res); + } + return $res; } protected function makeHTMLFooter() { -- 2.39.5