]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5769 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 2 Mar 2023 21:30:13 +0000 (22:30 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 2 Mar 2023 21:30:13 +0000 (22:30 +0100)
app/Fluidbook/Link/Custom/InpesPopinLink.php
app/Fluidbook/Links.php
app/Jobs/FluidbookCompiler.php
app/Models/FluidbookDocument.php
app/Models/FluidbookPublication.php
app/SubForms/Link/Base.php
app/SubForms/Link/Multimedia.php
resources/linkeditor/js/linkeditor.form.js
resources/linkeditor/js/linkeditor.layers.js
resources/linkeditor/js/linkeditor.links.js

index c114607a7374f16c75a0286c1b5782517c1e5961..9af1605e5b58373fc90f757982b3a6e5a2b89235 100644 (file)
@@ -9,7 +9,6 @@ class InpesPopinLink extends HTMLMultimediaLink
 {
     public function getHTMLContent()
     {
-        $this->alternative = $this->to;
         $c = parent::getHTMLContent();
 
         $class = $this->getClasses();
index 030a6d04101a0b5232a520b195c2d1843c3a68cc..1c4c593f01af536d277a7c5c29f0a51d33869575 100644 (file)
@@ -198,6 +198,7 @@ class Links
     {
         self::_correctImageSpecialLinks($links);
         self::_fixWebVideoServices($links);
+        self::_fixMultimedia($links);
     }
 
     protected static function _correctImageSpecialLinks(&$links)
@@ -206,8 +207,8 @@ class Links
             if (preg_match('/^link_(.*)$/', $link['page'], $matches) && strlen($matches[1]) !== 32) {
                 $uid = $matches[1];
                 foreach ($links as $l) {
-                    if ($l['uid'] === $uid && $l['alternative']) {
-                        $links[$k]['page'] = 'link_' . md5($l['alternative']);
+                    if ($l['uid'] === $uid && $l['to']) {
+                        $links[$k]['page'] = 'link_' . md5($l['to']);
                         break;
                     }
                 }
@@ -228,6 +229,16 @@ class Links
         }
     }
 
+    protected static function _fixMultimedia(&$links)
+    {
+        foreach ($links as $k => $link) {
+            if (isset($link['alternative']) && $link['alternative'] && $link['type'] == 6) {
+                $links[$k]['to'] = $link['alternative'];
+                unset($links[$k]['alternative']);
+            }
+        }
+    }
+
     public static function getLinksFromExcel($xls, &$links, &$rulers)
     {
         $s = $xls->setActiveSheetIndexByName('Links');
index 88003237424cbb7dd9c44e9cafe402423d4f44ed..851563508c4cdff7b21900450357c65eb59be324 100644 (file)
@@ -2220,7 +2220,6 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                     'height' => 100,
                     'type' => 6,
                     'to' => $this->fluidbookSettings->tabsHTML5,
-                    'alternative' => $this->fluidbookSettings->tabsHTML5,
                     'image' => '',
                     'inline' => 1,
                     'interactive' => 1,
@@ -2262,9 +2261,6 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
 
         foreach ($linksCopy as $k => $linkData) {
             if ($this->fluidbookSettings->PDFRendererIframe === 'svg' && (($linkData['type'] == 31 && stristr($linkData['to'], '.pdf')) || ($linkData['type'] == 6 && stristr($linkData['alternative'], '.pdf')))) {
-                if ($linkData['type'] == 6) {
-                    $linkData['to'] = $linkData['alternative'];
-                }
                 $ofile = $this->wdir . '/' . $linkData['to'];
                 $dfile = $this->wdir . '/' . $linkData['to'] . '.svg';
                 if (!file_exists($dfile) || filemtime($dfile) < filemtime($ofile)) {
@@ -2272,7 +2268,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                     `$cmd`;
                 }
                 $linkData['type'] = 6;
-                $linkData['to'] = $linkData['alternative'] = $linkData['to'] . '.svg';
+                $linkData['to'] = $linkData['to'] . '.svg';
                 $linkData['backgroundColor'] = '#fff';
                 $links[$k] = $linkData;
             }
@@ -2320,7 +2316,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                 $dupData['animation'] = '';
                 $dupData['inline'] = true;
                 $dupData['interactive'] = false;
-                $dupData['alternative'] = $linkData['animation'];
+                $dupData['to'] = $linkData['animation'];
                 $dupData['type'] = 6;
                 $linkData['relatedAnimation'] = $dupData['uid'] = 'a_' . $linkData['uid'];
                 $dupData['video_width'] = $dupData['video_height'] = 0;
index ec9d0a375923856a461bacd6847fe11a04e63a12..42f9acf81341664c9672f01856a2cb114d469aa0 100644 (file)
@@ -423,7 +423,7 @@ class FluidbookDocument extends ToolboxModel
 
     public function lnCrop()
     {
-        link($this->getPDFSource('crop'), $this->getPDFSource('fixed'));
+        link($this->getPDFSource('fixed'), $this->getPDFSource());
     }
 
     protected function isCropped()
index 68c2b3d33a211c411543b05a693c8d3aa2e18799..06c8045b92c2a1b0b36b88a05357080d6e74387d 100644 (file)
@@ -441,15 +441,18 @@ class FluidbookPublication extends ToolboxSettingsModel
                 continue;
             }
 
-            $file = $this->asset_path($link['alternative']);
+            if (!isset($link['to']) || !$link['to']) {
+                continue;
+            }
+            $file = $this->asset_path($link['to']);
             if (!file_exists($file)) {
                 continue;
             }
-            $md5 = md5($link['alternative']);
+            $md5 = md5($link['to']);
             if (isset($res[$md5])) {
                 continue;
             }
-            $res[$md5] = ['name' => $link['alternative'], 'dim' => Image::getimagesize($file), 'url' => url('/fluidbook-publication/' . $this->id . '/edit/links/assets/' . $link['alternative'])];
+            $res[$md5] = ['name' => $link['to'], 'dim' => Image::getimagesize($file), 'url' => url('/fluidbook-publication/' . $this->id . '/edit/links/assets/' . $link['to'])];
         }
         return $res;
     }
index f6495ac2d5a22b4039f5212ebd43610f4ad1f1a9..6c5870d05e65a1412d48fec4c1292cf6396e1d32 100644 (file)
@@ -22,6 +22,7 @@ use Cubist\Backpack\Magic\Fields\Textarea;
 use Cubist\Backpack\Magic\Form;
 use Fluidbook\Tools\Compiler\DummyCompiler;
 use App\Fluidbook\Link\Link;
+
 // __('!! Editeur de liens')
 class Base extends Form
 {
@@ -92,7 +93,7 @@ class Base extends Form
 
     protected static $_acceptImage = ['.jpg', '.jpeg', '.png', '.svg', '.gif'];
     protected static $_acceptImageAZip = ['.jpg', '.jpeg', '.png', '.svg', '.gif', '.zip'];
-    protected static $_acceptAnimation = ['.jpg', '.jpeg', '.png', '.svg', '.gif', '.zip', '.oam', '.html', '.json'];
+    protected static $_acceptAnimation = ['.jpg', '.jpeg', '.png', '.svg', '.gif', '.zip', '.oam', '.html', '.json', '.pdf'];
     protected static $_acceptVideo = ['.mp4'];
     protected static $_acceptFont = ['.otf', '.ttf'];
     protected static $_acceptAudiodescription = ['.mp3', '.txt'];
@@ -335,7 +336,7 @@ class Base extends Form
                 }
             }
             if ($type['type'] === 6) {
-                $optionsChoices['alternative'] = ['file.jpg', 'file.zip'];
+                $optionsChoices['to'] = ['file.jpg', 'file.zip'];
             }
 
             $configs[$type['type']] = $optionsChoices;
@@ -351,7 +352,7 @@ class Base extends Form
         }
 
         $id = 1;
