Example #1
0
 /**
  * @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;
 }
Example #2
0
 /**
  * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement $xmlElement)
  * @return CultureFeed_Cdb_Item_Page
  */
 public static function parseFromCdbXml(SimpleXMLElement $xmlElement)
 {
     if (empty($xmlElement->uid)) {
         throw new CultureFeed_Cdb_ParseException('Uid missing for page element');
     }
     if (empty($xmlElement->name)) {
         throw new CultureFeed_Cdb_ParseException('Name missing for page element');
     }
     $page = new self();
     // Set ID + name.
     $page->setId((string) $xmlElement->uid);
     $page->setName((string) $xmlElement->name);
     $page->setOfficialPage(filter_var((string) $xmlElement->officialPage, FILTER_VALIDATE_BOOLEAN));
     // Set categories
     $categories = array();
     if (!empty($xmlElement->categoryIds->categoryId)) {
         foreach ($xmlElement->categoryIds->categoryId as $category) {
             $categories[] = (string) $category;
         }
     }
     $page->setCategories($categories);
     // Set keywords
     $keywords = array();
     if (!empty($xmlElement->keywords->keyword)) {
         foreach ($xmlElement->keywords->keyword as $keyword) {
             $keywords[] = (string) $keyword;
         }
     }
     $page->setKeywords($keywords);
     // Set description.
     if (!empty($xmlElement->description)) {
         $page->setDescription((string) $xmlElement->description);
     }
     // Set the image.
     if (!empty($xmlElement->image)) {
         $page->setImage((string) $xmlElement->image);
     }
     // Set the cover.
     if (!empty($xmlElement->cover)) {
         $page->setCover((string) $xmlElement->cover);
     }
     // Set the visibility.
     if (!empty($xmlElement->visible)) {
         $page->setVisibility((string) $xmlElement->visible);
     }
     // Set address.
     $address = new CultureFeed_Cdb_Data_Address_PhysicalAddress();
     $addressElement = $xmlElement->address;
     $has_address = FALSE;
     if (!empty($addressElement->city)) {
         $address->setCity((string) $addressElement->city);
         $has_address = TRUE;
     }
     if (!empty($addressElement->street)) {
         $address->setStreet((string) $addressElement->street);
         $has_address = TRUE;
     }
     if (!empty($addressElement->zip)) {
         $address->setZip((string) $addressElement->zip);
         $has_address = TRUE;
     }
     if (!empty($addressElement->country)) {
         $address->setCountry((string) $addressElement->country);
         $has_address = TRUE;
     }
     if (!empty($addressElement->lat) && !empty($addressElement->lon)) {
         $coordinates = $addressElement->lat . '-' . $addressElement->lon;
         if ($coordinates != '0.0-0.0') {
             $address->setGeoInformation(new CultureFeed_Cdb_Data_Address_GeoInformation((string) $addressElement->lon, (string) $addressElement->lat));
             $has_address = TRUE;
         }
     }
     if ($has_address) {
         $page->setAddress($address);
     }
     // Set contact info.
     if (!empty($xmlElement->contactInfo->email)) {
         $page->setEmail((string) $xmlElement->contactInfo->email);
     }
     if (!empty($xmlElement->contactInfo->telephone)) {
         $page->setTelephone((string) $xmlElement->contactInfo->telephone);
     }
     // Set links.
     $links = array();
     if (!empty($xmlElement->links)) {
         foreach ($xmlElement->links->children() as $link) {
             $url = (string) $link;
             if (empty($url)) {
                 continue;
             }
             // Make sure http is in front of the url.
             if (strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) {
                 $url = 'http://' . $url;
             }
             $links[$link->getName()] = $url;
         }
     }
     $page->setLinks($links);
     // Set the permissions.
     $page->setPermissions(CultureFeed_Cdb_Data_PagePermissions::parseFromCdbXml($xmlElement->permissions));
     // Set tagline.
     $page->setTagline((string) $xmlElement->tagline);
     return $page;
 }