From be515f5150f20c773371f680efad58f2d0fcaaf0 Mon Sep 17 00:00:00 2001
From: Benjamin Peter
Date: Sat, 9 Dec 2017 23:44:47 +0100
Subject: Added multple translation tracks with configurable endpoints and
labels
---
view/room.php | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
(limited to 'view')
diff --git a/view/room.php b/view/room.php
index d586248..c63f9ec 100644
--- a/view/room.php
+++ b/view/room.php
@@ -1,8 +1,14 @@
getRoom($_GET['room']);
-$stream = $room->selectStream(
- $_GET['selection'], $_GET['language']);
+$selection = $_GET['selection'];
+$language = $_GET['language'];
+
+if (! $room->isValidLanguage($language)) {
+ throw new NotFoundException('Language not found');
+}
+
+$stream = $room->selectStream($selection, $language);
echo $tpl->render(array(
'page' => 'room',
--
cgit v1.3.1
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(-)
(limited to 'view')
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 @@
diff --git a/view/embed.php b/view/embed.php
index eb7caee..aaf203d 100644
--- a/view/embed.php
+++ b/view/embed.php
@@ -1,11 +1,24 @@
getRoom($_GET['room']);
+
if(!$room->hasEmbed())
throw new NotFoundException('Embedding is not enabled in this room');
-$stream = $room->selectStream(
- $_GET['selection'], $_GET['language']);
+$selection = $_GET['selection'];
+$language = $_GET['language'];
+
+if ($language !== 'native' && $language !== 'stereo') {
+ if (! $room->hasTranslation()) {
+ throw new NotFoundException('Not translated');
+ }
+
+ if (! $room->isValidLanguage($language)) {
+ throw new NotFoundException('Language not found');
+ }
+}
+
+$stream = $room->selectStream($selection, $language);
echo $tpl->render(array(
'page' => 'embed',
--
cgit v1.3.1
From 0b73843d5e0d0ac22a46db28090e707566668ae4 Mon Sep 17 00:00:00 2001
From: dedeibel
Date: Mon, 11 Dec 2017 20:03:35 +0100
Subject: Leading Spaces to Tabs
---
model/Room.php | 70 ++++++++++++++++++++++++-------------------------
model/RoomSelection.php | 6 ++---
model/Stream.php | 6 ++---
view/embed.php | 12 ++++-----
view/room.php | 2 +-
5 files changed, 48 insertions(+), 48 deletions(-)
(limited to 'view')
diff --git a/model/Room.php b/model/Room.php
index dd63038..24d87cb 100644
--- a/model/Room.php
+++ b/model/Room.php
@@ -179,35 +179,35 @@ class Room
return $this->getConference()->get('ROOMS.'.$this->getSlug().'.TRANSLATION');
}
- private function getTranslationEndpoints() {
- return array_map(
- function ($translation) {
- return $translation['endpoint'];
- },
- $this->getTranslations()
- );
- }
-
- private function isTranslationEndpoint($endpoint) {
- return in_array($endpoint, $this->getTranslationEndpoints());
- }
-
- private function findTranslationLabel($language) {
- foreach($this->getTranslations() as $translation) {
- if ($translation['endpoint'] === $language) {
- return $translation['label'];
- }
- }
- return null;
- }
+ private function getTranslationEndpoints() {
+ return array_map(
+ function ($translation) {
+ return $translation['endpoint'];
+ },
+ $this->getTranslations()
+ );
+ }
+
+ private function isTranslationEndpoint($endpoint) {
+ return in_array($endpoint, $this->getTranslationEndpoints());
+ }
+
+ private function findTranslationLabel($language) {
+ foreach($this->getTranslations() as $translation) {
+ if ($translation['endpoint'] === $language) {
+ return $translation['label'];
+ }
+ }
+ return null;
+ }
public function hasTranslation() {
return count($this->getTranslations()) > 0;
}
- public function isValidLanguage($language) {
- return ($language === 'native' || $this->isTranslationEndpoint($language));
- }
+ public function isValidLanguage($language) {
+ return ($language === 'native' || $this->isTranslationEndpoint($language));
+ }
public function getSelectionNames()
{
@@ -343,17 +343,17 @@ class Room
if(!in_array($selection, $selections))
throw new NotFoundException('Selection '.$selection.' in Room '.$this->getSlug());
- $translation_label = null;
- 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);
- }
+ $translation_label = null;
+ 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);
+ }
return $this->createStreamObject($selection, $language, $translation_label);
}
diff --git a/model/RoomSelection.php b/model/RoomSelection.php
index a83b5c6..c21ea7e 100644
--- a/model/RoomSelection.php
+++ b/model/RoomSelection.php
@@ -18,15 +18,15 @@ class RoomSelection
return $this->selection;
}
- private function getSelectionPath() {
+ private function getSelectionPath() {
$path = [$this->getRoom()->getConference()->getSlug(), $this->getRoom()->getSlug()];
$selection = $this->getRoom()->getSelectionNames();
if ($selection[0] != $this->getSelection())
$path[] = $this->getSelection();
- return joinpath($path);
- }
+ return joinpath($path);
+ }
public function getLink()
{
diff --git a/model/Stream.php b/model/Stream.php
index 28cb0f8..99abaf1 100644
--- a/model/Stream.php
+++ b/model/Stream.php
@@ -32,9 +32,9 @@ class Stream
public function isTranslated()
{
- return !empty($this->getLanguage()) &&
- $this->getLanguage() !== 'native' &&
- $this->getLanguage() !== 'stereo';
+ return !empty($this->getLanguage()) &&
+ $this->getLanguage() !== 'native' &&
+ $this->getLanguage() !== 'stereo';
}
public function getVideoSize()
diff --git a/view/embed.php b/view/embed.php
index aaf203d..97df148 100644
--- a/view/embed.php
+++ b/view/embed.php
@@ -9,13 +9,13 @@ $selection = $_GET['selection'];
$language = $_GET['language'];
if ($language !== 'native' && $language !== 'stereo') {
- if (! $room->hasTranslation()) {
- throw new NotFoundException('Not translated');
- }
+ if (! $room->hasTranslation()) {
+ throw new NotFoundException('Not translated');
+ }
- if (! $room->isValidLanguage($language)) {
- throw new NotFoundException('Language not found');
- }
+ if (! $room->isValidLanguage($language)) {
+ throw new NotFoundException('Language not found');
+ }
}
$stream = $room->selectStream($selection, $language);
diff --git a/view/room.php b/view/room.php
index c63f9ec..d035219 100644
--- a/view/room.php
+++ b/view/room.php
@@ -5,7 +5,7 @@ $selection = $_GET['selection'];
$language = $_GET['language'];
if (! $room->isValidLanguage($language)) {
- throw new NotFoundException('Language not found');
+ throw new NotFoundException('Language not found');
}
$stream = $room->selectStream($selection, $language);
--
cgit v1.3.1