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)) {
$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 {
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'));
$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;