public function addEvent(EventModel $event, $groups = array(), VenueModel $venue = null, AreaModel $area = null, CountryModel $country = null, $eventMedias = array()) { global $CONFIG; $out = array('slug' => $event->getSlug(), 'slugforurl' => $event->getSlugForUrl(), 'summary' => $event->getSummary(), 'summaryDisplay' => $event->getSummaryDisplay(), 'description' => $event->getDescription() ? $event->getDescription() : '', 'deleted' => (bool) $event->getIsDeleted(), 'cancelled' => (bool) $event->getIsCancelled(), 'is_physical' => (bool) $event->getIsPhysical(), 'is_virtual' => (bool) $event->getIsVirtual(), 'custom_fields' => array()); $out['siteurl'] = $CONFIG->isSingleSiteMode ? 'http://' . $CONFIG->webSiteDomain . '/event/' . $event->getSlugForUrl() : 'http://' . ($this->site ? $this->site->getSlug() : $event->getSiteSlug()) . "." . $CONFIG->webSiteDomain . '/event/' . $event->getSlugForUrl(); $out['url'] = $event->getUrl() && filter_var($event->getUrl(), FILTER_VALIDATE_URL) ? $event->getUrl() : $out['siteurl']; $out['ticket_url'] = $event->getTicketUrl() && filter_var($event->getTicketUrl(), FILTER_VALIDATE_URL) ? $event->getTicketUrl() : null; $out['timezone'] = $event->getTimezone(); $startLocal = clone $event->getStartAt(); $startLocal->setTimeZone($this->localTimeZone); $startTimeZone = clone $event->getStartAt(); $startTimeZone->setTimeZone(new \DateTimeZone($event->getTimezone())); $out['start'] = array('timestamp' => $event->getStartAt()->getTimestamp(), 'rfc2882utc' => $event->getStartAt()->format('r'), 'rfc2882local' => $startLocal->format('r'), 'displaylocal' => $startLocal->format('D j M Y h:ia'), 'yearlocal' => $startLocal->format('Y'), 'monthlocal' => $startLocal->format('n'), 'daylocal' => $startLocal->format('j'), 'hourlocal' => $startLocal->format('G'), 'minutelocal' => $startLocal->format('i'), 'rfc2882timezone' => $startTimeZone->format('r'), 'displaytimezone' => $startTimeZone->format('D j M Y h:ia'), 'yeartimezone' => $startTimeZone->format('Y'), 'monthtimezone' => $startTimeZone->format('n'), 'daytimezone' => $startTimeZone->format('j'), 'hourtimezone' => $startTimeZone->format('G'), 'minutetimezone' => $startTimeZone->format('i')); $endLocal = clone $event->getEndAt(); $endLocal->setTimeZone($this->localTimeZone); $endTimeZone = clone $event->getEndAt(); $endTimeZone->setTimeZone(new \DateTimeZone($event->getTimezone())); $out['end'] = array('timestamp' => $event->getEndAt()->getTimestamp(), 'rfc2882utc' => $event->getEndAt()->format('r'), 'rfc2882local' => $endLocal->format('r'), 'displaylocal' => $endLocal->format('D j M Y h:ia'), 'yearlocal' => $endLocal->format('Y'), 'monthlocal' => $endLocal->format('n'), 'daylocal' => $endLocal->format('j'), 'hourlocal' => $endLocal->format('G'), 'minutelocal' => $endLocal->format('i'), 'rfc2882timezone' => $endTimeZone->format('r'), 'displaytimezone' => $endTimeZone->format('D j M Y h:ia'), 'yeartimezone' => $endTimeZone->format('Y'), 'monthtimezone' => $endTimeZone->format('n'), 'daytimezone' => $endTimeZone->format('j'), 'hourtimezone' => $endTimeZone->format('G'), 'minutetimezone' => $endTimeZone->format('i')); if (is_array($groups)) { $out['groups'] = array(); foreach ($groups as $group) { $out['groups'][] = array('slug' => $group->getSlug(), 'title' => $group->getTitle(), 'description' => $group->getDescription()); } } if ($venue) { $out['venue'] = array('slug' => $venue->getSlug(), 'title' => $venue->getTitle(), 'description' => $venue->getDescription(), 'address' => $venue->getAddress(), 'addresscode' => $venue->getAddressCode(), 'lat' => $venue->getLat(), 'lng' => $venue->getLng()); } if ($area) { $out['areas'] = array(array('slug' => $area->getSlug(), 'title' => $area->getTitle())); } if ($country) { $out['country'] = array('title' => $country->getTitle()); } if (is_array($eventMedias)) { $out['medias'] = array(); $siteurl = $CONFIG->getWebSiteDomainSecure($this->site->getSlug()); foreach ($eventMedias as $eventMedia) { $out['medias'][] = array('slug' => $eventMedia->getSlug(), 'title' => $eventMedia->getTitle(), 'sourceUrl' => $eventMedia->getSourceUrl(), 'sourcetext' => $eventMedia->getSourceText(), 'picture' => array('fullURL' => $siteurl . '/media/' . $eventMedia->getSlug() . '/full', 'normalURL' => $siteurl . '/media/' . $eventMedia->getSlug() . '/normal', 'thumbnailURL' => $siteurl . '/media/' . $eventMedia->getSlug() . '/thumbnail')); } } if ($this->site) { foreach ($this->site->getCachedEventCustomFieldDefinitionsAsModels() as $customField) { $out['custom_fields'][$customField->getKey()] = $event->getCustomField($customField); } } $this->events[] = $out; }
public function addEvent(EventModel $event, $groups = array(), VenueModel $venue = null, AreaModel $area = null, CountryModel $country = null, $eventMedias = array()) { global $CONFIG; if ($event->getIsDeleted()) { return false; } // ########################################### Get Data $siteSlug = $this->site ? $this->site->getSlug() : $event->getSiteSlug(); $ourUrl = $CONFIG->isSingleSiteMode ? 'http://' . $CONFIG->webSiteDomain . '/event/' . $event->getSlug() : 'http://' . $siteSlug . "." . $CONFIG->webSiteDomain . '/event/' . $event->getSlug(); $dh = new \DateTime('', $this->localTimeZone); $dh->setTimestamp($event->getStartAt()->getTimestamp()); $dateTxt = $dh->format('D j M Y h:ia') . ' to '; $dateTxtShort = $dh->format('D j M'); $dh->setTimestamp($event->getEndAt()->getTimestamp()); $dateTxt .= $dh->format('D j M Y h:ia'); // ########################################## Build $txt = '<entry>'; $txt .= '<id>' . $ourUrl . '</id>'; $txt .= '<link href="' . $ourUrl . '"/>'; $txt .= '<title>' . $this->getData($event->getSummaryDisplay() . ', ' . $dateTxtShort) . '</title>'; $txt .= '<summary>' . $dateTxt . '</summary>'; $content = ''; foreach ($this->extraHeaders as $extraHeader) { $content .= $extraHeader->getHtml() . "<br><br>"; } $content .= $dateTxt . "<br>"; if ($event->getDescription()) { $content .= str_replace("\n", "<br>", htmlentities($event->getDescription(), ENT_QUOTES, 'UTF-8')) . '<br>'; } // TODO $event->getUrl() $content .= '<a href="' . htmlentities($ourUrl) . '">More details at ' . htmlentities($ourUrl) . '</a><br>'; $content .= '<p style="font-style:italic;font-size:80%">' . 'Powered by <a href="' . $ourUrl . '">' . $CONFIG->siteTitle . '</a>'; foreach ($this->extraFooters as $extraFooter) { $content .= "<br>" . $extraFooter->getHtml(); } $content .= '</p>'; $txt .= '<content type="html">' . $this->getBigData($content) . '</content>'; $txt .= $this->getUpdatedString($event); $txt .= '<author><name>' . $CONFIG->siteTitle . '</name></author></entry>' . " \r\n"; $this->events[] = $txt; }
/** * * Gets new monthly events on the basis that the event is on the something day in the week. * eg. 2nd tuesday of month * eg. 4th saturday in month * * @param \models\EventModel $event * @param type $monthsInAdvance * @return \models\EventModel */ public function getNewMonthlyEventsOnSetDayInWeek(EventModel $event, $daysInAdvance = 186) { // constants $interval = new \DateInterval('P1D'); $timeZone = new \DateTimeZone($this->timeZoneName); $timeZoneUTC = new \DateTimeZone("UTC"); // calculate which day of month it should be $dayOfWeek = $event->getStartAt()->format("N"); $thisStart = new \DateTime($event->getStartAt()->format('Y-m-d H:i:s'), $timeZoneUTC); $thisEnd = new \DateTime($event->getEndAt()->format('Y-m-d H:i:s'), $timeZoneUTC); $thisStart->setTimeZone($timeZone); $thisEnd->setTimeZone($timeZone); $weekInMonth = 1; while ($thisStart->format('d') > 1) { $thisStart->sub($interval); $thisEnd->sub($interval); if ($thisStart->format("N") == $dayOfWeek) { ++$weekInMonth; } } // vars $out = array(); $currentMonthLong = $thisStart->format('F'); $currentMonthShort = $thisStart->format('M'); $currentMonth = $thisStart->format('m'); $currentWeekInMonth = 1; $loopStop = \TimeSource::time() + $daysInAdvance * 24 * 60 * 60; while ($thisStart->getTimestamp() < $loopStop) { $thisStart->add($interval); $thisEnd->add($interval); //print $thisStart->format("r")." current month: ".$currentMonth." current week: ".$currentWeekInMonth."\n"; if ($currentMonth != $thisStart->format('m')) { $currentMonth = $thisStart->format('m'); $currentWeekInMonth = 1; } if ($thisStart->format("N") == $dayOfWeek) { if ($currentWeekInMonth == $weekInMonth && $thisStart->getTimestamp() > \TimeSource::time()) { $start = clone $thisStart; $end = clone $thisEnd; $start->setTimeZone($timeZoneUTC); $end->setTimeZone($timeZoneUTC); $include = true; if ($include) { $newEvent = new EventModel(); $newEvent->setGroupId($event->getGroupId()); $newEvent->setVenueId($event->getVenueId()); $newEvent->setCountryId($event->getCountryId()); $newEvent->setEventRecurSetId($this->id); $newEvent->setSummary($event->getSummary()); $newEvent->setDescription($event->getDescription()); $newEvent->setStartAt($start); $newEvent->setEndAt($end); foreach ($this->customFields as $customField) { if ($event->hasCustomField($customField)) { $newEvent->setCustomField($customField, $event->getCustomField($customField)); } } if (stripos($newEvent->getSummary(), $currentMonthLong) !== false) { $newEvent->setSummary(str_ireplace($currentMonthLong, $newEvent->getStartAt()->format('F'), $newEvent->getSummary())); } else { if (stripos($newEvent->getSummary(), $currentMonthShort) !== false) { $newEvent->setSummary(str_ireplace($currentMonthShort, $newEvent->getStartAt()->format('M'), $newEvent->getSummary())); } } $out[] = $newEvent; } } ++$currentWeekInMonth; } } return $out; }
function getScoreForConsideredEvent(EventModel $event) { $score = 0; // Only 1 of Start or End matching can count as a point. To many false positives when both matched. // Due to standard event time of 2 hours, an event that happened to be at same start and end time would show as match when it was completely different. if ($this->event->getStartAt() && $event->getStartAt() && $this->event->getStartAt()->getTimestamp() == $event->getStartAt()->getTimestamp()) { $score++; } else { if ($this->event->getEndAt() && $event->getEndAt() && $this->event->getEndAt()->getTimestamp() == $event->getEndAt()->getTimestamp()) { $score++; } } if ($this->event->getGroupId() && $this->event->getGroupId() == $event->getGroupId()) { $score++; } if ($this->event->getUrl() && $this->getCanonicalURL($this->event->getUrl()) == $this->getCanonicalURL($event->getUrl())) { $score++; } if ($this->event->getTicketUrl() && $this->getCanonicalURL($this->event->getTicketUrl()) == $this->getCanonicalURL($event->getTicketUrl())) { $score++; } if ($this->event->getSummary()) { if ($this->event->getSummary() == $event->getSummary()) { $score++; } else { $bits1 = explode(" ", strtolower($this->event->getSummary())); $bits2 = explode(" ", strtolower($event->getSummary())); $flag = false; foreach ($bits1 as $bit) { if ($bit && in_array($bit, $bits2) && !in_array($bit, $this->wordsNotToMatchInSummary)) { $flag = true; } } if ($flag) { $score++; } } } if ($this->event->getVenueId() && $this->event->getVenueId() == $event->getVenueId()) { $score++; } if ($this->event->getAreaId() && $this->event->getAreaId() == $event->getAreaId()) { $score++; } elseif ($this->event->getAreaId() && $event->getArea() && $this->event->getAreaId() == $event->getArea()->getId()) { $score++; } return $score; }
public function addEvent(EventModel $event, $groups = array(), VenueModel $venue = null, AreaModel $area = null, CountryModel $country = null, $eventMedias = array()) { global $CONFIG; $siteSlug = $this->site ? $this->site->getSlug() : $event->getSiteSlug(); $txt = $this->getIcalLine('BEGIN', 'VEVENT'); $txt .= $this->getIcalLine('UID', $event->getSlug() . '@' . $siteSlug . "." . $CONFIG->webSiteDomain); $url = $CONFIG->isSingleSiteMode ? 'http://' . $CONFIG->webSiteDomain . '/event/' . $event->getSlugForUrl() : 'http://' . $siteSlug . "." . $CONFIG->webSiteDomain . '/event/' . $event->getSlugForUrl(); $txt .= $this->getIcalLine('URL', $url); if ($event->getIsDeleted()) { $txt .= $this->getIcalLine('SUMMARY', $event->getSummaryDisplay() . " [DELETED]"); $txt .= $this->getIcalLine('METHOD', 'CANCEL'); $txt .= $this->getIcalLine('STATUS', 'CANCELLED'); $txt .= $this->getIcalLine('DESCRIPTION', 'DELETED'); } else { if ($event->getIsCancelled()) { $txt .= $this->getIcalLine('SUMMARY', $event->getSummaryDisplay() . " [CANCELLED]"); $txt .= $this->getIcalLine('METHOD', 'CANCEL'); $txt .= $this->getIcalLine('STATUS', 'CANCELLED'); $txt .= $this->getIcalLine('DESCRIPTION', 'CANCELLED'); } else { $txt .= $this->getIcalLine('SUMMARY', $event->getSummaryDisplay()); $description = ''; foreach ($this->extraHeaders as $extraHeader) { $description .= $extraHeader->getText() . "\n\n"; } $description .= $event->getDescription() . "\n" . $url . "\n" . "Powered by " . $CONFIG->siteTitle; foreach ($this->extraFooters as $extraFooter) { $description .= "\n" . $extraFooter->getText(); } $txt .= $this->getIcalLine('DESCRIPTION', $description); $descriptionHTML = "<html><body>"; foreach ($this->extraHeaders as $extraHeader) { $descriptionHTML .= "<p>" . $extraHeader->getHtml() . "</p>"; } $descriptionHTML .= "<p>" . str_replace("\r", "", str_replace("\n", "<br>", htmlentities($event->getDescription()))) . "</p>"; //if ($event->getUrl()) $descriptionHTML .= '<p>More info: <a href="'.$event->getUrl().'">'.$event->getUrl().'</a></p>'; $descriptionHTML .= '<p>More info: <a href="' . $url . '">' . $url . '</a></p>'; $descriptionHTML .= '<p style="font-style:italic;font-size:80%">Powered by <a href="' . $url . '">' . $CONFIG->siteTitle . '</a>'; foreach ($this->extraFooters as $extraFooter) { $descriptionHTML .= "<br>" . $extraFooter->getHtml(); } $descriptionHTML .= '</p>'; $descriptionHTML .= '</body></html>'; $txt .= $this->getIcalLine("X-ALT-DESC;FMTTYPE=text/html", $descriptionHTML); $locationDetails = array(); if ($event->getVenue() && $event->getVenue()->getTitle()) { $locationDetails[] = $event->getVenue()->getTitle(); } if ($event->getVenue() && $event->getVenue()->getAddress()) { $locationDetails[] = $event->getVenue()->getAddress(); } if ($event->getArea() && $event->getArea()->getTitle()) { $locationDetails[] = $event->getArea()->getTitle(); } if ($event->getVenue() && $event->getVenue()->getAddressCode()) { $locationDetails[] = $event->getVenue()->getAddressCode(); } if ($locationDetails) { $txt .= $this->getIcalLine('LOCATION', implode(", ", $locationDetails)); } if ($event->getVenue() && $event->getVenue()->getLat() && $event->getVenue()->getLng()) { $txt .= $this->getIcalLine('GEO', $event->getVenue()->getLat() . ";" . $event->getVenue()->getLng()); } } } $txt .= $this->getIcalLine('DTSTART', $event->getStartAt()->format("Ymd") . "T" . $event->getStartAt()->format("His") . "Z"); $txt .= $this->getIcalLine('DTEND', $event->getEndAt()->format("Ymd") . "T" . $event->getEndAt()->format("His") . "Z"); $txt .= $this->getIcalLine('END', 'VEVENT'); $this->events[] = $txt; }
public function update(EventModel $event, $fields, EventEditMetaDataModel $eventEditMetaDataModel) { $alreadyInTransaction = $this->db->inTransaction(); // Make Information Data $fieldsSQL1 = array(); $fieldsParams1 = array('id' => $event->getId()); foreach ($fields as $field) { if ($field == 'custom') { $fieldsSQL1[] = " custom_fields = :custom_fields "; $fieldsParams1['custom_fields'] = json_encode($event->getCustomFields()); } else { $fieldsSQL1[] = " " . $field . "=:" . $field . " "; if ($field == 'summary') { $fieldsParams1['summary'] = substr($event->getSummary(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'description') { $fieldsParams1['description'] = $event->getDescription(); } else { if ($field == 'start_at') { $fieldsParams1['start_at'] = $event->getStartAt()->format("Y-m-d H:i:s"); } else { if ($field == 'end_at') { $fieldsParams1['end_at'] = $event->getEndAt()->format("Y-m-d H:i:s"); } else { if ($field == 'venue_id') { $fieldsParams1['venue_id'] = $event->getVenueId(); } else { if ($field == 'area_id') { $fieldsParams1['area_id'] = $event->getAreaId(); } else { if ($field == 'country_id') { $fieldsParams1['country_id'] = $event->getCountryId(); } else { if ($field == 'timezone') { $fieldsParams1['timezone'] = substr($event->getTimezone(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'url') { $fieldsParams1['url'] = substr($event->getUrl(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'ticket_url') { $fieldsParams1['ticket_url'] = substr($event->getTicketUrl(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'is_physical') { $fieldsParams1['is_physical'] = $event->getIsPhysical() ? 1 : 0; } else { if ($field == 'is_virtual') { $fieldsParams1['is_virtual'] = $event->getIsVirtual() ? 1 : 0; } else { if ($field == 'is_cancelled') { $fieldsParams1['is_cancelled'] = $event->getIsCancelled() ? 1 : 0; } else { if ($field == 'is_deleted') { $fieldsParams1['is_deleted'] = $event->getIsDeleted() ? 1 : 0; } else { if ($field == 'is_duplicate_of_id') { $fieldsParams1['is_duplicate_of_id'] = $event->getIsDuplicateOfId(); } } } } } } } } } } } } } } } } } // Make History Data $fieldsSQL2 = array('event_id', 'user_account_id', 'created_at', 'approved_at', 'from_ip'); $fieldsSQLParams2 = array(':event_id', ':user_account_id', ':created_at', ':approved_at', ':from_ip'); $fieldsParams2 = array('event_id' => $event->getId(), 'user_account_id' => $eventEditMetaDataModel->getUserAccount() ? $eventEditMetaDataModel->getUserAccount()->getId() : null, 'created_at' => $this->timesource->getFormattedForDataBase(), 'approved_at' => $this->timesource->getFormattedForDataBase(), 'from_ip' => $eventEditMetaDataModel->getIp()); if ($eventEditMetaDataModel->getRevertedFromHistoryCreatedAt()) { $fieldsSQL2[] = ' reverted_from_created_at '; $fieldsSQLParams2[] = ' :reverted_from_created_at '; $fieldsParams2['reverted_from_created_at'] = $eventEditMetaDataModel->getRevertedFromHistoryCreatedAt()->format("Y-m-d H:i:s"); } if ($eventEditMetaDataModel->getEditComment()) { $fieldsSQL2[] = ' edit_comment '; $fieldsSQLParams2[] = ' :edit_comment '; $fieldsParams2['edit_comment'] = $eventEditMetaDataModel->getEditComment(); } foreach ($this->possibleFields as $field) { if (in_array($field, $fields) || $field == 'summary') { $fieldsSQL2[] = " " . $field . " "; $fieldsSQLParams2[] = " :" . $field . " "; if ($field == 'summary') { $fieldsParams2['summary'] = substr($event->getSummary(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'description') { $fieldsParams2['description'] = $event->getDescription(); } else { if ($field == 'start_at') { $fieldsParams2['start_at'] = $event->getStartAt()->format("Y-m-d H:i:s"); } else { if ($field == 'end_at') { $fieldsParams2['end_at'] = $event->getEndAt()->format("Y-m-d H:i:s"); } else { if ($field == 'venue_id') { $fieldsParams2['venue_id'] = $event->getVenueId(); } else { if ($field == 'area_id') { $fieldsParams2['area_id'] = $event->getAreaId(); } else { if ($field == 'country_id') { $fieldsParams2['country_id'] = $event->getCountryId(); } else { if ($field == 'timezone') { $fieldsParams2['timezone'] = substr($event->getTimezone(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'url') { $fieldsParams2['url'] = substr($event->getUrl(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'ticket_url') { $fieldsParams2['ticket_url'] = substr($event->getTicketUrl(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'is_physical') { $fieldsParams2['is_physical'] = $event->getIsPhysical() ? 1 : 0; } else { if ($field == 'is_virtual') { $fieldsParams2['is_virtual'] = $event->getIsVirtual() ? 1 : 0; } else { if ($field == 'is_cancelled') { $fieldsParams2['is_cancelled'] = $event->getIsCancelled() ? 1 : 0; } else { if ($field == 'is_deleted') { $fieldsParams2['is_deleted'] = $event->getIsDeleted() ? 1 : 0; } else { if ($field == 'is_duplicate_of_id') { $fieldsParams2['is_duplicate_of_id'] = $event->getIsDuplicateOfId(); } } } } } } } } } } } } } } } $fieldsSQL2[] = " " . $field . "_changed "; $fieldsSQLParams2[] = " 0 "; } else { $fieldsSQL2[] = " " . $field . "_changed "; $fieldsSQLParams2[] = " -2 "; } } if (in_array("custom", $fields)) { $fieldsSQL2[] = " custom_fields "; $fieldsSQLParams2[] = " :custom_fields "; $fieldsParams2['custom_fields'] = json_encode($event->getCustomFields()); $fieldsSQL2[] = " custom_fields_changed "; $fieldsSQLParams2[] = " 0 "; } else { $fieldsSQL2[] = " custom_fields_changed "; $fieldsSQLParams2[] = " -2 "; } try { if (!$alreadyInTransaction) { $this->db->beginTransaction(); } // Information SQL $stat = $this->db->prepare("UPDATE event_information SET " . implode(",", $fieldsSQL1) . " WHERE id=:id"); $stat->execute($fieldsParams1); // History SQL $stat = $this->db->prepare("INSERT INTO event_history (" . implode(",", $fieldsSQL2) . ") VALUES (" . implode(",", $fieldsSQLParams2) . ")"); $stat->execute($fieldsParams2); if (!$alreadyInTransaction) { $this->db->commit(); } } catch (Exception $e) { if (!$alreadyInTransaction) { $this->db->rollBack(); } throw $e; } }
public function addEvent(EventModel $event, VenueModel $venue = null, AreaModel $area = null, CountryModel $country = null) { global $CONFIG; $out = array('slug' => $event->getSlug(), 'slugforurl' => $event->getSlugForUrl(), 'summary' => $event->getSummary(), 'summaryDisplay' => $event->getSummaryDisplay(), 'description' => $event->getDescription() ? $event->getDescription() : '', 'deleted' => (bool) $event->getIsDeleted(), 'cancelled' => (bool) $event->getIsCancelled(), 'is_physical' => (bool) $event->getIsPhysical(), 'is_virtual' => (bool) $event->getIsVirtual()); $out['siteurl'] = $CONFIG->isSingleSiteMode ? 'http://' . $CONFIG->webSiteDomain . '/event/' . $event->getSlugForUrl() : 'http://' . ($this->site ? $this->site->getSlug() : $event->getSiteSlug()) . "." . $CONFIG->webSiteDomain . '/event/' . $event->getSlugForUrl(); $out['url'] = $event->getUrl() && filter_var($event->getUrl(), FILTER_VALIDATE_URL) ? $event->getUrl() : $out['siteurl']; $out['ticket_url'] = $event->getTicketUrl() && filter_var($event->getTicketUrl(), FILTER_VALIDATE_URL) ? $event->getTicketUrl() : null; $out['timezone'] = $event->getTimezone(); $startLocal = clone $event->getStartAt(); $startLocal->setTimeZone($this->localTimeZone); $startTimeZone = clone $event->getStartAt(); $startTimeZone->setTimeZone(new \DateTimeZone($event->getTimezone())); $out['start'] = array('timestamp' => $event->getStartAt()->getTimestamp(), 'rfc2882utc' => $event->getStartAt()->format('r'), 'rfc2882local' => $startLocal->format('r'), 'displaylocal' => $startLocal->format('D j M Y h:ia'), 'yearlocal' => $startLocal->format('Y'), 'monthlocal' => $startLocal->format('n'), 'daylocal' => $startLocal->format('j'), 'hourlocal' => $startLocal->format('G'), 'minutelocal' => $startLocal->format('i'), 'rfc2882timezone' => $startTimeZone->format('r'), 'displaytimezone' => $startTimeZone->format('D j M Y h:ia'), 'yeartimezone' => $startTimeZone->format('Y'), 'monthtimezone' => $startTimeZone->format('n'), 'daytimezone' => $startTimeZone->format('j'), 'hourtimezone' => $startTimeZone->format('G'), 'minutetimezone' => $startTimeZone->format('i')); $endLocal = clone $event->getEndAt(); $endLocal->setTimeZone($this->localTimeZone); $endTimeZone = clone $event->getEndAt(); $endTimeZone->setTimeZone(new \DateTimeZone($event->getTimezone())); $out['end'] = array('timestamp' => $event->getEndAt()->getTimestamp(), 'rfc2882utc' => $event->getEndAt()->format('r'), 'rfc2882local' => $endLocal->format('r'), 'displaylocal' => $endLocal->format('D j M Y h:ia'), 'yearlocal' => $endLocal->format('Y'), 'monthlocal' => $endLocal->format('n'), 'daylocal' => $endLocal->format('j'), 'hourlocal' => $endLocal->format('G'), 'minutelocal' => $endLocal->format('i'), 'rfc2882timezone' => $endTimeZone->format('r'), 'displaytimezone' => $endTimeZone->format('D j M Y h:ia'), 'yeartimezone' => $endTimeZone->format('Y'), 'monthtimezone' => $endTimeZone->format('n'), 'daytimezone' => $endTimeZone->format('j'), 'hourtimezone' => $endTimeZone->format('G'), 'minutetimezone' => $endTimeZone->format('i')); if ($venue) { $out['venue'] = array('slug' => $venue->getSlug(), 'title' => $venue->getTitle(), 'description' => $venue->getDescription(), 'address' => $venue->getAddress(), 'addresscode' => $venue->getAddressCode(), 'lat' => $venue->getLat(), 'lng' => $venue->getLng()); } if ($area) { $out['areas'] = array(array('slug' => $area->getSlug(), 'title' => $area->getTitle())); } if ($country) { $out['country'] = array('title' => $country->getTitle()); } return $out; }