From 35e7a2b2adad42b077de60d1566c22da62edeb77 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 18 Dec 2016 13:31:34 +0100 Subject: move upcoming & current logic from javascript/ajax into php --- view/overview.php | 18 ++++++++++++++++++ view/schedule-json.php | 13 ------------- 2 files changed, 18 insertions(+), 13 deletions(-) delete mode 100644 view/schedule-json.php (limited to 'view') diff --git a/view/overview.php b/view/overview.php index 93cf007..adc8d5f 100644 --- a/view/overview.php +++ b/view/overview.php @@ -1,8 +1,26 @@ getSchedule(); + +$talksPerRoom = $schedule->getSchedule(); +$now = time() + $schedule->getSimulationOffset(); + +$upcomingTalksPerRoom = array_map(function($talks) use($now) { + return [ + 'current' => array_filter_last($talks, function($talk) use ($now) { + return $talk['start'] < $now && $talk['end'] > $now; + }), + 'next' => array_filter_first($talks, function($talk) use ($now) { + return !isset($talk['special']) && $talk['start'] > $now; + }), + ]; +}, $talksPerRoom); + echo $tpl->render(array( 'page' => 'overview', 'title' => 'Live-Streams', 'overview' => $conference->getOverview(), + + 'upcomingTalksPerRoom' => $upcomingTalksPerRoom, )); diff --git a/view/schedule-json.php b/view/schedule-json.php deleted file mode 100644 index 19346fd..0000000 --- a/view/schedule-json.php +++ /dev/null @@ -1,13 +0,0 @@ -getSchedule(); -if(!$schedule->isEnabled()) - throw new NotFoundException('Schedule is disabled'); - -header('Content-Type: application/json'); - -if($conference->isClosed()) - echo '{}'; - -else - echo json_encode($schedule->getSchedule(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); -- cgit v1.2.3