- <?php
- /**
- * This file contains the two classes which store details of products returned by AWS.
- *
- * The two classes are {@link LiteDetails}, which stores information obtained by making a 'lite'
- * request; and {@link HeavyDetails}, which is created when making a 'heavy' request.
- *
- * Apparently the lite/heavy request types are going to change in AWS4, so this may
- * change (drastically?) in future releases.
- *
- * @author Mauricio Diaz <madd0@users.sourceforge.net>
- * @copyright 2004 (c) Mauricio Diaz Orlich
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
- * @version 0.3RC1
- *
- * @package amazOOP
- * @subpackage Details
- */
-
- /**
- * This file is included because it contains class {@link LiteDetails}, which is
- * the parent of class {@link HeavyDetails} contained in this file.
- * @access private
- */
- require_once(CORE_PATH . 'liteDetails.class.php');
-
- /**
- * The HeavyDetails class is used to store information on products returned when doing a heavy request to AWS.
- *
- * This class is an extention of {@link LiteDetails} and contains the following additional information:
- * - A list of ASINs for <i>Accessories</i> that go with the current product ({@link getAccessories()})
- * - The appropriate <i>Age Level</i> (for toys) ({@link getAgeGroup()})
- * - A <i>List of Browse Nodes</i> in which the current product is contained. Read the documentation of this
- * method for more information on the format of browse nodes. ({@link getBrowseNode()})
- * - A list of <i>Directors</i> for the DVD or video ({@link getDirectors()})
- * - The <i>Distributor</i> of a film ({@link getDistributor()})
- * - The <i>Encoding</i> of a DVD or video ({@link getEncoding()})
- * - The <i>ESRB Rating</i> for a computer or video game. Read the documentation of this method for
- * more information on ESRB ratings. ({@link getEsrbRating()})
- * - A list of <i>Features</i> for the current product ({@link getFeatures()})
- * - The book's <i>ISBN</i>. ({@link getISBN()})
- * - A list of <i>Listmania! lists</i> that contain the current product. Note, however, that Listmania!
- * searches are not yet supported by amazOOP. ({@link getList()})
- * - The product's <i>Medium</i> (i.e. paperback, audio-CD, etc.) ({@link getMedia()})
- * - The <i>MPAA Rating</i> for a DVD or video. Read the documentation for this method for more information
- * on MPAA ratings. ({@link getMpaaRating()})
- * - The <i>Manufacturer Product Number</i> ({@link getMPN()})
- * - The products <i>Medium</i> in numerical form ({@link getNumMedia()})
- * - Computer of video game <i>Platforms</i> that support the product ({@link getPlatforms()})
- * - Amazon's editorial <i>Review</i> of the product ({@link getProductDescription()})
- * - The <i>Publisher</i> of a book ({@link getPublisher()})
- * - Children books <i>Reading Level</i> ({@link getReadingLevel()})
- * - Customer <i>Reviews</i> and ratings. Read the documentation of this method for more information about
- * the format of customer reviews. ({@link getReviews()})
- * - Product <i>sales ranking</i> at Amazon ({@link getSalesRank()})
- * - List of ASINs for <i>Similar products</i> ({@link getSimilarProducts()})
- * - List of <i>Actors and Actresses</i> starring in a DVD or video ({@link getActors()})
- * - Date on which a DVD or video was or will be <i>realeased in the theatres</i> ({@link getTheatricalReleaseDate()})
- * - Price of the same item, sold <i>new by a Third Party seller</i>. Note, however, that Third Party searches
- * are not yet supported by amazOOP. ({@link getNewPrice()})
- * - Price of the same item, sold <i>refurbished by a Third Party seller</i>. Note, however, that Third Party searches
- * are not yet supported by amazOOP. ({@link getRefurbishedPrice()})
- * - Price of the same item, sold as <i>collectible by a Third Party seller</i>. Note, however, that Third Party searches
- * are not yet supported by amazOOP. ({@link getCollectiblePrice()})
- * - List of <i>Tracks</i> of a CD ({@link getTracks()})
- * - <i>UPC</i> code of the product. Read the documentaion of this method to learn which items return
- * a UPC code. ({@link getUPC()})
- *
- * @author Mauricio Diaz <madd0@users.sourceforge.net>
- * @copyright 2004 (c) Mauricio Diaz Orlich
- * @license http://www.gnu.org/licenses/gpl.html GNU Public License
- * @version 0.3RC1
- *
- * @package amazOOP
- */
- class HeavyDetails extends LiteDetails {
- /**#@+
- * @access private
- */
-
- /**
- * Amazon editorial review
- * @var string
- */
- var $productDescription;
- /**
- * Lowest price offered by a Third Party Seller
- * @var string
- */
- var $thirdPartyNewPrice;
- /**
- * Lowest price for a collectible version of the product
- * @var string
- */
- var $collectiblePrice;
- /**
- * Lowest price for a refurbished version of the product
- * @var string
- */
- var $refurbishedPrice;
- /**
- * DVD or video encoding
- * @var string
- */
- var $encoding;
- /**
- * DVD or video rating
- * @var string
- * @link http://www.mpaa.org/movieratings/ MPAA Movie Ratings
- */
- var $mpaaRating;
- /**
- * Computer or video game rating
- * @var string
- * @link http://www.esrb.org ESRB Ratings
- */
- var $esrbRating;
- /**
- * Appropriate age level (for toys)
- * @var string
- */
- var $ageGroup;
- /**
- * UPC code (found only for music)
- * @var string
- */
- var $upc;
- /**
- * Product type (paperback, audio-CD, etc.)
- * @var string
- */
- var $media;
- /**
- * Children books reading level
- * @var string
- */
- var $readingLevel;
- /**
- * Publisher of book
- * @var string
- */
- var $publisher;
- /**
- * Product type in numerical form
- * @var string
- */
- var $numMedia;
- /**
- * ISBN number (for books)
- * @var string
- */
- var $isbn;
- /**
- * Distributor of film
- * @var string
- */
- var $distributor;
- /**
- * Product sales ranking
- * @var string
- */
- var $salesRank;
- /**
- * Date that DVD or video was released in the theatres
- * @var string
- */
- var $theatricalReleaseDate;
- /**
- * Manufacturer Product Number
- * @var string
- */
- var $mpn;
-
- /**
- * Similar products (list of ASINs)
- * @var array
- */
- var $similarProducts;
- /**
- * Names of music tracks
- * @var array
- */
- var $tracks;
- /**
- * Accessories for this product (list of ASINs)
- * @var array
- */
- var $accessories;
- /**
- * Product features or selling points
- * @var array
- */
- var $features;
- /**
- * Computer or video game system that supports the product
- * @var array
- */
- var $platforms;
- /**
- * List of Listmania! lists that contain the product
- * @var array
- */
- var $lists;
- /**
- * A list of browse nodes containing the product
- * @var array
- */
- var $browseList;
- /**
- * List of actors and actresses of a DVD or video
- * @var array
- */
- var $starring;
- /**
- * List of directors of a DVD or video
- * @var array
- */
- var $directors;
-
- /**
- * Holds information about the product's ranking as well as customer and editorial reviews.
- * @var Reviews
- * @see Reviews
- *
- */
- var $reviews;
- /**#@-*/
-
- /**
- * Manufacturer Product Number
- *
- * @return string|booleanthe manufacturer product number. Or false if none is set.
- */
- function getMPN(){
- if(isset($this->mpn) && $this->mpn != "")
- return rawurldecode($this->mpn);
- else
- return false;
- }
-
- /**
- * Displays the actors and actresses of a DVD or video.
- *
- * You can specify how many actors you want to display, what character(s) should
- * separate each name and what should be appended at the end of the list if there are
- * more artists than were displayed.
- *
- * Additionally, since version 0.2, you can add a template that will be applied to
- * each name. This allows to create links, and apply other html transformation to each
- * name in the list.
- *
- * @param integer $howmany indicates how many actors you want to display. If the value is
- * zero or is greater than the total number of available artists, all actors are displayed.
- * @param string $separator determines what character(s) separate each name. The default value is
- * a comma followed by a space.
- * @param string $etc is the text appended to the end of a partial list of actors. The default
- * value is "et al.", but it could be something like "etc.", "and others", etc.
- * @param string $template a template to be applied to each name on the list. The default value
- * is "%name%" wich will display the name unmodified. You can submit templates such as
- * "<b>%name%</b>", which will display each name in bold characters, but not the separators, or
- * something like "<a href=\"/artist/%rawName%\">%name%</a>", which will create a link to a page
- * using the URL encoded artist's name.
- *
- * @return string|booleanA list of actors. Or false if there are no actors.
- *
- */
- function getActors($howmany = 0, $separator = ", ", $etc = "et al.", $template="%name%"){
- $res = "";
-
- // If no size was specified or if too many actors were requested
- if($howmany == 0 || $howmany > sizeof($this->starring))
- // The total number of actors will be returned
- $howmany = sizeof($this->starring);
-
- for($i = 0; $i < $howmany; $i++){
- // Each actor is displayed
- $actor = $this->starring[$i];
- $temp = preg_replace("/(%name%)/e", "rawurldecode(\$actor)", $template);
- $res .= preg_replace("/(%rawName%)/e", "\$actor", $temp);
-
- // Unless it's the last item, append the separator
- if($i < sizeof($this->starring)-1)
- $res .= $separator;
- }
-
- // If not all actors were displayed, append the $etc text
- if($howmany < sizeof($this->starring))
- $res .= $etc;
-
- // The list is returned
- return $res;
- }
-
- /**
- * Displays the directors of a DVD or video.
- *
- * You can specify how many directors you want to display, what character(s) should
- * separate each name and what should be appended at the end of the list if there are
- * more artists than were displayed.
- *
- * Additionally, since version 0.2, you can add a template that will be applied to
- * each name. This allows to create links, and apply other html transformation to each
- * name in the list.
- *
- * @param integer $howmany indicates how many directors you want to display. If the value is
- * zero or is greater than the total number of available artists, all directors are displayed.
- * @param string $separator determines what character(s) separate each name. The default value is
- * a comma followed by a space.
- * @param string $etc is the text appended to the end of a partial list of directors. The default
- * value is "et al.", but it could be something like "etc.", "and others", etc.
- * @param string $template a template to be applied to each name on the list. The default value
- * is "%name%" wich will display the name unmodified. You can submit templates such as
- * "<b>%name%</b>", which will display each name in bold characters, but not the separators, or
- * something like "<a href=\"/artist/%rawName%\">%name%</a>", which will create a link to a page
- * using the URL encoded artist's name.
- *
- * @return string|booleanA list of directors. Or false if there are no directors.
- *
- */
- function getDirectors($howmany = 0, $separator = ", ", $etc = "et al.", $template="%name%"){
- $res = "";
-
- // If no size was specified or if too many directors were requested
- if($howmany == 0 || $howmany > sizeof($this->directors))
- // The total number of directors will be returned
- $howmany = sizeof($this->directors);
-
- for($i = 0; $i < $howmany; $i++){
- // Each director is displayed
- $director = $this->directors[$i];
- $temp = preg_replace("/(%name%)/e", "rawurldecode(\$director)", $template);
- $res .= preg_replace("/(%rawName%)/e", "\$director", $temp);
-
- // Unless it's the last item, append the separator
- if($i < sizeof($this->directors)-1)
- $res .= $separator;
- }
-
- // If not all directors were displayed, append the $etc text
- if($howmany < sizeof($this->directors))
- $res .= $etc;
-
- // The list is returned
- return $res;
- }
-
- /**
- * Date of the theatrical release of a DVD or video
- *
- * @return string|booleanthe date of the theatrical release. Or false if none is set.
- */
- function getTheatricalReleaseDate(){
- if(isset($this->theatricalReleaseDate) && $this->theatricalReleaseDate != "")
- return rawurldecode($this->theatricalReleaseDate);
- else
- return false;
- }
-
- /**
- * The distributor of a file
- *
- * @return string|booleanthe distributor of a film. Or false if none is set.
- */
- function getDistributor(){
- if(isset($this->distributor) && $this->distributor != "")
- return rawurldecode($this->distributor);
- else
- return false;
- }
-
- /**
- * Sales rank of this product at Amazon
- *
- * @return string|booleanthe sales rank of the product. Or false if none is set.
- */
- function getSalesRank(){
- if(isset($this->salesRank) && $this->salesRank != "")
- return $this->salesRank;
- else
- return false;
- }
-
- /**
- * Obtains a Listmania! list in which the object appears.
- *
- * @param integer $listNumber the list you want to get. If set to 0 (default),
- * a random list is returned.
- *
- * @return string|booleanthe requested list ID, or false if the requested list ID
- * does not exist.
- */
- function getList($listNumber = 0){
- if(isset($this->lists) && sizeof($this->lists) != 0 && $listNumber <= sizeof($this->lists)){
- if($listNumber == 0){
- $number = rand(1, sizeof($this->lists));
- return $this->lists[$number-1];
- }
- else{
- if(isset($this->lists[$listNumber-1]))
- return $this->lists[$listNumber-1];
- else
- return false;
- }
- }
- else
- return false;
- }
-
- /**
- * Obtains a Browse Node in which the object appears from a list of Browse Nodes.
- * Browse nodes are stored as {@link BrowseNode} objects, which contain a node name and a
- * node ID (when such information is provided by AWS).
- *
- * Currently, AWS is not supposed to return node IDs, but it occasionally does so, especially
- * when querying locales other than "us".
- *
- * I don't see how node names by themselves could be useful, so I wrote {@link getModeFromCatalog()}
- * to use node IDs with {@link AmazonQuery::getBrowseNode() getBrowseNode()}. Use it, tweak it, and
- * send feedback!!!
- *
- * @param integer $browseNode the node you want to get. If set to 0 (default),
- * a random node from the list is returned.
- *
- * @return BrowseNode|booleanthe requested browse node from the list, or false if the requested
- * position of the list does not contain a browse node.
- *
- * @since version 0.3RC1 {@link BrowseNode} objects are returned instead of strings.
- */
- function getBrowseNode($browseNode = 0){
- if(isset($this->browseList) && sizeof($this->browseList) != 0 && $browseNode <= sizeof($this->browseList)){
- if($browseNode == 0){
- $number = rand(1, sizeof($this->browseList));
- return $this->browseList[$number-1];
- }
- else{
- if(isset($this->browseList[$browseNode-1]))
- //return rawurldecode($this->browseList[$browseNode-1]);
- return $this->browseList[$browseNode-1];
- else
- return false;
- }
- }
- else
- return false;
- }
-
- /**
- * Retrieves the medium of the product.
- *
- * The medium can be CD, DVD, VHS, Paperback, Hardcover, etc.
- * You can specify images for each medium by modifying the {@link $media} array
- * in {@link config.inc.php}. You can also add images for media that do not have any.
- *
- * The medium can be displayed as an image (if available), as text only, or as both
- * by calling the funcion with different parameters.
- *
- * @param boolean $showImage if set to true (default), the function will return an IMG
- * tag displaying the image for the product's medium.
- * @param boolean $andText if you want to display the image AND the text, you have to set
- * this to true also. If $showImage is set to false, this paramater is not used.
- *
- * @return string|booleanthe product's medium, either as an image, as text, or both, depending
- * on the parameters sent to the function. Or false if no medium was returned by AWS.
- */
- function getMedia($showImage = true, $andText = false){
-
- if(getAmazoopConfig('close_tag_character') == "xhtml")
- $closeTag = " />";
- else
- $closeTag = ">";
-
- if(!isset($this->media) || $this->media == "")
- return false;
-
- switch(rawurldecode($this->media)){
- case "VHS Tape":
- case "Videokassette":
- $medium = "vhs";
- break;
- case "DVD":
- $medium = "dvd";
- break;
- default:
- $medium = "";
- break;
- }
-
- if($showImage && $image = getMediaImage($medium)){
- $res = "<img src=\"" . $image[0] . "\" alt=\"" . rawurldecode($this->media) . "\" $image[3] hspace=\"3\" border=\"0\" align=\"absmiddle\"" . $closeTag;
- if($andText)
- $res .= rawurldecode($this->media);
- }
- else
- $res = rawurldecode($this->media);
-
- return $res;
- }
-
- /**
- * Reading level for children's books
- *
- * @return string|booleanthe reading level for children's books. Or false if no level was returned.
- */
- function getReadingLevel(){
- if(isset($this->readingLevel) && $this->readingLevel != "")
- return rawurldecode($this->readingLevel);
- else
- return false;
- }
-
- /**
- * Displays the publisher of a book.
- *
- * Since version 0.2, you can add a template that will be applied to the publisher's
- * name. This allows to create links, and apply other html transformatin to each
- * name in the list.
- *
- * @param string $template a template to be applied to the publisher's name. The default value
- * is "%name%" wich will display the name unmodified. You can submit templates such as
- * "<b>%name%</b>", which will display each name in bold characters, but not the separators, or
- * something like "<a href=\"/publisher/%rawName%\">%name%</a>", which will create a link to a page
- * using the URL encoded publisher's name.
- *
- * @return string|booleanthe publisher's name, eventually modified by a template.
- * Or false if no publisher was returned by Amazon.
- *
- */
- function getPublisher($template="%name%"){
- $res = false;
-
- if(isset($this->publisher) && $this->publisher != ""){
- $publisher = $this->publisher;
- $temp = preg_replace("/(%name%)/e", "rawurldecode(\$publisher)", $template);
- $res = preg_replace("/(%rawName%)/e", "\$publisher", $temp);
- }
-
- return $res;
- }
-
- /**
- * The product's media in numerical form.
- *
- * @return string|booleana number representing the product's type in numerical form.
- * Or false if the product's type is not set.
- *
- */
- function getNumMedia(){
- if(isset($this->numMedia) && $this->numMedia != "")
- return rawurldecode($this->numMedia);
- else
- return false;
- }
-
- /**
- * Retrieves a book's ISBN or International Standard Book Number.
- *
- * @return string|booleanthe book's ISBN. Or false if no ISBN is set, which would be the
- * case for all product's which are not books.
- *
- */
- function getISBN(){
- if(isset($this->isbn) && $this->isbn != "")
- return rawurldecode($this->isbn);
- else
- return false;
- }
-
- /**
- * Gets a feature out of the list of features of an object.
- *
- * @param integer $feature the feature you want to get. If set to 0 (default),
- * a random feature from the list is returned.
- *
- * @return string|booleanthe requested feature from the list, or false if the requested
- * position of the list does not contain a feature.
- */
- function getFeatures($feature = 0){
- if(isset($this->features) && sizeof($this->features) != 0 && $feature <= sizeof($this->features)){
- if($feature == 0){
- $number = rand(1, sizeof($this->features));
- return rawurldecode($this->features[$number-1]);
- }
- else{
- if(isset($this->features[$feature-1]))
- return rawurldecode($this->features[$feature-1]);
- else
- return false;
- }
- }
- else
- return false;
- }
-
- /**
- * The total number of features the product has.
- *
- * @return integer The number of features a product has.
- */
- function getNoOfFeatures(){
- if(isset($this->features))
- return sizeof($this->features);
- else
- return 0;
- }
-
- /**
- * Obtains the list of platforms that support the product.
- * This can be Operating Systems for software, or Consoles for video games.
- * If a same platform appears several times (e.g. several Windows versions)
- * the platform's name appears once and the different version are grouped
- * inside parenthesis (e.g. Windows (NT, 2000, 98)).
- * This function will create an IMG tag to display the platform's image
- * if such an image was set in the {@link $media} array found in the
- * {@link config.inc.php} file.
- *
- * @param string $separator the character(s) used to separate different
- * platforms. The default is a comma, followed by a space (", ").
- * @param boolean $showImage if set to true, an IMG tag will be created
- * if there is an image diffined for the platform in the {@link $media} array.
- *
- * @return string|booleanthe list of platforms of the current product, either
- * as text or as IMG tags. Or false if no platforms are set.
- */
- function getPlatforms($separator = ", ", $showImage = true){
-
- $plats = array();
- $res = "";
-
- if(!isset($this->platforms))
- return false;
-
- if(getAmazoopConfig('close_tag_character') == "xhtml")
- $closeTag = " />";
- else
- $closeTag = ">";
-
- foreach($this->platforms as $platform){
- $platform = rawurldecode($platform);
-
- if(strpos($platform, "Windows") === false){
- if($platform == "PlayStation2")
- $medium = "ps2";
- else if(!(strpos($platform, "Mac") === false))
- $medium = "macos";
- else
- $medium = strtolower($platform);
-
- $plats[$medium] = $platform;
- }
- else{
- if(!isset($plats["windows"]) || !is_array($plats["windows"]))
- $plats["windows"] = array();
-
- $temp = explode("Windows", $platform);
-
- if(isset($temp[1]) && $temp[1] != "")
- $plats["windows"][] = trim($temp[1]);
- }
- }
-
- $i = 0;
- foreach($plats as $medium => $versions){
- if($showImage && $image = getMediaImage($medium)){
- $res .= "<img src=\"" . $image[0] . "\" alt=\"" . rawurldecode($this->media) . "\" $image[3] hspace=\"3\" border=\"0\" align=\"absmiddle\"" . $closeTag;
- }
-
- if(!is_array($versions))
- $res .= $versions;
-
- else{
- $res .= "Windows";
-
- for($j = 0; isset($versions[$j]); $j++){
- $version = $versions[$j];
- if($j == 0)
- $res .= " (";
- $res .= $version;
- if($j < sizeof($versions)-1)
- $res .= ", ";
- else
- $res .= ")";
- }
- }
- if($i < sizeof($plats)-1)
- $res .= ", ";
- $i++;
- }
-
- return $res;
- }
-
- /**
- * Obtains the MPAA rating for a movie.
- *
- * MPAA ratings are:
- * - G: General Audiences (All ages admitted)
- * - PG: Parental Guidance Suggested (Some material may not be suitable for children)
- * - PG-13: Parents Strongly Cautioned (Some material may be inappropriate for children under 13)
- * - R: Restricted (Under 17 requires accompanying parent or adult guardian)
- * - NC-17: No one 17 and under admitted
- *
- * @return string|booleanthe MPAA rating of a DVD or video. Or false if no rating is set.
- *
- * @link http://www.mpaa.org/movieratings/ MPAA Movie Ratings
- */
- function getMpaaRating(){
- if(isset($this->mpaaRating) && $this->mpaaRating != "")
- return rawurldecode($this->mpaaRating);
- else
- return false;
- }
-
- /**
- * Obtains the ESRB rating for a video game.
- *
- * ESRB ratings are:
- * - EARLY CHILDHOOD:
- * Titles rated EC - Early Childhood have content that may be suitable for ages
- * 3 and older. Contains no material that parents would find inappropriate.
- * - EVERYONE:
- * Titles rated E - Everyone have content that may be suitable for persons ages 6
- * and older. Titles in this category may contain minimal violence, some comic
- * mischief and/or mild language.
- * - TEEN:
- * Titles rated T - Teen have content that may be suitable for persons ages 13 and
- * older. May contain violent content, mild or strong language, and/or suggestive themes.
- * - MATURE:
- * Titles rated M - Mature have content that may be suitable for persons ages 17
- * and older. Titles in this category may contain mature sexual themes, more
- * intense violence and/or strong language.
- * - ADULTS ONLY:
- * Titles rated AO - Adults Only have content suitable only for adults. Titles
- * in this category may include graphic depictions of sex and/or violence.
- * Adult Only products are not intended for persons under the age of 18.
- * - RATING PENDING:
- * Titles listed as RP - Rating Pending have been submitted to the ESRB and are
- * awaiting final rating.
- *
- * @return string|booleanthe ESRB rating of a video game. Or false if no rating is set.
- *
- * @link http://www.esrb.org ESRB Ratings
- */
- function getEsrbRating(){
- if(isset($this->esrbRating) && $this->esrbRating != "")
- return rawurldecode($this->esrbRating);
- else
- return false;
- }
-
- /**
- * Obtains the appropriate age level for toys.
- *
- * @return string|booleanthe age level for toys. Or false if none is set.
- */
- function getAgeGroup(){
- if(isset($this->ageGroup) && $this->ageGroup != "")
- return rawurldecode($this->ageGroup);
- else
- return false;
- }
-
- /**
- * Get the UPC code of a product.
- *
- * Currently Amazon only returns UPC codes for items in the music category.
- * Although, lately I've seen UPC codes returned for other objects too.
- *
- * @return string|booleanthe products UPC code. Or false if none is set.
- */
- function getUPC(){
- if(isset($this->upc) && $this->upc != "")
- return rawurldecode($this->upc);
- else
- return false;
- }
-
- /**
- * Gets the name of a track out of the list of tracks in a CD.
- *
- * @param integer $trackNo the track you want to get. If set to 0 (default),
- * a random name from the list is returned.
- *
- * @return string|booleanthe requested track from the list, or false if the requested
- * position of the list does not contain a track.
- */
- function getTracks($trackNo = 0){
- if(isset($this->tracks) && sizeof($this->tracks) != 0 && $trackNo <= sizeof($this->tracks)){
- if($trackNo == 0){
- $number = rand(1, sizeof($this->tracks));
- return rawurldecode($this->tracks[$number-1]);
- }
- else{
- if(isset($this->tracks[$trackNo-1]))
- return rawurldecode($this->tracks[$trackNo-1]);
- else
- return false;
- }
- }
- else
- return false;
- }
-
- /**
- * The total number of tracks the product has.
- *
- * @return integer The number of tracks a product has.
- */
- function getNoOfTracks(){
- if(isset($this->tracks))
- return sizeof($this->tracks);
- else
- return 0;
- }
-
- /**
- * Gets ASINs of accessories for the current product.
- *
- * As far as I know, the maximum number of ASINs resturned is 5, but
- * as usual, this is not well documented.
- *
- * @param integer $access the accessory you want to get. If set to 0 (default),
- * a random ASIN from the list is returned.
- *
- * @return string|booleanthe ASIN of the requested accessory from the list,
- * or false if the requested position of the list does not contain an ASIN.
- */
- function getAccessories($access = 0){
- if(isset($this->accessories) && sizeof($this->accessories) != 0 && $access <= sizeof($this->accessories)){
- if($access == 0){
- $number = rand(1, sizeof($this->accessories));
- return rawurldecode($this->accessories[$number-1]);
- }
- else{
- if(isset($this->accessories[$access-1]))
- return rawurldecode($this->accessories[$access-1]);
- else
- return false;
- }
- }
- else
- return false;
- }
-
- /**
- * Obtains the encoding of a DVD or video.
- *
- * @return string|booleanthe encoding of a DVD or video. Or false if none is set.
- */
- function getEncoding(){
- if(isset($this->encoding) && $this->encoding != "")
- return rawurldecode($this->encoding);
- else
- return false;
- }
-
- /**
- * Gets ASINs of other products sold at Amazon that are similar to the current product.
- *
- * @param integer $product the ASIN you want to get. If set to 0 (default),
- * a random ASIN from the list is returned.
- *
- * @return string|booleanthe ASIN of the requested product from the list,
- * or false if the requested position of the list does not contain an ASIN.
- */
- function getSimilarProducts($product = 0){
- if(isset($this->similar) && sizeof($this->similar) != 0 && $product <= sizeof($this->similar)){
- if($product == 0){
- $number = rand(1, sizeof($this->similar));
- return rawurldecode($this->similar[$number-1]);
- }
- else{
- if(isset($this->similar[$product-1]))
- return rawurldecode($this->similar[$product-1]);
- else
- return false;
- }
- }
- else
- return false;
- }
-
- /**
- * Obtains Amazon's Editorial Review for this product.
- *
- * Not all products return an Editorial Review.
- *
- * Also, note that the Editorial Review (or Product Description) IS NOT
- * the same as the Publisher's Description that appears on the Amazon sites
- * for some books.
- *
- * @param integer $words the number of words you want to get, or 0 if you want
- * the whole description.
- * @param string $end the character(s) to be appended at the end of the description
- * in case the whole text is not returned.
- *
- * @return string|booleanAmazon's Editorial Review for the current product, or at
- * least the number of words requested. Or false if no review is available.
- */
-
- function getProductDescription($words = 0, $end = "..."){
- if(!isset($this->productDescription))
- return false;
-
- else if($words == 0)
- return rawurldecode($this->productDescription);
- else{
- $wordArray = preg_split("/[\s]/", rawurldecode($this->productDescription));
-
- $res = "";
- $words = min($words, sizeof($wordArray));
- for($i = 0; $i < $words; $i++){
- $res .= $wordArray[$i];
- if($i != $words-1)
- $res .= " ";
- }
- if($words < sizeof($wordArray))
- $res .= $end;
- return $res;
- }
- }
-
- /**
- * Gets the average review given by Amazon customers.
- *
- * This is a number between 0 and 5. Where 0 doesn't necessariliy mean
- * that the product is terrible, it can also mean that it hasn't been
- * reviewed yet.
- *
- * @return float the average review given to the product by Amazon customers.
- */
- function getAvgReview(){
- if(isset($this->reviews))
- return $this->reviews->getAvgReview();
- else
- return 0;
- }
-
- /**
- * Gets the total number of reviews this item has received, which is not necessarily
- * the number of reviews returned, since currently AWS returns at the most 3 reviews.
- *
- * @return integer the total number of reviews received by the product.
- */
- function getTotalReviews(){
- if(isset($this->reviews))
- return $this->reviews->getTotalReviews();
- else
- return 0;
- }
-
- /**
- * Gets a Customer Review for the current product.
- *
- * A Customer Review is an object of type {@link CustomerReview} which contains the following
- * information:
- * - The customer's rating in the scale of 0-5
- * - A summary of the customer's review
- * - The customer's review
- *
- * Currently, AWS returns 0-3 reviews for each product.
- *
- * @param integer $number the product line you want to get from the list. If set to 0 (default),
- * a random product line from the list is returned.
- *
- * @return CustomerReview|booleanthe requested customer review from the list,
- * or false if the requested position of the list does not contain a review.
- *
- * @see CustomerReview
- */
- function getCustomerReview($number = 0){
- if(isset($this->reviews))
- return $this->reviews->getCustomerReview($number);
- else
- return false;
- }
-
- /**
- * The price offered by a Third Party seller for this product, new, including its currency symbol.
- *
- * @return string|booleanThird Party seller's price for the product. Or false if none is set.
- */
- function getNewPrice(){
- if(isset($this->thirdPartyNewPrice) && $this->thirdPartyNewPrice != "")
- return rawurldecode($this->thirdPartyNewPrice);
- else
- return false;
- }
-
- /**
- * The price offered for a collectible version of this product, including its currency symbol.
- *
- * @return string|booleanCollectible price for the product. Or false if none is set.
- */
- function getCollectiblePrice(){
- if(isset($this->collectiblePrice) && $this->collectiblePrice != "")
- return rawurldecode($this->collectiblePrice);
- else
- return false;
- }
-
- /**
- * The price offered for a refurbished version of this product, including its currency symbol.
- *
- * @return string|booleanRefurbished price for the product. Or false if none is set.
- */
- function getRefurbishedPrice(){
- if(isset($this->refurbishedPrice) && $this->refurbishedPrice != "")
- return rawurldecode($this->refurbishedPrice);
- else
- return false;
- }
- }
- ?>