From 7e209710796d7085dbee67e0c32be4a602a6a90b Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 20 Mar 2019 15:38:23 +0000 Subject: [PATCH] wip #2643 @6 --- .../html5/master/class.ws.html5.compiler.php | 31 ++++++++++++++++++- .../html5/master/class.ws.html5.links.php | 25 +++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) 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 63da3e71f..5cb547dc7 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -188,6 +188,7 @@ class wsHTML5Compiler public $securityPolicyWhitelist = ['*.google-analytics.com', '*.youtube.com', '*.ytimg.com', '*.googletagmanager.com']; public $writeLinksData = false; public $content_lock = []; + public $cssfont = []; protected $_indexVars = null; public $_signature; @@ -1191,7 +1192,7 @@ class wsHTML5Compiler $hiddenLinks = []; foreach ($links as $linkData) { - if (isset($linkData['image']) && $linkData['image'] && $linkData['type'] != 28) { + if (isset($linkData['image']) && $linkData['image'] && $linkData['type'] != 28 && $linkData['type'] != 35) { $dupData = $linkData; $dupData['image'] = ''; $dupData['to'] = $linkData['image']; @@ -1897,6 +1898,11 @@ class wsHTML5Compiler $lessVariables['tooltip-background'] = wsHTML5::colorToCSS($this->theme->parametres->tooltipBackColor); $lessVariables['tooltip-color'] = wsHTML5::colorToCSS($this->theme->parametres->tooltipTextColor); + #fonts + foreach ($this->cssfont as $item) { + $res[] = '@font-face{font-family: "' . $item . '";src:url("data/fonts/' . $item . '.woff") format("woff");}'; + } + # ZoomPopup close button background $res[] = '.zoomPopupClose {background-color:' . wsHTML5::colorToCSS($this->theme->parametres->couleurB) . ';}'; @@ -2074,6 +2080,29 @@ class wsHTML5Compiler $this->addLess('videojs/videojs'); } + public function addFont($fontFile) + { + $f = $this->wdir . '/' . $fontFile; + $e = explode('.', $f); + $ext = array_pop($f); + $hash = 'fb_' . substr(md5($fontFile), 0, 10); + if (array_search($hash, $this->cssfont) !== false) { + return; + } + $final = $hash . '.woff'; + if (!file_exists($final) || filemtime($final) < filemtime($f)) { + $dest = $this->wdir . '/' . $final; + if ($ext == 'otf' || $ext == 'woff') { + `sfnt2woff $f $dest`; + } else if ($ext == 'woff') { + copy($f, $dest); + } + } + $this->vdir->copy($dest, 'data/fonts/' . $hash . '.woff'); + $this->cssfont[] = $hash; + return $hash; + } + public function addJsLib($name, $files) { if (!is_array($files)) { 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 9441a4be6..6ca1f3f22 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -180,6 +180,9 @@ class wsHTML5Link case 34: $compiler->addContentLock($init['page'], $init['to']); break; + case 35: + return new textLink($id, $init, $compiler); + break; default: return null; } @@ -1086,6 +1089,28 @@ class colorLink extends contentLink } } +class textLink extends contentLink +{ + public function getCSS() + { + + $font = $this->compiler->addFont($this->image); + return 'font-family:' . $font . ';color:' . wsHTML5::colorToCSS($this->extra, 1) . ';'; + + } + + public function getAdditionnalContent() + { + $res = parent::getAdditionnalContent(); + return $res; + } + + public function getHTMLContent() + { + return $this->to; + } +} + class imageLink extends contentLink { -- 2.39.5