From 50c781da5d24d944081749453961c3e535555b20 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 29 Nov 2006 17:45:02 +0000 Subject: [PATCH] Fix for playlists in the scheduler spanning across day boundaries or even multiple days. Part of #2050. --- .../htmlUI/var/templates/scheduler/day.tpl | 7 +-- .../modules/htmlUI/var/ui_scheduler.class.php | 48 ++++++++++++++----- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/campcaster/src/modules/htmlUI/var/templates/scheduler/day.tpl b/campcaster/src/modules/htmlUI/var/templates/scheduler/day.tpl index d7a80fd6f..33ed850a3 100644 --- a/campcaster/src/modules/htmlUI/var/templates/scheduler/day.tpl +++ b/campcaster/src/modules/htmlUI/var/templates/scheduler/day.tpl @@ -69,9 +69,10 @@ {/if} {if $_entrys[$_hour].span} -
- ... -
+ {assign var="i" value=$_entrys[$_hour].span} +
+     ... {$i.title} ##continued## ... +
{/if} diff --git a/campcaster/src/modules/htmlUI/var/ui_scheduler.class.php b/campcaster/src/modules/htmlUI/var/ui_scheduler.class.php index 94e1b788b..97b235dc6 100644 --- a/campcaster/src/modules/htmlUI/var/ui_scheduler.class.php +++ b/campcaster/src/modules/htmlUI/var/ui_scheduler.class.php @@ -397,17 +397,43 @@ class uiScheduler extends uiCalendar { 'startsyesterday' => $startsYesterday); } - // If the item spans more than one hour - if ( ($endHour - $startHour) > 1) { - for ($i = $startHour + 1; $i < $endHour; $i++) { - $items[$i]['span'][] = - array('id' => $id, - 'scheduleid' => $val['id'], - 'start' => $startTime, - 'end' => $endTime, - 'title' => $title, - 'creator' => $creator, - 'type' => 'Playlist'); + $diffHours = floor(($end - $start)/3600); + // If the item spans three hours or more + if ( $diffHours > 2 ) { + // $skip becomes true if we dont actually have to do + // this section. + $skip = false; + if (strftime('%Y%m%d', $start) === $thisDay) { + // For the edge case of starting at the end of + // today. + if ($startHour == 23) { + $skip = true; + } + $countStart = $startHour + 1; + } else { + $countStart = 0; + } + if (strftime('%Y%m%d', $end) === $thisDay) { + // For the edge case of ending at the beginning + // of today. + if ($endHour == 0) { + $skip = true; + } + $countEnd = $endHour - 1; + } else { + $countEnd = 23; + } + if (!$skip) { + for ($i = $countStart; $i <= $countEnd; $i++) { + $items[$i]['span'] = + array('id' => $id, + 'scheduleid' => $val['id'], + 'start' => $startTime, + 'end' => $endTime, + 'title' => $title, + 'creator' => $creator, + 'type' => 'Playlist'); + } } } }