public function infoJson($slug, Request $request, Application $app) { if (!$this->build($slug, $request, $app)) { $app->abort(404, "Does not exist."); } $out = array('venue' => array('slug' => $this->venue->getSlug(), 'slugForURL' => $this->venue->getSlugForUrl(), 'title' => $this->venue->getTitle(), 'description' => $this->venue->getDescription(), 'address' => $this->venue->getAddress(), 'address_code' => $this->venue->getAddressCode(), 'lat' => $this->venue->getLat(), 'lng' => $this->venue->getLng())); return json_encode($out); }
public function addEvent(EventModel $event, $groups = array(), VenueModel $venue = null, AreaModel $area = null, CountryModel $country = null, $eventMedias = array()) { global $CONFIG; $siteurlbase = $CONFIG->getWebSiteDomainSecure($this->site ? $this->site->getSlug() : $event->getSiteSlug()); $siteurl = $siteurlbase . '/event/' . $event->getSlugForUrl(); $url = $event->getUrl() && filter_var($event->getUrl(), FILTER_VALIDATE_URL) ? $event->getUrl() : $siteurl; $ticket_url = $event->getTicketUrl() && filter_var($event->getTicketUrl(), FILTER_VALIDATE_URL) ? $event->getTicketUrl() : null; $this->events[] = $this->getCell($event->getSlug()) . $this->delimiter . $this->getCell($event->getSlugForUrl()) . $this->delimiter . $this->getCell($event->getSummary()) . $this->delimiter . $this->getCell($event->getSummaryDisplay()) . $this->delimiter . $this->getCell($event->getDescription()) . $this->delimiter . $this->getCellBoolean($event->getIsDeleted()) . $this->delimiter . $this->getCellBoolean($event->getIsCancelled()) . $this->delimiter . $this->getCellBoolean($event->getIsPhysical()) . $this->delimiter . $this->getCellBoolean($event->getIsVirtual()) . $this->delimiter . $this->getCell($siteurl) . $this->delimiter . $this->getCell($url) . $this->delimiter . $this->getCell($ticket_url) . $this->delimiter . $this->getCell($event->getTimezone()) . $this->delimiter . $this->getCell($event->getStartAtInUTC()->format("r")) . $this->delimiter . $this->getCell($event->getEndAtInUTC()->format("r")) . $this->delimiter . $this->getCell($event->getStartAtInTimezone()->format("r")) . $this->delimiter . $this->getCell($event->getEndAtInTimezone()->format("r")) . $this->delimiter . ($venue ? $this->getCell($venue->getSlug()) . $this->delimiter . $this->getCell($venue->getSlugForUrl()) . $this->delimiter . $this->getCell($venue->getTitle()) . $this->delimiter . $this->getCell($venue->getDescription()) . $this->delimiter . $this->getCell($venue->getAddress()) . $this->delimiter . $this->getCell($venue->getAddressCode()) . $this->delimiter . $this->getCell($venue->getLat()) . $this->delimiter . $this->getCell($venue->getLng()) . $this->delimiter . $this->getCell($siteurlbase . '/venue/' . $venue->getSlugForUrl()) . $this->delimiter : $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter) . ($area ? $this->getCell($area->getSlug()) . $this->delimiter . $this->getCell($area->getSlugForUrl()) . $this->delimiter . $this->getCell($area->getTitle()) . $this->delimiter . $this->getCell($area->getDescription()) . $this->delimiter . $this->getCell($siteurlbase . '/area/' . $area->getSlugForUrl()) . $this->delimiter : $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter) . ($country ? $this->getCell($country->getTwoCharCode()) . $this->delimiter . $this->getCell($country->getTitle()) . $this->delimiter . $this->getCell($siteurlbase . '/country/' . $country->getTwoCharCode()) . $this->delimiter : $this->delimiter . $this->delimiter . $this->delimiter); }
public function addDetailsToVenue(VenueModel $venue) { if ($venue->getAddressCode() && (!$venue->getLat() || !$venue->getLng())) { $cr = new CountryRepository(); $gb = $cr->loadByTwoCharCode("GB"); if ($venue->getCountryId() == $gb->getId()) { list($lat, $lng) = AddressCodeGBOpenCodePointGet::get($venue->getAddressCode()); if ($lat && $lng) { $venue->setLat($lat); $venue->setLng($lng); } } } }
public function update(VenueModel $venue, $fields, VenueEditMetaDataModel $venueEditMetaDataModel) { $alreadyInTransaction = $this->db->inTransaction(); // Make Information Data $fieldsSQL1 = array(); $fieldsParams1 = array('id' => $venue->getId()); foreach ($fields as $field) { $fieldsSQL1[] = " " . $field . "=:" . $field . " "; if ($field == 'title') { $fieldsParams1['title'] = substr($venue->getTitle(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'lat') { $fieldsParams1['lat'] = $venue->getLat(); } else { if ($field == 'lng') { $fieldsParams1['lng'] = $venue->getLng(); } else { if ($field == 'description') { $fieldsParams1['description'] = $venue->getDescription(); } else { if ($field == 'address') { $fieldsParams1['address'] = $venue->getAddress(); } else { if ($field == 'address_code') { $fieldsParams1['address_code'] = substr($venue->getAddressCode(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'country_id') { $fieldsParams1['country_id'] = $venue->getCountryId(); } else { if ($field == 'area_id') { $fieldsParams1['area_id'] = $venue->getAreaId(); } else { if ($field == 'is_duplicate_of_id') { $fieldsParams1['is_duplicate_of_id'] = $venue->getIsDuplicateOfId(); } else { if ($field == 'is_deleted') { $fieldsParams1['is_deleted'] = $venue->getIsDeleted() ? 1 : 0; } } } } } } } } } } } // Make History Data $fieldsSQL2 = array('venue_id', 'user_account_id', 'created_at', 'approved_at'); $fieldsSQLParams2 = array(':venue_id', ':user_account_id', ':created_at', ':approved_at'); $fieldsParams2 = array('venue_id' => $venue->getId(), 'user_account_id' => $venueEditMetaDataModel->getUserAccount() ? $venueEditMetaDataModel->getUserAccount()->getId() : null, 'created_at' => $this->timesource->getFormattedForDataBase(), 'approved_at' => $this->timesource->getFormattedForDataBase()); if ($venueEditMetaDataModel->getEditComment()) { $fieldsSQL2[] = ' edit_comment '; $fieldsSQLParams2[] = ' :edit_comment '; $fieldsParams2['edit_comment'] = $venueEditMetaDataModel->getEditComment(); } foreach ($this->possibleFields as $field) { if (in_array($field, $fields) || $field == 'title') { $fieldsSQL2[] = " " . $field . " "; $fieldsSQLParams2[] = " :" . $field . " "; if ($field == 'title') { $fieldsParams2['title'] = substr($venue->getTitle(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'lat') { $fieldsParams2['lat'] = $venue->getLat(); } else { if ($field == 'lng') { $fieldsParams2['lng'] = $venue->getLng(); } else { if ($field == 'description') { $fieldsParams2['description'] = $venue->getDescription(); } else { if ($field == 'address') { $fieldsParams2['address'] = $venue->getAddress(); } else { if ($field == 'address_code') { $fieldsParams2['address_code'] = substr($venue->getAddressCode(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'country_id') { $fieldsParams2['country_id'] = $venue->getCountryId(); } else { if ($field == 'area_id') { $fieldsParams2['area_id'] = $venue->getAreaId(); } else { if ($field == 'is_duplicate_of_id') { $fieldsParams2['is_duplicate_of_id'] = $venue->getIsDuplicateOfId(); } else { if ($field == 'is_deleted') { $fieldsParams2['is_deleted'] = $venue->getIsDeleted() ? 1 : 0; } } } } } } } } } } $fieldsSQL2[] = " " . $field . "_changed "; $fieldsSQLParams2[] = " 0 "; } else { $fieldsSQL2[] = " " . $field . "_changed "; $fieldsSQLParams2[] = " -2 "; } } try { if (!$alreadyInTransaction) { $this->db->beginTransaction(); } // Information SQL $stat = $this->db->prepare("UPDATE venue_information SET " . implode(",", $fieldsSQL1) . " WHERE id=:id"); $stat->execute($fieldsParams1); // History SQL $stat = $this->db->prepare("INSERT INTO venue_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 addOtherDataVenue(VenueModel $venue) { $this->otherData['venue'] = array('slug' => $venue->getId(), 'title' => $venue->getTitle(), 'lat' => $venue->getLat(), 'lng' => $venue->getLng()); }
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; }