public function html()
{
global $prefs;
if (!$this->_parsed) {
$this->parse();
}
$started = false;
$first_row = true;
$addLinks = Kronolith::getDefaultCalendar(Horde_Perms::EDIT) && ($GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') > Kronolith::countEvents());
$showLocation = Kronolith::viewShowLocation();
$showTime = Kronolith::viewShowTime();
require KRONOLITH_TEMPLATES . '/day/head.inc';
if ($this->sidebyside) {
require KRONOLITH_TEMPLATES . '/day/head_side_by_side.inc';
}
echo '<tbody>';
if ($addLinks) {
$newEventUrl = Horde::url('new.php')->add(array('datetime' => sprintf($this->dateString() . '%02d%02d00', $this->slots[0]['hour'], $this->slots[0]['min']), 'allday' => 1, 'url' => $this->link(0, true)))->link(array('title' => _("Create a New Event"))) . _("All day") . '</a>';
} else {
$newEventUrl = _("All day");
}
$row = '<td colspan="' . $this->totalspan . '">';
foreach (array_keys($this->_currentCalendars) as $cid) {
foreach ($this->all_day_events[$cid] as $event) {
$row .= '<div class="kronolith-event"' . $event->getCSSColors() . '>' . $event->getLink($this, true, $this->link(0, true));
if (!$event->isPrivate() && $showLocation) {
$row .= '<span class="event-location">' . htmlspecialchars($event->getLocation()) . '</span>';
}
$row .= '</div>';
}
}
$row .= '</td>';
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;
}
$row = '';
if (!count($this->_currentCalendars)) {
$row .= '<td> </td>';
}
foreach (array_keys($this->_currentCalendars) as $cid) {
$hspan = 0;
foreach ($this->_event_matrix[$cid][$i] as $key) {
$event =& $this->events[$key];
// 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->span[$cid] / $event->overlap;
// Store the indent we're starting this event at
// for future use.
if (!isset($event->indent)) {
$event->indent = $hspan;
}
// 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 cover
// _are_, we only cover the available nodes.
if (!isset($covered[$i][$event->indent])) {
$collision = false;
$available = 0;
for ($y = $event->indent; $y < $span + $event->indent; ++$y) {
if (isset($covered[$i][$y])) {
$collision = true;
break;
}
$available++;
}
if ($collision) {
$span = $available;
}
}
$hspan += $span;
$start = new Horde_Date(array('hour' => floor($i / $this->slotsPerHour), 'min' => $i % $this->slotsPerHour * $this->slotLength, 'month' => $this->month, 'mday' => $this->mday, 'year' => $this->year));
$end_slot = new Horde_Date($start);
$end_slot->min += $this->slotLength;
if ((!$day_hour_force || $i >= $day_hour_start) && $event->start->compareDateTime($start) >= 0 && $event->start->compareDateTime($end_slot) < 0 || $start->compareDateTime($this) == 0 || $day_hour_force && $i == $day_hour_start && $event->start->compareDateTime($start) < 0) {
// 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 < $hspan; ++$y) {
$covered[$x][$y] = true;
}
}
$row .= '<td class="kronolith-event"' . $event->getCSSColors() . 'width="' . round(90 / count($this->_currentCalendars) * ($span / $this->span[$cid])) . '%" ' . 'valign="top" colspan="' . $span . '" rowspan="' . $event->rowspan . '">' . '<div class="kronolith-event-info">';
if ($showTime) {
$row .= '<span class="kronolith-time">' . htmlspecialchars($event->getTimeRange()) . '</span>';
}
$row .= $event->getLink($this, true, $this->link(0, true));
if (!$event->isPrivate() && $showLocation) {
$row .= '<span class="kronolith-location">' . htmlspecialchars($event->getLocation()) . '</span>';
}
$row .= '</div></td>';
}
}
$diff = $this->span[$cid] - $hspan;
if ($diff > 0) {
$row .= '<td colspan="' . $diff . '"> </td>';
}
}
$time = $this->prefHourFormat($this->slots[$i]['hour'], $i % $this->slotsPerHour * $this->slotLength);
if ($addLinks) {
$newEventUrl = Horde::url('new.php')->add(array('datetime' => sprintf($this->dateString() . '%02d%02d00', $this->slots[$i]['hour'], $this->slots[$i]['min']), 'url' => $this->link(0, true)))->link(array('title' => _("Create a New Event"))) . $time . '</a>';
} else {
$newEventUrl = $time;
}
$rows[] = array('row' => $row, 'slot' => $newEventUrl);
}
$template = $GLOBALS['injector']->createInstance('Horde_Template');
$template->set('rows', $rows);
$template->set('show_slots', true, true);
echo $template->fetch(KRONOLITH_TEMPLATES . '/day/rows.html') . '</tbody></table>';
}