viewShowLocation() public static method

Should we show event location, based on the show_location pref?
public static viewShowLocation ( )
Esempio n. 1
0
 public function html()
 {
     global $prefs;
     if (!$this->_parsed) {
         $this->parse();
     }
     $started = false;
     $first_row = true;
     $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());
     $showLocation = Kronolith::viewShowLocation();
     $showTime = Kronolith::viewShowTime();
     require KRONOLITH_TEMPLATES . '/day/head.inc';
     if ($this->sidebyside) {
         require KRONOLITH_TEMPLATES . '/day/head_side_by_side.inc';
     }
     echo '<tbody>';
     if ($addLinks) {
         $newEventUrl = Horde::url('new.php')->add(array('datetime' => sprintf($this->dateString() . '%02d%02d00', $this->slots[0]['hour'], $this->slots[0]['min']), 'allday' => 1, 'url' => $this->link(0, true)))->link(array('title' => _("Create a New Event"))) . _("All day") . '</a>';
     } else {
         $newEventUrl = _("All day");
     }
     $row = '<td colspan="' . $this->totalspan . '">';
     foreach (array_keys($this->_currentCalendars) as $cid) {
         foreach ($this->all_day_events[$cid] as $event) {
             $row .= '<div class="kronolith-event"' . $event->getCSSColors() . '>' . $event->getLink($this, true, $this->link(0, true));
             if (!$event->isPrivate() && $showLocation) {
                 $row .= '<span class="event-location">' . htmlspecialchars($event->getLocation()) . '</span>';
             }
             $row .= '</div>';
         }
     }
     $row .= '</td>';
     require KRONOLITH_TEMPLATES . '/day/all_day.inc';
     $day_hour_force = $prefs->getValue('day_hour_force');
     $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->slotsPerHour;
     $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->slotsPerHour;
     $rows = array();
     $covered = array();
     for ($i = 0; $i < $this->slotsPerDay; ++$i) {
         if ($i >= $day_hour_end && $i > $this->_last) {
             break;
         }
         if ($i < $this->_first && $i < $day_hour_start) {
             continue;
         }
         $row = '';
         if (!count($this->_currentCalendars)) {
             $row .= '<td>&nbsp;</td>';
         }
         foreach (array_keys($this->_currentCalendars) as $cid) {
             $hspan = 0;
             foreach ($this->_event_matrix[$cid][$i] as $key) {
                 $event =& $this->events[$key];
                 // 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->span[$cid] / $event->overlap;
                 // Store the indent we're starting this event at
                 // for future use.
                 if (!isset($event->indent)) {
                     $event->indent = $hspan;
                 }
                 // If the first node that we would cover is
                 // already covered, we can assume that table
                 // rendering will take care of pushing the event
                 // over. However, if the first node _isn't_
                 // covered but any others that we would cover
                 // _are_, we only cover the available nodes.
                 if (!isset($covered[$i][$event->indent])) {
                     $collision = false;
                     $available = 0;
                     for ($y = $event->indent; $y < $span + $event->indent; ++$y) {
                         if (isset($covered[$i][$y])) {
                             $collision = true;
                             break;
                         }
                         $available++;
                     }
                     if ($collision) {
                         $span = $available;
                     }
                 }
                 $hspan += $span;
                 $start = new Horde_Date(array('hour' => floor($i / $this->slotsPerHour), 'min' => $i % $this->slotsPerHour * $this->slotLength, 'month' => $this->month, 'mday' => $this->mday, 'year' => $this->year));
                 $end_slot = new Horde_Date($start);
                 $end_slot->min += $this->slotLength;
                 if ((!$day_hour_force || $i >= $day_hour_start) && $event->start->compareDateTime($start) >= 0 && $event->start->compareDateTime($end_slot) < 0 || $start->compareDateTime($this) == 0 || $day_hour_force && $i == $day_hour_start && $event->start->compareDateTime($start) < 0) {
                     // Store the nodes that we're covering for
                     // this event in the coverage graph.
                     for ($x = $i; $x < $i + $event->rowspan; ++$x) {
                         for ($y = $event->indent; $y < $hspan; ++$y) {
                             $covered[$x][$y] = true;
                         }
                     }
                     $row .= '<td class="kronolith-event"' . $event->getCSSColors() . 'width="' . round(90 / count($this->_currentCalendars) * ($span / $this->span[$cid])) . '%" ' . 'valign="top" colspan="' . $span . '" rowspan="' . $event->rowspan . '">' . '<div class="kronolith-event-info">';
                     if ($showTime) {
                         $row .= '<span class="kronolith-time">' . htmlspecialchars($event->getTimeRange()) . '</span>';
                     }
                     $row .= $event->getLink($this, true, $this->link(0, true));
                     if (!$event->isPrivate() && $showLocation) {
                         $row .= '<span class="kronolith-location">' . htmlspecialchars($event->getLocation()) . '</span>';
                     }
                     $row .= '</div></td>';
                 }
             }
             $diff = $this->span[$cid] - $hspan;
             if ($diff > 0) {
                 $row .= '<td colspan="' . $diff . '">&nbsp;</td>';
             }
         }
         $time = $this->prefHourFormat($this->slots[$i]['hour'], $i % $this->slotsPerHour * $this->slotLength);
         if ($addLinks) {
             $newEventUrl = Horde::url('new.php')->add(array('datetime' => sprintf($this->dateString() . '%02d%02d00', $this->slots[$i]['hour'], $this->slots[$i]['min']), 'url' => $this->link(0, true)))->link(array('title' => _("Create a New Event"))) . $time . '</a>';
         } else {
             $newEventUrl = $time;
         }
         $rows[] = array('row' => $row, 'slot' => $newEventUrl);
     }
     $template = $GLOBALS['injector']->createInstance('Horde_Template');
     $template->set('rows', $rows);
     $template->set('show_slots', true, true);
     echo $template->fetch(KRONOLITH_TEMPLATES . '/day/rows.html') . '</tbody></table>';
 }
