]> _ Git - cubeextranet.git/commitdiff
wait #4686 @1.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 29 Oct 2021 09:48:05 +0000 (09:48 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 29 Oct 2021 09:48:05 +0000 (09:48 +0000)
inc/ws/Util/html5/master/class.ws.html5.links.php

index 0a2ff95853faf50ef3db8de38d463eb8f231f896..1c1a351e07af0c0f22da3c8350400c455d863041 100644 (file)
@@ -91,7 +91,7 @@ class wsHTML5Link
                     break;
             }
             if (isset($url)) {
-                $fname = commonTools::_youtubedl($url);
+                $fname = commonTools::_youtubedl($url, true);
                 $file = '/data/extranet/www/cache/youtubedl/' . $fname;
             }
             if (isset($file) && file_exists($file)) {
@@ -364,7 +364,7 @@ class wsHTML5Link
 
         $ext = mb_strtolower(files::getExtension($init['alternative']));
 
-        if (in_array($ext, array('oam', 'zip', 'html')) || substr($init['alternative'], 0, 4) == 'http') {
+        if (in_array($ext, array('oam', 'zip', 'html', 'json')) || substr($init['alternative'], 0, 4) == 'http') {
             if ($init['inline'] === 'inline') {
                 return new htmlMultimediaLink($id, $init, $compiler);
             } else {
@@ -684,6 +684,24 @@ class wsHTML5Link
         return array_merge($res, $r);
     }
 
+    public function getConfigLottieJSON($d, $json)
+    {
+        $a = json_decode($json);
+        if (!file_exists($d)) {
+            mkdir($d, 0777, true);
+        }
+
+        copy('https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js', $d . '/lottie-player.js');
+        $htmlContent = '<html><head><script src="lottie-player.js"></script></head><body><lottie-player src="animation.json"  background="transparent"  speed="1"  style="width: '.$a->w.'px; height: '.$a->h.'px;" autoplay loop></lottie-player></body></html>';
+        file_put_contents($d . '/index.html', $htmlContent);
+        file_put_contents($d . '/animation.json', $json);
+
+        $res = array('width' => $a->w, 'height' => $a->h);
+        $r = array('type' => 'html', 'html' => 'index.html', 'inject' => array(), 'injectcss' => array(), 'injectjs' => array());
+
+        return array_merge($res, $r);
+    }
+
     public function getConfigOAM($d)
     {
         $x = simplexml_load_string(file_get_contents($d . '/config.xml'));
@@ -1906,10 +1924,16 @@ class htmlMultimediaLink extends wsHTML5Link
                 $dir = $fdir;
 
                 $d = array('fdir' => $fdir, 'dir' => $dir);
-                $file = $this->compiler->wdir . '/' . $this->alternative;
-                $this->compiler->vdir->copy($this->compiler->wdir . '/' . $this->alternative, $d['dir'] . '/' . $this->alternative);
                 $this->_config = $this->getConfigHTML($d['dir'], $this->alternative);
+                $this->compiler->vdir->copy($this->compiler->wdir . '/' . $this->alternative, $d['dir'] . '/' . $this->alternative);
                 $this->copyExternalFile($d['dir'] . '/' . $this->alternative);
+            } else if ($ext === 'json') {
+                $basename = CubeIT_Text::str2URL(str_replace('.json', '', $this->alternative));
+                $file = $this->compiler->wdir . '/' . $this->alternative;
+                $d = ['fdir' => 'data/links/' . $basename];
+                $dir = $this->wdir . '/' . $basename;
+                $this->_config = $this->getConfigLottieJSON($dir, file_get_contents($file));
+                $this->copyExternalDir($dir, $d['fdir']);
             }
             if (substr($this->alternative, 0, 4) == 'http') {
                 $this->_url = $this->_externalIframe = $this->alternative;