From: Vincent Vanwaelscappel Date: Wed, 22 Sep 2021 07:37:11 +0000 (+0200) Subject: wip #4697 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ee1fed670a70643892452b28bc613dfe7fe305de;p=fluidbook_tools.git wip #4697 @0.25 --- diff --git a/composer.lock b/composer.lock index b4604f2..be869e6 100644 --- a/composer.lock +++ b/composer.lock @@ -194,13 +194,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_util.git", - "reference": "ca9f1c2f7c8e729a1b6ff64ece1e1c1ab1ef4228" + "reference": "3d0d8337bd9e4b3ccf3d99ab7070ede27b1475bb" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-e2358f.tar", - "reference": "ca9f1c2f7c8e729a1b6ff64ece1e1c1ab1ef4228", - "shasum": "c0c32959b037843d1d053b60223a3e13e0693278" + "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-b28a8b.tar", + "reference": "3d0d8337bd9e4b3ccf3d99ab7070ede27b1475bb", + "shasum": "b60f0a943faf5ff520e7bab322d71b124705e744" }, "require": { "cubist/net": "dev-master", @@ -230,7 +230,7 @@ } ], "description": "Utilities class", - "time": "2021-09-15T15:24:17+00:00" + "time": "2021-09-22T07:22:01+00:00" }, { "name": "dflydev/dot-access-data", @@ -671,12 +671,12 @@ "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "f267d7cb9b159805d3e6ca805210d85f40c27209" + "reference": "3d1ead403e05ee0b9aa93a6ff720704970aec9c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/f267d7cb9b159805d3e6ca805210d85f40c27209", - "reference": "f267d7cb9b159805d3e6ca805210d85f40c27209", + "url": "https://api.github.com/repos/laravel/framework/zipball/3d1ead403e05ee0b9aa93a6ff720704970aec9c8", + "reference": "3d1ead403e05ee0b9aa93a6ff720704970aec9c8", "shasum": "" }, "require": { @@ -835,7 +835,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-09-21T13:41:09+00:00" + "time": "2021-09-21T18:36:59+00:00" }, { "name": "laravel/serializable-closure", @@ -1571,12 +1571,12 @@ "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "d0d9bff8b7a496961c28877346be2e348fe5e6d6" + "reference": "25d75271d2d88f211d4684638cbc938a75868b12" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/d0d9bff8b7a496961c28877346be2e348fe5e6d6", - "reference": "d0d9bff8b7a496961c28877346be2e348fe5e6d6", + "url": "https://api.github.com/repos/nette/utils/zipball/25d75271d2d88f211d4684638cbc938a75868b12", + "reference": "25d75271d2d88f211d4684638cbc938a75868b12", "shasum": "" }, "require": { @@ -1649,7 +1649,7 @@ "issues": "https://github.com/nette/utils/issues", "source": "https://github.com/nette/utils/tree/master" }, - "time": "2021-09-20T10:52:29+00:00" + "time": "2021-09-22T00:14:13+00:00" }, { "name": "opis/closure", diff --git a/src/Links/ColorLink.php b/src/Links/ColorLink.php index c5365d2..5f35e5f 100644 --- a/src/Links/ColorLink.php +++ b/src/Links/ColorLink.php @@ -2,6 +2,8 @@ namespace Fluidbook\Tools\Links; +use Cubist\Util\Graphics\Color; + class ColorLink extends ContentLink { protected $role = ''; @@ -9,14 +11,14 @@ class ColorLink extends ContentLink public function getCSS() { $res = parent::getCSS(); - $res .= 'background-color:' . wsHTML5::colorToCSS($this->to, 1) . ';'; + $res .= 'background-color:' . Color::colorToCSS($this->to, 1) . ';'; return $res; } public function getAdditionnalContent() { $res = parent::getAdditionnalContent(); - $res .= ' data-color="' . wsHTML5::colorToCSS($this->to, 1) . '"'; + $res .= ' data-color="' . Color::colorToCSS($this->to, 1) . '"'; return $res; } } diff --git a/src/Links/FileLink.php b/src/Links/FileLink.php index 91bf92c..6c6a626 100644 --- a/src/Links/FileLink.php +++ b/src/Links/FileLink.php @@ -2,6 +2,8 @@ namespace Fluidbook\Tools\Links; +use Cubist\Util\Url; + class FileLink extends NormalLink { protected $role = 'link'; @@ -10,7 +12,7 @@ class FileLink extends NormalLink { $this->copyExternalFile($this->to); - if ($this->compiler->book->parametres->linkFilePrefix && !CubeIT_Util_Url::isDistant($this->to)) { + if ($this->compiler->book->parametres->linkFilePrefix && !Url::isDistant($this->to)) { return $this->compiler->book->parametres->linkFilePrefix . $this->to; } diff --git a/src/Links/HTMLMultimediaLink.php b/src/Links/HTMLMultimediaLink.php index 2358389..c23d8f6 100644 --- a/src/Links/HTMLMultimediaLink.php +++ b/src/Links/HTMLMultimediaLink.php @@ -2,6 +2,8 @@ namespace Fluidbook\Tools\Links; +use Cubist\Util\Files\Files; + class HTMLMultimediaLink extends Link { @@ -126,10 +128,10 @@ class HTMLMultimediaLink extends Link protected function _correctFiles($dir) { - $files = CubeIT_Files::getRecursiveDirectoryIterator($dir); + $files = Files::getRecursiveDirectoryIterator($dir); foreach ($files as $f) { /* @var $f SplFileInfo */ - if ($f->getExtension() == 'js') { + if ($f->getExtension() === 'js') { $this->_correctFile($f); } } diff --git a/src/Links/IFrameLink.php b/src/Links/IFrameLink.php index 36c07e8..64e1ca0 100644 --- a/src/Links/IFrameLink.php +++ b/src/Links/IFrameLink.php @@ -2,6 +2,8 @@ namespace Fluidbook\Tools\Links; +use Cubist\Util\Url; + class IFrameLink extends Link { protected $_defaultTooltip; @@ -24,7 +26,7 @@ class IFrameLink extends Link public static function _handleFile($link) { $to = preg_replace('/^data\/links\//', '', $link->to); - if (!CubeIT_Util_Url::isDistant($to)) { + if (!Url::isDistant($to)) { $e = explode('.', $to); $ext = array_pop($e); if ($ext === 'oam' || $ext === 'zip') { diff --git a/src/Links/InlineSlideshowLink.php b/src/Links/InlineSlideshowLink.php index 442e138..45781af 100644 --- a/src/Links/InlineSlideshowLink.php +++ b/src/Links/InlineSlideshowLink.php @@ -2,7 +2,7 @@ namespace Fluidbook\Tools\Links; -class inlineSlideshowLink extends slideshowLink +class InlineSlideshowLink extends SlideshowLink { public function getDepth() { diff --git a/src/Links/TextLink.php b/src/Links/TextLink.php index 8b82c41..9b1d2a1 100644 --- a/src/Links/TextLink.php +++ b/src/Links/TextLink.php @@ -2,6 +2,8 @@ namespace Fluidbook\Tools\Links; +use Cubist\Util\Graphics\Color; + class TextLink extends ContentLink { public function getCSS() @@ -13,7 +15,7 @@ class TextLink extends ContentLink $fz = $this->height * $this->getCssScale(); $fz = round($fz / $font['capHeight'], 2); $res = parent::getCSS(); - $res .= 'line-height:' . $font['capHeight'] . ';font-size:' . $fz . 'px;font-family:' . $font['family'] . ';color:' . wsHTML5::colorToCSS($this->extra, 1) . ';'; + $res .= 'line-height:' . $font['capHeight'] . ';font-size:' . $fz . 'px;font-family:' . $font['family'] . ';color:' . Color::colorToCSS($this->extra, 1) . ';'; return $res; } @@ -22,14 +24,6 @@ class TextLink extends ContentLink return parent::getHTMLContainerClass() . ' textLink'; } - - public function getAdditionnalContent() - { - $res = parent::getAdditionnalContent(); - - return $res; - } - public function getHTMLContent() { return $this->to; diff --git a/src/Links/VideoLink.php b/src/Links/VideoLink.php index 6a31522..1cd64f2 100644 --- a/src/Links/VideoLink.php +++ b/src/Links/VideoLink.php @@ -2,6 +2,8 @@ namespace Fluidbook\Tools\Links; +use Cubist\Util\Url; + class VideoLink extends Link { public $defaultZIndex = 50; @@ -27,7 +29,7 @@ class VideoLink extends Link public function getHTMLContent() { - if (!CubeIT_Util_Url::isDistant($this->to)) { + if (!Url::isDistant($this->to)) { $this->copyExternalFile($this->to, true); } @@ -61,7 +63,7 @@ class VideoLink extends Link { $attr['name'] = videoPopupLink::getBasename($data->to); - if (CubeIT_Util_Url::isDistant($data->to)) { + if (Url::isDistant($data->to)) { $attr['url'] = $data->to; } $attr['id'] = 'video_' . $data->id; @@ -76,7 +78,7 @@ class VideoLink extends Link if (!is_null($w) && !is_null($h)) { $attr['width'] = $w; $attr['height'] = $h; - } else if (!is_null($compiler) && CubeIT_Util_Url::isLocal($data->to)) { + } else if (!is_null($compiler) && Url::isLocal($data->to)) { // Get video dimensions from thumbnail if possible (locally uploaded files) $path = $compiler->wdir . '/' . $data->to; $e = explode(',', `ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 $path`); diff --git a/src/Links/VideoPopupLink.php b/src/Links/VideoPopupLink.php index 6232b72..43a610a 100644 --- a/src/Links/VideoPopupLink.php +++ b/src/Links/VideoPopupLink.php @@ -2,13 +2,15 @@ namespace Fluidbook\Tools\Links; +use Cubist\Util\Url; + class VideoPopupLink extends NormalLink { public static function getBasename($f) { $prefix = ''; - if (CubeIT_Util_Url::isDistant($f)) { + if (Url::isDistant($f)) { $prefix = mb_substr(sha1($f), 0, 10) . '-'; $e = explode('/', $f); $f = array_pop($e); @@ -20,7 +22,7 @@ class VideoPopupLink extends NormalLink public function getURL() { - if (!CubeIT_Util_Url::isDistant($this->to)) { + if (!Url::isDistant($this->to)) { $this->copyExternalFile($this->to, true); } return '#/video/' . self::getBasename($this->to); @@ -31,7 +33,7 @@ class VideoPopupLink extends NormalLink $this->video_auto_start = true; // Videos should always autoplay $this->video_sound_on = true; $this->video_controls = true; - return ' data-video="' . rawurlencode(videoLink::makeVideoTag($this, null, null, $this->compiler)) . '" '; + return ' data-video="' . rawurlencode(VideoLink::makeVideoTag($this, null, null, $this->compiler)) . '" '; } public function keep() diff --git a/src/Links/WebLink.php b/src/Links/WebLink.php index 9f74e55..44ad931 100644 --- a/src/Links/WebLink.php +++ b/src/Links/WebLink.php @@ -9,13 +9,12 @@ class WebLink extends NormalLink public function getURL() { - $res = str_replace('"', '\'', Link::getUniversalLocation($this->to)); - return $res; + return str_replace('"', '\'', Link::getUniversalLocation($this->to)); } public function getTarget() { - if (strpos($this->getURL(), 'javascript:') === 0) { + if (str_starts_with($this->getURL(), 'javascript:')) { return '_self'; } return $this->target; diff --git a/src/Links/WebVideoLink.php b/src/Links/WebVideoLink.php index c7199da..d93dec6 100644 --- a/src/Links/WebVideoLink.php +++ b/src/Links/WebVideoLink.php @@ -17,6 +17,9 @@ class WebVideoLink extends videoLink return $attributes; } + /** + * @throws \JsonException + */ public static function getVideoSetup($data, $compiler) { static::addVideoJS($compiler); // Ensure videoJS core is included first @@ -67,7 +70,7 @@ class WebVideoLink extends videoLink $setup = []; } - return json_encode($setup, JSON_UNESCAPED_SLASHES); + return json_encode($setup, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES); } @@ -109,7 +112,7 @@ class WebVideoLink extends videoLink } } - public static function makeVideoTag($link, $width, $height, $compiler = null) + public static function makeVideoTag($link, $width=null, $height=null, $compiler = null) { if ($link->video_service == 0) { return parent::makeVideoTag($link, $width, $height, $compiler); diff --git a/src/Links/ZoomLink.php b/src/Links/ZoomLink.php index 1d2b814..592f719 100644 --- a/src/Links/ZoomLink.php +++ b/src/Links/ZoomLink.php @@ -2,6 +2,9 @@ namespace Fluidbook\Tools\Links; +use Cubist\Util\Files\Files; +use Cubist\Util\Text; + class ZoomLink extends NormalLink { protected $maxzoom_default = 2; @@ -158,7 +161,7 @@ class ZoomLink extends NormalLink } if (isset($attributes['border']) && $attributes['border'] > 0) { - $tmp = CubeIT_Files::tempnam() . '.jpg'; + $tmp = Files::tempnam() . '.jpg'; CubeIT_CommandLine_Imagemagick::addBorder($both, $tmp, $attributes['border'], $attributes['borderColor']); $compiler->vdir->addTemp($both); $both = $tmp; @@ -185,7 +188,7 @@ class ZoomLink extends NormalLink foreach ($groups as $group) { if (empty($group)) continue; - $group_classes[] = 'zoom-group-' . trim(CubeIT_Text::str2URL($group)); + $group_classes[] = 'zoom-group-' . trim(Text::str2URL($group)); } return array_merge($group_classes, ['zoomPopup'], parent::getClasses());