]> _ Git - fluidbook_tools.git/commitdiff
wip #5408 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 22 Aug 2022 12:27:10 +0000 (14:27 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 22 Aug 2022 12:27:10 +0000 (14:27 +0200)
src/Compiler/Compiler.php
src/Compiler/CompilerInterface.php [new file with mode: 0644]
src/Links/CustomLink.php [new file with mode: 0644]
src/Links/Link.php

index 2ac03bd8dbe6cb5fefeec291877e31089080b287..d9c76ed2dbfd29180448b5614467266f1d4d743d 100644 (file)
@@ -15,13 +15,12 @@ use Illuminate\Contracts\Queue\ShouldBeUnique;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\Jobs\Job;
 use Illuminate\Queue\Jobs\SyncJob;
 use Illuminate\Queue\SerializesModels;
 use JsonException;
 use stdClass;
 
-class Compiler implements ShouldQueue, ShouldBeUnique
+class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
 {
     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 
@@ -340,4 +339,28 @@ class Compiler implements ShouldQueue, ShouldBeUnique
     }
 
 
+    public function addTriggersLink($page, $link)
+    {
+        // TODO: Implement addTriggersLink() method.
+    }
+
+    public function addAudiodescription($link)
+    {
+        // TODO: Implement addAudiodescription() method.
+    }
+
+    public function addBookmarkGroup($link)
+    {
+        // TODO: Implement addBookmarkGroup() method.
+    }
+
+    public function getConfigZIP($d)
+    {
+        // TODO: Implement getConfigZIP() method.
+    }
+
+    public function addContentLock($page, $unlockConditions = '')
+    {
+        // TODO: Implement addContentLock() method.
+    }
 }
diff --git a/src/Compiler/CompilerInterface.php b/src/Compiler/CompilerInterface.php
new file mode 100644 (file)
index 0000000..93bc8c4
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+namespace Fluidbook\Tools\Compiler;
+
+interface CompilerInterface
+{
+    public function addContentLock($page, $unlockConditions = '');
+
+    public function addTriggersLink($page, $link);
+
+    public function addAudiodescription($link);
+
+    public function addBookmarkGroup($link);
+
+    public function getConfigZIP($d);
+}
diff --git a/src/Links/CustomLink.php b/src/Links/CustomLink.php
new file mode 100644 (file)
index 0000000..64b6fb5
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+
+namespace Fluidbook\Tools\Links;
+
+class CustomLink extends NormalLink
+{
+    protected $role = 'link';
+
+    public function getURL()
+    {
+        return static::_getURL($this->to);
+    }
+
+    protected static function _getURLOfType($type, $ref)
+    {
+        global $core;
+        $nospaceref = str_replace(' ', '', $ref);
+        $r = $core->con->select("SELECT * FROM wsref WHERE (ref='" . $core->con->escape($ref) . "' OR ref='" . $core->con->escape($nospaceref) . "') AND type='" . $core->con->escape($type) . "'");
+        if ($r->count()) {
+            return $r->url;
+        }
+        return 'https://workshop.fluidbook.com/services/wsref?ref=' . urlencode($type . '|' . $ref);
+    }
+
+
+    public function getTarget()
+    {
+        return '_blank';
+    }
+
+    public function getDefaultTooltip()
+    {
+        return 'click to open the link';
+    }
+
+    public static function getCustomInstance($id, $init, &$compiler)
+    {
+        $e = explode(':', $init['to']);
+        if ($e[0] == '10doigts') {
+            $init['to'] = self::_getURL($init['to']);
+            $init['iframeType'] = '10doigts';
+            $init['infobulle'] = 'Voir le produit';
+            return new IFramePopupLink($id, $init, $compiler);
+        }
+        return new CustomLink($id, $init, $compiler);
+    }
+
+    public static function _getURL($to)
+    {
+        $e = explode(':', $to, 2);
+        if (!count($e) == 1) {
+            return 'https://workshop.fluidbook.com/services/wsref?ref=' . urlencode($to);
+        }
+        $type = trim($e[0]);
+        $ref = trim($e[1]);
+        return self::_getURLOfType($type, $ref);
+    }
+}
index 2e50050237bb73c74229558c0fe69599b71eec7f..cb992cf1cddb3764724b9c0ae1cdb9f22a72c9ac 100644 (file)
@@ -5,16 +5,19 @@ namespace Fluidbook\Tools\Links;
 use Cubist\Util\ArrayUtil;
 use Cubist\Util\Crypt;
 use Cubist\Util\CSS;
+use Cubist\Util\Files\Files;
 use Cubist\Util\Json;
 use Cubist\Util\ObjectUtil;
 use Cubist\Util\Text;
 use Cubist\Util\Xml;
 use Fluidbook\Tools\Compiler\Compiler;
+use Fluidbook\Tools\Compiler\CompilerInterface;
 use stdClass;
 
 class Link
 {
 
+    protected static string|false $_linksKey;
     public $left;
     public $top;
     public $width;
@@ -75,7 +78,7 @@ class Link
      *
      * @param integer $id
      * @param stdClass|array $init
-     * @param Compiler $compiler
+     * @param CompilerInterface $compiler
      * @return Link
      */
     public static function getInstance($id, $init, &$compiler)
@@ -94,7 +97,6 @@ class Link
             case 5:
                 return new InternalLink($id, $init, $compiler);
             case 4:
-
                 $init['inline'] = self::normalizeInlineIntegration($init['inline']);
                 if ($init['inline'] === 'inline') {
                     $init['inline'] = 'inline';
@@ -106,7 +108,8 @@ class Link
                     $init['inline'] = 'background_texts';
                     return new VideoBackgroundLink($id, $init, $compiler);
                 }
-
+            case 7:
+                return CustomLink::getCustomInstance($id, $init, $compiler);
             case 10:
                 $init['inline'] = self::normalizeInlineIntegration($init['inline']);
                 if ($init['inline'] === 'popup') {
@@ -115,6 +118,8 @@ class Link
                 return new WebVideoLink($id, $init, $compiler);
             case 11:
                 return new ActionLink($id, $init, $compiler);
+            case 12: // Basket / Cart links
+                return new CartLink($id, $init, $compiler);
             case 13: // zoom area
                 return new ZoomLink($id, $init, $compiler);
             case 14:
@@ -286,7 +291,7 @@ class Link
         }
         $init['inline'] = self::normalizeInlineIntegration($init['inline']);
 
-        $ext = mb_strtolower(files::getExtension($init['alternative']));
+        $ext = mb_strtolower(Files::getExtension($init['alternative']));
 
         if (in_array($ext, array('oam', 'zip', 'html')) || substr($init['alternative'], 0, 4) == 'http') {
             if ($init['inline'] === 'inline') {
@@ -329,7 +334,7 @@ class Link
                     $v = [];
                     parse_str($vv, $v);
                     $v = ObjectUtil::asObject($v);
-                } else if (strpos($v, '=') !== false) {
+                } else if (str_contains($v, '=')) {
                     $extras = self::parseExtras($v);
                     foreach ($extras as $extrak => $extrav) {
                         $this->$extrak = $extrav;
@@ -429,7 +434,7 @@ class Link
     {
         if ($this->infobulle === null || !$this->infobulle) {
             if ($this->getDefaultTooltip() === false) {
-                return;
+                return '';
             }
             return '~' . $this->getDefaultTooltip();
         }