Beispiel #1
0
 /**
  * Parse the given Offer Set Element
  *
  * @param  DOMElement $dom
  */
 public function __construct(DOMElement $dom)
 {
     $xpath = new DOMXPath($dom->ownerDocument);
     $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/' . Amazon::getVersion());
     $offer = $xpath->query('./az:OfferSummary', $dom);
     if ($offer->length == 1) {
         $lowestNewPrice = $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:Amount', $dom);
         if ($lowestNewPrice->length == 1) {
             $this->LowestNewPrice = (int) $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:Amount/text()', $dom)->item(0)->data;
             $this->LowestNewPriceCurrency = (string) $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:CurrencyCode/text()', $dom)->item(0)->data;
         }
         $lowestUsedPrice = $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:Amount', $dom);
         if ($lowestUsedPrice->length == 1) {
             $this->LowestUsedPrice = (int) $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:Amount/text()', $dom)->item(0)->data;
             $this->LowestUsedPriceCurrency = (string) $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:CurrencyCode/text()', $dom)->item(0)->data;
         }
         $this->TotalNew = (int) $xpath->query('./az:OfferSummary/az:TotalNew/text()', $dom)->item(0)->data;
         $this->TotalUsed = (int) $xpath->query('./az:OfferSummary/az:TotalUsed/text()', $dom)->item(0)->data;
         $this->TotalCollectible = (int) $xpath->query('./az:OfferSummary/az:TotalCollectible/text()', $dom)->item(0)->data;
         $this->TotalRefurbished = (int) $xpath->query('./az:OfferSummary/az:TotalRefurbished/text()', $dom)->item(0)->data;
     }
     $offers = $xpath->query('./az:Offers/az:Offer', $dom);
     if ($offers->length >= 1) {
         foreach ($offers as $offer) {
             $this->Offers[] = new Offer($offer);
         }
     }
 }
Beispiel #2
0
 /**
  * Parse the given Offer element
  *
  * @param DOMElement $dom
  */
 public function __construct(DOMElement $dom)
 {
     $xpath = new DOMXPath($dom->ownerDocument);
     $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/' . Amazon::getVersion());
     $this->MerchantId = (string) $xpath->query('./az:Merchant/az:MerchantId/text()', $dom)->item(0)->data;
     $name = $xpath->query('./az:Merchant/az:Name/text()', $dom);
     if ($name->length == 1) {
         $this->MerchantName = (string) $name->item(0)->data;
     }
     $this->GlancePage = (string) $xpath->query('./az:Merchant/az:GlancePage/text()', $dom)->item(0)->data;
     $this->Condition = (string) $xpath->query('./az:OfferAttributes/az:Condition/text()', $dom)->item(0)->data;
     $this->OfferListingId = (string) $xpath->query('./az:OfferListing/az:OfferListingId/text()', $dom)->item(0)->data;
     $Price = $xpath->query('./az:OfferListing/az:Price/az:Amount', $dom);
     if ($Price->length == 1) {
         $this->Price = (int) $xpath->query('./az:OfferListing/az:Price/az:Amount/text()', $dom)->item(0)->data;
         $this->CurrencyCode = (string) $xpath->query('./az:OfferListing/az:Price/az:CurrencyCode/text()', $dom)->item(0)->data;
     }
     $availability = $xpath->query('./az:OfferListing/az:Availability/text()', $dom)->item(0);
     if ($availability instanceof DOMText) {
         $this->Availability = (string) $availability->data;
     }
     $result = $xpath->query('./az:OfferListing/az:IsEligibleForSuperSaverShipping/text()', $dom);
     if ($result->length >= 1) {
         $this->IsEligibleForSuperSaverShipping = (bool) $result->item(0)->data;
     }
 }
Beispiel #3
0
 /**
  * Create an instance of Zend_Service_Amazon_ResultSet and create the necessary data objects
  *
  * @param  DOMDocument $dom
  * @return void
  */
 public function __construct(DOMDocument $dom)
 {
     $this->_dom = $dom;
     $this->_xpath = new DOMXPath($dom);
     $this->_xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/' . Amazon::getVersion());
     $this->_results = $this->_xpath->query('//az:Item');
 }