-        $base = ['top' => 1, 'left' => 1, 'width' => 1, 'height' => 1, 'to' => '-', 'inline' => 'inline', 'page' => 2, 'target' => '_blank', 'extra' => '', 'alternative' => '', 'interactive' => false];
+        $base = ['top' => 1, 'left' => 1, 'width' => 1, 'height' => 1, 'to' => '', 'inline' => 'inline', 'page' => 2, 'target' => '_blank', 'extra' => '', 'interactive' => false];
         $compiler = new FluidbookCompiler($fluidbook);
 
         /** @var Link $instances */
index 891e9c90382e1b7efac1092cdc7ac4e457697519..94724797b3ed0be290cce8fce56e367c5c26da6f 100644 (file)
@@ -13,7 +13,7 @@ class Multimedia extends Base
 
     public function addDestinationField()
     {
-        $this->addField('alternative', FilesOrURL::class, __('Animation'), $this->getFilesOrURLEntry() + ['accept' => self::$_acceptAnimation]);
+        $this->addField('to', FilesOrURL::class, __('Animation'), $this->getFilesOrURLEntry() + ['accept' => self::$_acceptAnimation]);
     }
 
     public function addMultimediaFields()
index 8003f74c0c2487a1f100dc02df874781e2292f8e..c3be0b69283b3d968c5555ad7f796b6541b2caeb 100644 (file)
@@ -154,6 +154,7 @@ LinkeditorForm.prototype = {
             if (link === undefined || link === null) {
                 return;
             }
+            this.lastSelectedLink = link;
         } catch (e) {
             return;
         }
index 3fce5ca80aaab104f622959dc53fa9862eb9828b..bea434fe1812ebcffe25af1e2c288b9bdda4f23a 100644 (file)
@@ -74,11 +74,16 @@ LinkeditorLayers.prototype = {
     },
 
     updateSelection() {
+
+        if (this.container === undefined || this.container.is(':hidden')) {
+            return;
+        }
         var $this = this;
         this.maskCheckEvents = true;
         setTimeout(function () {
             $this.maskCheckEvents = false;
         }, 100);
+
         $('#linkeditor-links .link').each(function () {
             let checkbox = $this.container.find('input[name=' + $(this).attr('fb-uid') + ']');
             checkbox.prop('checked', $(this).is('.selected'));
index d018d33ce1d63c1519a1ef9784ffc2ccadeb470a..405f7f8df39a5d02fe06ad6e60b87bcb292617a1 100644 (file)
@@ -291,13 +291,14 @@ LinkeditorLinks.prototype = {
             offset.y -= top;
         }
 
+        this.deselectAllLinks();
         $(linksInClipboard).each(function () {
             let data = $this._duplicateLink($(this), false);
 
             data.top += offset.y;
             data.left += offset.x;
 
-            $this.addLink(data);
+            $this.selectLink($this.addLink(data));
         });
 
         this.linkeditor.hasChanged();