getTomorrow() public méthode

public getTomorrow ( )
Exemple #1
0
 /**
  */
 protected function _content()
 {
     $GLOBALS['page_output']->addScriptFile('tooltips.js', 'horde');
     $now = new Horde_Date($_SERVER['REQUEST_TIME']);
     $today = date('j');
     $startDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n'), 'mday' => date('j')));
     $endDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n'), 'mday' => date('j') + $this->_params['days']));
     try {
         if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
             $calendars = Kronolith::listCalendars();
             if (!isset($calendars[$this->_params['calendar']])) {
                 return _("Calendar not found");
             }
             if (!$calendars[$this->_params['calendar']]->hasPermission(Horde_Perms::READ)) {
                 return _("Permission Denied");
             }
             list($type, $calendar) = explode('_', $this->_params['calendar'], 2);
             $driver = Kronolith::getDriver($type, $calendar);
             $all_events = Kronolith::sortEvents($driver->listEvents($startDate, $endDate, array('show_recurrence' => true)));
         } else {
             $all_events = Kronolith::listEvents($startDate, $endDate, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS));
         }
     } catch (Exception $e) {
         return '<em>' . $e->getMessage() . '</em>';
     }
     $html = '';
     $iMax = $today + $this->_params['days'];
     $firstday = true;
     $totalevents = 0;
     for ($i = $today; $i < $iMax; ++$i) {
         $day = new Kronolith_Day(date('n'), $i);
         $date_stamp = $day->dateString();
         if (empty($all_events[$date_stamp])) {
             continue;
         }
         $firstevent = true;
         $tomorrow = $day->getTomorrow();
         foreach ($all_events[$date_stamp] as $event) {
             if (!empty($this->_params['maxevents']) && $totalevents >= $this->_params['maxevents']) {
                 break 2;
             }
             if ($event->start->compareDate($day) < 0) {
                 $event->start = $day;
             }
             if ($event->end->compareDate($tomorrow) >= 0) {
                 $event->end = $tomorrow;
             }
             if ($event->end->compareDateTime($now) < 0) {
                 continue;
             }
             if (!empty($this->_params['alarms']) && !$event->alarm) {
                 continue;
             }
             $event_active = $event->start->compareDateTime($now) < 0 && $event->end->compareDateTime($now) > 0;
             if ($firstevent) {
                 $html .= '<tr><td colspan="3" class="control"><strong>';
                 if ($day->isToday()) {
                     $dayname = _("Today");
                 } elseif ($day->isTomorrow()) {
                     $dayname = _("Tomorrow");
                 } elseif ($day->diff() < 7) {
                     $dayname = $day->strftime('%A');
                 } else {
                     $dayname = $day->strftime($GLOBALS['prefs']->getValue('date_format'));
                 }
                 $url = Horde::url('day.php', true)->setRaw(false)->add('date', $day->dateString());
                 if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
                     $url->add('display_cal', $this->_params['calendar']);
                 }
                 $html .= $url->link(array('title' => sprintf(_("Goto %s"), $dayname))) . $dayname . '</a></strong></td></tr>';
                 $firstevent = false;
                 $firstday = false;
             }
             $html .= '<tr class="linedRow"><td class="text nowrap" valign="top">';
             if ($event_active) {
                 $html .= '<strong>';
             }
             if ($event->isAllDay()) {
                 $time = _("All day");
             } else {
                 $time = $event->start->format($GLOBALS['prefs']->getValue('twentyFour') ? 'H:i' : 'h:ia') . '-' . $event->end->format($GLOBALS['prefs']->getValue('twentyFour') ? 'H:i' : 'h:ia');
             }
             $html .= $time;
             if ($event_active) {
                 $html .= '</strong>';
             }
             $html .= '&nbsp;</td>';
             $html .= '<td class="text" valign="top"' . $event->getCSSColors() . '>';
             if ($event_active) {
                 $html .= '<strong>';
             }
             $html .= ' ' . $event->getLink(null, true, null, true, true);
             if ($event_active) {
                 $html .= '</strong>';
             }
             $html .= '</td></tr>';
             $totalevents++;
         }
     }
     if (empty($html)) {
         return '<em>' . _("No events to display") . '</em>';
     }
     return '<table cellspacing="0" width="100%">' . $html . '</table>';
 }
