*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*/
@define('KRONOLITH_BASE', dirname(__FILE__));
require_once KRONOLITH_BASE . '/lib/base.php';
if ($timestamp = (int)Util::getFormData('timestamp')) {
$year = date('Y', $timestamp);
} else {
$year = (int)Util::getFormData('year', date('Y'));
}
$today = mktime(0, 0, 0);
$timestamp = mktime(1, 1, 1, 1, 1, $year);
$prevstamp = mktime(1, 1, 1, 1, 1, $year - 1);
$nextstamp = mktime(1, 1, 1, 1, 1, $year + 1);
$title = strftime('%Y', $timestamp);
$print_view = (bool)Util::getFormData('print');
Horde::addScriptFile('tooltip.js', 'horde', true);
if (!$print_view) {
Horde::addScriptFile('popup.js', 'horde', true);
}
require KRONOLITH_TEMPLATES . '/common-header.inc';
if ($print_view) {
require_once $registry->get('templates', 'horde') . '/javascript/print.js';
} else {
$print_link = Util::addParameter('year.php', array('timestamp' => $timestamp,
'print' => 'true'));
$print_link = Horde::url($print_link);
require KRONOLITH_TEMPLATES . '/menu.inc';
}
$prevurl = Horde::applicationurl(Util::addParameter('year.php', array('year' => date('Y', $prevstamp))));
$nexturl = Horde::applicationUrl(Util::addParameter('year.php', array('year' => date('Y', $nextstamp))));
echo '
';
if (!$print_view) {
Kronolith::tabs();
}
require KRONOLITH_TEMPLATES . '/year/head.inc';
$startDate = &new Horde_Date(array('year' => $year,
'month' => 1,
'mday' => 1));
$endDate = &new Horde_Date(array('year' => $year,
'month' => 12,
'mday' => 31,
'hour' => 23,
'min' => 59,
'sec' => 59));
$startDate->correct();
$endDate->correct();
$allevents = Kronolith::listEvents($startDate, $endDate, $GLOBALS['display_calendars']);
$html = '';
for ($month = 1; $month <= 12; $month++) {
$html .= '
';
// Heading for each month.
$mtitle = strftime('%m', mktime(1, 1, 1, $month, 1, $year));
$html .= ' ';
$html .= '';
if (!$prefs->getValue('week_start_monday')) {
$html .= '| ' . _("Su"). ' | ';
}
$html .= '' . _("Mo") . ' | ';
$html .= '' . _("Tu") . ' | ';
$html .= '' . _("We") . ' | ';
$html .= '' . _("Th") . ' | ';
$html .= '' . _("Fr") . ' | ';
$html .= '' . _("Sa") . ' | ';
if ($prefs->getValue('week_start_monday')) {
$html .= '' . _("Su") . ' | ';
}
$html .= " \n";
$startday = &new Horde_Date(array('mday' => 1,
'month' => $month,
'year' => $year));
$startday = $startday->dayOfWeek();
$daysInView = Date_Calc::weeksInMonth($month, $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_SUNDAY) {
$daysInView -= 7;
}
$endday = &new Horde_Date(array('mday' => Horde_Date::daysInMonth($month, $year),
'month' => $month,
'year' => $year));
$endday = $endday->dayOfWeek();
if ($endday == HORDE_DATE_SUNDAY) {
$daysInView += 7;
}
} else {
if ($startday == HORDE_DATE_SUNDAY) {
$startOfView = -5;
} else {
$startOfView = 2 - $startday;
}
}
$currentCalendars = array(true);
$eventCategories = array();
foreach ($currentCalendars as $id => $cal) {
$cell = 0;
for ($day = $startOfView; $day < $startOfView + $daysInView; $day++) {
$date = &new Horde_Date(array('year' => $year, 'month' => $month, 'mday' => $day));
$daystamp = $date->timestamp();
$date->hour = $prefs->getValue('twentyFour') ? 12 : 6;
$timestamp = $date->timestamp();
$week = $date->weekOfYear();
if ($cell % 7 == 0 && $cell != 0) {
$html .= " \n";
}
if (date('n', $daystamp) != $month) {
$style = 'monthgrid';
} elseif (date('w', $daystamp) == 0 || date('w', $daystamp) == 6) {
$style = 'weekend';
} else {
$style = 'text';
}
/* Set up the link to the day view. */
$url = Horde::applicationUrl('day.php', true);
$url = Util::addParameter($url, array('timestamp' => $daystamp));
if (date('n', $daystamp) != $month) {
$cellday = ' ';
} elseif (!empty($allevents[$daystamp])) {
/* There are events; create a cell with tooltip to list
* them. */
$day_events = '';
foreach ($allevents[$daystamp] as $event) {
$day_events .= date($prefs->getValue('twentyFour') ? 'G:i' : 'g:ia', $event->start->timestamp()) . ' - ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:ia', $event->end->timestamp());
$day_events .= ($event->getLocation()) ? ' (' . $event->getLocation() . ')' : '';
$day_events .= ' ' . $event->getTitle() . "\n";
}
/* Bold the cell if there are events. */
$cellday = '' . Horde::linkTooltip($url, _("View Day"), '', '', '', $day_events) . date('j', $daystamp) . '';
/* Set the background color to distinguish the day */
$style = 'year-event';
} else {
/* No events, plain link to the day. */
$cellday = Horde::linkTooltip($url, _("View Day")) . date('j', $daystamp) . '';
}
if ($today == $daystamp && date('n', $daystamp) == $month) {
$style .= ' today';
}
$html .= '| ';
$html .= $cellday . ' | ';
$cell++;
}
}
$html .= "
|
| \n";
if ($month % 3 == 0 && $month != 12) {
$html .= "\n
";
}
}
echo $html . '
';
require $registry->get('templates', 'horde') . '/common-footer.inc';