]> _ Git - cubeextranet.git/commitdiff
wip #3827 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 29 Jul 2020 17:18:13 +0000 (17:18 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 29 Jul 2020 17:18:13 +0000 (17:18 +0000)
inc/ws/Metier/class.ws.book.parametres.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 43e8e04091fd7580141e96be97422b0aa687e88d..dca24d2b03ac65079a65044219f44ebe8cb6bfb1 100644 (file)
@@ -488,7 +488,7 @@ class wsBookParametres extends wsParametres
             '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->fields['articlesStyle'] = ['type' => 'combo', 'default' => true, 'editable' => true, 'label' => __('Style'), 'grade' => 3, 'datas' => ['Défaut' => 'default', 'Atlantic' => 'atlantic', 'Harmonie Mutuelles' => 'harmonie-mutuelle']];
+        $this->fields['articlesStyle'] = ['type' => 'combo', 'default' => true, 'editable' => true, 'label' => __('Style'), 'grade' => 3, 'datas' => ['Défaut' => 'default', 'Atlantic' => 'atlantic', 'Harmonie Mutuelle' => 'harmonie-mutuelle']];
 
         $this->forms['articles'] = ['label' => __('Articles'), 'fieldsnames' => ['articlesFile', 'articlesShare', 'articlesImages', '|', 'articlesStyle', 'articlesFont']];
 
index 4601935eacf7f321df69778512bb9759cfdba25c..5d94086e0a2993e680f65a29079be09f318bebe7 100644 (file)
@@ -2437,13 +2437,30 @@ class wsHTML5Compiler
     public function addFontKit($font)
     {
         $path = 'style/fonts/' . $font;
-        $this->stylesheets[] = $path . '/font.css';
+        $css = $path . '/font.css';
+        if (in_array($css, $this->stylesheets)) {
+            return;
+        }
+        $this->stylesheets[] = $css;
         $this->vdir->copyDirectory($this->assets . '/' . $path, $path);
         return $path . '/font.css';
     }
 
+
+    public function SimpleXMLElement_innerXML($xml)
+    {
+        $innerXML = '';
+        foreach (dom_import_simplexml($xml)->childNodes as $child) {
+            $innerXML .= $child->ownerDocument->saveXML($child);
+        }
+        return $innerXML;
+    }
+
+
     public function writeArticles()
     {
+        $mapFonts = ['OpenSans' => 'Open Sans'];
+
         $this->lessVariables['articles-title-color'] = '#000000';
         $this->lessVariables['articles-font'] = 'OpenSans';
 
@@ -2460,11 +2477,15 @@ class wsHTML5Compiler
         }
 
         $this->addLess('articles');
+        if ($this->book->parametres->articlesStyle !== 'default') {
+            $this->lessVariables['articles-styles'] = $this->book->parametres->articlesStyle;
+        }
 
         $this->lessVariables['articles-title-color'] = '#565657';
-        $this->lessVariables['articles-font'] = $this->book->parametres->articlesFont;
+        $this->lessVariables['articles-font'] = $mapFonts[$this->book->parametres->articlesFont] ?? $this->book->parametres->articlesFont;
         $fontPath = $this->addFontKit($this->book->parametres->articlesFont);
 
+
         $svg = '<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><symbol id="nav-print" viewBox="0 0 512 512">
         <path d="m424 186l-39 0 0-114c0-9-6-15-14-15l-230 0c-8 0-14 6-14 15l0 114-39 0c-22 0-41 19-41 41l0 121c0 23 19 41 41 41l39 0 0 49c0 8 6 15 14 15l230 0c8 0 14-7 14-15l0-49 39 0c22 0 41-18 41-41l0-121c0-22-19-41-41-41z m-268-100l200 0 0 100-200 0z m200 340l-200 0 0-88 200 0z m80-76c0 6-6 12-12 12l-39 0 0-38c0-9-6-15-14-15l-230 0c-8 0-14 6-14 15l0 38-39 0c-6 0-12-6-12-12l0-121c0-6 6-12 12-12l336 0c6 0 12 6 12 12z m-278-96l-33 0c-8 0-14 6-14 14 0 8 6 15 14 15l35 0c8 0 14-7 14-15 0-8-8-14-16-14z m32 139l132 0c8 0 14-6 14-14 0-8-6-14-14-14l-132 0c-8 0-14 6-14 14 0 8 6 14 14 14z"/>
     </symbol></svg>';
@@ -2491,7 +2512,7 @@ class wsHTML5Compiler
             $prevurl = $url;
 
             $specificStyles = '## h3, ## figure figcaption{background-color:' . $article['color'] . '}';
-            $specificStyles .= '## .chapo, ## blockquote{color:' . $article['color'] . ';}';
+            $specificStyles .= '## .chapo, ## blockquote, ## a{color:' . $article['color'] . ';}';
 
             $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>';
@@ -2519,7 +2540,7 @@ class wsHTML5Compiler
                     $caption = $legend ? '<figcaption>' . $legend . '</figcaption>' : '';
                     $inner .= '<figure><img src="data/articles/' . $file . '" alt="' . $legend . '">' . $caption . '</figure>';
                 } else {
-                    $c = trim(((string)$child));
+                    $c = trim($this->SimpleXMLElement_innerXML($child));
                     if (!$c) {
                         continue;
                     }