From: Vincent Vanwaelscappel Date: Thu, 2 Mar 2023 21:30:55 +0000 (+0100) Subject: wait #5769 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=a3d71fee378d774d0f5148553c7911d87f3a7ce7;p=fluidbook_tools.git wait #5769 @0.5 --- diff --git a/src/Links/HTMLMultimediaImage.php b/src/Links/HTMLMultimediaImage.php index 1cd866d..4088a40 100644 --- a/src/Links/HTMLMultimediaImage.php +++ b/src/Links/HTMLMultimediaImage.php @@ -15,8 +15,8 @@ class HTMLMultimediaImage extends Link { $w = $this->width; $h = $this->height; - $this->copyExternalFile($this->alternative); - $alt = ''; + $this->copyExternalFile($this->to); + $alt = ''; return $alt; } diff --git a/src/Links/HTMLMultimediaLink.php b/src/Links/HTMLMultimediaLink.php index f15f925..94d7547 100644 --- a/src/Links/HTMLMultimediaLink.php +++ b/src/Links/HTMLMultimediaLink.php @@ -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); diff --git a/src/Links/HTMLMultimediaPopupImage.php b/src/Links/HTMLMultimediaPopupImage.php index bc547af..c6528c1 100644 --- a/src/Links/HTMLMultimediaPopupImage.php +++ b/src/Links/HTMLMultimediaPopupImage.php @@ -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 = '
'; + } + + $markup = '
'; $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; } diff --git a/src/Links/Link.php b/src/Links/Link.php index b7ea827..d4d53fe 100644 --- a/src/Links/Link.php +++ b/src/Links/Link.php @@ -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'; }