示例#1
0
文件: Actor.php 项目: cultuurnet/cdb
 /**
  * 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;
     $actorElement = $dom->createElement('actor');
     if ($this->cdbId) {
         $actorElement->setAttribute('cdbid', $this->cdbId);
     }
     if ($this->externalId) {
         $actorElement->setAttribute('externalid', $this->externalId);
     }
     if ($this->details) {
         $this->details->appendToDOM($actorElement);
     }
     if ($this->categories) {
         $this->categories->appendToDOM($actorElement);
     }
     if ($this->contactInfo) {
         $this->contactInfo->appendToDOM($actorElement);
     }
     if ($this->createdBy) {
         $actorElement->setAttribute('createdby', $this->createdBy);
     }
     if ($this->creationDate) {
         $actorElement->setAttribute('creationdate', $this->creationDate);
     }
     if (isset($this->lastUpdated)) {
         $actorElement->setAttribute('lastupdated', $this->lastUpdated);
     }
     if (isset($this->lastUpdatedBy)) {
         $actorElement->setAttribute('lastupdatedby', $this->lastUpdatedBy);
     }
     if (count($this->keywords) > 0) {
         $keywordsElement = $dom->createElement('keywords');
         if (version_compare($cdbScheme, '3.3', '>=')) {
             foreach ($this->keywords as $keyword) {
                 $keyword->appendToDOM($keywordsElement);
             }
             $actorElement->appendChild($keywordsElement);
         } else {
             $keywords = array();
             foreach ($this->keywords as $keyword) {
                 $keywords[$keyword->getValue()] = $keyword->getValue();
             }
             $keywordsElement->appendChild($dom->createTextNode(implode(';', $keywords)));
             $actorElement->appendChild($keywordsElement);
         }
     }
     if ($this->weekScheme) {
         $this->weekScheme->appendToDOM($actorElement);
     }
     $element->appendChild($actorElement);
 }
示例#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;
 }