Esempio n. 2
0
 public function html()
 {
     global $prefs;
     $more_timeslots = $prefs->getValue('time_between_days');
     $include_all_events = !$prefs->getValue('show_shared_side_by_side');
     $showLocation = Kronolith::viewShowLocation();
     $showTime = Kronolith::viewShowTime();
     if (!$this->parsed) {
         $this->parse();
     }
     $slots = $this->days[$this->startDay]->slots;
     $cid = 0;
     require KRONOLITH_TEMPLATES . '/week/head.inc';
     if ($this->sidebyside) {
         require KRONOLITH_TEMPLATES . '/week/head_side_by_side.inc';
     }
     echo '</thead><tbody>';
     $event_count = 0;
     for ($j = $this->startDay; $j <= $this->endDay; ++$j) {
         foreach (array_keys($this->_currentCalendars) as $cid) {
             $event_count = max($event_count, count($this->days[$j]->all_day_events[$cid]));
             reset($this->days[$j]->all_day_events[$cid]);
         }
     }
     $row = '';
     for ($j = $this->startDay; $j <= $this->endDay; ++$j) {
         if ($more_timeslots) {
             $row .= '<td class="kronolith-first-col"><span>' . _("All day") . '</span></td>';
         }
         $row .= '<td colspan="' . $this->days[$j]->totalspan . '" valign="top"';
         if ($this->days[$j]->isToday()) {
             $row .= ' class="kronolith-today"';
         } elseif ($this->days[$j]->dayOfWeek() == 0 || $this->days[$j]->dayOfWeek() == 6) {
             $row .= ' class="kronolith-weekend"';
         }
         $row .= '>';
         foreach (array_keys($this->days[$j]->currentCalendars) as $cid) {
             foreach ($this->days[$j]->all_day_events[$cid] as $event) {
                 $row .= '<div class="kronolith-event"' . $event->getCSSColors() . $event->getLink($this->days[$j], true, $this->link(0, true));
                 if (!$event->isPrivate() && $showLocation) {
                     $row .= '<span class="kronolith-location">' . htmlspecialchars($event->getLocation()) . '</span>';
                 }
                 $row .= '</div>';
             }
         }
         $row .= '</td>';
     }
     $first_row = !$more_timeslots;
     $newEventUrl = _("All day");
     require KRONOLITH_TEMPLATES . '/day/all_day.inc';
     $day_hour_force = $prefs->getValue('day_hour_force');
     $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->slotsPerHour;
     $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->slotsPerHour;
     $rows = array();
     $covered = array();
     for ($i = 0; $i < $this->slotsPerDay; ++$i) {
         if ($i >= $day_hour_end && $i > $this->last) {
             break;
         }
         if ($i < $this->first && $i < $day_hour_start) {
             continue;
         }
         $time = Kronolith_View_Day::prefHourFormat($slots[$i]['hour'], $i % $this->slotsPerHour * $this->slotLength);
         $row = '';
         for ($j = $this->startDay; $j <= $this->endDay; ++$j) {
             // Add spacer between days, or timeslots.
             if ($more_timeslots && $j != $this->startDay) {
                 $row .= '<td class="kronolith-first-col"><span>' . $time . '</span></td>';
             }
             if (!count($this->_currentCalendars)) {
                 $row .= '<td>&nbsp;</td>';
             }
             foreach (array_keys($this->_currentCalendars) as $cid) {
                 // Width (sum of colspans) of events for the current time
                 // slot.
                 $hspan = 0;
                 // $hspan + count of empty TDs in the current timeslot.
                 $current_indent = 0;
                 // $current_indent is initialized to the position of the
                 // first available cell of the day.
                 for (; isset($covered[$j][$i][$current_indent]); ++$current_indent) {
                 }
                 foreach ($this->days[$j]->event_matrix[$cid][$i] as $key) {
                     $event =& $this->days[$j]->events[$key];
                     if ($include_all_events || $event->calendar == $cid) {
                         // 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;
                         // Store the indent we're starting this event at
                         // for future use.
                         if (!isset($event->indent)) {
                             $event->indent = $current_indent;
                         }
                         // If $event->span is set this mean than we
                         // already calculated the width of the event.
                         if (!isset($event->span)) {
                             // If the first node that we would cover is
                             // already covered, we can assume that table
                             // rendering will take care of pushing the
                             // event over. However, if the first node
                             // _isn't_ covered but any others that we
                             // would covered _are_, we only cover the
                             // available nodes.
                             if (!isset($covered[$j][$i][$event->indent])) {
                                 $collision = false;
                                 $available = 0;
                                 for ($y = $event->indent; $y < $span + $event->indent; ++$y) {
                                     if (isset($covered[$j][$i][$y])) {
                                         $collision = true;
                                         break;
                                     }
                                     $available++;
                                 }
                                 if ($collision) {
                                     $span = $available;
                                 }
                             }
                             // We need to store the computed event span
                             // because in some cases it might not be
                             // possible to compute it again (when only the
                             // first half of the event is in colision).
                             // ceil() is needed because of some float
                             // values (bug ?)
                             $event->span = ceil($span);
                         }
                         $hspan += $event->span;
                         $current_indent += $event->span;
                         $start = new Horde_Date(array('hour' => floor($i / $this->slotsPerHour), 'min' => $i % $this->slotsPerHour * $this->slotLength, 'month' => $this->days[$j]->month, 'mday' => $this->days[$j]->mday, 'year' => $this->days[$j]->year));
                         $slot_end = new Horde_Date($start);
                         $slot_end->min += $this->slotLength;
                         if ((!$day_hour_force || $i >= $day_hour_start) && $event->start->compareDateTime($start) >= 0 && $event->start->compareDateTime($slot_end) < 0 || $start->compareDateTime($this->days[$j]) == 0 || $day_hour_force && $i == $day_hour_start) {
                             // Store the nodes that we're covering for
                             // this event in the coverage graph.
                             for ($x = $i; $x < $i + $event->rowspan; ++$x) {
                                 for ($y = $event->indent; $y < $current_indent; ++$y) {
                                     $covered[$j][$x][$y] = true;
                                 }
                             }
                             $row .= '<td class="kronolith-event"' . $event->getCSSColors() . 'valign="top" ' . 'width="' . floor(90 / count($this->days) / count($this->_currentCalendars) * ($span / $this->days[$j]->span[$cid])) . '%" ' . 'colspan="' . $event->span . '" rowspan="' . $event->rowspan . '">' . '<div class="kronolith-event-info">';
                             if ($showTime) {
                                 $row .= '<span class="kronolith-time">' . htmlspecialchars($event->getTimeRange()) . '</span>';
                             }
                             $row .= $event->getLink($this->days[$j], true, $this->link(0, true));
                             if (!$event->isPrivate() && $showLocation) {
                                 $row .= '<span class="kronolith-location">' . htmlspecialchars($event->getLocation()) . '</span>';
                             }
                             $row .= '</div></td>';
                         }
                     }
                 }
                 $diff = $this->days[$j]->span[$cid] - $hspan;
                 if ($diff > 0) {
                     $row .= '<td colspan="' . $diff . '"';
                     if ($this->days[$j]->isToday()) {
                         $row .= ' class="kronolith-today"';
                     } elseif ($this->days[$j]->dayOfWeek() == 0 || $this->days[$j]->dayOfWeek() == 6) {
                         $row .= ' class="kronolith-weekend"';
                     }
                     $row .= '>&nbsp;</td>';
                 }
             }
         }
         $rows[] = array('row' => $row, 'slot' => $time);
     }
     $template = $GLOBALS['injector']->createInstance('Horde_Template');
     $template->set('row_height', round(20 / $this->slotsPerHour));
     $template->set('rows', $rows);
     echo $template->fetch(KRONOLITH_TEMPLATES . '/day/rows.html') . '</tbody></table>';
 }
Esempio n. 3
0
 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>';
 }