[kronolith] side by side Day and Week (2)
Jeroen Huinink
j.huinink at wanadoo.nl
Sat Jan 4 20:29:32 PST 2003
Hello Everybody,
This message contains the files related to week. The previous message
contains files related to day. The week files depend on the day files.
If you only install the day files, the week view breaks.
I welcome any suggestions, remarks and comments.
WeekView.diff is the output of cvs diff kronolith\lib\WeekView.php
head.inc replaces kronolith\templates\week\head.inc
head_side_by_side should be added to directory
kronolith\templates\week
I currently implemented the weekview without additional columns
between the individual calendars and with the calendar names in
"control" style. I am not sure whether this is the preferred solution.
Any ideas?
I also feel that in the weekview the amount of information and the
size of the calendar grow very quick. In a previous message I already
mentioned that I felt that the monthtype presentation (showing dayly
information instead of hourly information) might be a better view for
side by side weekview. Any ideas?
Regards,
Jeroen
-------------- next part --------------
<table border="0" cellspacing="0" cellpadding="1" width="100%" class="item0">
<tr class="header">
<td class="header" align="center" colspan="<?php echo $this->totalspan + 3 + count($this->days) ?>">
<?php echo (!$print_view) ? Horde::link($this->link(-1), _("Last week"), 'menuitem') . Horde::img('prev.gif', _("Last week"), 'hspace="2"') . '</a>' : '' ?>
<b><?php echo $this->days[$this->startDay]->getTime($prefs->getValue('date_format')) . ' - ' . $this->days[$this->endDay]->getTime($prefs->getValue('date_format')) ?></b>
<?php echo (!$print_view) ? Horde::link($this->link(1), _("Next week"), 'menuitem') . Horde::img('next.gif', _("Next week"), 'hspace="2"') . '</a>' : '' ?>
</td>
</tr>
<tr class="control">
<td width="1%" align="center" colspan="3" nowrap="nowrap"> </td>
<?php foreach ($this->days as $day): ?>
<td width="1%"> </td>
<td<?php if ($day->isToday()) echo ' class="selected"' ?> width="<?php echo round(90 / count($this->days)) ?>%" colspan="<?php echo $day->_totalspan ?>" align="center" nowrap="nowrap">
<?php if (Auth::getAuth()) : ?>
<?php
if (!$print_view) {
$addurl = Horde::addParameter('addevent.php', 'month=' . $day->month);
$addurl = Horde::addParameter($addurl, 'year=' . $day->year);
$addurl = Horde::addParameter($addurl, 'mday=' . $day->mday);
$addurl = Horde::addParameter($addurl, 'url=' . urlencode(Horde::selfURL(true)));
echo Horde::link(Horde::applicationUrl($addurl), _("Create a New Event"));
echo Horde::img('new.gif', _("Create a New Event"), 'align="left"') . '</a>';
} ?>
<?php endif; ?>
<b><?php echo Horde::link($day->link(), $day->getTime('%A'), 'widget') . $day->getTime('%A, %d.') ?></a></b>
</td>
<?php endforeach; ?>
</tr>
<tr class="control">
<td width="1%" align="center" colspan="3" nowrap="nowrap"> </td>
<?php foreach ($this->days as $day): ?>
<td width="1%"> </td>
<?php foreach ($this->_currentCalendars as $cid => $cal): ?>
<td width="<?php echo floor((90/count($this->days)) / count($this->_currentCalendars)); ?>%" align="center" colspan="<?php echo $day->_span[$cid]; ?>">
<?php echo $cal->getShareName(); ?>
</td>
<?php endforeach; ?>
<?php endforeach; ?>
</tr>
-------------- next part --------------
<table border="0" cellspacing="0" cellpadding="1" width="100%" class="item0">
<tr class="header">
<td class="header" align="center" colspan="<?php echo $this->totalspan + 3 + count($this->days) ?>">
<?php echo (!$print_view) ? Horde::link($this->link(-1), _("Last week"), 'menuitem') . Horde::img('prev.gif', _("Last week"), 'hspace="2"') . '</a>' : '' ?>
<b><?php echo $this->days[$this->startDay]->getTime($prefs->getValue('date_format')) . ' - ' . $this->days[$this->endDay]->getTime($prefs->getValue('date_format')) ?></b>
<?php echo (!$print_view) ? Horde::link($this->link(1), _("Next week"), 'menuitem') . Horde::img('next.gif', _("Next week"), 'hspace="2"') . '</a>' : '' ?>
</td>
</tr>
<tr class="control">
<td width="1%" align="center" colspan="3" nowrap="nowrap"> </td>
<?php foreach ($this->days as $day): ?>
<td width="1%"> </td>
<td<?php if ($day->isToday()) echo ' class="selected"' ?> width="<?php echo round(90 / count($this->days)) ?>%" colspan="<?php echo $day->_totalspan ?>" align="center" nowrap="nowrap">
<?php if (Auth::getAuth()) : ?>
<?php
if (!$print_view) {
$addurl = Horde::addParameter('addevent.php', 'month=' . $day->month);
$addurl = Horde::addParameter($addurl, 'year=' . $day->year);
$addurl = Horde::addParameter($addurl, 'mday=' . $day->mday);
$addurl = Horde::addParameter($addurl, 'url', Horde::selfURL(true));
echo Horde::link(Horde::applicationUrl($addurl), _("Create a New Event"));
echo Horde::img('new.gif', _("Create a New Event"), 'align="left"') . '</a>';
} ?>
<?php endif; ?>
<b><?php echo Horde::link($day->link(), $day->getTime('%A'), 'widget') . $day->getTime('%A, %d.') ?></a></b>
</td>
<?php endforeach; ?>
</tr>
-------------- next part --------------
Index: WeekView.php
===================================================================
RCS file: /repository/kronolith/lib/WeekView.php,v
retrieving revision 1.67
diff -r1.67 WeekView.php
19a20,21
> var $_sidebyside = false;
> var $_currentCalendars = array();
67a70,71
> $this->_sidebyside = $this->days[$this->startDay]->_sidebyside;
> $this->_currentCalendars = $this->days[$this->startDay]->_currentCalendars;
72a77
> $include_all_events = !$prefs->getValue('show_shared_side_by_side');
79,80c84,89
<
< require $template_path . '/week/head.inc';
---
> $cid = 0;
> if ($this->_sidebyside) {
> require $template_path . '/week/head_side_by_side.inc';
> } else {
> require $template_path . '/week/head.inc';
> }
84,85c93,96
< $event_count = max($event_count, count($this->days[$j]->_all_day_events));
< reset($this->days[$j]->_all_day_events);
---
> foreach($this->_currentCalendars as $cid => $cal) {
> $event_count = max($event_count, count($this->days[$j]->_all_day_events[$cid]));
> reset($this->days[$j]->_all_day_events[$cid]);
> }
87d97
<
98,101c108,110
< $row .= '<td colspan="' . $this->days[$j]->_span . '" valign="top" style="padding:0px"><table border="0" width="100%" cellspacing="0" cellpadding="0">';
< if (count($this->days[$j]->_all_day_events) > 0) {
< foreach ($this->days[$j]->_all_day_events as $key => $event) {
< $categoryColor = isset($colors[$event->getCalendar()][$event->getCategory()]) ? $colors[$event->getCalendar()][$event->getCategory()] : '#ccffcc';
---
> $row .= '<td colspan="' . $this->days[$j]->_totalspan . '" valign="top" style="padding:0px"><table border="0" width="100%" cellspacing="0" cellpadding="0">';
> if ($this->days[$j]->_all_day_maxrowspan > 0) {
> for($k = 0; $k < $this->days[$j]->_all_day_maxrowspan; $k++) {
103,109c112,128
< $row .= '<td class="week-eventbox" style="background-color: ' . $categoryColor . '; ';
< $row .= 'border: thin solid ' . Kronolith::borderColor($categoryColor) . '" ';
< $row .= 'onmouseover="javascript:style.backgroundColor=\'' . Horde_Image::modifyColor($categoryColor) . '\'" ';
< $row .= 'onmouseout="javascript:style.backgroundColor=\'' . $categoryColor . '\'" ';
< $row .= 'valign="top">';
< $row .= $event->getLink($this->days[$j]->getStamp());
< $row .= '</td></tr>' . "\n";
---
> foreach ($this->days[$j]->_currentCalendars as $cid => $cal) {
> if (count($this->days[$j]->_all_day_events[$cid]) === $k) {
> $row .= '<td rowspan="' . ($this->days[$j]->_all_day_maxrowspan - $k) . '" width="'. round(99/count($this->days[$j]->_currentCalendars)) . '%"> </td>';
> } elseif (count($this->days[$j]->_all_day_events[$cid]) > $k) {
> $event = $this->days[$j]->_all_day_events[$cid][$k];
> $categoryColor = isset($colors[$event->getCalendar()][$event->getCategory()]) ? $colors[$event->getCalendar()][$event->getCategory()] : '#ccffcc';
> $row .= '<td class="week-eventbox" style="background-color: ' . $categoryColor . '; ';
> $row .= 'border: thin solid ' . Kronolith::borderColor($categoryColor) . '" ';
> $row .= 'onmouseover="javascript:style.backgroundColor=\'' . Horde_Image::modifyColor($categoryColor) . '\'" ';
> $row .= 'onmouseout="javascript:style.backgroundColor=\'' . $categoryColor . '\'" ';
> $row .= 'width="' . round(99/count($this->days[$j]->_currentCalendars)) . '%" ';
> $row .= 'valign="top">';
> $row .= $event->getLink($this->days[$j]->getStamp());
> $row .= '</td>';
> }
> }
> $row .= '</tr>';
112c131
< $row .= '<tr><td colspan="' . $this->days[$j]->_span . '"> </td></tr>';
---
> $row .= '<tr><td colspan="' . count($this->_currentCalendars) . '"> </td></tr>';
117,118c136,137
< require $template_path . '/day/all_day.inc';
<
---
> require $template_path . '/day/all_day.inc';
>
120c139
< $started = false;
---
> $rows = array();
125,132c144,145
< if (!$started && $i < $prefs->getValue('day_hour_start')) {
< $notstarted = true;
< for ($j = $this->startDay; $j <= $this->endDay; $j++) {
< $notstarted &= !count($this->days[$j]->_event_matrix[$i]);
< }
< if ($notstarted) {
< continue;
< }
---
> if ($i < $this->first && $i < $prefs->getValue('day_hour_start')) {
> continue;
135,136d147
< $started = true;
< $row = '';
139a151
> $row = '';
141d152
< $hspan = 0;
146,165c157,185
< foreach ($this->days[$j]->_event_matrix[$i] as $key) {
< $event = $this->days[$j]->_events[$key];
< $start = mktime(floor($i/2), ($i % 2) * 30, 0, $this->days[$j]->month, $this->days[$j]->mday, $this->days[$j]->year);
<
< // 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->days[$j]->_span / $event->overlap;
< $hspan += $span;
<
< $categoryColor = isset($colors[$event->getCalendar()][$event->getCategory()]) ? $colors[$event->getCalendar()][$event->getCategory()] : '#ccccff';
< if ($event->startTimestamp >= $start && $event->startTimestamp < $start + 60 * 30 || $start == $this->days[$j]->getStamp()) {
< $row .= '<td class="week-eventbox" style="background-color: ' . $categoryColor . '; ';
< $row .= 'border: thin solid ' . Kronolith::borderColor($categoryColor) . '" ';
< $row .= 'onmouseover="javascript:style.backgroundColor=\'' . Horde_Image::modifyColor($categoryColor) . '\'" ';
< $row .= 'onmouseout="javascript:style.backgroundColor=\'' . $categoryColor . '\'" ';
< $row .= 'valign="top" width="' . round(90 * ($span / $this->days[$j]->_span / count($this->days))) . '%" colspan="' . $span . '" rowspan="' . $event->rowspan . '">';
< $row .= $event->getLink($this->days[$j]->getStamp());
< $row .= ' </td>' . "\n";
---
> foreach ($this->_currentCalendars as $cid => $cal) {
> $hspan = 0;
> foreach ($this->days[$j]->_event_matrix[$cid][$i] as $key) {
> $event = $this->days[$j]->_events[$key];
> if ($include_all_events || $event->getCalendar() == $cid) {
> $start = mktime(floor($i/2), ($i % 2) * 30, 0, $this->days[$j]->month, $this->days[$j]->mday, $this->days[$j]->year);
>
> // 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->days[$j]->_span[$cid] / $event->overlap;
> $hspan += $span;
>
> $categoryColor = isset($colors[$event->getCalendar()][$event->getCategory()]) ? $colors[$event->getCalendar()][$event->getCategory()] : '#ccccff';
> if ($event->startTimestamp >= $start && $event->startTimestamp < $start + 60 * 30 || $start == $this->days[$j]->getStamp()) {
> $row .= '<td class="week-eventbox" style="background-color: ' . $categoryColor . '; ';
> $row .= 'border: thin solid ' . Kronolith::borderColor($categoryColor) . '" ';
> $row .= 'onmouseover="javascript:style.backgroundColor=\'' . Horde_Image::modifyColor($categoryColor) . '\'" ';
> $row .= 'onmouseout="javascript:style.backgroundColor=\'' . $categoryColor . '\'" ';
> $row .= 'valign="top" ';
> //$row .= 'width="' . round(90 * ($span / $this->days[$j]->_span[$cid] / count($this->days))) . '%" ';
> //$row .= 'width="' . round((90/count($this->_currentCalendars)) * ($span / $this->days[$j]->_span[$cid])) . '%" ';
> $row .= 'width="' . floor(((90/count($this->days)) / count($this->_currentCalendars)) * ($span / $this->days[$j]->_span[$cid])) . '%"';
> $row .= 'colspan="' . $span . '" rowspan="' . $event->rowspan . '">';
> $row .= $event->getLink($this->days[$j]->getStamp());
> $row .= ' </td>';
> }
> }
167,173c187,193
< }
<
< $diff = $this->days[$j]->_span - $hspan;
<
< if ($diff > 0) {
< for ($t = 0; $t < $diff; $t++) {
< $row .= '<td width="' . round(90 * (1 / $this->days[$j]->_span / count($this->days))) . '%" colspan="1" class="' . $style . '"> </td>' . "\n";
---
> $diff = $this->days[$j]->_span[$cid] - $hspan;
>
> if ($diff > 0) {
> for ($t = 0; $t < $diff; $t++) {
> //$row .= '<td width="' . round(90 * ($this->days[$j]->_span[$cid] / $this->days[$j]->_totalspan / count($this->days))) . '%" colspan="1" class="' . $style . '"> </td>';
> $row .= '<td colspan="1" class="' . $style . '"> </td>';
> }
177d196
<
210c229,230
< $this->span = 0;
---
> $this->totalspan = 0;
> $this->span = array();
212c232,239
< $this->span += $this->days[$i]->_span;
---
> $this->totalspan += $this->days[$i]->_totalspan;
> foreach ($this->_currentCalendars as $cid => $key) {
> if (isset($this->span[$cid])) {
> $this->span[$cid] += $this->days[$i]->_span[$cid];
> } else {
> $this->span[$cid] = $this->days[$i]->_span[$cid];
> }
> }
215a243
> $this->first = 48;
218a247,249
> }
> if ($this->days[$i]->first < $this->first) {
> $this->first = $this->days[$i]->first;
More information about the kronolith
mailing list