From 89ebdfc436bf6067fcb43fd927d450c65ea9290b Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 1 Jul 2020 18:39:52 +0000 Subject: [PATCH] wip #3747 @7 --- .../html5/master/class.ws.html5.compiler.php | 12 ++- .../Util/html5/master/class.ws.html5.seo.php | 78 ++++++++++++------- 2 files changed, 59 insertions(+), 31 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 eee4f8efc..91a8aa588 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -211,6 +211,7 @@ class wsHTML5Compiler public $cssfont = []; public $lessVariables = []; protected $_indexVars = null; + public $accessibleTexts = []; public $_signature; /** @@ -589,10 +590,10 @@ class wsHTML5Compiler $this->log('Widget written'); $this->writeSounds(); $this->log('Sound written'); - $this->writeAccessibility(); - $this->log('Accessibility writter'); $this->writeTexts(); $this->log('Texts written'); + $this->writeAccessibility(); + $this->log('Accessibility writter'); $this->writeExtras(); $this->log('Extras written'); $this->populateConfig(); @@ -766,6 +767,13 @@ class wsHTML5Compiler $this->config->audiodescription[$page] = $fname; $this->vdir->copy($file, 'data/audiodescription/' . $fname); } + $this->accessibleTexts[$page] = $text; + } + + + if (count($this->accessibleTexts) > 0) { + // Overwrite SEO version + $this->seo = new wsHTML5Seo($this); } } diff --git a/inc/ws/Util/html5/master/class.ws.html5.seo.php b/inc/ws/Util/html5/master/class.ws.html5.seo.php index a682ec7ff..a7bc5586d 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.seo.php +++ b/inc/ws/Util/html5/master/class.ws.html5.seo.php @@ -18,35 +18,7 @@ class wsHTML5Seo { $this->compiler = $compiler; // Define default seo contents - $this->pages = []; - - foreach ($compiler->pages as $page => $infos) { - $p = new wsHTML5SeoPage($this); - $p->page = $page; - $p->title = ($page == 1) ? $this->compiler->book->parametres->title : $this->_getPageLabel($page); - $p->text = $this->getTextContent($infos); - $p->description = $this->compiler->book->parametres->seoDescription ? $this->compiler->book->parametres->seoDescription : $this->compiler->book->parametres->title . ' - Powered by Fluidbook'; - $p->socialDescription = $this->compiler->book->parametres->facebook_description || $this->compiler->book->parametres->seoDescription; - $p->keywords = $this->compiler->book->parametres->seoKeywords; - $p->robots = $this->compiler->book->parametres->seoRobots ? 'index,follow' : 'noindex,nofollow'; - - // Google analytics - $p->ua = ''; - if ($this->compiler->book->parametres->googleAnalytics != '') { - $codes = explode(',', $this->compiler->book->parametres->googleAnalytics); - $p->ua .= ""; - } - if ($this->compiler->book->parametres->googleAnalyticsCustom != '') { - $p->ua .= $this->compiler->book->parametres->googleAnalyticsCustom; - } - - if ($this->compiler->book->parametres->statsCustom != '') { - $p->footer = $this->compiler->book->parametres->statsCustom; - } - - $this->pages[$page] = $p; - } - + $this->createPages(); if ($compiler->book->parametres->seoAdvanced) { $sheets = wsUtil::excelToArray($compiler->wdir . '/' . $compiler->book->parametres->seoAdvanced, true); @@ -75,6 +47,54 @@ class wsHTML5Seo $this->html = file_get_contents($this->compiler->assets . '/_index.html'); } + public function createPages() + { + $this->pages = []; + if (isset($this->compiler->accessibleTexts) && count($this->compiler->accessibleTexts) > 0) { + foreach ($this->compiler->accessibleTexts as $page => $accessibleText) { + if ($page == 0) { + $page = 1; + } + $this->createPage($page, $accessibleText); + } + if (!isset($this->pages[1])) { + $this->createPage(1, $this->compiler->pages[1]); + } + return; + } + foreach ($this->compiler->pages as $page => $infos) { + $this->createPage($page, $this->getTextContent($infos)); + } + } + + public function createPage($page, $content) + { + $p = new wsHTML5SeoPage($this); + $p->page = $page; + $p->title = ($page == 1) ? $this->compiler->book->parametres->title : $this->_getPageLabel($page); + $p->text = $content; + $p->description = $this->compiler->book->parametres->seoDescription ? $this->compiler->book->parametres->seoDescription : $this->compiler->book->parametres->title . ' - Powered by Fluidbook'; + $p->socialDescription = $this->compiler->book->parametres->facebook_description || $this->compiler->book->parametres->seoDescription; + $p->keywords = $this->compiler->book->parametres->seoKeywords; + $p->robots = $this->compiler->book->parametres->seoRobots ? 'index,follow' : 'noindex,nofollow'; + + // Google analytics + $p->ua = ''; + if ($this->compiler->book->parametres->googleAnalytics != '') { + $codes = explode(',', $this->compiler->book->parametres->googleAnalytics); + $p->ua .= ""; + } + if ($this->compiler->book->parametres->googleAnalyticsCustom != '') { + $p->ua .= $this->compiler->book->parametres->googleAnalyticsCustom; + } + + if ($this->compiler->book->parametres->statsCustom != '') { + $p->footer = $this->compiler->book->parametres->statsCustom; + } + + $this->pages[$page] = $p; + } + public function getTextContent($infos) { switch ($this->compiler->book->parametres->textExtraction) { -- 2.39.5