From 08b5cb31d788f43c9289cedf227ddf2644791aab Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 7 Dec 2021 17:45:35 +0000 Subject: [PATCH] wait #4946 @1 --- .../html5/master/class.ws.html5.compiler.php | 55 ++++++++++++++----- .../html5/master/class.ws.html5.links.php | 7 ++- 2 files changed, 47 insertions(+), 15 deletions(-) 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 21d5b6939..8cb7c0a1f 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -939,6 +939,8 @@ class wsHTML5Compiler $this->writeImages(); $this->log('Images written'); $this->writeCartConfig(); + $this->writeXMLArticles(); + $this->log('XML Articles written'); $linksCSS = $this->writeLinks(); $this->log('Links written'); $this->writeArticles(); @@ -3253,29 +3255,29 @@ height="0" width="0" style="display:none;visibility:hidden"> return $innerXML; } - public function writeArticles() + public function writeXMLArticles() { - $mapFonts = ['OpenSans' => 'Open Sans']; - - $this->lessVariables['articles-title-color'] = '#000000'; - $this->lessVariables['articles-font'] = 'OpenSans'; + $f = $this->book->parametres->articlesFile; + if ($f !== '' && file_exists($this->wdir . '/' . $f)) { + $f = $this->wdir . '/' . $f; - $list = []; - if (isset($this->config->articlesList)) { - $list = $this->config->articlesList; - } - $f = $this->book->parametres->articlesFile; - if ($f !== '' && file_exists($f = $this->wdir . '/' . $f)) { + $mapFonts = ['OpenSans' => 'Open Sans']; + $this->lessVariables['articles-title-color'] = '#000000'; + $this->lessVariables['articles-font'] = 'Open Sans'; $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'] = $mapFonts[$this->book->parametres->articlesFont] ?? $this->book->parametres->articlesFont; $fontPath = $this->addFontKit($this->book->parametres->articlesFont); + $list = $this->config->articlesList ?? []; + + + $this->lessVariables['articles-title-color'] = '#565657'; + + $svg = ' '; @@ -3365,6 +3367,33 @@ height="0" width="0" style="display:none;visibility:hidden"> } } + $this->config->articlesList = $list; + + } + + public function findArticleById($id) + { + foreach ($this->config->articlesList as $item) { + if ($item['id'] === $id) { + return $item; + } + } + return null; + } + + public function updateArticleById($id, $article) + { + foreach ($this->config->articlesList as $k => $item) { + if ($item['id'] === $id) { + $this->config->articlesList[$k] = $article; + break; + } + } + } + + public function writeArticles() + { + $list = $this->config->articlesList ?? []; $nb = count($list); foreach ($list as $k => $item) { 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 197ea8fa7..46549ce8e 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -3130,10 +3130,13 @@ class articleLink extends normalLink { parent::init(); + $this->article = $this->compiler->findArticleById($this->to); - $this->article = $this->compiler->config->articlesList[$this->to]; if (!isset($this->compiler->config->articlesList[$this->to]['page'])) { - $this->compiler->config->articlesList[$this->to]['page'] = $this->page; + if (!isset($this->article['page'])) { + $this->article['page'] = $this->page; + $this->compiler->updateArticleById($this->to, $this->article); + } } } -- 2.39.5