aboutsummaryrefslogtreecommitdiff
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/Conference.php30
-rw-r--r--model/Conferences.php4
-rw-r--r--model/Relive.php7
-rw-r--r--model/Schedule.php18
4 files changed, 39 insertions, 20 deletions
diff --git a/model/Conference.php b/model/Conference.php
index 07d72dd..8d387a0 100644
--- a/model/Conference.php
+++ b/model/Conference.php
@@ -19,7 +19,7 @@ class Conference extends ModelBase
}
public function isPreviewEnabled() {
- if($GLOBALS['forceopen'])
+ if(@$GLOBALS['forceopen'])
return true;
if($this->has('PREVIEW_DOMAIN') && ($this->get('PREVIEW_DOMAIN') == $_SERVER['SERVER_NAME']))
@@ -32,12 +32,22 @@ class Conference extends ModelBase
return !$this->hasBegun() || $this->hasEnded();
}
+ public function isOpen() {
+ return !$this->isClosed();
+ }
+
public function startsAt() {
- return $this->get('CONFERENCE.STARTS_AT');
+ if(!$this->has('CONFERENCE.STARTS_AT'))
+ return null;
+
+ return DateTime::createFromFormat('U', $this->get('CONFERENCE.STARTS_AT'));
}
public function endsAt() {
- return $this->get('CONFERENCE.ENDS_AT');
+ if(!$this->has('CONFERENCE.ENDS_AT'))
+ return null;
+
+ return DateTime::createFromFormat('U', $this->get('CONFERENCE.ENDS_AT'));
}
public function hasBegun() {
@@ -62,7 +72,8 @@ class Conference extends ModelBase
}
if($this->has('CONFERENCE.STARTS_AT')) {
- return time() >= $this->get('CONFERENCE.STARTS_AT');
+ $now = new DateTime('now');
+ return $now >= $this->startsAt();
} else {
return true;
}
@@ -84,7 +95,8 @@ class Conference extends ModelBase
}
if($this->has('CONFERENCE.ENDS_AT')) {
- return time() >= $this->get('CONFERENCE.ENDS_AT');
+ $now = new DateTime('now');
+ return $now >= $this->endsAt();
} else {
return false;
}
@@ -128,10 +140,10 @@ class Conference extends ModelBase
}
public function hasRelive() {
- return $this->has('CONFERENCE.RELIVE_JSON');
+ return $this->getRelive()->isEnabled();
}
public function getReliveUrl() {
- if($this->has('CONFERENCE.RELIVE_JSON'))
+ if($this->getRelive()->isEnabled())
return joinpath([$this->getSlug(), 'relive']).url_params();
else
@@ -209,4 +221,8 @@ class Conference extends ModelBase
public function getRelive() {
return new Relive($this);
}
+
+ public function getExtraFiles() {
+ return $this->get('EXTRA_FILES', []);
+ }
}
diff --git a/model/Conferences.php b/model/Conferences.php
index 2dc9f35..f930e32 100644
--- a/model/Conferences.php
+++ b/model/Conferences.php
@@ -33,7 +33,7 @@ class Conferences
public static function getActiveConferences() {
return array_values(array_filter(
- Conferences::getConferences(),
+ Conferences::getConferencesSorted(),
function($conference) {
return !$conference->isClosed();
}
@@ -48,7 +48,7 @@ class Conferences
$sorted = Conferences::getConferences();
usort($sorted, function($a, $b) {
- return $b->startsAt() - $a->endsAt();
+ return $b->startsAt() > $a->endsAt() ? 1 : -1;
});
return $sorted;
diff --git a/model/Relive.php b/model/Relive.php
index 7f0e747..542836d 100644
--- a/model/Relive.php
+++ b/model/Relive.php
@@ -24,9 +24,14 @@ class Relive
return $this->getConference()->get('CONFERENCE.RELIVE_JSON');
}
+ public function getJsonCache()
+ {
+ return sprintf('/tmp/relive-cache-%s.json', $this->getConference()->getSlug());
+ }
+
public function getTalks()
{
- if(!file_exists($this->getJsonUrl()))
+ if(!file_exists($this->getJsonCache()))
return array();
$talks = file_get_contents($this->getJsonUrl());
diff --git a/model/Schedule.php b/model/Schedule.php
index eb9fe05..b54709e 100644
--- a/model/Schedule.php
+++ b/model/Schedule.php
@@ -36,17 +36,10 @@ class Schedule
private function fetchSchedule()
{
- $opts = array(
- 'http' => array(
- 'timeout' => 2,
- 'user_agent' => 'C3VOC Universal Streaming-Website Backend @ '.$_SERVER['HTTP_HOST'],
- )
- );
- $context = stream_context_create($opts);
- $schedule = file_get_contents($this->getScheduleUrl(), false, $context);
+ $schedule = file_get_contents($this->getScheduleCache());
if(!$schedule)
- throw new ScheduleException("Error Downloading Schedule from ".$this->getConference()->getScheduleUrl());
+ throw new ScheduleException("Error Loading Schedule from ".$this->getScheduleCache());
return simplexml_load_string($schedule);
}
@@ -265,11 +258,16 @@ class Schedule
return ((int)$parts[0] * 60 + (int)$parts[1]) * 60;
}
- private function getScheduleUrl()
+ public function getScheduleUrl()
{
return $this->getConference()->get('SCHEDULE.URL');
}
+ public function getScheduleCache()
+ {
+ return sprintf('/tmp/schedule-cache-%s.xml', $this->getConference()->getSlug());
+ }
+
public function getScheduleToRoomSlugMapping()
{
$mapping = array();