public function html() { global $prefs; $html = '<table id="kronolith-view-year" class="kronolith-minical"><tr>'; for ($month = 1; $month <= 12; ++$month) { $html .= '<td>'; // Heading for each month. $date = new Horde_Date(sprintf('%04d%02d01010101', $this->year, $month)); $html .= '<table><thead><tr class="kronolith-minical-nav"><th colspan="7">' . Horde::url('month.php')->add('date', $date->dateString())->link() . $date->strftime('%B') . '</a></th></tr><tr><th class="kronolith-minical-empty"> </th>'; if (!$prefs->getValue('week_start_monday')) { $html .= '<th>' . _("Su") . '</th>'; } $html .= '<th>' . _("Mo") . '</th>' . '<th>' . _("Tu") . '</th>' . '<th>' . _("We") . '</th>' . '<th>' . _("Th") . '</th>' . '<th>' . _("Fr") . '</th>' . '<th>' . _("Sa") . '</th>'; if ($prefs->getValue('week_start_monday')) { $html .= '<th>' . _("Su") . '</th>'; } $html .= '</tr></thead><tbody><tr><td class="kronolith-minical-week">'; $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 .= "</tr>\n<tr><td class=\"kronolith-minical-week\">"; } $html .= (int) $date->weekOfYear() . '</td>'; } 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 = '<strong>' . Horde::linkTooltip($url, _("View Day"), '', '', '', $day_events) . $date->mday . '</a></strong>'; } else { /* No events, plain link to the day. */ $cellday = Horde::linkTooltip($url, _("View Day")) . $date->mday . '</a>'; } if ($date->isToday() && $date->month == $month) { $style .= ' kronolith-today'; } $html .= '<td align="center" class="' . $style . '" height="10" width="5%" valign="top">' . $cellday . '</td>'; ++$cell; } } $html .= '</tr></tbody></table></td>'; if ($month % 3 == 0 && $month != 12) { $html .= '</tr><tr>'; } } echo $html . '</tr></table>'; }
public function html() { global $prefs; $sidebyside = $prefs->getValue('show_shared_side_by_side'); $twentyFour = $prefs->getValue('twentyFour'); $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()); if ($sidebyside) { require KRONOLITH_TEMPLATES . '/month/head_side_by_side.inc'; } else { require KRONOLITH_TEMPLATES . '/month/head.inc'; } $html = ''; if (!$sidebyside && count($this->_currentCalendars)) { $html .= '<tr>'; } $showLocation = Kronolith::viewShowLocation(); $showTime = Kronolith::viewShowTime(); $day_url = Horde::url('day.php'); $this_link = $this->link(0, true); $new_url = Horde::url('new.php')->add('url', $this_link); $new_img = Horde::img('new_small.png', '+'); foreach ($this->_currentCalendars as $id => $cal) { if ($sidebyside) { $html .= '<tr>'; } $cell = 0; for ($day = $this->_startOfView; $day < $this->_startOfView + $this->_daysInView; ++$day) { $date = new Kronolith_Day($this->month, $day, $this->year); $date->hour = $twentyFour ? 12 : 6; $week = $date->weekOfYear(); if ($cell % 7 == 0) { $weeklink = Horde::url('week.php')->add('date', $date->dateString())->link(array('class' => 'kronolith-weeklink')) . ($sidebyside ? sprintf(_("Week %d"), $week) : $week) . '</a>'; if ($sidebyside) { $html .= sprintf('<td class="kronolith-first-col">%s<br />%s</td>', $weeklink, htmlspecialchars(Kronolith::getLabel($cal))); } else { if ($cell != 0) { $html .= "</tr>\n<tr>"; } $html .= '<td class="kronolith-first-col">' . $weeklink . '</td>'; } } if ($date->isToday()) { $style = ' class="kronolith-today"'; } elseif ($date->month != $this->month) { $style = ' class="kronolith-other-month"'; } elseif ($date->dayOfWeek() == 0 || $date->dayOfWeek() == 6) { $style = ' class="kronolith-weekend"'; } else { $style = ''; } $html .= '<td' . $style . '><div class="kronolith-day">'; $html .= $day_url->add('date', $date->dateString())->link() . $date->mday . '</a>'; if ($addLinks) { $new_url->add('date', $date->dateString()); if ($sidebyside) { $new_url->add('calendar', $id); } $html .= $new_url->link(array('title' => _("Create a New Event"), 'class' => 'newEvent')) . $new_img . '</a>'; } $html .= '</div>'; $date_stamp = $date->dateString(); if (!empty($this->_events[$date_stamp])) { foreach ($this->_events[$date_stamp] as $event) { if (!$sidebyside || $event->calendar == $id) { $html .= '<div class="kronolith-event"' . $event->getCSSColors() . '>'; if ($showTime && !$event->isAllDay()) { $html .= '<span class="kronolith-time">' . htmlspecialchars($event->getTimeRange()) . '</span>'; } $html .= $event->getLink($date, true, $this_link); if (!$event->isPrivate() && $showLocation) { $html .= '<span class="kronolith-location">' . htmlspecialchars($event->getLocation()) . '</span>'; } $html .= '</div>'; } } } $html .= "</td>\n"; ++$cell; } if ($sidebyside) { $html .= '</tr>'; } } if (!$sidebyside && count($this->_currentCalendars)) { $html .= '</tr>'; } echo $html . '</tbody></table>'; }