From eed207f8dfd68117715518c83fc32d3ae9e1e094 Mon Sep 17 00:00:00 2001 From: dedeibel Date: Sun, 10 Dec 2017 18:02:48 +0100 Subject: Allowed multi translation for embedding, fixed autoplay option --- assets/js/lustiges-script.js | 8 +++++++- index.php | 4 +--- model/Room.php | 9 ++++++--- model/Stream.php | 4 +++- template/assemblies/embed-form.phtml | 2 +- view/embed.php | 17 +++++++++++++++-- 6 files changed, 33 insertions(+), 11 deletions(-) diff --git a/assets/js/lustiges-script.js b/assets/js/lustiges-script.js index c14de15..22c4e04 100644 --- a/assets/js/lustiges-script.js +++ b/assets/js/lustiges-script.js @@ -374,7 +374,13 @@ $(function() { if(!originalsrc) originalsrc = $iframe.attr('src'); - var src = originalsrc + (autoplay ? '' : 'no-autoplay/'); + var src = originalsrc; + if (! autoplay) { + if (src.slice(-1) !== '/') { + src += '/'; + } + src += 'no-autoplay' + } $iframe.attr({width: selected[0], height: selected[1]}); $iframe.attr({src: src}); diff --git a/index.php b/index.php index 43a704e..a526b06 100644 --- a/index.php +++ b/index.php @@ -315,9 +315,7 @@ try { require('view/room.php'); } - // TODO use dynamic i18n parameter - // TODO change to no-autoplay query parameter? - else if(preg_match('@^embed/([^/]+)/(hd|sd|audio|slides)/(native|translated|translated2|stereo)(/no-autoplay)?$@', $route, $m)) + else if(preg_match('@^embed/([^/]+)/(hd|sd|audio|slides)/(native|stereo|[^/]+)(/no-autoplay)?$@', $route, $m)) { $_GET = array( 'room' => $m[1], diff --git a/model/Room.php b/model/Room.php index 56dab4c..27a8d97 100644 --- a/model/Room.php +++ b/model/Room.php @@ -337,9 +337,12 @@ class Room throw new NotFoundException('Selection '.$selection.' in Room '.$this->getSlug()); $translation_label = null; - if (substr($language, 0, strlen('native')) !== 'native') { - if (!$this->hasTranslation()) { - throw new NotFoundException('Translated Streams of Room '.$this->getSlug()); + if ($language !== 'native' && $language !== 'stereo') { + if (! $this->hasTranslation()) { + throw new NotFoundException('Translated Streams of Room '. $this->getSlug()); + } + if (! $this->isValidLanguage($language)) { + throw new NotFoundException('Selected translation'); } $translation_label = $this->findTranslationLabel($language); diff --git a/model/Stream.php b/model/Stream.php index a4dcf72..28cb0f8 100644 --- a/model/Stream.php +++ b/model/Stream.php @@ -32,7 +32,9 @@ class Stream public function isTranslated() { - return !empty($this->getLanguage()) && $this->getLanguage() !== 'native'; + return !empty($this->getLanguage()) && + $this->getLanguage() !== 'native' && + $this->getLanguage() !== 'stereo'; } public function getVideoSize() diff --git a/template/assemblies/embed-form.phtml b/template/assemblies/embed-form.phtml index 721d886..020a22f 100644 --- a/template/assemblies/embed-form.phtml +++ b/template/assemblies/embed-form.phtml @@ -20,7 +20,7 @@