예제 #1
0
 /**
  * Add event to calendar
  *
  * @param SZend_Calendar_Event $event
  */
 public function addEvent(SZend_Calendar_Event $event)
 {
     $startTimestamp = $event->getStartTimestamp();
     $endTimestamp = $event->getEndTimestamp();
     $day = (int) strftime('%d', $startTimestamp);
     $month = (int) strftime('%m', $startTimestamp);
     $year = (int) strftime('%Y', $startTimestamp);
     $span = $this->dateDiff(date('c', $startTimestamp), date('c', $endTimestamp));
     $days = $span + 1;
     // Add regular event
     $event->eventSpan = $span;
     $event->eventDays = $days;
     $this->_events[] = $event;
     $eventId = count($this->_events) - 1;
     // Add event id
     $date = new Zend_Date($startTimestamp);
     $event = array('id' => $eventId, 'days' => $days, 'span' => $span);
     $this->_dayEvents[$year][$month][(int) $date->get(Zend_Date::DAY_SHORT)][SZend_Calendar_Event::MULTI][] = $event;
 }
예제 #2
0
 /**
  * Add event to calendar
  * 
  * @param SZend_Calendar_Event $event
  */
 public function addEvent(SZend_Calendar_Event $event)
 {
     $startTimestamp = $event->getStartTimestamp();
     $endTimestamp = $event->getEndTimestamp();
     $day = (int) strftime('%d', $startTimestamp);
     $month = (int) strftime('%m', $startTimestamp);
     $year = (int) strftime('%Y', $startTimestamp);
     $span = $this->dateDiff(date('c', $startTimestamp), date('c', $endTimestamp));
     // Add regular event
     $event->eventSpan = $span;
     $this->_events[] = $event;
     $eventId = count($this->_events) - 1;
     // Single day events
     if (0 == $span) {
         $event = array('id' => $eventId, 'status' => 'single');
         $this->_dayEvents[$year][$month][$day][SZend_Calendar_Event::SINGLE][] = $event;
         return;
     }
     // Add event id to all days that intersect it
     $date = new Zend_Date($startTimestamp);
     for ($i = 0; $i < $span; $i++) {
         if ($i == 0) {
             $status = 'starts';
         } else {
             if ($i + 1 == $span) {
                 $status = 'ends';
             } else {
                 $status = 'continues';
             }
         }
         $event = array('id' => $eventId, 'status' => $status);
         $this->_dayEvents[$year][$month][(int) $date->get(Zend_Date::DAY_SHORT)][SZend_Calendar_Event::MULTI][] = $event;
         $date->addDay(1);
     }
 }