]> _ Git - fluidbook_tools.git/commitdiff
wip #4697
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 Sep 2021 08:30:56 +0000 (10:30 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 Sep 2021 08:30:56 +0000 (10:30 +0200)
composer.lock
src/Links/AnchorLink.php
src/Links/HTMLMultimediaLink.php
src/Links/Link.php
src/Links/SlideshowLink.php
src/Links/ZoomLink.php

index be869e6db0741d1ff393ff3b7fe93cafc4054886..8e8f41d6397f16c8105b87c5e72a0a23f2fe0a8a 100644 (file)
             "source": {
                 "type": "git",
                 "url": "git://git.cubedesigners.com/cubist_util.git",
-                "reference": "3d0d8337bd9e4b3ccf3d99ab7070ede27b1475bb"
+                "reference": "2e5ce49625c437ce2dc155802189cc992d1f72c6"
             },
             "dist": {
                 "type": "tar",
-                "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-b28a8b.tar",
-                "reference": "3d0d8337bd9e4b3ccf3d99ab7070ede27b1475bb",
-                "shasum": "b60f0a943faf5ff520e7bab322d71b124705e744"
+                "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-3f73fc.tar",
+                "reference": "2e5ce49625c437ce2dc155802189cc992d1f72c6",
+                "shasum": "2474139d9b492690ee5656902d81b84bbc173106"
             },
             "require": {
                 "cubist/net": "dev-master",
                 }
             ],
             "description": "Utilities class",
