Пример #1
0
 /**
  * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement
  *     $xmlElement)
  * @throws CultureFeed_Cdb_ParseException
  * @return CultureFeed_Cdb_Item_Actor
  */
 public static function parseFromCdbXml(SimpleXMLElement $xmlElement)
 {
     if (empty($xmlElement->categories)) {
         throw new CultureFeed_Cdb_ParseException('Categories missing for actor element');
     }
     if (empty($xmlElement->actordetails)) {
         throw new CultureFeed_Cdb_ParseException('Actordetails missing for actor element');
     }
     $actor = new self();
     CultureFeed_Cdb_Item_Base::parseCommonAttributes($actor, $xmlElement);
     $actor->setDetails(CultureFeed_Cdb_Data_ActorDetailList::parseFromCdbXml($xmlElement->actordetails));
     // Set categories
     $actor->setCategories(CultureFeed_Cdb_Data_CategoryList::parseFromCdbXml($xmlElement->categories));
     // Set contact information.
     if (!empty($xmlElement->contactinfo)) {
         $actor->setContactInfo(CultureFeed_Cdb_Data_ContactInfo::parseFromCdbXml($xmlElement->contactinfo));
     }
     // Set the keywords.
     self::parseKeywords($xmlElement, $actor);
     // Set the weekscheme.
     if (!empty($xmlElement->weekscheme)) {
         $actor->setWeekScheme(CultureFeed_Cdb_Data_Calendar_Weekscheme::parseFromCdbXml($xmlElement->weekscheme));
     }
     return $actor;
 }
Пример #2
0
 /**
  * @param CultureFeed_Cdb_Item_Base $item
  * @param SimpleXMLElement $xmlElement
  */
 protected static function parseCommonAttributes(CultureFeed_Cdb_Item_Base $item, SimpleXMLElement $xmlElement)
 {
     $attributes = $xmlElement->attributes();
     if (isset($attributes['cdbid'])) {
         $item->setCdbId((string) $attributes['cdbid']);
     }
     if (isset($attributes['externalid'])) {
         $item->setExternalId((string) $attributes['externalid']);
     }
     if (isset($attributes['availablefrom'])) {
         $item->setAvailableFrom((string) $attributes['availablefrom']);
     }
     if (isset($attributes['availableto'])) {
         $item->setAvailableTo((string) $attributes['availableto']);
     }
     if (isset($attributes['createdby'])) {
         $item->setCreatedBy((string) $attributes['createdby']);
     }
     if (isset($attributes['creationdate'])) {
         $item->setCreationDate((string) $attributes['creationdate']);
     }
     if (isset($attributes['lastupdated'])) {
         $item->setLastUpdated((string) $attributes['lastupdated']);
     }
     if (isset($attributes['lastupdatedby'])) {
         $item->setLastUpdatedBy((string) $attributes['lastupdatedby']);
     }
     if (isset($attributes['owner'])) {
         $item->setOwner((string) $attributes['owner']);
     }
     if (isset($attributes['publisher'])) {
         $item->setPublisher((string) $attributes['publisher']);
     }
     if (isset($attributes['wfstatus'])) {
         $item->setWfStatus((string) $attributes['wfstatus']);
     }
 }
