]> _ Git - cubeextranet.git/commitdiff
wip #3634 @3
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 27 May 2020 15:41:01 +0000 (15:41 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 27 May 2020 15:41:01 +0000 (15:41 +0000)
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php
inc/ws/Util/html5/master/class.ws.html5.links.php

index afa8f8af301b4b87f0d52ded67fc39824d79e0ee..374169ff2733f425d5f40c5fb1ea3a8805a1ad0d 100644 (file)
@@ -1283,6 +1283,9 @@ class wsDAOBook extends commonDAO
 
     public function copy($source, $dest)
     {
+        if(!file_exists($source)){
+            return;
+        }
         copy($source, $dest);
         touch($dest, filemtime($source));
     }
index 030f5396a62ff5e3a87fab892147f929d4735506..f6c76b0b8a6fbbf6455672beec3b2b0c95603eb1 100644 (file)
@@ -93,6 +93,7 @@ class wsHTML5Compiler
                 'js/libs/fluidbook/fluidbook.print.js',
                 'js/libs/fluidbook/fluidbook.secure.js',
                 'js/libs/fluidbook/fluidbook.tabs.js',
+                'js/libs/fluidbook/fluidbook.articles.js',
                 'js/libs/fluidbook/fluidbook.widget.js',
                 'js/libs/fluidbook/fluidbook.js',
                 'js/main.js'],
@@ -578,6 +579,8 @@ class wsHTML5Compiler
         $this->log('Links written');
         $this->writeLangs();
         $this->log('Langs written');
+        $this->writeArticles();
+        $this->log('Articles written');
         $this->writeSEO();
         $this->log('SEO written');
         $this->writeWidget();
@@ -585,7 +588,7 @@ class wsHTML5Compiler
         $this->writeSounds();
         $this->log('Sound written');
         $this->writeAccessibility();
-        $this->log('Sound accessibility');
+        $this->log('Accessibility writter');
         $this->writeTexts();
         $this->log('Texts written');
         $this->writeExtras();
@@ -605,6 +608,7 @@ class wsHTML5Compiler
         $this->log('Files Synced');
     }
 
+
     protected function loadPlugins()
     {
         $e = explode("\n", $this->book->parametres->mobilePlugins);
@@ -2369,6 +2373,57 @@ class wsHTML5Compiler
         return $res;
     }
 
+    public function writeArticles()
+    {
+        $list = [];
+        $f = $this->book->parametres->articlesFile;
+        if ($f === '') {
+            $this->config->articlesList = $list;
+            return;
+        }
+        $f = $this->wdir . '/' . $f;
+        if (!file_exists($f)) {
+            $this->config->articlesList = $list;
+            return;
+        }
+
+        $markupMap = ['category' => 'h3', 'subtitle' => 'h2', 'title' => 'h1', 'lead' => 'div.chapo', 'paragraph' => 'p', 'note' => 'div.note', 'quote' => 'blockquote', 'signature' => 'div.author'];
+
+        $x = simplexml_load_string(file_get_contents($f));
+        foreach ($x->xpath('/articles/article') as $k => $a) {
+            $article = ['id' => (string)$a['id'],
+                'url' => (string)$a['url'],
+                'color' => (string)$a['color'],
+                'contents' => ''];
+
+            $id = 'article_' . $k;
+
+            $content = '<article id="' . $id . '">';
+            foreach ($a->children() as $child) {
+                $tag = $child->getName();
+                if ($tag === 'image') {
+                    $file = (string)$child['file'];
+                    $legend = (string)$child;
+                    $content .= '<figure><img src="data/articles/' . $file . '" alt="' . $legend . '"><figcation>' . $legend . '</figcation></figure>';
+                } else {
+                    $m = $markupMap[$tag] ?? $tag;
+                    $e = explode('.', $m);
+                    $markup = $e[0];
+                    $class = '';
+                    if (count($e) === 2) {
+                        $class = ' class="' . $e[1] . '"';
+                    }
+                    $content .= '<' . $markup . $class . '>' . ((string)$child) . '</' . $markup . '>';
+                }
+            }
+            $content .= '</article>';
+            $article['contents'] = $content;
+            $list[] = $article;
+        }
+
+        $this->config->articlesList = $list;
+    }
+
 }
 
 if (!function_exists('is_countable')) {
index cb80ffcdf6fb52c04630b79e617025986faac776..db80328a0b895897f9448b91a6dcb579cab3882d 100644 (file)
@@ -333,7 +333,7 @@ class wsHTML5Link
     {
 
         $res = array();
-        if ($this->image_rollover != 'none') {
+        if (isset($this->image_rollover) && $this->image_rollover != 'none') {
             $res[] = 'image_rollover';
         }
         return $res;