]> _ Git - fluidbook_tools.git/commitdiff
wait #5769 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 2 Mar 2023 21:30:55 +0000 (22:30 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 2 Mar 2023 21:30:55 +0000 (22:30 +0100)
src/Links/HTMLMultimediaImage.php
src/Links/HTMLMultimediaLink.php
src/Links/HTMLMultimediaPopupImage.php
src/Links/Link.php

index 1cd866d6531b6bfd611e8a61c24a58c710b51ec4..4088a40402a97356d52940ad14bbb104d171cbdf 100644 (file)
@@ -15,8 +15,8 @@ class HTMLMultimediaImage extends Link
     {
         $w = $this->width;
         $h = $this->height;
-        $this->copyExternalFile($this->alternative);
-        $alt = '<img class="multimediaimage"  data-width="' . $w . '" data-height="' . $h . '" src="' . Link::getUniversalLocation($this->alternative) . '" width="' . $w . '" height="' . $h . '" />';
+        $this->copyExternalFile($this->to);
+        $alt = '<img class="multimediaimage"  data-width="' . $w . '" data-height="' . $h . '" src="' . Link::getUniversalLocation($this->to) . '" width="' . $w . '" height="' . $h . '" />';
         return $alt;
     }
 
index f15f9256eebc0664a6b9b185e140a64ee6027311..94d754748a986b5793037f7fc07913c2a2dcde8e 100644 (file)
@@ -19,14 +19,14 @@ class HTMLMultimediaLink extends Link
     public function getHTMLContent()
     {
         if ($this->_content == '') {
-            $ext = files::getExtension($this->alternative);
+            $ext = files::getExtension($this->to);
 
             if ($ext === 'oam') {
-                $d = $this->unzipFile($this->alternative, true);
+                $d = $this->unzipFile($this->to, true);
                 $this->_config = $this->getConfigOAM($d['dir']);
                 $this->copyExternalDir($d['dir'], $d['fdir']);
             } elseif ($ext === 'zip') {
-                $d = $this->unzipFile($this->alternative, false);
+                $d = $this->unzipFile($this->to, false);
                 $this->_config = $this->getConfigZIP($d['dir']);
                 $this->copyExternalDir($d['dir'], $d['fdir']);
                 if (file_exists($d['dir'] . '/index.html')) {
@@ -40,12 +40,12 @@ class HTMLMultimediaLink extends Link
                 $dir = $fdir;
 
                 $d = array('fdir' => $fdir, 'dir' => $dir);
-                $this->compiler->getVirtualDirectory()->copy( $this->compiler->working_path($this->alternative), $d['dir'] . '/' . $this->alternative);
-                $this->_config = $this->getConfigHTML($d['dir'], $this->alternative);
-                $this->copyExternalFile($d['dir'] . '/' . $this->alternative);
+                $this->compiler->getVirtualDirectory()->copy( $this->compiler->working_path($this->to), $d['dir'] . '/' . $this->to);
+                $this->_config = $this->getConfigHTML($d['dir'], $this->to);
+                $this->copyExternalFile($d['dir'] . '/' . $this->to);
             }
-            if (substr($this->alternative, 0, 4) == 'http') {
-                $this->_url = $this->_externalIframe = $this->alternative;
+            if (substr($this->to, 0, 4) == 'http') {
+                $this->_url = $this->_externalIframe = $this->to;
                 $this->_config = array('html' => false, 'width' => $this->width, 'height' => $this->height);
             }
 
@@ -87,10 +87,10 @@ class HTMLMultimediaLink extends Link
             // debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
             // $trace = ob_get_contents();
             // ob_end_clean();
-            // $this->compiler->log("##### Multimedia Link getHTMLContent ID: {$this->id} | {$this->alternative} ######\n\n!!!! BACKTRACE !!!!!\n$trace\n===============\n");
+            // $this->compiler->log("##### Multimedia Link getHTMLContent ID: {$this->id} | {$this->to} ######\n\n!!!! BACKTRACE !!!!!\n$trace\n===============\n");
 
             foreach ($this->_config['inject'] as $i) {
-                $infos = ['path' => 'data/links/' . str_replace('.', '_', $this->alternative) . '/'];
+                $infos = ['path' => 'data/links/' . str_replace('.', '_', $this->to) . '/'];
                 $i = str_replace('$id', '"#l_' . $this->id . '"', $i);
                 $i = str_replace('$path', '"' . $infos['path'] . '"', $i);
                 $i = str_replace('$init', Json::encode($infos), $i);
index bc547af54d11ae407cea2237bfbec442f8cac509..c6528c10eb77b64e19881157ce8e1956764f1b6c 100644 (file)
@@ -3,24 +3,26 @@
 namespace Fluidbook\Tools\Links;
 
 use Cubist\Util\Graphics\Image;
+use Cubist\Util\Graphics\Resizer;
 
-class HTMLMultimediaPopupImage extends NormalLink
-{
+class HTMLMultimediaPopupImage extends NormalLink {
     public $clickToClose = 0;
 
-    public function getURL()
-    {
-        $this->copyExternalFile($this->alternative);
+    public function getURL() {
+        $this->copyExternalFile($this->to);
         $read = ($this->read_mode) ? 'r_' : '';
-        return '#/multimedia/' . $read . md5($this->alternative . '/' . $this->extra . '/' . $this->id);
+        return '#/multimedia/' . $read . md5($this->to . '/' . $this->extra . '/' . $this->id);
     }
 
-    public function getAdditionnalContent()
-    {
+    public function getAdditionnalContent() {
         $res = parent::getAdditionnalContent();
-        $dim = Image::getimagesize($this->compiler->working_path($this->alternative));
+        $dim = Image::getimagesize($this->compiler->working_path($this->to));
+        if ($this->video_width || $this->video_height) {
+            $dim = Resizer::keepRatio($dim[0], $dim[1], $this->video_width, $this->video_height);
 
-        $markup = '<div class="multimediaContainer" data-click-to-close="' . $this->clickToClose . '"><img data-width="' . $dim[0] . '" data-height="' . $dim[1] . '" src="' . Link::getUniversalLocation($this->alternative) . '" width="' . $dim[0] . '" height="' . $dim[1] . '" class="multimedia" /></div>';
+        }
+
+        $markup = '<div class="multimediaContainer" data-click-to-close="' . $this->clickToClose . '"><img data-width="' . $dim[0] . '" data-height="' . $dim[1] . '" src="' . Link::getUniversalLocation($this->to) . '" width="' . $dim[0] . '" height="' . $dim[1] . '" class="multimedia" /></div>';
         $read = '';
         if ($this->read_mode) {
             $read = ' data-readmode="1"';
@@ -28,8 +30,7 @@ class HTMLMultimediaPopupImage extends NormalLink
         return $res . ' ' . $read . ' data-multimedia="' . rawurlencode($markup) . '" ';
     }
 
-    public function keep()
-    {
+    public function keep() {
         return true;
     }
 
index b7ea8274a37434dfd0d1fcd7bc72b21ff0ec173c..d4d53feafab3b1c79e510199974bac62b5f45d9f 100644 (file)
@@ -294,14 +294,14 @@ class Link {
     }
 
     public static function getMultimediaInstance($id, $init, &$compiler) {
-        if ($init['alternative'] == '') {
+        if ($init['to'] == '') {
             return null;
         }
         $init['inline'] = self::normalizeInlineIntegration($init['inline']);
 
-        $ext = mb_strtolower(Files::getExtension($init['alternative']));
+        $ext = mb_strtolower(Files::getExtension($init['to']));
 
-        if (in_array($ext, array('oam', 'zip', 'html')) || substr($init['alternative'], 0, 4) == 'http') {
+        if (in_array($ext, array('oam', 'zip', 'html')) || substr($init['to'], 0, 4) == 'http') {
             if ($init['inline'] === 'inline') {
                 return new HTMLMultimediaLink($id, $init, $compiler);
             } else {
@@ -318,7 +318,7 @@ class Link {
     }
 
     public static function isScorm($linkData) {
-        return (isset($linkData['scorm']) && $linkData['scorm']) || (self::_isScormLink($linkData['to']) || (isset($linkData['alternative']) && self::_isScormLink($linkData['alternative'])));
+        return (isset($linkData['scorm']) && $linkData['scorm']) || (self::_isScormLink($linkData['to']));
     }
 
     protected static function _isScormLink($url) {
@@ -354,12 +354,7 @@ class Link {
             }
             $this->$k = $v;
         }
-        if (!$this->video_width) {
-            $this->video_width = $this->width;
-        }
-        if (!$this->video_height) {
-            $this->video_height = $this->height;
-        }
+
         if ($this->target == '') {
             $this->target = '_blank';
         }