';
$event_count = 0;
for ($j = $this->startDay; $j <= $this->endDay; ++$j) {
foreach (array_keys($this->_currentCalendars) as $cid) {
$event_count = max($event_count, count($this->days[$j]->all_day_events[$cid]));
reset($this->days[$j]->all_day_events[$cid]);
}
}
$row = '';
for ($j = $this->startDay; $j <= $this->endDay; ++$j) {
if ($more_timeslots) {
$row .= '' . _("All day") . ' | ';
}
$row .= 'days[$j]->isToday()) {
$row .= ' class="kronolith-today"';
} elseif ($this->days[$j]->dayOfWeek() == 0 ||
$this->days[$j]->dayOfWeek() == 6) {
$row .= ' class="kronolith-weekend"';
}
$row .= '>';
foreach (array_keys($this->days[$j]->currentCalendars) as $cid) {
foreach ($this->days[$j]->all_day_events[$cid] as $event) {
$row .= ' getCSSColors()
. $event->getLink($this->days[$j], true, Horde::signUrl($this->link(0, true)));
if (!$event->isPrivate() && $showLocation) {
$row .= '' . htmlspecialchars($event->getLocation()) . '';
}
$row .= ' ';
}
}
$row .= ' | ';
}
$first_row = !$more_timeslots;
$newEventUrl = _("All day");
require KRONOLITH_TEMPLATES . '/day/all_day.inc';
$day_hour_force = $prefs->getValue('day_hour_force');
$day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->slotsPerHour;
$day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->slotsPerHour;
$rows = array();
$covered = array();
for ($i = 0; $i < $this->slotsPerDay; ++$i) {
if ($i >= $day_hour_end && $i > $this->last) {
break;
}
if ($i < $this->first && $i < $day_hour_start) {
continue;
}
$time = Kronolith_View_Day::prefHourFormat($slots[$i]['hour'], ($i % $this->slotsPerHour) * $this->slotLength);
$row = '';
for ($j = $this->startDay; $j <= $this->endDay; ++$j) {
// Add spacer between days, or timeslots.
if ($more_timeslots && $j != $this->startDay) {
$row .= '' . $time . ' | ';
}
if (!count($this->_currentCalendars)) {
$row .= ' | ';
}
foreach (array_keys($this->_currentCalendars) as $cid) {
// Width (sum of colspans) of events for the current time
// slot.
$hspan = 0;
// $hspan + count of empty TDs in the current timeslot.
$current_indent = 0;
// $current_indent is initialized to the position of the
// first available cell of the day.
for (; isset($covered[$j][$i][$current_indent]); ++$current_indent);
foreach ($this->days[$j]->event_matrix[$cid][$i] as $key) {
$event = &$this->days[$j]->events[$key];
if ($include_all_events || $event->calendar == $cid) {
// Since we've made sure that this event's
// overlap is a factor of the total span,
// we get this event's individual span by
// dividing the total span by this event's
// overlap.
$span = $this->days[$j]->span[$cid] / $event->overlap;
// Store the indent we're starting this event at
// for future use.
if (!isset($event->indent)) {
$event->indent = $current_indent;
}
// If $event->span is set this mean than we
// already calculated the width of the event.
if (!isset($event->span)) {
// If the first node that we would cover is
// already covered, we can assume that table
// rendering will take care of pushing the
// event over. However, if the first node
// _isn't_ covered but any others that we
// would covered _are_, we only cover the
// available nodes.
if (!isset($covered[$j][$i][$event->indent])) {
$collision = false;
$available = 0;
for ($y = $event->indent; $y < ($span + $event->indent); ++$y) {
if (isset($covered[$j][$i][$y])) {
$collision = true;
break;
}
$available++;
}
if ($collision) {
$span = $available;
}
}
// We need to store the computed event span
// because in some cases it might not be
// possible to compute it again (when only the
// first half of the event is in colision).
// ceil() is needed because of some float
// values (bug ?)
$event->span = ceil($span);
}
$hspan += $event->span;
$current_indent += $event->span;
$start = new Horde_Date(array(
'hour' => floor($i / $this->slotsPerHour),
'min' => ($i % $this->slotsPerHour) * $this->slotLength,
'month' => $this->days[$j]->month,
'mday' => $this->days[$j]->mday,
'year' => $this->days[$j]->year));
$slot_end = new Horde_Date($start);
$slot_end->min += $this->slotLength;
if (((!$day_hour_force || $i >= $day_hour_start) &&
$event->start->compareDateTime($start) >= 0 &&
$event->start->compareDateTime($slot_end) < 0 ||
$start->compareDateTime($this->days[$j]) == 0) ||
($day_hour_force &&
$i == $day_hour_start)) {
// Store the nodes that we're covering for
// this event in the coverage graph.
for ($x = $i; $x < ($i + $event->rowspan); ++$x) {
for ($y = $event->indent; $y < $current_indent; ++$y) {
$covered[$j][$x][$y] = true;
}
}
$row .= 'getCSSColors()
. 'valign="top" '
. 'width="' . floor(((90 / count($this->days)) / count($this->_currentCalendars)) * ($span / $this->days[$j]->span[$cid])) . '%" '
. 'colspan="' . $event->span . '" rowspan="' . $event->rowspan . '">'
. ' ';
if ($showTime) {
$row .= '' . htmlspecialchars($event->getTimeRange()) . '';
}
$row .= $event->getLink($this->days[$j], true, Horde::signUrl($this->link(0, true)));
if (!$event->isPrivate() && $showLocation) {
$row .= '' . htmlspecialchars($event->getLocation()) . '';
}
$row .= ' | ';
}
}
}
$diff = $this->days[$j]->span[$cid] - $hspan;
if ($diff > 0) {
$row .= 'days[$j]->isToday()) {
$row .= ' class="kronolith-today"';
} elseif ($this->days[$j]->dayOfWeek() == 0 ||
$this->days[$j]->dayOfWeek() == 6) {
$row .= ' class="kronolith-weekend"';
}
$row .= '> | ';
}
}
}
$rows[] = array('row' => $row, 'slot' => $time);
}
$template = $GLOBALS['injector']->createInstance('Horde_Template');
$template->set('row_height', round(20 / $this->slotsPerHour));
$template->set('rows', $rows);
echo $template->fetch(KRONOLITH_TEMPLATES . '/day/rows.html')
. '';
}
/**
* Parse all events for all of the days that we're handling; then
* run through the results to get the total horizontal span for
* the week, and the latest event of the week.
*/
public function parse()
{
for ($i = $this->startDay; $i <= $this->endDay; ++$i) {
$this->days[$i]->parse();
}
$this->totalspan = 0;
$this->span = array();
for ($i = $this->startDay; $i <= $this->endDay; ++$i) {
$this->totalspan += $this->days[$i]->totalspan;
foreach (array_keys($this->_currentCalendars) as $cid) {
if (isset($this->span[$cid])) {
$this->span[$cid] += $this->days[$i]->span[$cid];
} else {
$this->span[$cid] = $this->days[$i]->span[$cid];
}
}
}
$this->last = 0;
$this->first = $this->slotsPerDay;
for ($i = $this->startDay; $i <= $this->endDay; ++$i) {
if ($this->days[$i]->last > $this->last) {
$this->last = $this->days[$i]->last;
}
if ($this->days[$i]->first < $this->first) {
$this->first = $this->days[$i]->first;
}
}
}
public function getWeek($offset = 0)
{
$week = new Horde_Date($this->startDate);
$week->mday += $offset * 7;
return $week;
}
public function link($offset = 0, $full = false)
{
$week = $this->getWeek($offset);
return Horde::url($this->_controller, $full)
->add('date', $week->dateString());
}
public function getName()
{
return 'Week';
}
}