Beispiel #4
0
 /**
  * Assigns values to properties relevant to Accessories
  *
  * @param  DOMElement $dom
  */
 public function __construct(DOMElement $dom)
 {
     $xpath = new DOMXPath($dom->ownerDocument);
     $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/' . Amazon::getVersion());
     foreach (array('ASIN', 'Title') as $el) {
         $this->{$el} = (string) $xpath->query("./az:{$el}/text()", $dom)->item(0)->data;
     }
 }
Beispiel #5
0
 /**
  * Assigns values to properties relevant to Image
  *
  * @param  DOMElement $dom
  */
 public function __construct(DOMElement $dom)
 {
     $xpath = new DOMXPath($dom->ownerDocument);
     $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/' . Amazon::getVersion());
     $this->Url = Uri\UriFactory::factory($xpath->query('./az:URL/text()', $dom)->item(0)->data);
     $this->Height = (int) $xpath->query('./az:Height/text()', $dom)->item(0)->data;
     $this->Width = (int) $xpath->query('./az:Width/text()', $dom)->item(0)->data;
 }
Beispiel #6
0
 /**
  * Assigns values to properties relevant to CustomerReview
  *
  * @param  DOMElement $dom
  */
 public function __construct(DOMElement $dom)
 {
     $xpath = new DOMXPath($dom->ownerDocument);
     $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/' . Amazon::getVersion());
     foreach (array('Rating', 'HelpfulVotes', 'CustomerId', 'TotalVotes', 'Date', 'Summary', 'Content') as $el) {
         $result = $xpath->query("./az:{$el}/text()", $dom);
         if ($result->length == 1) {
             $this->{$el} = (string) $result->item(0)->data;
         }
     }
 }
Beispiel #7
0
 /**
  * Parse the given Offer element
  *
  * @param DOMElement $dom
  */
 public function __construct(DOMElement $dom)
 {
     $xpath = new DOMXPath($dom->ownerDocument);
     $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/' . Amazon::getVersion());
     $map = array('MerchantId' => './az:Merchant/az:MerchantId/text()', 'MerchantName' => './az:Merchant/az:Name/text()', 'GlancePage' => './az:Merchant/az:GlancePage/text()', 'Condition' => './az:OfferAttributes/az:Condition/text()', 'OfferListingId' => './az:OfferListing/az:OfferListingId/text()', 'Price' => './az:OfferListing/az:Price/az:Amount/text()', 'CurrencyCode' => './az:OfferListing/az:Price/az:CurrencyCode/text()', 'Availability' => './az:OfferListing/az:Availability/text()', 'IsEligibleForSuperSaverShipping' => './az:OfferListing/az:IsEligibleForSuperSaverShipping/text()');
     foreach ($map as $param_name => $xquery) {
         $query_result = $xpath->query($xquery, $dom);
         if ($query_result->length <= 0) {
             continue;
         }
         $text = $query_result->item(0);
         if (!$text instanceof DOMText) {
             continue;
         }
         $this->{$param_name} = (string) $text->data;
     }
     if (isset($this->IsEligibleForSuperSaverShipping)) {
         $this->IsEligibleForSuperSaverShipping = (bool) $this->IsEligibleForSuperSaverShipping;
     }
 }
