Skip to content

Commit

Permalink
Merge branch 'feature/III-907' into feature/III-878
Browse files Browse the repository at this point in the history
* feature/III-907:
  III-907: Moved shared attributes & elements to Base and added externalurl attribute.
  III-907: Fixed bug where a price value of 0 would be parsed as null.

# Conflicts:
#	lib/CultureFeed/Cdb/Item/Event.php
  • Loading branch information
bertramakers committed Apr 20, 2016
2 parents 0301f35 + ec1de9d commit e6919aa
Show file tree
Hide file tree
Showing 9 changed files with 433 additions and 309 deletions.
2 changes: 1 addition & 1 deletion lib/CultureFeed/Cdb/Data/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function appendToDOM(DOMELement $element)
public static function parseFromCdbXml(SimpleXMLElement $xmlElement)
{

$value = !empty($xmlElement->pricevalue) ? (string) $xmlElement->pricevalue : null;
$value = ($xmlElement->pricevalue != null) ? (string) $xmlElement->pricevalue : null;
$price = new CultureFeed_Cdb_Data_Price($value);

if (!empty($xmlElement->pricedescription)) {
Expand Down
70 changes: 8 additions & 62 deletions lib/CultureFeed/Cdb/Item/Actor.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ public function __construct()
*/
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'
Expand All @@ -60,21 +54,16 @@ public static function parseFromCdbXml(SimpleXMLElement $xmlElement)

$actor = new self();

CultureFeed_Cdb_Item_Base::parseCommonAttributes($actor, $xmlElement);
self::parseCommonAttributes($actor, $xmlElement);
self::parseKeywords($actor, $xmlElement);
self::parseCategories($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(
Expand All @@ -84,9 +73,6 @@ public static function parseFromCdbXml(SimpleXMLElement $xmlElement)
);
}

// Set the keywords.
self::parseKeywords($xmlElement, $actor);

// Set the weekscheme.
if (!empty($xmlElement->weekscheme)) {
$actor->setWeekScheme(
Expand Down Expand Up @@ -146,66 +132,26 @@ public function setWeekScheme(CultureFeed_Cdb_Data_Calendar_Weekscheme $weekSche
*/
public function appendToDOM(DOMElement $element, $cdbScheme = '3.2')
{

$dom = $element->ownerDocument;

$actorElement = $dom->createElement('actor');

if ($this->cdbId) {
$actorElement->setAttribute('cdbid', $this->cdbId);
}
$this->appendCommonAttributesToDOM($actorElement, $cdbScheme);
$this->appendKeywordsToDOM($actorElement, $cdbScheme);
$this->appendCategoriesToDOM($actorElement, $cdbScheme);

if ($this->externalId) {
$actorElement->setAttribute('externalid', $this->externalId);
if ($this->asset == true) {
$actorElement->setAttribute('asset', true);
}

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);
}
Expand Down
Loading

0 comments on commit e6919aa

Please sign in to comment.