示例#1
0
文件: Event.php 项目: cultuurnet/cdb
 /**
  * Appends the current object to the passed DOM tree.
  *
  * @param DOMElement $element
  *   The DOM tree to append to.
  * @param string $cdbScheme
  *   The cdb schema version.
  *
  * @see CultureFeed_Cdb_IElement::appendToDOM()
  */
 public function appendToDOM(DOMElement $element, $cdbScheme = '3.2')
 {
     $dom = $element->ownerDocument;
     $eventElement = $dom->createElement('event');
     if ($this->ageFrom) {
         $eventElement->appendChild($dom->createElement('agefrom', $this->ageFrom));
     }
     if ($this->availableFrom) {
         $eventElement->setAttribute('availablefrom', $this->availableFrom);
     }
     if ($this->availableTo) {
         $eventElement->setAttribute('availableto', $this->availableTo);
     }
     if ($this->cdbId) {
         $eventElement->setAttribute('cdbid', $this->cdbId);
     }
     if ($this->createdBy) {
         $eventElement->setAttribute('createdby', $this->createdBy);
     }
     if ($this->creationDate) {
         $eventElement->setAttribute('creationdate', $this->creationDate);
     }
     if ($this->externalId) {
         $eventElement->setAttribute('externalid', $this->externalId);
     }
     if (isset($this->isParent)) {
         $eventElement->setAttribute('isparent', $this->isParent ? 'true' : 'false');
     }
     if (isset($this->lastUpdated)) {
         $eventElement->setAttribute('lastupdated', $this->lastUpdated);
     }
     if (isset($this->lastUpdatedBy)) {
         $eventElement->setAttribute('lastupdatedby', $this->lastUpdatedBy);
     }
     if (isset($this->owner)) {
         $eventElement->setAttribute('owner', $this->owner);
     }
     if (isset($this->pctComplete)) {
         $eventElement->setAttribute('pctcomplete', $this->pctComplete);
     }
     if (isset($this->private)) {
         $eventElement->setAttribute('private', $this->private ? 'true' : 'false');
     }
     if (isset($this->published)) {
         $eventElement->setAttribute('published', $this->published ? 'true' : 'false');
     }
     if (isset($this->validator)) {
         $eventElement->setAttribute('validator', $this->validator);
     }
     if (isset($this->wfStatus)) {
         $eventElement->setAttribute('wfstatus', $this->wfStatus);
     }
     if ($this->publisher) {
         $eventElement->setAttribute('publisher', $this->publisher);
     }
     if ($this->calendar) {
         $this->calendar->appendToDOM($eventElement);
     }
     if ($this->categories) {
         $this->categories->appendToDOM($eventElement);
     }
     if ($this->contactInfo) {
         $this->contactInfo->appendToDOM($eventElement);
     }
     if ($this->details) {
         $this->details->appendToDOM($eventElement);
     }
     if (count($this->keywords) > 0) {
         $keywordsElement = $dom->createElement('keywords');
         if (version_compare($cdbScheme, '3.3', '>=')) {
             foreach ($this->keywords as $keyword) {
                 $keyword->appendToDOM($keywordsElement);
             }
             $eventElement->appendChild($keywordsElement);
         } else {
             $keywords = array();
             foreach ($this->keywords as $keyword) {
                 $keywords[$keyword->getValue()] = $keyword->getValue();
             }
             $keywordsElement->appendChild($dom->createTextNode(implode(';', $keywords)));
             $eventElement->appendChild($keywordsElement);
         }
     }
     if (isset($this->languages)) {
         $this->languages->appendToDOM($eventElement);
     }
     if ($this->location) {
         $this->location->appendToDOM($eventElement);
     }
     if ($this->organiser) {
         $this->organiser->appendToDOM($eventElement);
     }
     if ($this->maxParticipants) {
         $eventElement->appendChild($dom->createElement('maxparticipants', $this->maxParticipants));
     }
     if ($this->bookingPeriod) {
         $this->bookingPeriod->appendToDOM($eventElement);
     }
     if (!empty($this->relations)) {
         $relationsElement = $dom->createElement('eventrelations');
         foreach ($this->relations as $relation) {
             $relationElement = $dom->createElement('relatedproduction');
             $relationElement->appendChild($dom->createTextNode($relation->getTitle()));
             $relationElement->setAttribute('cdbid', $relation->getCdbid());
             $externalId = $relation->getExternalId();
             if ($externalId) {
                 $relationElement->setAttribute('externalid', $relation->getExternalId());
             }
             $relationsElement->appendChild($relationElement);
         }
         $eventElement->appendChild($relationsElement);
     }
     $element->appendChild($eventElement);
 }