Beispiel #8
0
 /**
  * Parse the given <Item> element
  *
  * @param DOMElement $dom
  *
  * @group ZF-9547
  */
 public function __construct(DOMElement $dom)
 {
     $xpath = new DOMXPath($dom->ownerDocument);
     $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/' . Amazon::getVersion());
     $this->ASIN = $xpath->query('./az:ASIN/text()', $dom)->item(0)->data;
     $result = $xpath->query('./az:DetailPageURL/text()', $dom);
     if ($result->length == 1) {
         $this->DetailPageURL = $result->item(0)->data;
     }
     if ($xpath->query('./az:ItemAttributes/az:ListPrice', $dom)->length >= 1) {
         $this->CurrencyCode = (string) $xpath->query('./az:ItemAttributes/az:ListPrice/az:CurrencyCode/text()', $dom)->item(0)->data;
         $this->Amount = (int) $xpath->query('./az:ItemAttributes/az:ListPrice/az:Amount/text()', $dom)->item(0)->data;
         $this->FormattedPrice = (string) $xpath->query('./az:ItemAttributes/az:ListPrice/az:FormattedPrice/text()', $dom)->item(0)->data;
     }
     $result = $xpath->query('./az:ItemAttributes/az:*/text()', $dom);
     if ($result->length >= 1) {
         foreach ($result as $v) {
             if (isset($this->{$v->parentNode->tagName})) {
                 if (is_array($this->{$v->parentNode->tagName})) {
                     array_push($this->{$v->parentNode->tagName}, (string) $v->data);
                 } else {
                     $this->{$v->parentNode->tagName} = array($this->{$v->parentNode->tagName}, (string) $v->data);
                 }
             } else {
                 $this->{$v->parentNode->tagName} = (string) $v->data;
             }
         }
     }
     foreach (array('SmallImage', 'MediumImage', 'LargeImage') as $im) {
         $result = $xpath->query("./az:ImageSets/az:ImageSet[position() = 1]/az:{$im}", $dom);
         if ($result->length == 1) {
             $this->{$im} = new Image($result->item(0));
         }
     }
     $result = $xpath->query('./az:SalesRank/text()', $dom);
     if ($result->length == 1) {
         $this->SalesRank = (int) $result->item(0)->data;
     }
     $result = $xpath->query('./az:CustomerReviews/az:Review', $dom);
     if ($result->length >= 1) {
         foreach ($result as $review) {
             $this->CustomerReviews[] = new CustomerReview($review);
         }
         $this->AverageRating = (double) $xpath->query('./az:CustomerReviews/az:AverageRating/text()', $dom)->item(0)->data;
         $this->TotalReviews = (int) $xpath->query('./az:CustomerReviews/az:TotalReviews/text()', $dom)->item(0)->data;
     }
     $result = $xpath->query('./az:EditorialReviews/az:*', $dom);
     if ($result->length >= 1) {
         foreach ($result as $r) {
             $this->EditorialReviews[] = new EditorialReview($r);
         }
     }
     $result = $xpath->query('./az:SimilarProducts/az:*', $dom);
     if ($result->length >= 1) {
         foreach ($result as $r) {
             $this->SimilarProducts[] = new SimilarProduct($r);
         }
     }
     $result = $xpath->query('./az:ListmaniaLists/*', $dom);
     if ($result->length >= 1) {
         foreach ($result as $r) {
             $this->ListmaniaLists[] = new ListmaniaList($r);
         }
     }
     $result = $xpath->query('./az:Tracks/az:Disc', $dom);
     if ($result->length > 1) {
         foreach ($result as $disk) {
             foreach ($xpath->query('./*/text()', $disk) as $t) {
                 // TODO: For consistency in a bugfix all tracks are appended to one single array
                 // Erroreous line: $this->Tracks[$disk->getAttribute('number')] = (string) $t->data;
                 $this->Tracks[] = (string) $t->data;
             }
         }
     } elseif ($result->length == 1) {
         foreach ($xpath->query('./*/text()', $result->item(0)) as $t) {
             $this->Tracks[] = (string) $t->data;
         }
     }
     $result = $xpath->query('./az:Offers', $dom);
     $resultSummary = $xpath->query('./az:OfferSummary', $dom);
     if ($result->length > 1 || $resultSummary->length == 1) {
         $this->Offers = new OfferSet($dom);
     }
     $result = $xpath->query('./az:Accessories/*', $dom);
     if ($result->length > 1) {
         foreach ($result as $r) {
             $this->Accessories[] = new Accessories($r);
         }
     }
     $this->_dom = $dom;
 }