From dc735d1f294a4c4114a5510cf709646e268e40dd Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Mon, 29 Jun 2020 18:54:21 +0000 Subject: [PATCH] wait #3698 --- inc/ws/Metier/class.ws.book.parametres.php | 3 +- .../html5/master/class.ws.html5.compiler.php | 45 ++++++++++++++++--- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index c050ddc93..c6a78da36 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -479,8 +479,9 @@ class wsBookParametres extends wsParametres $this->fields['articlesFont'] = ['type' => 'combo', 'label' => __('Police des articles'), 'default' => 'OpenSans', 'datas' => [ 'Open Sans (police du Fluidbook)' => 'OpenSans', 'Montserrat' => 'Montserrat'], 'editable' => 'true', 'grade' => 3]; $this->fields['articlesImages'] = ['type' => 'freefile', 'label' => __('Images des articles'), 'default' => '', 'hint' => __('Les noms des fichiers doivent être les même que ceux des balises du XML'), 'editable' => true, 'grade' => 3, 'dir' => 'articles']; + $this->fields['articlesShare'] = ['type' => 'boolean', 'default' => true, 'editable' => true, 'label' => 'Activer le partage', 'grade' => 3]; - $this->forms['articles'] = ['label' => __('Articles'), 'fieldsnames' => ['articlesFile', 'articlesFont', 'articlesImages']]; + $this->forms['articles'] = ['label' => __('Articles'), 'fieldsnames' => ['articlesFile', 'articlesShare', 'articlesFont', 'articlesImages']]; //. $this->fields['externalArchives'] = array('type' => 'freefile', 'default' => '', 'editable' => true, 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 1f998b908..73dc8b0d8 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -1373,7 +1373,7 @@ class wsHTML5Compiler $linkData['hidden'] = in_array($linkData['uid'], $hiddenLinks); if ($linkData['type'] == 28) { - $this->addSEOArticle($linkData['page'], $linkData['to'], $linkData['extra'], $linkData['image']); + $this->addSEOArticle('#/page/' . $linkData['page'], $linkData['to'], $linkData['extra'], $linkData['image']); continue; } $link = wsHTML5Link::getInstance($this->base62($i), $linkData, $this); @@ -1449,9 +1449,16 @@ class wsHTML5Compiler return $css; } - public function addSEOArticle($page, $title, $intro, $image) + public function addSEOArticle($page, $title, $intro, $image, $id = null, $url = null, $content = '') { - $this->seoArticles[$title] = ['title' => $title, 'description' => $intro, 'image' => $image, 'content' => '', 'page' => $page, 'url' => CubeIT_Text::str2URL($title) . '.html']; + if (null === $url) { + $url = CubeIT_Text::str2URL($title) . '.html'; + } + if (null === $id) { + $id = $title; + } + + $this->seoArticles[$id] = ['title' => $title, 'description' => $intro, 'image' => $image, 'content' => $content, 'page' => $page, 'url' => $url, 'id' => $id]; } public function _sortLinks($a, $b) @@ -2349,7 +2356,7 @@ class wsHTML5Compiler public function getConfigZIP($d) { - $res = array('type'=>'zip','width' => 0, 'height' => 0); + $res = array('type' => 'zip', 'width' => 0, 'height' => 0); if (file_exists($d . '/index.html')) { $doc = new DOMDocument(); @$doc->loadHTMLFile($d . '/index.html'); @@ -2442,15 +2449,39 @@ class wsHTML5Compiler $inner = '
'; $inner .= ''; - $inner .= ''; + $inner .= '
'; + if ($this->book->parametres->articlesShare && $this->book->parametres->share) { + $inner .= ''; + } + $inner .= ''; + $inner .= '
'; + + $title = ''; + $lead = ''; + $image = ''; + foreach ($a->children() as $child) { $tag = $child->getName(); if ($tag === 'image') { + $file = (string)$child['file']; + if ($image === '') { + $image = 'articles/' . $file; + } $this->vdir->copy($this->wdir . '/articles/' . $file, 'data/articles/' . $file); $legend = (string)$child; $inner .= '
' . $legend . '
' . $legend . '
'; } else { + $c = trim(((string)$child)); + if (!$c) { + continue; + } + if (!$title && $tag === 'title') { + $title = $c; + } + if (!$lead && $tag === 'lead') { + $lead = $c; + } $m = $markupMap[$tag] ?? $tag; $e = explode('.', $m); $markup = $e[0]; @@ -2458,7 +2489,7 @@ class wsHTML5Compiler if (count($e) === 2) { $class = ' class="' . $e[1] . '"'; } - $inner .= '<' . $markup . $class . '>' . ((string)$child) . ''; + $inner .= '<' . $markup . $class . '>' . $c . ''; } } $inner .= '
'; @@ -2477,6 +2508,8 @@ class wsHTML5Compiler $content .= ''; $article['print'] = $content; $list[] = $article; + + $this->addSEOArticle('#/article/' . $article['url'], $title, $lead, $image, $article['id'], $article['url'], $inner); } $list[0]['prev'] = $prevurl; $list[count($list) - 1]['next'] = $firsturl; -- 2.39.5