aboutsummaryrefslogtreecommitdiff
path: root/model
diff options
context:
space:
mode:
authorMaZderMind2015-03-15 19:13:25 +0100
committerMaZderMind2015-03-29 21:42:01 +0200
commitea4b6c7699a7fbb7be3d9e5ce86c84a36b63f569 (patch)
treec919029a8b12e43c363b898a1ff9f7adf5c3312b /model
parent97fe6bf0af2989abbaaba138df3c54c4e55af3c9 (diff)
Move get/set-Calls into ModelBase and abstract all access into a Model
Conflicts: model/Overview.php model/Room.php model/StreamList.php tests/ModelTestbase.php
Diffstat (limited to 'model')
-rw-r--r--model/Conference.php70
-rw-r--r--model/Feedback.php11
-rw-r--r--model/ModelBase.php42
-rw-r--r--model/Overview.php31
-rw-r--r--model/Room.php10
-rw-r--r--model/Schedule.php8
-rw-r--r--model/StreamList.php28
7 files changed, 165 insertions, 35 deletions
diff --git a/model/Conference.php b/model/Conference.php
new file mode 100644
index 0000000..6753c0c
--- /dev/null
+++ b/model/Conference.php
@@ -0,0 +1,70 @@
+<?php
+
+class Conference extends ModelBase
+{
+ public function getTitle() {
+ return $this->get('CONFERENCE.TITLE', 'C3Voc Streaming');
+ }
+
+ public function hasAuthor() {
+ return $this->has('CONFERENCE.AUTHOR');
+ }
+ public function getAuthor() {
+ return $this->get('CONFERENCE.AUTHOR', '');
+ }
+
+ public function hasDescription() {
+ return $this->has('CONFERENCE.DESCRIPTION');
+ }
+ public function getDescription() {
+ return $this->get('CONFERENCE.DESCRIPTION', '');
+ }
+
+ public function hasKeywords() {
+ return $this->has('CONFERENCE.KEYWORDS');
+ }
+ public function getKeywords() {
+ return $this->get('CONFERENCE.KEYWORDS', '');
+ }
+
+
+
+ public function hasReleases() {
+ return $this->has('CONFERENCE.RELEASES');
+ }
+ public function getReleasesUrl() {
+ return $this->get('CONFERENCE.RELEASES');
+ }
+
+ public function hasRelive() {
+ return $this->has('CONFERENCE.RELIVE') || $this->has('CONFERENCE.RELIVE_JSON');
+ }
+ public function getReliveUrl() {
+ if($this->has('CONFERENCE.RELIVE'))
+ return $this->get('CONFERENCE.RELIVE');
+
+ elseif($this->has('CONFERENCE.RELIVE_JSON'))
+ return 'relive/';
+
+ else
+ return null;
+ }
+
+ public function hasBannerHtml() {
+ return $this->has('CONFERENCE.BANNER_HTML');
+ }
+ public function getBannerHtml() {
+ return $this->get('CONFERENCE.BANNER_HTML');
+ }
+
+ public function hasFooterHtml() {
+ return $this->has('CONFERENCE.FOOTER_HTML');
+ }
+ public function getFooterHtml() {
+ return $this->get('CONFERENCE.FOOTER_HTML');
+ }
+
+ public function getAboutUrl() {
+ return 'about/';
+ }
+}
diff --git a/model/Feedback.php b/model/Feedback.php
new file mode 100644
index 0000000..86ef886
--- /dev/null
+++ b/model/Feedback.php
@@ -0,0 +1,11 @@
+<?php
+
+class Feedback extends ModelBase
+{
+ public function isEnabled() {
+ return $this->has('FEEDBACK');
+ }
+ public function getUrl() {
+ return 'feedback/';
+ }
+}
diff --git a/model/ModelBase.php b/model/ModelBase.php
new file mode 100644
index 0000000..1ee41b4
--- /dev/null
+++ b/model/ModelBase.php
@@ -0,0 +1,42 @@
+<?php
+
+class Modelbase
+{
+ protected function has($keychain)
+ {
+ return $this->_has($GLOBALS['CONFIG'], $keychain);
+ }
+ private function _has($array, $keychain)
+ {
+ if(!is_array($keychain))
+ $keychain = explode('.', $keychain);
+
+ $key = $keychain[0];
+ if(!isset($array[$key]))
+ return false;
+
+ if(count($keychain) == 1)
+ return true;
+
+ return $this->_has($array[$key], array_slice($keychain, 1));
+ }
+
+ protected function get($keychain, $default = null)
+ {
+ return $this->_get($GLOBALS['CONFIG'], $keychain, $default);
+ }
+ private function _get($array, $keychain, $default)
+ {
+ if(!is_array($keychain))
+ $keychain = explode('.', $keychain);
+
+ $key = $keychain[0];
+ if(!isset($array[$key]))
+ return $default;
+
+ if(count($keychain) == 1)
+ return $array[$key];
+
+ return $this->_get($array[$key], array_slice($keychain, 1), $default);
+ }
+}
diff --git a/model/Overview.php b/model/Overview.php
index 10507cc..f02f9f2 100644
--- a/model/Overview.php
+++ b/model/Overview.php
@@ -1,13 +1,11 @@
<?php
-require_once('model/Room.php');
-
-class Overview
+class Overview extends ModelBase
{
public function getGroups() {
$groups = array();
- foreach(get('OVERVIEW.GROUPS') as $group => $rooms)
+ foreach($this->get('OVERVIEW.GROUPS') as $group => $rooms)
{
foreach($rooms as $room)
{
@@ -24,29 +22,4 @@ class Overview
return $groups;
}
-
- public function getReleasesUrl() {
- return get('OVERVIEW.RELEASES');
- }
-
- public function getReliveUrl() {
- if(has('OVERVIEW.RELIVE'))
- return get('OVERVIEW.RELIVE');
-
- elseif(has('OVERVIEW.RELIVE_JSON'))
- return 'relive/';
-
- else
- return null;
- }
-
-
-
- public function hasRelive() {
- return has('OVERVIEW.RELIVE') || has('OVERVIEW.RELIVE_JSON');
- }
-
- public function hasReleases() {
- return has('OVERVIEW.RELEASES');
- }
}
diff --git a/model/Room.php b/model/Room.php
index fc1b40d..c7e51f9 100644
--- a/model/Room.php
+++ b/model/Room.php
@@ -1,12 +1,12 @@
<?php
-class Room
+class Room extends ModelBase
{
private $slug;
public function __construct($slug)
{
- if(! has('ROOMS.'.$slug))
+ if(! $this->has('ROOMS.'.$slug))
throw new NotFoundException('Room '.$slug);
$this->slug = $slug;
@@ -26,11 +26,11 @@ class Room
}
public function getStream() {
- return get('ROOMS.'.$this->getSlug().'.STREAM', $this->getSlug());
+ return $this->get('ROOMS.'.$this->getSlug().'.STREAM', $this->getSlug());
}
public function getDisplay() {
- return get('ROOMS.'.$this->getSlug().'.DISPLAY', $this->getSlug());
+ return $this->get('ROOMS.'.$this->getSlug().'.DISPLAY', $this->getSlug());
}
@@ -40,6 +40,6 @@ class Room
}
public function hasSchedule() {
- return get('ROOMS.'.$this->getSlug().'.SCHEDULE') && has('SCHEDULE');
+ return $this->get('ROOMS.'.$this->getSlug().'.SCHEDULE') && $this->has('SCHEDULE');
}
}
diff --git a/model/Schedule.php b/model/Schedule.php
new file mode 100644
index 0000000..db940ce
--- /dev/null
+++ b/model/Schedule.php
@@ -0,0 +1,8 @@
+<?php
+
+class Schedule extends ModelBase
+{
+ public function getSimulationOffset() {
+ return $this->get('SCHEDULE.SIMULATE_OFFSET', 0);
+ }
+}
diff --git a/model/StreamList.php b/model/StreamList.php
index 531a787..d203a52 100644
--- a/model/StreamList.php
+++ b/model/StreamList.php
@@ -1,9 +1,35 @@
<?php
-class StreamList implements AggregateIterator
+class StreamList extends ModelBase implements IteratorAggregate
{
private $streams = array();
+ public function __construct($slug)
+ {
+ if(! $this->has('ROOMS.'.$slug))
+ throw new NotFoundException('Room '.$slug);
+
+ $this->slug = $slug;
+ $this->streams = array();
+
+ $streams = $this->get("ROOMS.$slug.STREAMS");
+ foreach((array)$streams as $stream) {
+ $this->streams[$stream] = explode('-', $stream);
+ }
+ }
+
+ public function getRoomSlug() {
+ return $this->slug;
+ }
+
+ public function getRoom() {
+ return new Room($this->getRoomSlug());
+ }
+
+ public function getStreams() {
+ return array_keys($this->streams);
+ }
+
public function getIterator() {
return new ArrayIterator($this->streams);
}