]> _ Git - cubeextranet.git/commitdiff
wip #3747 @7
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 1 Jul 2020 18:39:52 +0000 (18:39 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 1 Jul 2020 18:39:52 +0000 (18:39 +0000)
inc/ws/Util/html5/master/class.ws.html5.compiler.php
inc/ws/Util/html5/master/class.ws.html5.seo.php

index eee4f8efc10e632f0323b89eb0fb0a028f4a4edb..91a8aa5888b60a71a321efd28e41959fa54c02ad 100644 (file)
@@ -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);
         }
     }
 
index a682ec7ffcd845092a1b3c5233d1bbd62ae3dad7..a7bc5586d1e0e4e7659dfdefb440736f0df0030c 100644 (file)
@@ -18,35 +18,7 @@ class wsHTML5Seo
     {\r
         $this->compiler = $compiler;\r
         // Define default seo contents\r
-        $this->pages = [];\r
-\r
-        foreach ($compiler->pages as $page => $infos) {\r
-            $p = new wsHTML5SeoPage($this);\r
-            $p->page = $page;\r
-            $p->title = ($page == 1) ? $this->compiler->book->parametres->title : $this->_getPageLabel($page);\r
-            $p->text = $this->getTextContent($infos);\r
-            $p->description = $this->compiler->book->parametres->seoDescription ? $this->compiler->book->parametres->seoDescription : $this->compiler->book->parametres->title . ' - Powered by Fluidbook';\r
-            $p->socialDescription = $this->compiler->book->parametres->facebook_description || $this->compiler->book->parametres->seoDescription;\r
-            $p->keywords = $this->compiler->book->parametres->seoKeywords;\r
-            $p->robots = $this->compiler->book->parametres->seoRobots ? 'index,follow' : 'noindex,nofollow';\r
-\r
-            // Google analytics\r
-            $p->ua = '';\r
-            if ($this->compiler->book->parametres->googleAnalytics != '') {\r
-                $codes = explode(',', $this->compiler->book->parametres->googleAnalytics);\r
-                $p->ua .= "<script async src=\"https://www.googletagmanager.com/gtag/js?id=" . $codes[0] . "\"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}</script>";\r
-            }\r
-            if ($this->compiler->book->parametres->googleAnalyticsCustom != '') {\r
-                $p->ua .= $this->compiler->book->parametres->googleAnalyticsCustom;\r
-            }\r
-\r
-            if ($this->compiler->book->parametres->statsCustom != '') {\r
-                $p->footer = $this->compiler->book->parametres->statsCustom;\r
-            }\r
-\r
-            $this->pages[$page] = $p;\r
-        }\r
-\r
+        $this->createPages();\r
 \r
         if ($compiler->book->parametres->seoAdvanced) {\r
             $sheets = wsUtil::excelToArray($compiler->wdir . '/' . $compiler->book->parametres->seoAdvanced, true);\r
@@ -75,6 +47,54 @@ class wsHTML5Seo
         $this->html = file_get_contents($this->compiler->assets . '/_index.html');\r
     }\r
 \r
+    public function createPages()\r
+    {\r
+        $this->pages = [];\r
+        if (isset($this->compiler->accessibleTexts) && count($this->compiler->accessibleTexts) > 0) {\r
+            foreach ($this->compiler->accessibleTexts as $page => $accessibleText) {\r
+                if ($page == 0) {\r
+                    $page = 1;\r
+                }\r
+                $this->createPage($page, $accessibleText);\r
+            }\r
+            if (!isset($this->pages[1])) {\r
+                $this->createPage(1, $this->compiler->pages[1]);\r
+            }\r
+            return;\r
+        }\r
+        foreach ($this->compiler->pages as $page => $infos) {\r
+            $this->createPage($page, $this->getTextContent($infos));\r
+        }\r
+    }\r
+\r
+    public function createPage($page, $content)\r
+    {\r
+        $p = new wsHTML5SeoPage($this);\r
+        $p->page = $page;\r
+        $p->title = ($page == 1) ? $this->compiler->book->parametres->title : $this->_getPageLabel($page);\r
+        $p->text = $content;\r
+        $p->description = $this->compiler->book->parametres->seoDescription ? $this->compiler->book->parametres->seoDescription : $this->compiler->book->parametres->title . ' - Powered by Fluidbook';\r
+        $p->socialDescription = $this->compiler->book->parametres->facebook_description || $this->compiler->book->parametres->seoDescription;\r
+        $p->keywords = $this->compiler->book->parametres->seoKeywords;\r
+        $p->robots = $this->compiler->book->parametres->seoRobots ? 'index,follow' : 'noindex,nofollow';\r
+\r
+        // Google analytics\r
+        $p->ua = '';\r
+        if ($this->compiler->book->parametres->googleAnalytics != '') {\r
+            $codes = explode(',', $this->compiler->book->parametres->googleAnalytics);\r
+            $p->ua .= "<script async src=\"https://www.googletagmanager.com/gtag/js?id=" . $codes[0] . "\"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}</script>";\r
+        }\r
+        if ($this->compiler->book->parametres->googleAnalyticsCustom != '') {\r
+            $p->ua .= $this->compiler->book->parametres->googleAnalyticsCustom;\r
+        }\r
+\r
+        if ($this->compiler->book->parametres->statsCustom != '') {\r
+            $p->footer = $this->compiler->book->parametres->statsCustom;\r
+        }\r
+\r
+        $this->pages[$page] = $p;\r
+    }\r
+\r
     public function getTextContent($infos)\r
     {\r
         switch ($this->compiler->book->parametres->textExtraction) {\r