]> _ Git - cubeextranet.git/commitdiff
fix #3613 @4
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 24 Apr 2020 15:00:09 +0000 (15:00 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 24 Apr 2020 15:00:09 +0000 (15:00 +0000)
inc/ws/Util/html5/master/class.ws.html5.links.php

index 9cd8f67824e8fccd304b1590b6ce2fa9aab476ea..543defd3a88ed988fa0781f0b632e0e944422599 100644 (file)
@@ -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 '<iframe src="' . $this->to . '" width="100%" height="100%" frameborder="0" marginwidth="0" marginheight="0" scrolling="auto" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel=""></iframe>';
+        return '<iframe src="' . self::_handleFile($this) . '" width="100%" height="100%" frameborder="0" marginwidth="0" marginheight="0" scrolling="auto" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel=""></iframe>';
+    }
+
+    /**
+     * @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 = '<div class="iframeContainer" data-type="' . $this->iframeType . '">';
-        $markup .= '<iframe src="' . $this->to . '" width="100%" height="100%" frameborder="0" marginwidth="0" marginheight="0" scrolling="auto" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel=""></iframe>';
+        $markup .= '<iframe src="' . iframeLink::_handleFile($this) . '" width="100%" height="100%" frameborder="0" marginwidth="0" marginheight="0" scrolling="auto" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel=""></iframe>';
         $markup .= '</div>';
         return $res . ' data-iframe="' . rawurlencode($markup) . '" ';
     }