]> _ Git - cubeextranet.git/commitdiff
wip #2116 @4
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 5 Jul 2018 16:30:15 +0000 (16:30 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 5 Jul 2018 16:30:15 +0000 (16:30 +0000)
inc/ws/Metier/class.ws.book.parametres.php
inc/ws/Util/html5/advancedseo/class.ws.html5.compiler.php
inc/ws/Util/html5/advancedseo/class.ws.html5.seo.php

index 5af5e9fe914772e1190cb2e95881ab8d52d55952..fd3fc83374008700ef85c21fff4930dc2b0c4f99 100644 (file)
@@ -484,9 +484,10 @@ class wsBookParametres extends wsParametres
                $this->fields['seoDescription'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Meta tag Description'));
                $this->fields['seoKeywords'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Meta tag Keywords'));
                $this->fields['seoAdvanced'] = ['type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Données SEO par page'), 'grade' => 5, 'fileFilter' => $seoFilter];
+               $this->fields['seoBaseURL'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('URL de base'), 'grade' => 5, 'hint' => __("Si l'authentification échoue, redirection vers cette adresse"));
 
                $this->forms['seo'] = array('label' => __('Optimisation pour les moteurs de recherche'),
-                       'fieldsnames' => array('seoVersion', 'seoRobots', 'seoDescription', "seoKeywords", '|', 'seoAdvanced'));
+                       'fieldsnames' => array('seoVersion', 'seoRobots', 'seoDescription', "seoKeywords", '|', 'seoBaseURL', 'seoAdvanced'));
 
                $this->fields['home'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Accueil de l'interface multibrochure"), 'grade' => 5);
                $this->fields['multilang'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Langues'), 'hint' => __('Code langue') . ',' . __('Code pays') . ',' . __('URL'));
index 852ac734dded1bc1da3a81852870a963f35e010f..3be2a1f4915a77ad2813fe0cbfcade52f1946473 100644 (file)
@@ -363,6 +363,7 @@ class wsHTML5Compiler
                $this->log('Langs written');
                $this->writeSEO();
                $this->writeIndex();
+               $this->writeWidget();
                $this->log('Index written');
                $this->writeSounds();
                $this->log('Sound written');
@@ -477,12 +478,12 @@ class wsHTML5Compiler
                $this->vdir->copyDirectory(WS_SOUNDS . '/' . $this->book->parametres->soundTheme, 'data/sounds');
        }
 
-       protected function writeIndex()
+       protected function _writeIndex($page)
        {
                global $core;
 
-               $html = $this->seo->pages[1]->getHTML();
-               $uhtml = $html;
+               $seo = $this->seo->pages[$page];
+               $html = $seo->getHTML();
 
                $titre = $this->book->parametres->title;
 
@@ -526,7 +527,7 @@ class wsHTML5Compiler
                        $iscript .= '</script>' . "\n";
                }
 
-               $script = '';
+               $script = '<script type="text/javascript">var FLUIDBOOK_START_PAGE="' . $page . '";</script>' . "\n";
                $script .= '<script type="text/javascript" charset="utf-8" src="data/datas.js"></script>' . "\n";
                $script .= '<script type="text/javascript" charset="utf-8" src="data/fluidbook.js"></script>' . "\n";
                if ($this->book->parametres->scorm_enable) {
@@ -627,45 +628,21 @@ class wsHTML5Compiler
                        }
                }
 
-               $scripts = array();
-               foreach ($this->debugJsFiles as $js) {
-                       $scripts[] = '<script type="text/javascript" charset="utf-8" src="' . $js . '"></script>';
-               }
-               foreach ($this->jsFiles as $js) {
-                       $scripts[] = '<script type="text/javascript" charset="utf-8" src="' . $js . '"></script>';
-               }
-               foreach ($this->pluginJs as $js) {
-                       $scripts[] = '<script type="text/javascript" charset="utf-8" src="' . $js . '"></script>';
-               }
-
-               $scripts[] = '<script type="text/javascript" charset="utf-8" src="data/datas.js"></script>';
-               $scripts[] = $iscript;
-               $script = implode("\n\t\t", $scripts);
-
-               $scripts = array();
-               foreach ($this->testJsFiles as $js) {
-                       $scripts[] = '<script type="text/javascript" charset="utf-8" src="' . $js . '"></script>';
-               }
-               $scripts[] = '<script type="text/javascript" charset="utf-8" src="data/datas.js"></script>';
-               $script_test = implode("\n\t\t", $scripts);
-
-               $thtml = $uhtml;
-
-               $vars = array('credits', 'style', 'script', 'pagesContents', 'print', 'hiddenContents', 'splash', 'cache', 'bgcolor', 'message', 'favicon');
-               foreach ($vars as $v) {
-                       $uhtml = str_replace('<!-- $' . $v . ' -->', $$v, $uhtml);
+               $seo->writePage($html, $this->vdir);
+               if ($page == 1) {
+                       $seo->writePage($html, $this->vdir, 'index.html');
                }
+       }
 
-               $script .= "\n\t\t" . '<script type="text/javascript" charset="utf-8">window.tester = true;</script>';
-               $vars = array('credits', 'style', 'script', 'print', 'hiddenContents', 'splash', 'message');
-               foreach ($vars as $v) {
-                       $thtml = str_replace('<!-- $' . $v . ' -->', $$v, $thtml);
+       protected function writeIndex()
+       {
+               foreach ($this->pages as $page => $infos) {
+                       $this->_writeIndex($page);
                }
+       }
 
-               $this->vdir->file_put_contents('index.html', $html);
-               $this->vdir->file_put_contents('indexu.html', $uhtml);
-               $this->vdir->file_put_contents('indext.html', $thtml);
-
+       protected function writeWidget()
+       {
                // Write widget html
                if ($this->widget) {
                        $whtml = file_get_contents($this->assets . '/widget.html');
index 4f8661f8f3463e0fd531305a3136d201eba2d56a..4890796db19ece8822999b1229b63707763916c9 100644 (file)
@@ -143,7 +143,6 @@ class wsHTML5SeoPage
                $compiler = $this->_container->compiler;\r
                $html = file_get_contents($this->_container->compiler->assets . '/_index.html');\r
 \r
-\r
                $vars = ['description' => $this->description ? '<meta name="description" content="' . $this->description . '">' : '',\r
                        'keywords' => $this->keywords ? '<meta name="keywords" content="' . $this->keywords . '">' : '',\r
                        'titre' => $this->title,\r
@@ -176,8 +175,44 @@ class wsHTML5SeoPage
        public function getURL()\r
        {\r
                if (null === $this->url) {\r
-                       return $this->page . '-' . CubeIT_Text::str2URL($this->title);\r
+                       return $this->page . '-' . CubeIT_Text::str2URL($this->title) . '.html';\r
                }\r
                return $this->url;\r
        }\r
+\r
+       public function getHTMLRelativePath()\r
+       {\r
+               $url = $this->getURL();\r
+               if (null == $this->url) {\r
+                       $res = 'p/' . $url;\r
+               }\r
+\r
+               if ($this->_container->compiler->book->parametres->seoBaseURL == '') {\r
+                       $res = $url;\r
+               } else {\r
+                       $res = str_replace($this->_container->compiler->book->parametres->seoBaseURL, '', $url);\r
+               }\r
+\r
+               return ltrim($res, '/');\r
+       }\r
+\r
+       /**\r
+        * @param string $html\r
+        * @param CubeIT_Files_VirtualDirectory $vdir\r
+        * @param null|string $path\r
+        */\r
+       public function writePage($html, $vdir, $path = null)\r
+       {\r
+               if ($path == null) {\r
+                       $path = $this->getHTMLRelativePath();\r
+               }\r
+               $relativeLevel = count(explode('/', rtrim($path, "/"))) - 1;\r
+               $base = '';\r
+               if ($relativeLevel > 0) {\r
+                       $base = '<base href="' . str_repeat('../', $relativeLevel) . '" >';\r
+               }\r
+               $html = str_replace('<!-- $base -->', $base, $html);\r
+\r
+               $vdir->file_put_contents($path, $html);\r
+       }\r
 }
\ No newline at end of file