-            "time": "2021-09-22T07:22:01+00:00"
+            "time": "2021-09-22T08:26:26+00:00"
         },
         {
             "name": "dflydev/dot-access-data",
index 2f739ee21f0f5800f018dafa4abf6a882deb12f1..1f73627cd1f53fe9e9876e822eb5997b6274802a 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace Fluidbook\Tools\Links;
 
+use Cubist\Util\Text;
+
 class AnchorLink extends Link
 {
     protected $role = '';
@@ -20,6 +22,6 @@ class AnchorLink extends Link
 
     public static function normalizeAnchor($anchor)
     {
-        return mb_strtolower(CubeIT_Text::str2URL($anchor));
+        return mb_strtolower(Text::str2URL($anchor));
     }
 }
index c23d8f6bf0bef06c940830d46697846862ee5f92..1da2864dc5d68c1d101fca97ccc401550479270c 100644 (file)
@@ -2,7 +2,9 @@
 
 namespace Fluidbook\Tools\Links;
 
+use Cubist\Util\CSS;
 use Cubist\Util\Files\Files;
+use Cubist\Util\Json;
 
 class HTMLMultimediaLink extends Link
 {
@@ -92,7 +94,7 @@ class HTMLMultimediaLink extends Link
                 $infos = ['path' => 'data/links/' . str_replace('.', '_', $this->alternative) . '/'];
                 $i = str_replace('$id', '"#l_' . $this->id . '"', $i);
                 $i = str_replace('$path', '"' . $infos['path'] . '"', $i);
-                $i = str_replace('$init', CubeIT_Util_Json::encode($infos), $i);
+                $i = str_replace('$init', Json::encode($infos), $i);
                 // Key the array with the ID so we don't get duplicates even when this function is called multiple times
                 $this->compiler->HTMLMultimedia[$this->id] = $i;
             }
@@ -153,7 +155,7 @@ class HTMLMultimediaLink extends Link
         $css .= $this->getCSS();
         $css .= '}';
         if ($this->_externalIframe !== false && $this->in_popup) {
-            $css .= '#l_' . $this->id . '>iframe{' . wsHTML5::writeCSSUA('transform', 'scale(' . $this->getCssScale() . ')') . '}';
+            $css .= '#l_' . $this->id . '>iframe{' . CSS::writeCSSUA('transform', 'scale(' . $this->getCssScale() . ')') . '}';
         }
 
         if ($this->_config['type'] === 'oam') {
@@ -162,13 +164,13 @@ class HTMLMultimediaLink extends Link
             if ($this->compiler->book->parametres->OAMChromeFactor != 1) {
                 $css .= '.chrome #l_' . $this->id . '{';
                 $css .= 'width:' . ($this->_config['width'] * $this->compiler->book->parametres->OAMChromeFactor) . 'px;height:' . ($this->_config['height'] * $this->compiler->book->parametres->OAMChromeFactor) . 'px;';
-                $css .= wsHTML5::writeCSSUA('transform', 'scale(' . ($sx / $this->compiler->book->parametres->OAMChromeFactor) . ',' . ($sy / $this->compiler->book->parametres->OAMChromeFactor) . ')');
+                $css .= CSS::writeCSSUA('transform', 'scale(' . ($sx / $this->compiler->book->parametres->OAMChromeFactor) . ',' . ($sy / $this->compiler->book->parametres->OAMChromeFactor) . ')');
                 $css .= '}';
             }
             if ($this->compiler->book->parametres->OAMIEFactor != 1) {
                 $css .= '.msie #l_' . $this->id . '{';
                 $css .= 'width:' . ($this->_config['width'] * $this->compiler->book->parametres->OAMIEFactor) . 'px;height:' . ($this->_config['height'] * $this->compiler->book->parametres->OAMIEFactor) . 'px;';
-                $css .= wsHTML5::writeCSSUA('transform', 'scale(' . ($sx / $this->compiler->book->parametres->OAMIEFactor) . ',' . ($sy / $this->compiler->book->parametres->OAMIEFactor) . ')');
+                $css .= CSS::writeCSSUA('transform', 'scale(' . ($sx / $this->compiler->book->parametres->OAMIEFactor) . ',' . ($sy / $this->compiler->book->parametres->OAMIEFactor) . ')');
                 $css .= '}';
             }
 
@@ -183,8 +185,8 @@ class HTMLMultimediaLink extends Link
         $sx = ($this->width / ($this->_config['width'])) * $this->getCssScale();
         $sy = ($this->height / ($this->_config['height'])) * $this->getCssScale();
 
-        $res = wsHTML5::writeCSSUA('transform', 'scale(' . $sx . ',' . $sy . ')');
-        $res .= wsHTML5::writeCSSUA('transform-origin', '0% 0%');
+        $res = CSS::writeCSSUA('transform', 'scale(' . $sx . ',' . $sy . ')');
+        $res .= CSS::writeCSSUA('transform-origin', '0% 0%');
 
         if (!$this->_config['html']) {
             return '';
index ec948e91b19f1ebbc29f3389cf89c47ca5426174..54c776ccdb71335f4789920dacdfe72d546803d0 100644 (file)
@@ -3,6 +3,11 @@
 namespace Fluidbook\Tools\Links;
 
 use Cubist\Util\ArrayUtil;
+use Cubist\Util\CSS;
+use Cubist\Util\Json;
+use Cubist\Util\ObjectUtil;
+use Cubist\Util\Text;
+use Cubist\Util\Xml;
 
 class Link
 {
@@ -81,106 +86,57 @@ class Link
         switch ($init['type']) {
             case 1:
             case 2:
-                return new webLink($id, $init, $compiler);
+                return new WebLink($id, $init, $compiler);
             case 3:
-                return new mailLink($id, $init, $compiler);
+                return new MailLink($id, $init, $compiler);
             case 5:
-                return new internalLink($id, $init, $compiler);
+                return new InternalLink($id, $init, $compiler);
             case 4:
 
                 $init['inline'] = self::normalizeInlineIntegration($init['inline']);
                 if ($init['inline'] === 'inline') {
                     $init['inline'] = 'inline';
-                    return new videoLink($id, $init, $compiler);
+                    return new VideoLink($id, $init, $compiler);
                 } else if ($init['inline'] === 'popup') {
                     $init['inline'] = 'popup';
-                    return new videoPopupLink($id, $init, $compiler);
+                    return new VideoPopupLink($id, $init, $compiler);
                 } else if ($init['inline'] === 'background_texts') {
                     $init['inline'] = 'background_texts';
-                    return new videoBackgroundLink($id, $init, $compiler);
+                    return new VideoBackgroundLink($id, $init, $compiler);
                 }
 
-            case 7:
-                if ($compiler->book->parametres->basketManager === 'Puma') {
-                    return new pumaCartLink($id, $init, $compiler);
-                }
-                if ($compiler->book->parametres->basketManager === 'MIF') {
-                    return new cartLink($id, $init, $compiler);
-                }
-                switch ($compiler->book->parametres->customLinkClass) {
-                    case 'WescoLink':
-                        return new wescoLink($id, $init, $compiler);
-                    case 'HaguenauManifLink':
-                        return new haguenauManifLink($id, $init, $compiler);
-                    case 'FLFLink':
-                        return new flfLink($id, $init, $compiler);
-                    case 'InpesPopinLink':
-                        return new inpesPopinLink($id, $init, $compiler);
-                    case 'PierronLink':
-                        return new pierronLink($id, $init, $compiler);
-                    case 'WescoSalesLink':
-                        return new wescoSalesLink($id, $init, $compiler);
-                    case 'AtlanticDownloadLink':
-                        return new atlanticDownloadLink($id, $init, $compiler);
-                    case 'MiraklEaster2021':
-                        return new miraklEaster2021Link($id, $init, $compiler);
-                    default :
-                        return customLink::getCustomInstance($id, $init, $compiler);
-                }
-            case 8:
-            case 9:
-                return null;
             case 10:
                 $init['inline'] = self::normalizeInlineIntegration($init['inline']);
                 if ($init['inline'] === 'popup') {
-                    return new webVideoPopupLink($id, $init, $compiler);
+                    return new WebVideoPopupLink($id, $init, $compiler);
                 }
-                return new webVideoLink($id, $init, $compiler);
+                return new WebVideoLink($id, $init, $compiler);
             case 11:
-                return new actionLink($id, $init, $compiler);
-            case 12:
-                if ($compiler->book->parametres->basketManager === 'Puma' || $compiler->book->parametres->basketManager === 'MIF' || $compiler->book->parametres->basketManager === 'Flexipan') {
-                    return new zoomProductLink($id, $init, $compiler);
-                }
-                if ($compiler->book->parametres->product_zoom_references !== '') {
-                    return new zoomProductLink($id, $init, $compiler);
-                }
-                switch ($compiler->book->parametres->basketManager) {
-                    case 'GrandVision':
-                        return new grandVisionCartLink($id, $init, $compiler);
-                    case 'JoueclubWishlist':
-                        return new JoueclubWishlistLink($id, $init, $compiler);
-                    case 'Remarkable':
-                        return new remarkableCartLink($id, $init, $compiler);
-                    case 'ZoomProductLink':
-                        return new zoomProductLink($id, $init, $compiler);
-                    default :
-                        return new cartLink($id, $init, $compiler);
-                }
+                return new ActionLink($id, $init, $compiler);
             case 13: // zoom area
-                return new zoomLink($id, $init, $compiler);
+                return new ZoomLink($id, $init, $compiler);
             case 14:
-                return new colorLink($id, $init, $compiler);
+                return new ColorLink($id, $init, $compiler);
             case 15:
                 if (stristr($init['to'], '.zip')) {
-                    return new inlineSlideshowLink($id, $init, $compiler);
+                    return new InlineSlideshowLink($id, $init, $compiler);
                 }
-                return new imageLink($id, $init, $compiler);
+                return new ImageLink($id, $init, $compiler);
             case 16:
-                return new fileLink($id, $init, $compiler);
+                return new FileLink($id, $init, $compiler);
             case 17:
 
                 $init['inline'] = self::normalizeInlineIntegration($init['inline']);
                 if ($init['inline'] === 'inline') {
-                    return new audioLink($id, $init, $compiler);
+                    return new AudioLink($id, $init, $compiler);
                 }
-                return new audioPopupLink($id, $init, $compiler);
+                return new AudioPopupLink($id, $init, $compiler);
             case 18:
                 $init['inline'] = self::normalizeInlineIntegration($init['inline']);
                 if ($init['inline'] === 'inline') {
-                    return new tooltipLink($id, $init, $compiler);
+                    return new TooltipLink($id, $init, $compiler);
                 }
-                return new textPopupLink($id, $init, $compiler);
+                return new TextPopupLink($id, $init, $compiler);
             case 19:
                 break;
             case 20:
@@ -190,49 +146,49 @@ class Link
             case 6:
                 return self::getMultimediaInstance($id, $init, $compiler);
             case 23:
-                return new statsTagLink($id, $init, $compiler);
+                return new StatsTagLink($id, $init, $compiler);
             case 24:
-                return new phoneLink($id, $init, $compiler);
+                return new PhoneLink($id, $init, $compiler);
             case 25:
                 $compiler->addAudiodescription($init);
                 break;
             case 26:
             case 40:
-                return new anchorLink($id, $init, $compiler);
+                return new AnchorLink($id, $init, $compiler);
             case 27:
-                return new eventOverlayLink($id, $init, $compiler);
+                return new EventOverlayLink($id, $init, $compiler);
             case 29:
-                return new facebookLikeLink($id, $init, $compiler);
+                return new FacebookLikeLink($id, $init, $compiler);
             case 30:
-                return new slideshowLink($id, $init, $compiler);
+                return new SlideshowLink($id, $init, $compiler);
             case 31:
                 $init['inline'] = self::normalizeInlineIntegration($init['inline']);
                 if ($init['inline'] === 'inline') {
-                    return new iframeLink($id, $init, $compiler);
+                    return new IFrameLink($id, $init, $compiler);
                 }
-                return new iframePopupLink($id, $init, $compiler);
+                return new IFramePopupLink($id, $init, $compiler);
             case 32:
-                return new showLinkLink($id, $init, $compiler);
+                return new ShowLinkLink($id, $init, $compiler);
             case 33:
-                return new zoomhdLink($id, $init, $compiler);
+                return new ZoomHDLink($id, $init, $compiler);
             case 34:
                 $compiler->addContentLock($init['page'], $init['to']);
                 break;
             case 35:
-                return new textLink($id, $init, $compiler);
+                return new TextLink($id, $init, $compiler);
             case 36:
-                return new articleLink($id, $init, $compiler);
+                return new ArticleLink($id, $init, $compiler);
             case 37:
-                return new downloadPortionLink($id, $init, $compiler);
+                return new DownloadPortionLink($id, $init, $compiler);
             case 38:
                 if ($init['target'] != 'click') {
                     $compiler->addTriggersLink($init['page'], $init['to']);
                 } else {
-                    return new triggerLink($id, $init, $compiler);
+                    return new TriggerLink($id, $init, $compiler);
                 }
                 break;
             case 39:
-                return new layerLink($id, $init, $compiler);
+                return new LayerLink($id, $init, $compiler);
             default:
                 return null;
         }
@@ -263,7 +219,7 @@ class Link
             return [];
         }
         $res = [];
-        $lines = CubeIT_Text::splitLines($extras);
+        $lines = Text::splitLines($extras);
         foreach ($lines as $line) {
             $e = explode('=', $line);
             if (count($e) < 2) {
@@ -365,13 +321,13 @@ class Link
         $this->_init = $init;
         foreach ($init as $k => $v) {
             if ($k == 'extra') {
-                if (CubeIT_Util_Json::isJson($v)) {
-                    $v = CubeIT_Util_Json::decode($v);
-                } else if (strpos($v, '=') !== false && strpos($v, '&') !== false) {
+                if (Json::isJson($v)) {
+                    $v = Json::decode($v);
+                } else if (str_contains($v, '=') && str_contains($v, '&')) {
                     $vv = $v;
                     $v = [];
                     parse_str($vv, $v);
-                    $v = CubeIT_Util_Object::asObject($v);
+                    $v = ObjectUtil::asObject($v);
                 } else if (strpos($v, '=') !== false) {
                     $extras = self::parseExtras($v);
                     foreach ($extras as $extrak => $extrav) {
@@ -591,15 +547,15 @@ class Link
         $css .= $this->getCSSZIndex();
         $origin = false;
         if ($this->rot) {
-            $css .= wsHTML5::writeCSSUA('transform', 'rotate(' . $this->rot . 'deg)');
+            $css .= CSS::writeCSSUA('transform', 'rotate(' . $this->rot . 'deg)');
             $origin = true;
         }
         if (isset($this->skewX)) {
-            $css .= wsHTML5::writeCSSUA('transform', 'skewX(' . $this->skewX . 'deg)');
+            $css .= CSS::writeCSSUA('transform', 'skewX(' . $this->skewX . 'deg)');
             $origin = true;
         }
         if (isset($this->skew)) {
-            $css .= wsHTML5::writeCSSUA('transform', 'skew(' . $this->skew . ')');
+            $css .= CSS::writeCSSUA('transform', 'skew(' . $this->skew . ')');
             $origin = true;
         }
 
@@ -653,7 +609,7 @@ class Link
         $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);
+        $c = Xml::toObject($x);
 
         $props = array('default-width' => 'width', 'default-height' => 'height', 'html-page' => 'html');
 
index 593d91a0256c4f3a5546d17db41c92ec7bb8bf0f..c8f5692a3ff54b0ed904f3134c2f5f6be442f889 100644 (file)
@@ -2,6 +2,10 @@
 
 namespace Fluidbook\Tools\Links;
 
+use Cubist\Util\Files\Files;
+use Cubist\Util\Graphics\Image;
+use Cubist\Util\Xml;
+
 class SlideshowLink extends NormalLink
 {
 
@@ -62,7 +66,7 @@ class SlideshowLink extends NormalLink
 
         // If the zip file contained a slideshow.xml file, use that for fetching images and their captions
         if (file_exists($XML_path) && $slideshow_XML = simplexml_load_string(file_get_contents($XML_path))) {
-            $slideshowData = CubeIT_Util_Xml::toObject($slideshow_XML);
+            $slideshowData = Xml::toObject($slideshow_XML);
             $thumbnails = isset($slideshowData->_thumbnails) && $slideshowData->_thumbnails !== 'false';
 
             // Allow "fade" transition to be enabled
@@ -126,7 +130,7 @@ class SlideshowLink extends NormalLink
         // when there was a __MACOSX sub directory inside the zip file containing
         // resource forks for the JPGs. There's no need to support nested directories
         // in the zip so we only look at the zip's root directory...
-        $files = CubeIT_Files::getDirectoryIterator($path);
+        $files = Files::getDirectoryIterator($path);
         $slides = [];
 
         foreach ($files as $file) {
@@ -160,7 +164,7 @@ class SlideshowLink extends NormalLink
 
         foreach ($slides as $slide) {
             $image_path_relative = $this->compiler->vdir->relativePath($slide['path']);
-            $image_info = CubeIT_Image::getimagesize($slide['path']);
+            $image_info = Image::getimagesize($slide['path']);
             $image_info_json = ($image_info) ? json_encode(['width' => $image_info[0], 'height' => $image_info[1], 'ratio' => round($image_info[0] / $image_info[1], 4)]) : '';
             $image_dimensions = ($image_info) ? $image_info[3] : '';
 
index 592f7193a2515c7206d2ae07480a153b2a03df1a..1c49c84561d9322e1e8f24e1517948eec7af7b28 100644 (file)
@@ -2,7 +2,9 @@
 
 namespace Fluidbook\Tools\Links;
 
+use Cubist\Util\CommandLine\Imagemagick;
 use Cubist\Util\Files\Files;
+use Cubist\Util\Graphics\PDF;
 use Cubist\Util\Text;
 
 class ZoomLink extends NormalLink
@@ -16,7 +18,7 @@ class ZoomLink extends NormalLink
             $this->_groups = [];
             $groups = explode(',', $this->group);
             foreach ($groups as $group) {
-                $this->_groups[] = CubeIT_Text::str2URL(trim($group));
+                $this->_groups[] = Text::str2URL(trim($group));
             }
         }
         return $this->_groups;
@@ -124,11 +126,11 @@ class ZoomLink extends NormalLink
             $extractPage = $attributes['page'];
         }
 
-        $left = CubeIT_Files::tempnam();
-        $leftfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
+        $left = Files::tempnam();
+        $leftfile = PDF::extractArea($pdfpath,
             $extractPage,
             array('x' => $x, 'y' => $y, 'width' => $w, 'height' => $h),
-            $left, $extractOptions, WS_CACHE . '/' . $cachedir . '/' . $compiler->book_id . '/');
+            $left, $extractOptions, storage_path('cache/' . $cachedir . '/' . $compiler->book_id . '/'));
 
         if (($x + $w) > $bookwidth) {
             if (!isset($attributes['pdf']) || !$attributes['pdf']) {
@@ -141,18 +143,18 @@ class ZoomLink extends NormalLink
             }
 
             $diff = ($w + $x) - $bookwidth;
-            $right = CubeIT_Files::tempnam();
-            $rightfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
+            $right = Files::tempnam();
+            $rightfile = PDF::extractArea($pdfpath,
                 $extractPage,
                 array('x' => 0, 'y' => $y, 'width' => $diff, 'height' => $h),
-                $right, $extractOptions, WS_CACHE . '/' . $cachedir . '/' . $compiler->book_id . '/');
+                $right, $extractOptions, storage_path('cache/' . $cachedir . '/' . $compiler->book_id . '/'));
 
             if (!file_exists($rightfile)) {
                 die('Error generating right part ' . $rightfile);
             }
 
-            $both = CubeIT_Files::tempnam() . '.jpg';
-            CubeIT_CommandLine_Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal');
+            $both = Files::tempnam() . '.jpg';
+            Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal');
             if (!file_exists($both)) {
                 die('Error glueing ' . $leftfile . ' and ' . $rightfile);
             }
@@ -162,7 +164,7 @@ class ZoomLink extends NormalLink
 
         if (isset($attributes['border']) && $attributes['border'] > 0) {
             $tmp = Files::tempnam() . '.jpg';
-            CubeIT_CommandLine_Imagemagick::addBorder($both, $tmp, $attributes['border'], $attributes['borderColor']);
+            Imagemagick::addBorder($both, $tmp, $attributes['border'], $attributes['borderColor']);
             $compiler->vdir->addTemp($both);
             $both = $tmp;
         }