]> _ Git - cubeextranet.git/commitdiff
wip #2643 @6
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 20 Mar 2019 15:38:23 +0000 (15:38 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 20 Mar 2019 15:38:23 +0000 (15:38 +0000)
inc/ws/Util/html5/master/class.ws.html5.compiler.php
inc/ws/Util/html5/master/class.ws.html5.links.php

index 63da3e71fc2ee684d06e02e838feca9e8beb703f..5cb547dc7fabd55612528c5abf37615ea80438f6 100644 (file)
@@ -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)) {
index 9441a4be663f85fc957adf1316bbb439aff3e6b4..6ca1f3f2275b50934142d79bf029842d39036d9c 100644 (file)
@@ -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
 {