コード例 #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
ファイル: 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;
 }