From cf54d6f1a5aecc6d77a6c7511b6a54bbab70cf8b Mon Sep 17 00:00:00 2001 From: Anna Date: Mon, 22 Jan 2024 13:29:52 +0100 Subject: [PATCH] Feature/hantera embed urls i municipio istllet fr komponenten iframe cu 8693h2a8z (#367) * refact: Moving handling of generated urls to Municipio * feat: Added Spotify and SoundCloud as named suppliers to the Acceptance component * Removed commented line of code --- .../php/Component/Acceptance/Acceptance.php | 18 ++++- source/php/Component/Iframe/Iframe.php | 73 +------------------ 2 files changed, 18 insertions(+), 73 deletions(-) diff --git a/source/php/Component/Acceptance/Acceptance.php b/source/php/Component/Acceptance/Acceptance.php index d0e1ee8c..382cff1a 100644 --- a/source/php/Component/Acceptance/Acceptance.php +++ b/source/php/Component/Acceptance/Acceptance.php @@ -174,7 +174,21 @@ public function getSuppliers() 'https://twoday.se/privacy-policy', false, 'login' - ) + ), + new Supplier( + 'Spotify', + array('www.spotify.com', 'open.spotify.com', 'spotify.com'), + 'https://www.spotify.com/se/legal/privacy-policy/', + true, + 'music' + ), + new Supplier( + 'Soundcloud', + array('www.soundcloud.com', 'w.soundcloud.com', 'soundcloud.com'), + 'https://soundcloud.com/pages/privacy', + true, + 'music' + ), ); if (function_exists('apply_filters')) { @@ -250,4 +264,4 @@ public function __construct( $this->requiresAccept = $requiresAccept; $this->systemType = $systemType; } -} \ No newline at end of file +} diff --git a/source/php/Component/Iframe/Iframe.php b/source/php/Component/Iframe/Iframe.php index 356a065a..d2b8538e 100755 --- a/source/php/Component/Iframe/Iframe.php +++ b/source/php/Component/Iframe/Iframe.php @@ -35,8 +35,7 @@ public function init() } if (isset($src)) { - $url = $this->buildEmbedUrl($src); - $this->data['attributeList']['src'] = $url; + $this->data['attributeList']['src'] = $src; if (empty($poster) && function_exists('apply_filters')) { $this->data['poster'] = apply_filters('ComponentLibrary/Iframe/Poster', $url); @@ -57,75 +56,7 @@ public function init() $this->data['embeddedDomain'] = $this->getDomainFromUrl($src); } - /** - * Build embed url - * - * @param string $src Arbitrary embed url - * @return string $src Correct embed url - */ - private function buildEmbedUrl($src) - { - $srcParsed = parse_url($src); - - $ytParams = 'autoplay=1&showinfo=0&rel=0&mute=1&modestbranding=1&cc_load_policy=1'; - - switch ($srcParsed['host']) { - case 'youtube.com': - case 'www.youtube.com': - /* - Replacing the path with /embed/ and then - adding the v query parameter to the path - and removing the v parameter from the - query string. - */ - $srcParsed['host'] = 'youtube.com'; - $srcParsed['path'] = '/embed/'; - - if (isset($srcParsed['query'])) { - parse_str($srcParsed['query'], $query); - if (isset($query['v'])) { - $srcParsed['path'] .= $query['v']; - $srcParsed['query'] = $ytParams; - } - } - break; - case 'youtu.be': - $srcParsed['host'] = 'youtube.com'; - if (isset($srcParsed['path'])) { - $srcParsed['path'] = '/embed/' . $srcParsed['path']; - $srcParsed['query'] = $ytParams; - } - break; - case 'vimeo.com': - case 'www.vimeo.com': - $srcParsed['host'] = 'player.vimeo.com'; - if (isset($srcParsed['path'])) { - $srcParsed['path'] = '/video' . $srcParsed['path'] . "?autoplay=1&autopause=0&muted=1"; - } - break; - case 'spotify.com': - case 'www.spotify.com': - case 'open.spotify.com': - $srcParsed['host'] = 'open.spotify.com'; - $srcParsed['path'] = '/embed' . $srcParsed['path']; - $srcParsed['query'] = 'utm_source=oembed'; - break; - default: - break; - } - - $scheme = $srcParsed['scheme'] ?? 'https'; - $embedUrl = $scheme . '://' . strtolower($srcParsed['host']); - - if (isset($srcParsed['path'])) { - $embedUrl .= $srcParsed['path']; - } - if (isset($srcParsed['query'])) { - $embedUrl .= '?' . $srcParsed['query']; - } - - return $embedUrl; - } + /** * Gets the domain from a given URL.