aboutsummaryrefslogtreecommitdiff
path: root/lib/program.php
diff options
context:
space:
mode:
authorMaZderMind2014-11-08 11:39:50 +0100
committerMaZderMind2014-11-08 11:39:50 +0100
commit7a1b70bf164358281a701c87ede07205fbb47984 (patch)
treee73a847a47a78a29b3f66c5185f9cb21c68c40f7 /lib/program.php
parent860a084e67a0d189c2b5af8e8c9e2d49c2c5e488 (diff)
test with fiffkon schedule
(and fix problem with broken daystart/dayend)
Diffstat (limited to '')
-rw-r--r--lib/program.php34
1 files changed, 30 insertions, 4 deletions
diff --git a/lib/program.php b/lib/program.php
index c134b8e..b599f9c 100644
--- a/lib/program.php
+++ b/lib/program.php
@@ -2,19 +2,45 @@
function program()
{
- $cacheidx = __FILE__.':'.__FUNCTION__.':program';
+ $cacheidx = __FILE__.':'.__FUNCTION__.':program:'.$GLOBALS['CONFIG']['SCHEDULE'];
if(function_exists('apc_fetch') && $program = apc_fetch($cacheidx))
return $program;
$program = array();
$schedule = simplexml_load_file($GLOBALS['CONFIG']['SCHEDULE']);
+ // re-calculate day-ends
+ // some schedules have long gaps before the first talk or talks that expand beyond the dayend
+ // (fiffkon, i look at you)
+ // so to be on the safer side we calculate our own daystart/end here
+ foreach($schedule->day as $day)
+ {
+ $daystart = PHP_INT_MAX;
+ $dayend = 0;
+
+ foreach($day->room as $room)
+ {
+ foreach($room->event as $event)
+ {
+ $start = strtotime((string)$event->date);
+ $duration = strtoduration((string)$event->duration);
+ $end = $start + $duration;
+
+ $daystart = min($daystart, $start);
+ $dayend = max($dayend, $end);
+ }
+ }
+
+ $day['start'] = $daystart;
+ $day['end'] = $dayend;
+ }
+
$dayidx = 0;
foreach($schedule->day as $day)
{
$dayidx++;
- $daystart = strtotime((string)$day['start']);
- $dayend = strtotime((string)$day['end']);
+ $daystart = (int)$day['start'];
+ $dayend = (int)$day['end'];
$roomidx = 0;
foreach($day->room as $room)
@@ -23,7 +49,7 @@ function program()
$name = (string)$room['name'];
$lastend = false;
- foreach ($room->event as $event)
+ foreach($room->event as $event)
{
$start = strtotime((string)$event->date);
$duration = strtoduration((string)$event->duration);