';
for ($month = 1; $month <= 12; ++$month) {
$html .= '';
// Heading for each month.
$date = new Horde_Date(sprintf('%04d%02d01010101', $this->year, $month));
$html .= ''
. Horde::url('month.php')->add('date', $date->dateString())->link()
. $date->strftime('%B')
. ' |
---|
| ';
if (!$prefs->getValue('week_start_monday')) {
$html .= '' . _("Su"). ' | ';
}
$html .= '' . _("Mo") . ' | ' .
'' . _("Tu") . ' | ' .
'' . _("We") . ' | ' .
'' . _("Th") . ' | ' .
'' . _("Fr") . ' | ' .
'' . _("Sa") . ' | ';
if ($prefs->getValue('week_start_monday')) {
$html .= '' . _("Su") . ' | ';
}
$html .= '
---|
';
$startday = new Horde_Date(array('mday' => 1,
'month' => $month,
'year' => $this->year));
$startday = $startday->dayOfWeek();
$daysInView = Date_Calc::weeksInMonth($month, $this->year) * 7;
if (!$prefs->getValue('week_start_monday')) {
$startOfView = 1 - $startday;
// We may need to adjust the number of days in the
// view if we're starting weeks on Sunday.
if ($startday == Horde_Date::DATE_SUNDAY) {
$daysInView -= 7;
}
$endday = new Horde_Date(array('mday' => Horde_Date_Utils::daysInMonth($month, $this->year),
'month' => $month,
'year' => $this->year));
$endday = $endday->dayOfWeek();
if ($endday == Horde_Date::DATE_SUNDAY) {
$daysInView += 7;
}
} else {
if ($startday == Horde_Date::DATE_SUNDAY) {
$startOfView = -5;
} else {
$startOfView = 2 - $startday;
}
}
$currentCalendars = array(true);
foreach ($currentCalendars as $id => $cal) {
$cell = 0;
for ($day = $startOfView; $day < $startOfView + $daysInView; ++$day) {
$date = new Kronolith_Day($month, $day, $this->year);
$date->hour = $prefs->getValue('twentyFour') ? 12 : 6;
$week = $date->weekOfYear();
if ($cell % 7 == 0) {
if ($cell != 0) {
$html .= " | \n";
}
$html .= (int)$date->weekOfYear() . ' | ';
}
if ($date->month != $month) {
$style = 'kronolith-other-month';
} else {
$style = '';
}
/* Set up the link to the day view. */
$url = Horde::url('day.php', true)
->add('date', $date->dateString());
if ($date->month == $month &&
!empty($this->_events[$date->dateString()])) {
/* There are events; create a cell with tooltip to list
* them. */
$day_events = '';
foreach ($this->_events[$date->dateString()] as $event) {
if ($event->status == Kronolith::STATUS_CONFIRMED) {
/* Set the background color to distinguish the
* day */
$style = 'year-event';
}
if ($event->isAllDay()) {
$day_events .= _("All day");
} else {
$day_events .= $event->start->strftime($prefs->getValue('twentyFour') ? '%R' : '%I:%M%p') . '-' . $event->end->strftime($prefs->getValue('twentyFour') ? '%R' : '%I:%M%p');
}
$day_events .= ':'
. ($event->getLocation() ? ' (' . $event->getLocation() . ')' : '')
. ' ' . $event->getTitle() . "\n";
}
/* Bold the cell if there are events. */
$cellday = '' . Horde::linkTooltip($url, _("View Day"), '', '', '', $day_events) . $date->mday . '';
} else {
/* No events, plain link to the day. */
$cellday = Horde::linkTooltip($url, _("View Day")) . $date->mday . '';
}
if ($date->isToday() && $date->month == $month) {
$style .= ' kronolith-today';
}
$html .= '' .
$cellday . ' | ';
++$cell;
}
}
$html .= '
| ';
if ($month % 3 == 0 && $month != 12) {
$html .= '