]> _ Git - cubeextranet.git/commitdiff
wait #3698
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 29 Jun 2020 18:54:21 +0000 (18:54 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 29 Jun 2020 18:54:21 +0000 (18:54 +0000)
inc/ws/Metier/class.ws.book.parametres.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index c050ddc93fcde85825540fb2f01d269d8fa1e5cd..c6a78da36356e421dc1b7e0cc639e7a69594ceed 100644 (file)
@@ -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 <image> 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,
index 1f998b908eaf222a45a32f83b817bc7ba2de3eaf..73dc8b0d8c6422d3fd4c5b3ff15e50bc700e1d35 100644 (file)
@@ -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 = '<article data-id="' . $article['id'] . '" class="menu-article" id="article_' . $article['id'] . '">';
             $inner .= '<style type="text/css">' . str_replace('##', '#article_' . $article['id'], $specificStyles) . '</style>';
-            $inner .= '<a href="#" class="print"><svg viewBox="0 0 512 512" class="nav-print nav-icon svg-icon"><use xlink:href="#nav-print"></use></svg></a>';
+            $inner .= '<div class="actions">';
+            if ($this->book->parametres->articlesShare && $this->book->parametres->share) {
+                $inner .= '<a data-id="' . $article['id'] . '" data-url="' . $url . '" href="#" class="articlesShare"><svg viewBox="0 0 512 512" class="nav-share nav-icon svg-icon"><use xlink:href="#nav-share"></use></svg></a>';
+            }
+            $inner .= '<a href="#" class="articlesPrint"><svg viewBox="0 0 512 512" class="nav-print nav-icon svg-icon"><use xlink:href="#nav-print"></use></svg></a>';
+            $inner .= '</div>';
+
+            $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 .= '<figure><img src="data/articles/' . $file . '" alt="' . $legend . '"><figcaption>' . $legend . '</figcaption></figure>';
                 } 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) . '</' . $markup . '>';
+                    $inner .= '<' . $markup . $class . '>' . $c . '</' . $markup . '>';
                 }
             }
             $inner .= '</article>';
@@ -2477,6 +2508,8 @@ class wsHTML5Compiler
             $content .= '</body></html>';
             $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;