aboutsummaryrefslogtreecommitdiff
path: root/model/Relive.php
diff options
context:
space:
mode:
authorMaZderMind2016-12-18 13:34:57 +0100
committerMaZderMind2016-12-18 13:34:57 +0100
commita12d86ec058bc89e6feeda6ec8cfce691269b0a9 (patch)
tree6be1f764a8addd025eb774bcd2039788a4b1873f /model/Relive.php
parent521f0e2e1c94538fdce65a021144180f368364d9 (diff)
parentefd0b59f8ed363e12211894d8892e4d18b198c04 (diff)
Merge branch 'master' into events/33c3
Diffstat (limited to '')
-rw-r--r--model/Relive.php54
1 files changed, 35 insertions, 19 deletions
diff --git a/model/Relive.php b/model/Relive.php
index d0e7522..542836d 100644
--- a/model/Relive.php
+++ b/model/Relive.php
@@ -1,21 +1,37 @@
<?php
-class Relive extends ModelBase
+class Relive
{
+ private $conference;
+
+ public function __construct($conference)
+ {
+ $this->conference = $conference;
+ }
+
+ public function getConference() {
+ return $this->conference;
+ }
+
public function isEnabled()
{
// having CONFERENCE.RELIVE is not enough!
- return $this->has('CONFERENCE.RELIVE_JSON');
+ return $this->getConference()->has('CONFERENCE.RELIVE_JSON');
}
public function getJsonUrl()
{
- return $this->get('CONFERENCE.RELIVE_JSON');
+ 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());
@@ -23,22 +39,22 @@ class Relive extends ModelBase
$mapping = $this->getScheduleToRoomMapping();
- usort($talks, function($a, $b) {
- // first, make sure that live talks are always on top
- if($a['status'] == 'live' && $b['status'] != 'live') {
- return -1;
- } else if($a['status'] != 'live' && $b['status'] == 'live') {
- return 1;
- } else if($a['status'] == 'live' && $b['status'] == 'live') {
- // sort live talks by room
-
- return strcmp($a['room'], $b['room']);
- }
-
- // all other talks get sorted by their name
+ usort($talks, function($a, $b) {
+ // first, make sure that live talks are always on top
+ if($a['status'] == 'live' && $b['status'] != 'live') {
+ return -1;
+ }
+ else if($a['status'] != 'live' && $b['status'] == 'live') {
+ return 1;
+ }
+ else if($a['status'] == 'live' && $b['status'] == 'live') {
+ // sort live talks by room
+ return strcmp($a['room'], $b['room']);
+ }
- return strcmp($a['title'], $b['title']);
- });
+ // all other talks get sorted by their name
+ return strcmp($a['title'], $b['title']);
+ });
$talks_by_id = array();
foreach ($talks as $talk)