Exemplo n.º 1
0
 /**
  * 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;
     $productionElement = $dom->createElement('production');
     if ($this->availableFrom) {
         $productionElement->setAttribute('availablefrom', $this->availableFrom);
     }
     if ($this->availableTo) {
         $productionElement->setAttribute('availableto', $this->availableTo);
     }
     if ($this->createdBy) {
         $productionElement->setAttribute('createdby', $this->createdBy);
     }
     if ($this->creationDate) {
         $productionElement->setAttribute('creationdate', $this->creationDate);
     }
     if ($this->ageFrom) {
         $productionElement->appendChild($dom->createElement('agefrom', $this->ageFrom));
     }
     if ($this->maxParticipants) {
         $productionElement->appendChild($dom->createElement('maxparticipants', $this->maxParticipants));
     }
     if ($this->bookingPeriod) {
         $this->bookingPeriod->appendToDOM($productionElement);
     }
     if ($this->cdbId) {
         $productionElement->setAttribute('cdbid', $this->cdbId);
     }
     if ($this->externalId) {
         $productionElement->setAttribute('externalid', $this->externalId);
     }
     if ($this->categories) {
         $this->categories->appendToDOM($productionElement);
     }
     if ($this->details) {
         $this->details->appendToDOM($productionElement);
     }
     if (count($this->keywords) > 0) {
         $keywordElement = $dom->createElement('keywords');
         $keywordElement->appendChild($dom->createTextNode(implode(';', $this->keywords)));
         $productionElement->appendChild($keywordElement);
     }
     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());
             $relationElement->setAttribute('externalid', $relation->getExternalId());
             $relationsElement->appendChild($relationElement);
         }
         $productionElement->appendChild($relationsElement);
     }
     $element->appendChild($productionElement);
 }
Exemplo n.º 2
0
 /**
  * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement $xmlElement)
  *
  * @return CultureFeed_Cdb_Item_Production
  */
 public static function parseFromCdbXml(SimpleXMLElement $xmlElement)
 {
     if (empty($xmlElement->categories)) {
         throw new CultureFeed_ParseException('Categories are required for production element');
     }
     if (empty($xmlElement->productiondetails)) {
         throw new CultureFeed_ParseException('Production details are required for production element');
     }
     $attributes = $xmlElement->attributes();
     $production = new CultureFeed_Cdb_Item_Production();
     // Set ID.
     if (isset($attributes['cdbid'])) {
         $production->setCdbId((string) $attributes['cdbid']);
     }
     if (isset($attributes['externalid'])) {
         $production->setExternalId((string) $attributes['externalid']);
     }
     if (isset($event_attributes['availablefrom'])) {
         $production->setAvailableFrom((string) $event_attributes['availablefrom']);
     }
     if (isset($event_attributes['availableto'])) {
         $production->setAvailableTo((string) $event_attributes['availableto']);
     }
     if (isset($event_attributes['createdby'])) {
         $production->setCreatedBy((string) $event_attributes['createdby']);
     }
     if (isset($event_attributes['creationdate'])) {
         $production->setCreationDate((string) $event_attributes['creationdate']);
     }
     if (!empty($xmlElement->agefrom)) {
         $production->setAgeFrom((int) $xmlElement->agefrom);
     }
     // Set organiser.
     if (!empty($xmlElement->organiser)) {
         $production->setOrganiser(CultureFeed_Cdb_Data_Organiser::parseFromCdbXml($xmlElement->organiser));
     }
     // Set categories
     $production->setCategories(CultureFeed_Cdb_Data_CategoryList::parseFromCdbXml($xmlElement->categories));
     // Set production details.
     $production->setDetails(CultureFeed_Cdb_Data_ProductionDetailList::parseFromCdbXml($xmlElement->productiondetails));
     // Set max participants.
     if (!empty($xmlElement->maxparticipants)) {
         $production->setMaxParticipants((int) $xmlElement->maxparticipants);
     }
     // Set booking period.
     if (!empty($xmlElement->bookingperiod)) {
         $production->setBookingPeriod(CultureFeed_Cdb_Data_Calendar_BookingPeriod::parseFromCdbXml($xmlElement->bookingperiod));
     }
     // Set the related events for this production.
     if (!empty($xmlElement->relatedevents) && isset($xmlElement->relatedevents->id)) {
         foreach ($xmlElement->relatedevents->id as $relatedItem) {
             $attributes = $relatedItem->attributes();
             $production->addRelation(new CultureFeed_Cdb_Item_Reference((string) $attributes['cdbid']));
         }
     }
     // Set the keywords.
     self::parseKeywords($xmlElement, $production);
     return $production;
 }
Exemplo n.º 3
0
 /**
  * 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);
 }