aboutsummaryrefslogtreecommitdiff
path: root/model/Room.php
diff options
context:
space:
mode:
authorMaZderMind2015-03-30 16:20:30 +0200
committerMaZderMind2015-03-30 16:20:30 +0200
commitf7d9d592745d1cb5cb2de76ed6ae99be974f1807 (patch)
tree0f9f77efe9efc70b3ac0404a46b249f809197922 /model/Room.php
parentea4b6c7699a7fbb7be3d9e5ce86c84a36b63f569 (diff)
Implement MVT Pattern based on simple Config options
Diffstat (limited to 'model/Room.php')
-rw-r--r--model/Room.php193
1 files changed, 192 insertions, 1 deletions
diff --git a/model/Room.php b/model/Room.php
index c7e51f9..f428d87 100644
--- a/model/Room.php
+++ b/model/Room.php
@@ -35,11 +35,202 @@ class Room extends ModelBase
+ public function hasStereo() {
+ return $this->get('ROOMS.'.$this->getSlug().'.STEREO');
+ }
+
public function hasPreview() {
- return get('ROOMS.'.$this->getSlug().'.PREVIEW');
+ return $this->get('ROOMS.'.$this->getSlug().'.PREVIEW');
}
public function hasSchedule() {
return $this->get('ROOMS.'.$this->getSlug().'.SCHEDULE') && $this->has('SCHEDULE');
}
+
+ public function hasFeedback() {
+ return $this->get('ROOMS.'.$this->getSlug().'.FEEDBACK') && $this->has('FEEDBACK');
+ }
+
+
+ public function hasTwitter() {
+ return $this->get('ROOMS.'.$this->getSlug().'.TWITTER') && $this->has('TWITTER');
+ }
+
+ public function getTwitterDisplay() {
+ return sprintf(
+ $this->get('ROOMS.'.$this->getSlug().'.TWITTER_CONFIG.DISPLAY', $this->get('TWITTER.DISPLAY')),
+ $this->getSlug()
+ );
+ }
+
+ public function getTwitterUrl() {
+ return sprintf(
+ 'https://twitter.com/intent/tweet?text=%s',
+ rawurlencode($this->getTwitterText())
+ );
+ }
+
+ public function getTwitterText() {
+ return sprintf(
+ $this->get('ROOMS.'.$this->getSlug().'.TWITTER_CONFIG.TEXT', $this->get('TWITTER.TEXT')),
+ $this->getSlug()
+ );
+ }
+
+
+ public function hasIrc() {
+ return $this->get('ROOMS.'.$this->getSlug().'.IRC') && $this->has('IRC');
+ }
+
+ public function getIrcDisplay() {
+ return sprintf(
+ $this->get('ROOMS.'.$this->getSlug().'.IRC_CONFIG.DISPLAY', $this->get('IRC.DISPLAY')),
+ $this->getSlug()
+ );
+ }
+
+ public function getIrcUrl() {
+ return sprintf(
+ $this->get('ROOMS.'.$this->getSlug().'.IRC_CONFIG.URL', $this->get('IRC.URL')),
+ rawurlencode($this->getSlug())
+ );
+ }
+
+
+ public function hasChat() {
+ return $this->hasTwitter() || $this->hasIrc();
+ }
+
+
+ public function hasSdVideo() {
+ return $this->get('ROOMS.'.$this->getSlug().'.SD_VIDEO');
+ }
+
+ public function hasHdVideo() {
+ return $this->get('ROOMS.'.$this->getSlug().'.HD_VIDEO');
+ }
+
+ public function hasVideo() {
+ return $this->hasSdVideo() || $this->hasHdVideo();
+ }
+
+ public function hasAudio() {
+ return $this->get('ROOMS.'.$this->getSlug().'.AUDIO');
+ }
+
+ public function hasSlides() {
+ return $this->get('ROOMS.'.$this->getSlug().'.SLIDES');
+ }
+
+ public function hasMusic() {
+ return $this->get('ROOMS.'.$this->getSlug().'.MUSIC');
+ }
+
+ public function hasTranslation() {
+ return $this->get('ROOMS.'.$this->getSlug().'.TRANSLATION');
+ }
+
+ public function getSelectionNames()
+ {
+ $selections = array();
+ if($this->hasHdVideo())
+ $selections[] = 'hd';
+
+ if($this->hasSdVideo())
+ $selections[] = 'sd';
+
+ if($this->hasSlides())
+ $selections[] = 'slides';
+
+ if($this->hasAudio())
+ $selections[] = 'audio';
+
+ if($this->hasMusic())
+ $selections[] = 'music';
+
+ return $selections;
+ }
+
+ public function getTabNames()
+ {
+ $tabs = array();
+ if($this->hasVideo())
+ $tabs[] = 'video';
+
+ if($this->hasSlides())
+ $tabs[] = 'slides';
+
+ if($this->hasAudio())
+ $tabs[] = 'audio';
+
+ if($this->hasMusic())
+ $tabs[] = 'music';
+
+ return $tabs;
+ }
+
+ public function getSelections()
+ {
+ $selections = array();
+ foreach($this->getSelectionNames() as $selection)
+ $selections[$tab] = $this->createSelectionObject($selection);
+
+ return $selections;
+ }
+
+ public function createSelectionObject($selection)
+ {
+ return new RoomSelection($this, $selection);
+ }
+
+ public function getTabs()
+ {
+ $tabs = array();
+ foreach($this->getTabNames() as $tab)
+ $tabs[$tab] = $this->createTabObject($tab);
+
+ return $tabs;
+ }
+
+ public function createTabObject($tab)
+ {
+ return new RoomTab($this, $tab);
+ }
+
+ public function getVideoResolutions()
+ {
+ $res = array();
+ if($this->hasHdVideo())
+ $res[] = 'hd';
+
+ if($this->hasSdVideo())
+ $res[] = 'sd';
+
+ return $res;
+ }
+
+ public function selectStream($selection, $language = 'native')
+ {
+ $selections = $this->getSelectionNames();
+
+ // default page
+ if(!$selection)
+ $selection = $selections[0];
+
+ if(!in_array($selection, $selections))
+ throw new NotFoundException('Selection '.$selection.' in Room '.$this->getSlug());
+
+ if($language == 'translated' && !$this->hasTranslation())
+ throw new NotFoundException('Translated Streams of Room '.$this->getSlug());
+
+ return $this->createStreamObject($selection, $language);
+ }
+
+ public function createStreamObject($selection, $language = 'native')
+ {
+ if($language == 'native' && $this->hasStereo())
+ $language = 'stereo';
+
+ return new Stream($this, $selection, $language);
+ }
}