示例#1
0
文件: Actor.php 项目: cultuurnet/cdb
 /**
  * @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
文件: Actor.php 项目: RustiSub/Cdb
 /**
  * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement $xmlElement)
  * @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();
     $actor_attributes = $xmlElement->attributes();
     if (isset($actor_attributes['cdbid'])) {
         $actor->setCdbId((string) $actor_attributes['cdbid']);
     }
     if (isset($actor_attributes['externalid'])) {
         $actor->setExternalId((string) $actor_attributes['externalid']);
     }
     if (isset($actor_attributes['availablefrom'])) {
         $actor->setAvailableFrom((string) $actor_attributes['availablefrom']);
     }
     if (isset($actor_attributes['availableto'])) {
         $actor->setAvailableTo((string) $actor_attributes['availableto']);
     }
     if (isset($actor_attributes['createdby'])) {
         $actor->setCreatedBy((string) $actor_attributes['createdby']);
     }
     if (isset($actor_attributes['creationdate'])) {
         $actor->setCreationDate((string) $actor_attributes['creationdate']);
     }
     if (isset($actor_attributes['lastupdated'])) {
         $actor->setLastUpdated((string) $actor_attributes['lastupdated']);
     }
     if (isset($actor_attributes['lastupdatedby'])) {
         $actor->setLastUpdatedBy((string) $actor_attributes['lastupdatedby']);
     }
     if (isset($actor_attributes['owner'])) {
         $actor->setOwner((string) $actor_attributes['owner']);
     }
     $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;
 }
示例#3
0
文件: Event.php 项目: cultuurnet/cdb
 /**
  * @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;
 }