]> _ Git - cubeextranet.git/commitdiff
#2119
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 27 Jun 2018 14:17:59 +0000 (14:17 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 27 Jun 2018 14:17:59 +0000 (14:17 +0000)
inc/ws/Util/html5/diaporama/class.ws.html5.compiler.php
inc/ws/Util/html5/diaporama/class.ws.html5.links.php

index fc03e4bdc28a1082f1162d84416ea9cc35438105..4672bbbc5b625ec75daf7ac0570d5b9cf69d37c2 100644 (file)
@@ -26,7 +26,6 @@ class wsHTML5Compiler {
                'js/libs/gal/gal.js',
                'js/libs/gal/gal.filesystem.js',
                'js/libs/hammer.min.js',
-               'js/libs/fluidbook/forms/fluidbook.form.bulle.js',
                'js/libs/fluidbook/fluidbook.utils.js',
                'js/libs/fluidbook/fluidbook.links.js',
                'js/libs/fluidbook/fluidbook.support.js',
@@ -1082,6 +1081,9 @@ class wsHTML5Compiler {
                if ($this->book->parametres->highlightResults) {
                        $this->vdir->file_put_contents('data/search.highlight.js', 'var HIGHLIGHTS=' . json_encode($this->daoBook->makeHighlightIndex($this->book, $this->pages)) . ";\r");
                }
+               if ($this->book->parametres->searchWordSelectionAlgorithm == 'expression') {
+                       $this->vdir->file_put_contents('data/search.texts.js', 'var TEXTS=' . $textes . ";\r");
+               }
        }
 
        public function supportSVG() {
@@ -1134,7 +1136,25 @@ class wsHTML5Compiler {
                        $this->config->manifest = $this->writeManifest();
                }
 
+               if ($this->config->form == 'bulle') {
+                       $this->addJs('js/libs/fluidbook/forms/fluidbook.form.bulle.js');
+               } else if ($this->config->form == 'bourbon') {
+                       $this->addJs('js/libs/parsley.min.js');
+                       $this->addJs('js/libs/fluidbook/forms/fluidbook.form.bourbon.js');
+               }
+
                if ($this->config->basket) {
+                       $this->addJs('js/libs/fluidbook/fluidbook.cart.js');
+                       switch ($this->config->basketManager) {
+                               case 'Remarkable':
+                                       $this->addJs('js/libs/parsley.min.js');
+                                       $this->addJs('js/libs/fluidbook/cart/fluidbook.cart.remarkable.js');
+                                       break;
+                               default:
+                                       break;
+                       }
+
+
                        if (file_exists($this->config->basketReferences) || CubeIT_Util_Url::isDistant($this->config->basketReferences)) {
                                $referencesFile = $this->config->basketReferences;
                        } else {
@@ -1443,7 +1463,6 @@ class wsHTML5Compiler {
 
                //Icons
                $res = array_merge($res, $this->writeIcons());
-               $res[] = '#nav #locales{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->couleurI) . ';}';
 
                // Logo
                $logo = '#logo{';
@@ -1472,6 +1491,7 @@ class wsHTML5Compiler {
 
                // Links Styles
                $lessVariables['links-color'] = wsHTML5::colorToCSS($this->theme->parametres->linksColor);
+               $lessVariables['inlineslideshow-transition-time'] = (floatval($this->book->parametres->inlineSlideshowTransitionDuration) * 1000) . 'ms';
                $res = array_merge($res, $links);
 
                // Bookmarks
@@ -1696,6 +1716,19 @@ class wsHTML5Compiler {
                $this->vdir->copy($source, $dest);
        }
 
+       public function addVideoJs()
+       {
+               $locale = $this->book->lang;
+               $map = ['pt' => 'pt-PT', 'pt-br' => 'pt-BR', 'zh' => 'zh-CN', 'es-pr' => 'es'];
+               if (isset($map[$locale])) {
+                       $locale = $map[$locale];
+               }
+
+               $this->addJs('js/libs/videojs/video.withscalefix.js');
+               $this->addJs('js/libs/videojs/lang/' . $locale . '.js');
+               $this->addLess('videojs/videojs');
+       }
+
        public function copyLinkFile($source, $dest, $video = false) {
                if ($video && $this->book->parametres->mobileVideosPath != '') {
 
@@ -1769,6 +1802,16 @@ class wsHTML5Compiler {
                                $res['height'] = intval((string)$canvas->getAttribute('height'));
                        }
 
+                       $m = $xpath->query('//meta[@name="width"]');
+                       foreach ($m as $meta) {
+                               $res['width'] = intval((string)$meta->getAttribute('content'));
+                       }
+
+                       $m = $xpath->query('//meta[@name="height"]');
+                       foreach ($m as $meta) {
+                               $res['height'] = intval((string)$meta->getAttribute('content'));
+                       }
+
                        $r = array('html' => 'index.html', 'inject' => array(), 'injectcss' => array(), 'injectjs' => array());
                } else {
                        $r = array('html' => false, 'inject' => array(file_get_contents($d . '/init.js')), 'injectcss' => array('multimedia.css'), 'injectjs' => array('multimedia.js'));
index a43a6416ec9e69d1beb74a88cf95228b623d3e7a..687618b72d0087b9cdeb6a21fbafbd6c59233481 100644 (file)
@@ -92,13 +92,25 @@ class wsHTML5Link {
                        case 11:
                                return new actionLink($id, $init, $compiler);
                        case 12:
-                               return new basketLink($id, $init, $compiler);
+                               switch ($compiler->book->parametres->basketManager) {
+                                       case 'Remarkable':
+                                               return new remarkableCartLink($id, $init, $compiler);
+                                               break;
+                                       default :
+                                               return new cartLink($id, $init, $compiler);
+                                               break;
+                               }
                        case 13: // zoom area
                                return new zoomLink($id, $init, $compiler);
                        case 14:
                                return new colorLink($id, $init, $compiler);
                        case 15:
+
+                               if (stristr($init['to'], '.zip')) {
+                                       return new inlineSlideshowLink($id, $init, $compiler);
+                               } else {
                                return new imageLink($id, $init, $compiler);
+                               }
                        case 16:
                                return new fileLink($id, $init, $compiler);
                        case 17:
@@ -203,7 +215,7 @@ class wsHTML5Link {
        }
 
        public function getHTMLContainer() {
-               return '<div class="' . $this->getHTMLContainerClass() . '" data-id="' . $this->uid . '" id="l_' . $this->id . '">' . $this->getHTMLContent() . '</div>';
+               return '<div class="' . $this->getHTMLContainerClass() . '" data-id="' . $this->uid . '" id="l_' . $this->id . '"' . $this->getAdditionnalContent() . '>' . $this->getHTMLContent() . '</div>';
        }
 
        public function getHTMLContainerClass() {
@@ -214,11 +226,14 @@ class wsHTML5Link {
                return $res;
        }
 
-       public function getHTMLContent() {
+       public function getHTMLContent()
+       {
                return '';
        }
 
-       public function getAdditionnalContent() {
+       public function getAdditionnalContent()
+       {
+               return '';
 
        }
 
@@ -287,7 +302,7 @@ class wsHTML5Link {
        public static function getUniversalLocation($loc, $css = false) {
                $datas = parse_url($loc);
 
-               if (isset($datas['scheme']) && !is_null($datas['scheme'])) {
+               if (isset($datas['scheme']) && !is_null($datas['scheme']) || strpos($loc, '#') === 0) {
                        return $loc;
                } else {
                        if ($css) {
@@ -354,7 +369,7 @@ class htmlMultimediaImage extends wsHTML5Link {
        public $zindex = 2;
 
        public function getHTMLContainerClass() {
-               return parent::getHTMLContainerClass() . ' multimedia';
+               return parent::getHTMLContainerClass() . ' multimedia notinteractive';
        }
 
        public function getHTMLContent() {
@@ -517,9 +532,9 @@ class internalLink extends normalLink {
 class videoLink extends wsHTML5Link {
        public $zindex = 2;
 
-       public static function addVideoJS($compiler) {
-               $compiler->addJs('js/libs/videojs/video.withscalefix.js');
-               $compiler->addLess('videojs/videojs');
+       public static function addVideoJS($compiler)
+       {
+               $compiler->addVideoJs();
        }
 
        public function getClasses() {
@@ -780,11 +795,29 @@ class actionLink extends internalLink {
 
 }
 
-class basketLink extends contentLink {
+class cartLink extends normalLink
+{
 
-       public function getCSS() {
-               return 'background-color:#fff;';
+       public function getURL()
+       {
+               return '#';
+       }
+
+       public function getDefaultTooltip()
+       {
+               return 'add to cart';
+       }
+
+       public function getAdditionnalContent()
+       {
+               $res = parent::getAdditionnalContent();
+               $res .= 'data-cart-ref="' . $this->to . '" ';
+               return $res;
        }
+       }
+
+class remarkableCartLink extends cartLink
+{
 
 }
 
@@ -805,7 +838,29 @@ class imageLink extends contentLink {
 
 }
 
-class fileLink extends normalLink {
+class inlineSlideshowLink extends contentLink
+{
+       public function getHTMLContent()
+       {
+               $d = $this->unzipFile($this->to, false);
+               $this->compiler->vdir->copyDirectory($d['dir'], $d['fdir']);
+
+               $iterator = CubeIT_Files::getRecursiveDirectoryIterator($d['dir']);
+
+               $files = array();
+               foreach ($iterator as $f) {
+                       /* @var $f SplFileInfo */
+                       $files[] = $f->getFilename();
+               }
+               sort($files);
+               $f = htmlspecialchars(json_encode($files), ENT_QUOTES);
+
+               return '<div class="inlineslideshow" data-dir="' . str_replace('.', '_', $this->to) . '" data-images="' . $f . '"></div>';
+       }
+}
+
+class fileLink extends normalLink
+{
 
        public function getURL() {
                if ($this->compiler->book->parametres->linkFilePrefix && !CubeIT_Util_Url::isDistant($this->to)) {
@@ -851,7 +906,11 @@ class htmlMultimediaLink extends wsHTML5Link {
                        } elseif ($ext == 'zip') {
                                $d = $this->unzipFile($this->alternative, false);
                                $this->_config = $this->getConfigZIP($d['dir']);
+                               $html = file_get_contents($d['dir'] . '/index.html');
+                               $html = str_replace('var pRatio = window.devicePixelRatio || 1,', 'var pRatio = 0.5,', $html);
                                $this->copyExternalDir($d['dir'], $d['fdir']);
+                               $this->_config['lowDef'] = 'index_ld.html';
+                               $this->compiler->vdir->file_put_contents($d['fdir'] . '/' . $this->_config['lowDef'], $html);
                        } elseif ($ext == 'html') {
                                $fdir = 'data/links';
                                $dir = $fdir;
@@ -867,6 +926,13 @@ class htmlMultimediaLink extends wsHTML5Link {
                                $this->_config = array('html' => false, 'width' => $this->width, 'height' => $this->height);
                        }
 
+                       if ($this->_config['width'] == 0) {
+                               $this->_config['width'] = $this->width;
+                       }
+                       if ($this->_config['height'] == 0) {
+                               $this->_config['height'] = $this->height;
+                       }
+
                        $res = '';
                        if ($this->_config['html']) {
                                $this->_url = $d['fdir'] . '/' . $this->_config['html'];
@@ -877,7 +943,12 @@ class htmlMultimediaLink extends wsHTML5Link {
                                $iw = $this->_config['width'];
                                $ih = $this->_config['height'];
 
-                               $res = '<iframe data-width="' . $iw . '" data-height="' . $ih . '" width="' . $iw . '" height="' . $ih . '" src="' . $this->_url . '" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel=""></iframe>';
+                               $ld = '';
+                               if (isset($this->_config['lowDef'])) {
+                                       $ld = ' data-ld="' . str_replace('index.html', $this->_config['lowDef'], $this->_url) . '" ';
+                               }
+
+                               $res = '<iframe ' . $ld . ' data-width="' . $iw . '" data-height="' . $ih . '" width="' . $iw . '" height="' . $ih . '" src="' . $this->_url . '" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel=""></iframe>';
                        }
                        if ($this->_externalIframe !== false) {
                                $s = $this->in_popup ? 1 : $this->getCssScale();