From 8beec6fda376b842a9ddb7a2425829690f0a8b48 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 11 Dec 2016 20:27:35 +0100 Subject: use DateTime objects for ends/startsAt --- model/Conference.php | 16 ++++++++++++---- model/Conferences.php | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'model') diff --git a/model/Conference.php b/model/Conference.php index 07d72dd..ae5ab41 100644 --- a/model/Conference.php +++ b/model/Conference.php @@ -33,11 +33,17 @@ class Conference extends ModelBase } 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 +68,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 +91,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; } diff --git a/model/Conferences.php b/model/Conferences.php index 2dc9f35..8de4029 100644 --- a/model/Conferences.php +++ b/model/Conferences.php @@ -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; -- cgit v1.2.3 From 4c9cc1f8e6bcb8c68e5106437fcb41bbbc380885 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 11 Dec 2016 20:27:58 +0100 Subject: list conferences sorted on startpage --- model/Conferences.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'model') diff --git a/model/Conferences.php b/model/Conferences.php index 8de4029..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(); } -- cgit v1.2.3 From 6e0f7423769174b83d6b5618db7c33d54967099a Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 11 Dec 2016 21:17:30 +0100 Subject: download files of forced-open conferences --- model/Conference.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'model') diff --git a/model/Conference.php b/model/Conference.php index ae5ab41..be62fdb 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,6 +32,10 @@ class Conference extends ModelBase return !$this->hasBegun() || $this->hasEnded(); } + public function isOpen() { + return !$this->isClosed(); + } + public function startsAt() { if(!$this->has('CONFERENCE.STARTS_AT')) return null; -- cgit v1.2.3 From 284878f0f9917b55359cd464b86508cacc472653 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 11 Dec 2016 21:46:01 +0100 Subject: add cache-file getters and download preparations --- model/Conference.php | 4 ++++ model/Relive.php | 5 +++++ model/Schedule.php | 7 ++++++- 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'model') diff --git a/model/Conference.php b/model/Conference.php index be62fdb..6c14746 100644 --- a/model/Conference.php +++ b/model/Conference.php @@ -221,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/Relive.php b/model/Relive.php index 7f0e747..5676b62 100644 --- a/model/Relive.php +++ b/model/Relive.php @@ -24,6 +24,11 @@ class Relive return $this->getConference()->get('CONFERENCE.RELIVE_JSON'); } + public function getJsonCache() + { + return sprintf('/tmp/relive-cache-%s', $this->getConference()->getSlug()); + } + public function getTalks() { if(!file_exists($this->getJsonUrl())) diff --git a/model/Schedule.php b/model/Schedule.php index eb9fe05..4032ecb 100644 --- a/model/Schedule.php +++ b/model/Schedule.php @@ -265,11 +265,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', $this->getConference()->getSlug()); + } + public function getScheduleToRoomSlugMapping() { $mapping = array(); -- cgit v1.2.3 From 9c7bccc3f2cc226cd5043752403e4c5d39c8b5b5 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 11 Dec 2016 21:46:54 +0100 Subject: access relive config through relive-model --- model/Conference.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'model') diff --git a/model/Conference.php b/model/Conference.php index 6c14746..8d387a0 100644 --- a/model/Conference.php +++ b/model/Conference.php @@ -140,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 -- cgit v1.2.3 From 3384e963da66e9089b71c546750c8981be8c6ed8 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sat, 17 Dec 2016 14:11:47 +0100 Subject: change storage paths according to issue description --- model/Relive.php | 2 +- model/Schedule.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'model') diff --git a/model/Relive.php b/model/Relive.php index 5676b62..1e8266a 100644 --- a/model/Relive.php +++ b/model/Relive.php @@ -26,7 +26,7 @@ class Relive public function getJsonCache() { - return sprintf('/tmp/relive-cache-%s', $this->getConference()->getSlug()); + return sprintf('/tmp/relive-cache-%s.json', $this->getConference()->getSlug()); } public function getTalks() diff --git a/model/Schedule.php b/model/Schedule.php index 4032ecb..6536864 100644 --- a/model/Schedule.php +++ b/model/Schedule.php @@ -272,7 +272,7 @@ class Schedule public function getScheduleCache() { - return sprintf('/tmp/schedule-cache-%s', $this->getConference()->getSlug()); + return sprintf('/tmp/schedule-cache-%s.xml', $this->getConference()->getSlug()); } public function getScheduleToRoomSlugMapping() -- cgit v1.2.3 From da739f3b60a30d5dd5c7877742f8b5c292f25f46 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 18 Dec 2016 10:37:10 +0100 Subject: use the new cache-files for viewing --- model/Relive.php | 2 +- model/Schedule.php | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'model') diff --git a/model/Relive.php b/model/Relive.php index 1e8266a..542836d 100644 --- a/model/Relive.php +++ b/model/Relive.php @@ -31,7 +31,7 @@ class Relive 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 6536864..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); } -- cgit v1.2.3