From e5a0ddad2659dded2a6ad2752ade7f87f1a8582f Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 27 May 2020 15:41:01 +0000 Subject: [PATCH] wip #3634 @3 --- inc/ws/DAO/class.ws.dao.book.php | 3 + .../html5/master/class.ws.html5.compiler.php | 57 ++++++++++++++++++- .../html5/master/class.ws.html5.links.php | 2 +- 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index afa8f8af3..374169ff2 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -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)); } 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 030f5396a..f6c76b0b8 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -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 = '
'; + foreach ($a->children() as $child) { + $tag = $child->getName(); + if ($tag === 'image') { + $file = (string)$child['file']; + $legend = (string)$child; + $content .= '
' . $legend . '' . $legend . '
'; + } 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) . ''; + } + } + $content .= '
'; + $article['contents'] = $content; + $list[] = $article; + } + + $this->config->articlesList = $list; + } + } if (!function_exists('is_countable')) { diff --git a/inc/ws/Util/html5/master/class.ws.html5.links.php b/inc/ws/Util/html5/master/class.ws.html5.links.php index cb80ffcdf..db80328a0 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -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; -- 2.39.5