function onThisStepProcessPage() { if ($this->getCurrentMode() == $this->MODE_FREE) { if ($this->request->request->get('action') == 'startAndEndFreeText') { $this->draftEvent->setDetailsValue('event.start_end_freetext.start', \TimeSource::getDateTime()); $this->draftEvent->setDetailsValue('event.start_end_freetext.end', \TimeSource::getDateTime()); if ($this->request->request->get('startAndEndFreeText')) { $parse = new ParseDateTimeRangeString(\TimeSource::getDateTime(), $this->application['currentTimeZone']); $parseResult = $parse->parse($this->request->request->get('startAndEndFreeText')); if ($parseResult->getStart()) { $this->draftEvent->setDetailsValue('event.start_end_freetext.start', $parseResult->getStart()); // If no end is returned, just set start as sensible default $this->draftEvent->setDetailsValue('event.start_end_freetext.end', $parseResult->getEnd() ? $parseResult->getEnd() : $parseResult->getStart()); } } $this->draftEvent->setDetailsValue('event.start_end_freetext.text', $this->request->request->get('startAndEndFreeText')); $this->draftEvent->setDetailsValue('event.start_end_freetext.done', 'yes'); return true; } } else { if ('POST' == $this->request->getMethod()) { $this->form->bind($this->request); // Store these on object for JS $this->currentStart = $this->form->get('start_at')->getData(); $this->currentEnd = $this->form->get('end_at')->getData(); $this->currentTimeZone = $this->form->get('timezone')->getData(); if ($this->form->isValid()) { $this->draftEvent->setDetailsValue('event.start_at', $this->form->get('start_at')->getData()); $this->draftEvent->setDetailsValue('event.end_at', $this->form->get('end_at')->getData()); $this->draftEvent->setDetailsValue('event.country_id', $this->form->get('country_id')->getData()); $this->draftEvent->setDetailsValue('event.timezone', $this->form->get('timezone')->getData()); $this->isAllInformationGathered = true; return true; } } } return false; }
protected function setOurEventFromEventObject(ImportedEventModel $importedEvent, $event) { $changesToSave = false; if ($importedEvent->getTitle() != $event->eventTitle) { $importedEvent->setTitle($event->eventTitle); $changesToSave = true; } $description = $event->eventDetails . "\n\n"; $description .= $event->additionalInfo . "\n\n"; $description .= $event->practicalities . "\n\n"; $description .= $event->contactName . "\n"; $description .= $event->organisation . "\n"; $description .= $event->contactEmail . "\n"; $description .= $event->contactPhone . "\n"; $description .= $event->organisedBy . "\n"; $description .= $event->eventLocation . "\n"; $description .= $event->constitName . "\n"; $description .= $event->eventPostcode . "\n"; $description .= $event->eventDate . " " . $event->eventTime . "\n"; if ($importedEvent->getDescription() != $description) { $importedEvent->setDescription($description); $changesToSave = true; } if ($importedEvent->getUrl() != $event->url) { $importedEvent->setUrl($event->url); $changesToSave = true; } $importedEvent->setTimezone("Europe/London"); $p = new ParseDateTimeRangeString(TimeSource::getDateTime(), "Europe/London"); $r = $p->parse($event->eventDate . " " . $event->eventTime); if (!$importedEvent->getStartAt() || $importedEvent->getStartAt()->getTimeStamp() != $r->getStart()->getTimeStamp()) { $importedEvent->setStartAt(clone $r->getStart()); $changesToSave = true; } if (!$importedEvent->getEndAt() || $importedEvent->getEndAt()->getTimeStamp() != $r->getEnd()->getTimeStamp()) { $importedEvent->setEndAt(clone $r->getEnd()); $changesToSave = true; } return $changesToSave; }