Пример #3
0
 /**
  * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement
  *     $xmlElement)
  * @return CultureFeed_Cdb_Item_Event
  */
 public static function parseFromCdbXml(SimpleXMLElement $xmlElement)
 {
     if (empty($xmlElement->calendar)) {
         throw new CultureFeed_Cdb_ParseException('Calendar missing for event element');
     }
     if (empty($xmlElement->categories)) {
         throw new CultureFeed_Cdb_ParseException('Categories missing for event element');
     }
     if (empty($xmlElement->contactinfo)) {
         throw new CultureFeed_Cdb_ParseException('Contact info missing for event element');
     }
     if (empty($xmlElement->eventdetails)) {
         throw new CultureFeed_Cdb_ParseException('Eventdetails missing for event element');
     }
     if (empty($xmlElement->location)) {
         throw new CultureFeed_Cdb_ParseException('Location missing for event element');
     }
     $event_attributes = $xmlElement->attributes();
     $event = new CultureFeed_Cdb_Item_Event();
     CultureFeed_Cdb_Item_Base::parseCommonAttributes($event, $xmlElement);
     if (isset($event_attributes['private'])) {
         $event->setPrivate(filter_var((string) $event_attributes['private'], FILTER_VALIDATE_BOOLEAN));
     }
     if (isset($event_attributes['isparent'])) {
         $event->setIsParent(filter_var((string) $event_attributes['isparent'], FILTER_VALIDATE_BOOLEAN));
     }
     if (isset($event_attributes['pctcomplete'])) {
         $event->setPctComplete(floatval($event_attributes['pctcomplete']));
     }
     if (isset($event_attributes['published'])) {
         $event->setPublished(filter_var((string) $event_attributes['published'], FILTER_VALIDATE_BOOLEAN));
     }
     if (isset($event_attributes['validator'])) {
         $event->setValidator((string) $event_attributes['validator']);
     }
     if (isset($event_attributes['weight'])) {
         $event->setWeight((int) $event_attributes['weight']);
     }
     if (isset($xmlElement->agefrom)) {
         $event->setAgeFrom((int) $xmlElement->agefrom);
     }
     // Set calendar information.
     $calendar_type = key($xmlElement->calendar);
     if ($calendar_type == 'permanentopeningtimes') {
         $event->setCalendar(CultureFeed_Cdb_Data_Calendar_Permanent::parseFromCdbXml($xmlElement->calendar));
     } elseif ($calendar_type == 'timestamps') {
         $event->setCalendar(CultureFeed_Cdb_Data_Calendar_TimestampList::parseFromCdbXml($xmlElement->calendar->timestamps));
     } elseif ($calendar_type == 'periods') {
         $event->setCalendar(CultureFeed_Cdb_Data_Calendar_PeriodList::parseFromCdbXml($xmlElement->calendar));
     }
     // Set categories
     $event->setCategories(CultureFeed_Cdb_Data_CategoryList::parseFromCdbXml($xmlElement->categories));
     // Set contact information.
     $event->setContactInfo(CultureFeed_Cdb_Data_ContactInfo::parseFromCdbXml($xmlElement->contactinfo));
     // Set event details.
     $event->setDetails(CultureFeed_Cdb_Data_EventDetailList::parseFromCdbXml($xmlElement->eventdetails));
     // Set location.
     $event->setLocation(CultureFeed_Cdb_Data_Location::parseFromCdbXml($xmlElement->location));
     // Set organiser
     if (!empty($xmlElement->organiser)) {
         $event->setOrganiser(CultureFeed_Cdb_Data_Organiser::parseFromCdbXml($xmlElement->organiser));
     }
     // Set max participants.
     if (!empty($xmlElement->maxparticipants)) {
         $event->setMaxParticipants((int) $xmlElement->maxparticipants);
     }
     // Set booking period.
     if (!empty($xmlElement->bookingperiod)) {
         $event->setBookingPeriod(CultureFeed_Cdb_Data_Calendar_BookingPeriod::parseFromCdbXml($xmlElement->bookingperiod));
     }
     // Set relations.
     if (!empty($xmlElement->eventrelations) && !empty($xmlElement->eventrelations->relatedproduction)) {
         foreach ($xmlElement->eventrelations->relatedproduction as $relatedProduction) {
             $attributes = $relatedProduction->attributes();
             $event->addRelation(new CultureFeed_Cdb_Item_Reference((string) $attributes['cdbid'], (string) $relatedProduction, (string) $attributes['externalid']));
         }
     }
     self::parseKeywords($xmlElement, $event);
     if (!empty($xmlElement->languages)) {
         $event->setLanguages(CultureFeed_Cdb_Data_LanguageList::parseFromCdbXml($xmlElement->languages));
     }
     return $event;
 }
Пример #4
0
 /**
  * @param \CultureFeed_Cdb_Item_Base $cdbItem
  */
 private function createLabelAggregatesFromCdbItem(\CultureFeed_Cdb_Item_Base $cdbItem)
 {
     /* @var \CultureFeed_Cdb_Data_Keyword[] $keywords */
     $keywords = $cdbItem->getKeywords(true);
     foreach ($keywords as $keyword) {
         $this->labelService->createLabelAggregateIfNew(new LabelName($keyword->getValue()), $keyword->isVisible());
     }
 }
Пример #5
0
 /**
  * Parses keywords from cdbxml.
  * @param SimpleXMLElement $xmlElement
  * @param CultureFeed_Cdb_Item_Base $item
  */
 protected static function parseKeywords(SimpleXMLElement $xmlElement, CultureFeed_Cdb_Item_Base $item)
 {
     if (@count($xmlElement->keywords)) {
         $keywordsString = trim($xmlElement->keywords);
         if ($keywordsString === '') {
             /** @var SimpleXMLElement $keywordElement */
             foreach ($xmlElement->keywords->keyword as $keywordElement) {
                 $attributes = $keywordElement->attributes();
                 $visible = !isset($attributes['visible']) || $attributes['visible'] == 'true';
                 $item->addKeyword(new CultureFeed_Cdb_Data_Keyword((string) $keywordElement, $visible));
             }
         } else {
             $keywords = explode(';', $keywordsString);
             foreach ($keywords as $keyword) {
                 $item->addKeyword(trim($keyword));
             }
         }
     }
 }