Exemple #2
0
 /**
  */
 protected function _content()
 {
     global $page_output;
     $page_output->addScriptFile('tooltips.js', 'horde');
     $now = new Horde_Date($_SERVER['REQUEST_TIME']);
     $today = date('j');
     $current_month = '';
     $startDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n'), 'mday' => date('j')));
     $endDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n') + $this->_params['months'], 'mday' => date('j') - 1));
     try {
         if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
             $calendars = Kronolith::listCalendars();
             if (!isset($calendars[$this->_params['calendar']])) {
                 return _("Calendar not found");
             }
             if (!$calendars[$this->_params['calendar']]->hasPermission(Horde_Perms::READ)) {
                 return _("Permission Denied");
             }
             list($type, $calendar) = explode('_', $this->_params['calendar'], 2);
             $driver = Kronolith::getDriver($type, $calendar);
             $all_events = $driver->listEvents($startDate, $endDate, array('show_recurrence' => true, 'has_alarm' => !empty($this->_params['alarms']), 'cover_dates' => false));
         } else {
             $all_events = Kronolith::listEvents($startDate, $endDate, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS), array('has_alarm' => !empty($this->_params['alarms']), 'cover_dates' => false));
         }
     } catch (Exception $e) {
         return '<em>' . $e->getMessage() . '</em>';
     }
     /* How many days do we need to check. */
     $days = Date_Calc::dateDiff($startDate->mday, $startDate->month, $startDate->year, $endDate->mday, $endDate->month, $endDate->year);
     /* Loop through the days. */
     $totalevents = 0;
     $html = '';
     for ($i = 0; $i < $days; ++$i) {
         $day = new Kronolith_Day($startDate->month, $today + $i);
         $date_stamp = $day->dateString();
         if (empty($all_events[$date_stamp])) {
             continue;
         }
         if (!empty($this->_params['maxevents']) && $totalevents >= $this->_params['maxevents']) {
             break;
         }
         /* Output month header. */
         if ($current_month != $day->month) {
             $html .= '<tr><td colspan="4" class="control"><strong>' . $day->strftime('%B') . '</strong></td></tr>';
         }
         $firstevent = true;
         $tomorrow = $day->getTomorrow();
         foreach ($all_events[$date_stamp] as $event) {
             $isMultiDay = false;
             if ($event->start->compareDate($day) < 0) {
                 $event->start = new Horde_Date($day);
             }
             if ($event->end->compareDate($tomorrow) >= 1) {
                 $isMultiDay = true;
             }
             if ($event->end->compareDate($now) < 0 && !$event->isAllDay() || !empty($this->_params['alarms']) && !$event->alarm) {
                 continue;
             }
             if ($firstevent || $isMultiDay) {
                 $html .= '<tr';
                 if ($current_month == $day->month) {
                     $html .= ' class="upcomingday"';
                 }
                 $html .= '><td class="text" valign="top" align="right"><strong>';
                 if ($day->isToday()) {
                     $html .= _("Today");
                 } elseif ($day->isTomorrow()) {
                     $html .= _("Tomorrow");
                 } else {
                     $html .= $day->mday;
                 }
                 if ($isMultiDay) {
                     $endDay = new Kronolith_Day($event->end->month, $event->end->mday);
                     $html .= ' - ';
                     if ($endDay->isTomorrow()) {
                         $html .= _("Tomorrow");
                     } else {
                         $html .= $event->end->mday;
                     }
                 }
                 $html .= '</strong>&nbsp;</td>';
                 $firstevent = $isMultiDay;
             } else {
                 $html .= '<tr><td class="text">&nbsp;</td>';
             }
             $html .= '<td class="text" nowrap="nowrap" valign="top">';
             if ($event->start->compareDate($now) < 0 && $event->end->compareDate($now) > 0) {
                 $html .= '<strong>' . htmlspecialchars($event->getLocation()) . '</strong>';
             } else {
                 $html .= htmlspecialchars($event->getLocation());
             }
             if ($event->start->compareDate($now) < 0 && $event->end->compareDate($now) > 0) {
                 $html .= '<strong>';
             }
             $html .= $event->getLink(null, true, null, true);
             if ($event->start->compareDate($now) < 0 && $event->end->compareDate($now) > 0) {
                 $html .= '</strong>';
             }
             $html .= '</td></tr>';
             $totalevents++;
         }
         $current_month = $day->strftime('%m');
     }
     if (empty($html)) {
         return '<em>' . _("No events to display") . '</em>';
     }
     return '<table cellspacing="0" width="100%">' . $html . '</table>';
 }