/** * Formats information about events to be displayed on calendar events * main screen. * * @param array $eventListing Event listing in a given date range to be * formatted for visualization * @param int $currCalendarId The id of the current calendar in use * @param stdClass $currDateRange Formatted date range with month and * year values * @return array Formatted list of events */ private function formatEventsForVisualization($eventListing, $currCalendarId, $currDateRange) { if (isset($eventListing) && count($eventListing) > 0) { foreach ($eventListing as &$event) { $fromData = DateUtils::getInfomationAboutDate($event->from); $untilData = DateUtils::getInfomationAboutDate($event->until); $event->formattedDay = $fromData->dayVal; $event->formattedFrom = $fromData->timeVal; $event->formattedUntil = $untilData->timeVal; $event->formattedMonth = $fromData->monthName; $event->formattedWeekDay = $fromData->weekdayName; $event->notYetOccurred = DateUtils::compareToCurrentDate($event->from); $event->lnkOpenEvent = $this->makeUrl('Calendar.OpenEvent', array('from' => $event->from, 'until' => $event->until, 'idEvent' => $event->id, 'calendarId' => $currCalendarId, 'monthVal' => $currDateRange->monthVal, 'yearVal' => $currDateRange->yearVal)); } return $eventListing; } else { return array(); } }
/** * Check if the event is scheduled to current date. * * @param string $strTime Information about date and time in the following * format '2015-12-24 23:59' * @return boolean True if event's day, month and year are equals to * current's day, month and year; false otherwise */ public static function isEventScheduledForToday($strTime) { $dtEvent = DateUtils::getInfomationAboutDate($strTime); return $dtEvent->dayVal === DateUtils::getCurrentDay() && $dtEvent->monthVal === DateUtils::getCurrentMonthNumber() && $dtEvent->yearVal === DateUtils::getCurrentYear(); }
/** * Format information about a particular calendar event to be viewed. * * @param stdClass $event The Event object * @return stdClass An object containning formatted event information like date (->date), * time (->schedule), the organizer's name (->organizerName), organization * unit and region (->orgUnitRegion), the total count of attendees * (->countAttendees), the list of attendees (->attendees), the event's * summary (->summary) and the description about the event (->description) */ private function formatEventInformation($event) { $fromInfo = DateUtils::getInfomationAboutDate($event->from); $untilInfo = DateUtils::getInfomationAboutDate($event->until); return (object) array('schedule' => $fromInfo->timeVal . ' às ' . $untilInfo->timeVal, 'date' => $fromInfo->weekdayName . ', ' . $fromInfo->dayVal . ' de ' . $fromInfo->monthName . ' de ' . $fromInfo->yearVal . '.', 'attendees' => $event->attendees, 'organizerName' => $event->organizer->name, 'organizerOrgUnitRegion' => $event->organizer->orgUnit . ', ' . $event->organizer->region, 'summary' => empty($event->summary) ? EventUtils::EVENTS_WITHOUT_SUMMARY : $event->summary, 'location' => empty($event->location) ? EventUtils::EVENTS_WITHOUT_LOCATION : $event->location, 'description' => empty($event->description) ? EventUtils::EVENTS_WITHOUT_DESCRIPTION : nl2br($event->description)); }