From 945bda7a6756799e75ce024e1affd1f45c34cd02 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 22 Aug 2022 14:27:10 +0200 Subject: [PATCH] wip #5408 @1 --- src/Compiler/Compiler.php | 27 ++++++++++++-- src/Compiler/CompilerInterface.php | 16 +++++++++ src/Links/CustomLink.php | 58 ++++++++++++++++++++++++++++++ src/Links/Link.php | 17 +++++---- 4 files changed, 110 insertions(+), 8 deletions(-) create mode 100644 src/Compiler/CompilerInterface.php create mode 100644 src/Links/CustomLink.php diff --git a/src/Compiler/Compiler.php b/src/Compiler/Compiler.php index 2ac03bd..d9c76ed 100644 --- a/src/Compiler/Compiler.php +++ b/src/Compiler/Compiler.php @@ -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 index 0000000..93bc8c4 --- /dev/null +++ b/src/Compiler/CompilerInterface.php @@ -0,0 +1,16 @@ +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); + } +} diff --git a/src/Links/Link.php b/src/Links/Link.php index 2e50050..cb992cf 100644 --- a/src/Links/Link.php +++ b/src/Links/Link.php @@ -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(); } -- 2.39.5