1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
<?php
/**
* $Horde: kronolith/year.php,v 1.16.2.3 2006/01/01 21:29:02 jan Exp $
*
* Copyright 1999-2006 Chuck Hagenbuch <chuck@horde.org>
*
* 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 '<div id="page">';
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 .= '<td valign="top">';
// Heading for each month.
$mtitle = strftime('%B', mktime(1, 1, 1, $month, 1, $year));
$html .= '<table class="nopadding" cellspacing="0" width="100%"><tr><th class="header">';
$url = Util::addParameter(Horde::applicationUrl('month.php'), array('month' => $month, 'year' => date('Y', $timestamp), 'timestamp' => $timestamp));
$html .= '<a href="' . $url . '">' . $mtitle . '</a></th></tr>';
$html .= '<tr><td class="monthgrid"><table class="nopadding" cellspacing="1" width="100%"><tr>';
if (!$prefs->getValue('week_start_monday')) {
$html .= '<th class="item">' . _("Su"). '</th>';
}
$html .= '<th class="item">' . _("Mo") . '</th>';
$html .= '<th class="item">' . _("Tu") . '</th>';
$html .= '<th class="item">' . _("We") . '</th>';
$html .= '<th class="item">' . _("Th") . '</th>';
$html .= '<th class="item">' . _("Fr") . '</th>';
$html .= '<th class="item">' . _("Sa") . '</th>';
if ($prefs->getValue('week_start_monday')) {
$html .= '<th class="item">' . _("Su") . '</th>';
}
$html .= "</tr>\n<tr>";
$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 .= "</tr>\n<tr>";
}
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 = '<strong>' . Horde::linkTooltip($url, _("View Day"), '', '', '', $day_events) . date('j', $daystamp) . '</a></strong>';
/* 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) . '</a>';
}
if ($today == $daystamp && date('n', $daystamp) == $month) {
$style .= ' today';
}
$html .= '<td align="center" class="' . $style . '" height="10" width="5%" valign="top">';
$html .= $cellday . '</td>';
$cell++;
}
}
$html .= "</tr></table></td></tr></table></td>\n";
if ($month % 3 == 0 && $month != 12) {
$html .= "</tr>\n<tr>";
}
}
echo $html . '</tr></table></div>';
require $registry->get('templates', 'horde') . '/common-footer.inc';
|