From: vincent@cubedesigners.com Date: Mon, 5 Jul 2021 09:39:50 +0000 (+0000) Subject: wip #4575 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=8d53ec848cb3b4f54748cd03709022299f52c527;p=cubeextranet.git wip #4575 @0.5 --- 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 f62b458b4..3e9bfa47f 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -1794,7 +1794,7 @@ height="0" width="0" style="display:none;visibility:hidden"> $this->config->pagesOfCustomLinks = $pagesOfCustomLinks; - $i = 0; + $i = 1; $pages = array(); $cpages = array(); $ctpages = array(); @@ -1826,12 +1826,14 @@ height="0" width="0" style="display:none;visibility:hidden"> } foreach ($linksToAdd as $lta) { + /** @var $lta wsLink */ + // Keep this line because some properties of the link (like blend mode) are parsed with this function $c = $lta->getHTMLContainer(); $css[] = $lta->getCSSContainer(); if (!isset($pages[$lta->page])) { - $pages[$lta->page] = ''; - $cpages[$lta->page] = ''; - $ctpages[$lta->page] = ''; + $pages[$lta->page] = ['normal' => []]; + $cpages[$lta->page] = ['normal' => []]; + $ctpages[$lta->page] = ['normal' => []]; } $d = $lta->getDepth(); @@ -1843,7 +1845,13 @@ height="0" width="0" style="display:none;visibility:hidden"> $v = 'pages'; } - $$v[$lta->page] .= $c; + $lta->setInitialOrder($i); + if (!isset($$v[$lta->page][$lta->blendmode])) { + $$v[$lta->page][$lta->blendmode] = []; + } + + array_push($$v[$lta->page][$lta->blendmode], $lta); + $i++; } // Make old "aftersearch" link compatible with new "extra" menu option by extracting link URL if ($link->page == 'aftersearch') { @@ -1862,9 +1870,8 @@ height="0" width="0" style="display:none;visibility:hidden"> $allLinksData[$linkData['uid']] = $linkData; if ($link->keep()) { - $this->hiddenContents[] = $c; + $this->hiddenContents[] = $link->getHTMLContainer(); } - $i++; } $allpages = range(0, $this->book->parametres->pages + 1); @@ -1878,22 +1885,9 @@ height="0" width="0" style="display:none;visibility:hidden"> } foreach ($allpages as $i) { - - $c = ''; - $cc = ''; - $ct = ''; - if (isset($pages[$i])) { - $c = $pages[$i]; - } - if (isset($cpages[$i])) { - $cc = $cpages[$i]; - } - if (isset($ctpages[$i])) { - $ct = $ctpages[$i]; - } - $this->config->links[$i] = $c; - $this->config->clinks[$i] = $cc; - $this->config->ctlinks[$i] = $ct; + $this->config->links[$i] = $this->_htmlLinkList($pages[$i] ?? []); + $this->config->clinks[$i] = $this->_htmlLinkList($cpages[$i] ?? []); + $this->config->ctlinks[$i] = $this->_htmlLinkList($ctpages[$i] ?? []); } if ($this->writeLinksData) { @@ -1904,6 +1898,33 @@ height="0" width="0" style="display:none;visibility:hidden"> return $css; } + protected function _htmlLinkList($list) + { + if (!count($list)) { + return []; + } + $res = []; + foreach ($list as $blendmode => $l) { + usort($l, [$this, '_sortLinksByDepth']); + $res[$blendmode] = []; + foreach ($l as $item) { + $res[$blendmode][] = $item->getHTMLContainer(); + } + + } + return $res; + + } + + protected function _sortLinksByDepth($a, $b) + { + $c = $a->getDepth() - $b->getDepth(); + if ($c === 0) { + return $a->getInitialOrder() - $b->getInitialOrder(); + } + return $c; + } + public function addSlideshowLibrary($inline = true) { $l = ($inline ? $this->config->inlineSlideshowLibrary : $this->config->popupSlideshowLibrary); @@ -2670,9 +2691,35 @@ height="0" width="0" style="display:none;visibility:hidden"> $dest = $dest; } + if (stripos($source, '.svg') !== false) { + $source = $this->_fixSVG($source); + } + $this->vdir->copy($source, $dest); } + protected function _fixSVG($source) + { + $fixed = str_replace('.svg', '.f.svg', $source); + if (file_exists($fixed) && filemtime($fixed) >= filemtime($source)) { + return $fixed; + } + $svg = simplexml_load_string(file_get_contents($source)); + $attr = $svg->attributes(); + if (isset($attr['width'], $attr['height'])) { + copy($source, $fixed); + return $fixed; + } + + $dim = CubeIT_Image::getimagesize($source); + $svg->addAttribute('preserveAspectRatio', 'none'); + $svg->addAttribute('width', $dim[0]); + $svg->addAttribute('height', $dim[1]); + file_put_contents($fixed, $svg->asXML()); + + return $fixed; + } + public function addVideoJs() { $locale = $this->book->lang; 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 86f468457..ff2cb86e1 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -29,6 +29,7 @@ class wsHTML5Link public $read_mode; public $group; public $infobulle; + public $blendmode = "normal"; public $extra; public $id; public $rot; @@ -462,7 +463,8 @@ class wsHTML5Link public function getHTMLContainer() { - return '
getAdditionnalContent() . '>' . $this->getHTMLContent() . '
'; + $addContent=$this->getAdditionnalContent(); + return '
' . $this->getHTMLContent() . '
'; } public function getHTMLContainerClass() @@ -940,6 +942,10 @@ class contentLink extends wsHTML5Link $res = parent::getAdditionnalContent(); $animations = self::parseAnimations($this->image_rollover); foreach ($animations as $animation) { + if (isset($animation['blendmode'])) { + $this->blendmode = $animation['blendmode']; + unset($animation['blendmode']); + } if (isset($animation['zindex'])) { $this->animZindex = $animation['zindex']; } @@ -948,10 +954,24 @@ class contentLink extends wsHTML5Link if ($this->_isHiddenFirst($animations)) { $res .= ' data-animation-hide '; } + if ($this->_isFinallyHidden($animations)) { + $res .= ' data-animation-hide-on-leave '; + } return $res; } + protected function _isFinallyHidden($animations) + { + $hiddenAnimations = ['fadeout', 'unmask']; + foreach ($animations as $animation) { + if (in_array($animation['type'], $hiddenAnimations)) { + return true; + } + } + return false; + } + protected function _isHiddenFirst($animations) { $hiddenAnimations = ['reveal', 'fadein', 'translatefrom']; @@ -1527,7 +1547,7 @@ class layerLink extends imageLink if (!$this->rightClone) { zoomLink::generateImage($attributes, $this->compiler, 'layerlink', 'layer'); } - return 'background-image:url(' . $this->getImageUrl() . ');background-size:100% 100%;background-repeat:no-repeat;'; + return 'background-image:url(' . $this->getImageUrl() . ');background-size:' . $this->getBackgroundSize() . ';background-position:' . $this->getBackgroundPosition() . ';background-repeat:no-repeat;'; } public function getImageUrl() @@ -1555,7 +1575,9 @@ class colorLink extends contentLink public function getCSS() { - return 'background-color:' . wsHTML5::colorToCSS($this->to, 1) . ';'; + $res = parent::getCSS(); + $res .= 'background-color:' . wsHTML5::colorToCSS($this->to, 1) . ';'; + return $res; } public function getAdditionnalContent() @@ -1576,7 +1598,9 @@ class textLink extends contentLink } $fz = $this->height * $this->getCssScale(); $fz = round($fz / $font['capHeight'], 2); - return 'line-height:' . $font['capHeight'] . ';font-size:' . $fz . 'px;font-family:' . $font['family'] . ';color:' . wsHTML5::colorToCSS($this->extra, 1) . ';'; + $res = parent::getCSS(); + $res .= 'line-height:' . $font['capHeight'] . ';font-size:' . $fz . 'px;font-family:' . $font['family'] . ';color:' . wsHTML5::colorToCSS($this->extra, 1) . ';'; + return $res; } public function getHTMLContainerClass() @@ -1608,8 +1632,34 @@ class imageLink extends contentLink public function getCSS() { + $res = parent::getCSS(); $this->copyExternalFile($this->to); - return 'background-image:url(' . $this->getImageUrl() . ');background-size:100% 100%;background-repeat:no-repeat;'; + $res .= 'background-image:url(' . $this->getImageUrl() . ');background-size:' . $this->getBackgroundSize() . ';background-position:' . $this->getBackgroundPosition() . ';background-repeat:no-repeat;'; + return $res; + } + + public function getBackgroundPosition() + { + $animations = self::parseAnimations($this->image_rollover); + foreach ($animations as $animation) { + if (($animation['type'] === 'zoomout' || $animation['type'] === 'zoomin') && isset($animation['transformorigin'])) { + return $animation['transformorigin']; + } + } + return '50% 50%'; + } + + public function getBackgroundSize() + { + + $size = '100%'; + $animations = self::parseAnimations($this->image_rollover); + foreach ($animations as $animation) { + if ($animation['type'] === 'zoomout') { + $size = round($animation['scale'] * 100) . '%'; + } + } + return $size . ' ' . $size; } public function getAdditionnalContent() @@ -1749,13 +1799,13 @@ class htmlMultimediaLink extends wsHTML5Link public function getHTMLContent() { if ($this->_content == '') { - $type = $ext = files::getExtension($this->alternative); + $ext = files::getExtension($this->alternative); - if ($ext == 'oam') { + if ($ext === 'oam') { $d = $this->unzipFile($this->alternative, true); $this->_config = $this->getConfigOAM($d['dir']); $this->copyExternalDir($d['dir'], $d['fdir']); - } elseif ($ext == 'zip') { + } elseif ($ext === 'zip') { $d = $this->unzipFile($this->alternative, false); $this->_config = $this->getConfigZIP($d['dir']); $this->copyExternalDir($d['dir'], $d['fdir']); @@ -1771,10 +1821,6 @@ class htmlMultimediaLink extends wsHTML5Link $d = array('fdir' => $fdir, 'dir' => $dir); $file = $this->compiler->wdir . '/' . $this->alternative; - $content = file_get_contents($file); -// if (false && strpos($content, '
')) { -// return $this->getLottieContent($content, $this->width, $this->height); -// } $this->compiler->vdir->copy($this->compiler->wdir . '/' . $this->alternative, $d['dir'] . '/' . $this->alternative); $this->_config = $this->getConfigHTML($d['dir'], $this->alternative); $this->copyExternalFile($d['dir'] . '/' . $this->alternative); @@ -1893,6 +1939,8 @@ class htmlMultimediaLink extends wsHTML5Link $this->left += $this->compiler->width; } + $this->getHTMLContent(); + $css = '#l_' . $this->id . '{'; $css .= 'left:' . $this->left * $this->getCssScale() . 'px;top:' . $this->top * $this->getCssScale() . 'px;'; $css .= 'width:' . $this->_config['width'] . 'px;height:' . $this->_config['height'] . 'px;'; diff --git a/inc/ws/Util/html5/twofaces/class.ws.html5.compiler.php b/inc/ws/Util/html5/twofaces/class.ws.html5.compiler.php index 393cfe10b..0f87e2866 100644 --- a/inc/ws/Util/html5/twofaces/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/twofaces/class.ws.html5.compiler.php @@ -329,6 +329,10 @@ class wsHTML5Compiler $this->initMobileFirst(); } + + if ((int)$this->theme->parametres->iconSet < 15) { + $this->theme->parametres->iconSet = 15; + } $this->svgfiles = array($this->assets . '/images/symbols/interface.svg', WS_ICONS . '/' . $this->theme->parametres->iconSet . '/interface.svg'); @@ -1310,10 +1314,6 @@ height="0" width="0" style="display:none;visibility:hidden"> } } - if ($this->theme->parametres->iconSet < 15) { - $this->theme->parametres->iconSet = 15; - } - $svg = ''; foreach ($this->svgfiles as $svgfile) {