From eddf6ed0cb521e2d83bad4697065bb2ae72f323a Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 24 Apr 2020 15:00:09 +0000 Subject: [PATCH] fix #3613 @4 --- .../html5/master/class.ws.html5.links.php | 119 +++++++++++------- 1 file changed, 77 insertions(+), 42 deletions(-) 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 9cd8f6782..543defd3a 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -414,7 +414,7 @@ class wsHTML5Link { $datas = parse_url($loc); - if (isset($datas['scheme']) && !is_null($datas['scheme']) || strpos($loc, '#') === 0) { + if ((isset($datas['scheme']) && !is_null($datas['scheme'])) || strpos($loc, '#') === 0) { return $loc; } else { if ($css) { @@ -425,6 +425,45 @@ class wsHTML5Link } } + public function getConfigZIP($d) + { + return $this->compiler->getConfigZIP($d); + } + + public function getConfigHTML($d, $html) + { + $res = array('width' => $this->video_width, 'height' => $this->video_height); + $r = array('html' => $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')); + $config = (string)$x->oamfile['src']; + $config = str_replace('/Assets', '', $d . '/' . $config); + $x = simplexml_load_string(file_get_contents($config), 'SimpleXMLElement', LIBXML_NOCDATA); + $c = CubeIT_Util_Xml::toObject($x); + + $props = array('default-width' => 'width', 'default-height' => 'height', 'html-page' => 'html'); + + + $res = array('inject' => array(), 'injectcss' => array(), 'injectjs' => array(), 'content' => trim($c->content), 'name' => $c->_name, 'assets' => array()); + foreach ($c->properties->property as $p) { + if (isset($props[$p->_name])) { + $res[$props[$p->_name]] = $p->_defaultValue; + } + } + foreach ($c->require as $r) { + if ($r->_type == 'folder') { + continue; + } + $res['assets'][] = $r->_src; + } + return $res; + } + } class normalLink extends wsHTML5Link @@ -465,6 +504,7 @@ class normalLink extends wsHTML5Link return '_self'; } + } class showLinkLink extends normalLink @@ -1392,44 +1432,6 @@ class htmlMultimediaLink extends wsHTML5Link return $res; } - public function getConfigZIP($d) - { - return $this->compiler->getConfigZIP($d); - } - - public function getConfigHTML($d, $html) - { - $res = array('width' => $this->video_width, 'height' => $this->video_height); - $r = array('html' => $html, 'inject' => array(), 'injectcss' => array(), 'injectjs' => array()); - - return array_merge($res, $r); - } - - public function getConfigOAM($d) - { - $x = simplexml_load_file($d . '/config.xml'); - $config = (string)$x->oamfile['src']; - $config = str_replace('/Assets', '', $d . '/' . $config); - $x = simplexml_load_file($config, 'SimpleXMLElement', LIBXML_NOCDATA); - $c = CubeIT_Util_Xml::toObject($x); - - $props = array('default-width' => 'width', 'default-height' => 'height', 'html-page' => 'html'); - - - $res = array('inject' => array(), 'injectcss' => array(), 'injectjs' => array(), 'content' => trim($c->content), 'name' => $c->_name, 'assets' => array()); - foreach ($c->properties->property as $p) { - if (isset($props[$p->_name])) { - $res[$props[$p->_name]] = $p->_defaultValue; - } - } - foreach ($c->require as $r) { - if ($r->_type == 'folder') { - continue; - } - $res['assets'][] = $r->_src; - } - return $res; - } } @@ -1998,7 +2000,7 @@ class slideshowLink extends normalLink $thumbnails = true; if (file_exists($XML_path)) { - $slideshow_XML = simplexml_load_file($XML_path); + $slideshow_XML = simplexml_load_string(file_get_contents($XML_path)); $slideshowData = CubeIT_Util_Xml::toObject($slideshow_XML); foreach ($slideshowData->image as $img) { $full_path = $this->path_absolute . '/' . $img->_name; @@ -2053,6 +2055,8 @@ class slideshowLink extends normalLink class iframeLink extends wsHTML5Link { + protected $_defaultTooltip; + function getHTMLContainerClass() { return parent::getHTMLContainerClass() . ' iframe'; @@ -2060,7 +2064,38 @@ class iframeLink extends wsHTML5Link function getHTMLContent() { - return ''; + return ''; + } + + /** + * @param $link wsHTML5Link + */ + public static function _handleFile($link) + { + if (!CubeIT_Util_Url::isDistant($link->to)) { + $e = explode('.', $link->to); + $ext = array_pop($e); + if ($ext === 'oam' || $ext === 'zip') { + if ($ext === 'oam') { + $d = $link->unzipFile($link->to, true); + $config = $link->getConfigOAM($d['dir']); + $link->copyExternalDir($d['dir'], $d['fdir']); + } else if ($ext === 'zip') { + $d = $link->unzipFile($link->to, false); + $config = $link->getConfigZip($d['dir']); + $link->copyExternalDir($d['dir'], $d['fdir']); + } + if ($config['html']) { + return $d['fdir'] . '/' . $config['html']; + } + } else { + $link->_defaultTooltip = 'click to open the file'; + $link->copyExternalFile($link->to); + return wsHTML5Link::getUniversalLocation($link->to); + } + } + + return $link->to; } } @@ -2080,7 +2115,7 @@ class iframePopupLink extends normalLink { $res = parent::getAdditionnalContent(); $markup = '
'; - $markup .= ''; + $markup .= ''; $markup .= '
'; return $res . ' data-iframe="' . rawurlencode($markup) . '" '; } -- 2.39.5