amazOOP amazOOP
[ class tree: amazOOP ] [ index: amazOOP ] [ all elements ]

Source for file heavyDetails.class.php

Documentation is available at heavyDetails.class.php

  1. <?php
  2. /**
  3. * This file contains the two classes which store details of products returned by AWS.
  4. *
  5. * The two classes are {@link LiteDetails}, which stores information obtained by making a 'lite'
  6. * request; and {@link HeavyDetails}, which is created when making a 'heavy' request.
  7. *
  8. * Apparently the lite/heavy request types are going to change in AWS4, so this may
  9. * change (drastically?) in future releases.
  10. *
  11. * @author Mauricio Diaz <madd0@users.sourceforge.net>
  12. * @copyright 2004 (c) Mauricio Diaz Orlich
  13. * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
  14. * @version 0.3RC1
  15. *
  16. * @package amazOOP
  17. * @subpackage Details
  18. */
  19.  
  20. /**
  21. * This file is included because it contains class {@link LiteDetails}, which is
  22. * the parent of class {@link HeavyDetails} contained in this file.
  23. * @access private
  24. */
  25. require_once(CORE_PATH . 'liteDetails.class.php');
  26.  
  27. /**
  28. * The HeavyDetails class is used to store information on products returned when doing a heavy request to AWS.
  29. *
  30. * This class is an extention of {@link LiteDetails} and contains the following additional information:
  31. * - A list of ASINs for <i>Accessories</i> that go with the current product ({@link getAccessories()})
  32. * - The appropriate <i>Age Level</i> (for toys) ({@link getAgeGroup()})
  33. * - A <i>List of Browse Nodes</i> in which the current product is contained. Read the documentation of this
  34. * method for more information on the format of browse nodes. ({@link getBrowseNode()})
  35. * - A list of <i>Directors</i> for the DVD or video ({@link getDirectors()})
  36. * - The <i>Distributor</i> of a film ({@link getDistributor()})
  37. * - The <i>Encoding</i> of a DVD or video ({@link getEncoding()})
  38. * - The <i>ESRB Rating</i> for a computer or video game. Read the documentation of this method for
  39. * more information on ESRB ratings. ({@link getEsrbRating()})
  40. * - A list of <i>Features</i> for the current product ({@link getFeatures()})
  41. * - The book's <i>ISBN</i>. ({@link getISBN()})
  42. * - A list of <i>Listmania! lists</i> that contain the current product. Note, however, that Listmania!
  43. * searches are not yet supported by amazOOP. ({@link getList()})
  44. * - The product's <i>Medium</i> (i.e. paperback, audio-CD, etc.) ({@link getMedia()})
  45. * - The <i>MPAA Rating</i> for a DVD or video. Read the documentation for this method for more information
  46. * on MPAA ratings. ({@link getMpaaRating()})
  47. * - The <i>Manufacturer Product Number</i> ({@link getMPN()})
  48. * - The products <i>Medium</i> in numerical form ({@link getNumMedia()})
  49. * - Computer of video game <i>Platforms</i> that support the product ({@link getPlatforms()})
  50. * - Amazon's editorial <i>Review</i> of the product ({@link getProductDescription()})
  51. * - The <i>Publisher</i> of a book ({@link getPublisher()})
  52. * - Children books <i>Reading Level</i> ({@link getReadingLevel()})
  53. * - Customer <i>Reviews</i> and ratings. Read the documentation of this method for more information about
  54. * the format of customer reviews. ({@link getReviews()})
  55. * - Product <i>sales ranking</i> at Amazon ({@link getSalesRank()})
  56. * - List of ASINs for <i>Similar products</i> ({@link getSimilarProducts()})
  57. * - List of <i>Actors and Actresses</i> starring in a DVD or video ({@link getActors()})
  58. * - Date on which a DVD or video was or will be <i>realeased in the theatres</i> ({@link getTheatricalReleaseDate()})
  59. * - Price of the same item, sold <i>new by a Third Party seller</i>. Note, however, that Third Party searches
  60. * are not yet supported by amazOOP. ({@link getNewPrice()})
  61. * - Price of the same item, sold <i>refurbished by a Third Party seller</i>. Note, however, that Third Party searches
  62. * are not yet supported by amazOOP. ({@link getRefurbishedPrice()})
  63. * - Price of the same item, sold as <i>collectible by a Third Party seller</i>. Note, however, that Third Party searches
  64. * are not yet supported by amazOOP. ({@link getCollectiblePrice()})
  65. * - List of <i>Tracks</i> of a CD ({@link getTracks()})
  66. * - <i>UPC</i> code of the product. Read the documentaion of this method to learn which items return
  67. * a UPC code. ({@link getUPC()})
  68. *
  69. * @author Mauricio Diaz <madd0@users.sourceforge.net>
  70. * @copyright 2004 (c) Mauricio Diaz Orlich
  71. * @license http://www.gnu.org/licenses/gpl.html GNU Public License
  72. * @version 0.3RC1
  73. *
  74. * @package amazOOP
  75. */
  76. class HeavyDetails extends LiteDetails {
  77. /**#@+
  78. * @access private
  79. */
  80.  
  81. /**
  82. * Amazon editorial review
  83. * @var string
  84. */
  85. var $productDescription;
  86. /**
  87. * Lowest price offered by a Third Party Seller
  88. * @var string
  89. */
  90. var $thirdPartyNewPrice;
  91. /**
  92. * Lowest price for a collectible version of the product
  93. * @var string
  94. */
  95. var $collectiblePrice;
  96. /**
  97. * Lowest price for a refurbished version of the product
  98. * @var string
  99. */
  100. var $refurbishedPrice;
  101. /**
  102. * DVD or video encoding
  103. * @var string
  104. */
  105. var $encoding;
  106. /**
  107. * DVD or video rating
  108. * @var string
  109. * @link http://www.mpaa.org/movieratings/ MPAA Movie Ratings
  110. */
  111. var $mpaaRating;
  112. /**
  113. * Computer or video game rating
  114. * @var string
  115. * @link http://www.esrb.org ESRB Ratings
  116. */
  117. var $esrbRating;
  118. /**
  119. * Appropriate age level (for toys)
  120. * @var string
  121. */
  122. var $ageGroup;
  123. /**
  124. * UPC code (found only for music)
  125. * @var string
  126. */
  127. var $upc;
  128. /**
  129. * Product type (paperback, audio-CD, etc.)
  130. * @var string
  131. */
  132. var $media;
  133. /**
  134. * Children books reading level
  135. * @var string
  136. */
  137. var $readingLevel;
  138. /**
  139. * Publisher of book
  140. * @var string
  141. */
  142. var $publisher;
  143. /**
  144. * Product type in numerical form
  145. * @var string
  146. */
  147. var $numMedia;
  148. /**
  149. * ISBN number (for books)
  150. * @var string
  151. */
  152. var $isbn;
  153. /**
  154. * Distributor of film
  155. * @var string
  156. */
  157. var $distributor;
  158. /**
  159. * Product sales ranking
  160. * @var string
  161. */
  162. var $salesRank;
  163. /**
  164. * Date that DVD or video was released in the theatres
  165. * @var string
  166. */
  167. var $theatricalReleaseDate;
  168. /**
  169. * Manufacturer Product Number
  170. * @var string
  171. */
  172. var $mpn;
  173.  
  174. /**
  175. * Similar products (list of ASINs)
  176. * @var array
  177. */
  178. var $similarProducts;
  179. /**
  180. * Names of music tracks
  181. * @var array
  182. */
  183. var $tracks;
  184. /**
  185. * Accessories for this product (list of ASINs)
  186. * @var array
  187. */
  188. var $accessories;
  189. /**
  190. * Product features or selling points
  191. * @var array
  192. */
  193. var $features;
  194. /**
  195. * Computer or video game system that supports the product
  196. * @var array
  197. */
  198. var $platforms;
  199. /**
  200. * List of Listmania! lists that contain the product
  201. * @var array
  202. */
  203. var $lists;
  204. /**
  205. * A list of browse nodes containing the product
  206. * @var array
  207. */
  208. var $browseList;
  209. /**
  210. * List of actors and actresses of a DVD or video
  211. * @var array
  212. */
  213. var $starring;
  214. /**
  215. * List of directors of a DVD or video
  216. * @var array
  217. */
  218. var $directors;
  219.  
  220. /**
  221. * Holds information about the product's ranking as well as customer and editorial reviews.
  222. * @var Reviews
  223. * @see Reviews
  224. *
  225. */
  226. var $reviews;
  227. /**#@-*/
  228.  
  229. /**
  230. * Manufacturer Product Number
  231. *
  232. * @return string|booleanthe manufacturer product number. Or false if none is set.
  233. */
  234. function getMPN(){
  235. if(isset($this->mpn) && $this->mpn != "")
  236. return rawurldecode($this->mpn);
  237. else
  238. return false;
  239. }
  240.  
  241. /**
  242. * Displays the actors and actresses of a DVD or video.
  243. *
  244. * You can specify how many actors you want to display, what character(s) should
  245. * separate each name and what should be appended at the end of the list if there are
  246. * more artists than were displayed.
  247. *
  248. * Additionally, since version 0.2, you can add a template that will be applied to
  249. * each name. This allows to create links, and apply other html transformation to each
  250. * name in the list.
  251. *
  252. * @param integer $howmany indicates how many actors you want to display. If the value is
  253. * zero or is greater than the total number of available artists, all actors are displayed.
  254. * @param string $separator determines what character(s) separate each name. The default value is
  255. * a comma followed by a space.
  256. * @param string $etc is the text appended to the end of a partial list of actors. The default
  257. * value is "et al.", but it could be something like "etc.", "and others", etc.
  258. * @param string $template a template to be applied to each name on the list. The default value
  259. * is "%name%" wich will display the name unmodified. You can submit templates such as
  260. * "<b>%name%</b>", which will display each name in bold characters, but not the separators, or
  261. * something like "<a href=\"/artist/%rawName%\">%name%</a>", which will create a link to a page
  262. * using the URL encoded artist's name.
  263. *
  264. * @return string|booleanA list of actors. Or false if there are no actors.
  265. *
  266. */
  267. function getActors($howmany = 0, $separator = ", ", $etc = "et al.", $template="%name%"){
  268. $res = "";
  269.  
  270. // If no size was specified or if too many actors were requested
  271. if($howmany == 0 || $howmany > sizeof($this->starring))
  272. // The total number of actors will be returned
  273. $howmany = sizeof($this->starring);
  274.  
  275. for($i = 0; $i < $howmany; $i++){
  276. // Each actor is displayed
  277. $actor = $this->starring[$i];
  278. $temp = preg_replace("/(%name%)/e", "rawurldecode(\$actor)", $template);
  279. $res .= preg_replace("/(%rawName%)/e", "\$actor", $temp);
  280.  
  281. // Unless it's the last item, append the separator
  282. if($i < sizeof($this->starring)-1)
  283. $res .= $separator;
  284. }
  285.  
  286. // If not all actors were displayed, append the $etc text
  287. if($howmany < sizeof($this->starring))
  288. $res .= $etc;
  289.  
  290. // The list is returned
  291. return $res;
  292. }
  293.  
  294. /**
  295. * Displays the directors of a DVD or video.
  296. *
  297. * You can specify how many directors you want to display, what character(s) should
  298. * separate each name and what should be appended at the end of the list if there are
  299. * more artists than were displayed.
  300. *
  301. * Additionally, since version 0.2, you can add a template that will be applied to
  302. * each name. This allows to create links, and apply other html transformation to each
  303. * name in the list.
  304. *
  305. * @param integer $howmany indicates how many directors you want to display. If the value is
  306. * zero or is greater than the total number of available artists, all directors are displayed.
  307. * @param string $separator determines what character(s) separate each name. The default value is
  308. * a comma followed by a space.
  309. * @param string $etc is the text appended to the end of a partial list of directors. The default
  310. * value is "et al.", but it could be something like "etc.", "and others", etc.
  311. * @param string $template a template to be applied to each name on the list. The default value
  312. * is "%name%" wich will display the name unmodified. You can submit templates such as
  313. * "<b>%name%</b>", which will display each name in bold characters, but not the separators, or
  314. * something like "<a href=\"/artist/%rawName%\">%name%</a>", which will create a link to a page
  315. * using the URL encoded artist's name.
  316. *
  317. * @return string|booleanA list of directors. Or false if there are no directors.
  318. *
  319. */
  320. function getDirectors($howmany = 0, $separator = ", ", $etc = "et al.", $template="%name%"){
  321. $res = "";
  322.  
  323. // If no size was specified or if too many directors were requested
  324. if($howmany == 0 || $howmany > sizeof($this->directors))
  325. // The total number of directors will be returned
  326. $howmany = sizeof($this->directors);
  327.  
  328. for($i = 0; $i < $howmany; $i++){
  329. // Each director is displayed
  330. $director = $this->directors[$i];
  331. $temp = preg_replace("/(%name%)/e", "rawurldecode(\$director)", $template);
  332. $res .= preg_replace("/(%rawName%)/e", "\$director", $temp);
  333.  
  334. // Unless it's the last item, append the separator
  335. if($i < sizeof($this->directors)-1)
  336. $res .= $separator;
  337. }
  338.  
  339. // If not all directors were displayed, append the $etc text
  340. if($howmany < sizeof($this->directors))
  341. $res .= $etc;
  342.  
  343. // The list is returned
  344. return $res;
  345. }
  346.  
  347. /**
  348. * Date of the theatrical release of a DVD or video
  349. *
  350. * @return string|booleanthe date of the theatrical release. Or false if none is set.
  351. */
  352. function getTheatricalReleaseDate(){
  353. if(isset($this->theatricalReleaseDate) && $this->theatricalReleaseDate != "")
  354. return rawurldecode($this->theatricalReleaseDate);
  355. else
  356. return false;
  357. }
  358.  
  359. /**
  360. * The distributor of a file
  361. *
  362. * @return string|booleanthe distributor of a film. Or false if none is set.
  363. */
  364. function getDistributor(){
  365. if(isset($this->distributor) && $this->distributor != "")
  366. return rawurldecode($this->distributor);
  367. else
  368. return false;
  369. }
  370.  
  371. /**
  372. * Sales rank of this product at Amazon
  373. *
  374. * @return string|booleanthe sales rank of the product. Or false if none is set.
  375. */
  376. function getSalesRank(){
  377. if(isset($this->salesRank) && $this->salesRank != "")
  378. return $this->salesRank;
  379. else
  380. return false;
  381. }
  382.  
  383. /**
  384. * Obtains a Listmania! list in which the object appears.
  385. *
  386. * @param integer $listNumber the list you want to get. If set to 0 (default),
  387. * a random list is returned.
  388. *
  389. * @return string|booleanthe requested list ID, or false if the requested list ID
  390. * does not exist.
  391. */
  392. function getList($listNumber = 0){
  393. if(isset($this->lists) && sizeof($this->lists) != 0 && $listNumber <= sizeof($this->lists)){
  394. if($listNumber == 0){
  395. $number = rand(1, sizeof($this->lists));
  396. return $this->lists[$number-1];
  397. }
  398. else{
  399. if(isset($this->lists[$listNumber-1]))
  400. return $this->lists[$listNumber-1];
  401. else
  402. return false;
  403. }
  404. }
  405. else
  406. return false;
  407. }
  408.  
  409. /**
  410. * Obtains a Browse Node in which the object appears from a list of Browse Nodes.
  411. * Browse nodes are stored as {@link BrowseNode} objects, which contain a node name and a
  412. * node ID (when such information is provided by AWS).
  413. *
  414. * Currently, AWS is not supposed to return node IDs, but it occasionally does so, especially
  415. * when querying locales other than "us".
  416. *
  417. * I don't see how node names by themselves could be useful, so I wrote {@link getModeFromCatalog()}
  418. * to use node IDs with {@link AmazonQuery::getBrowseNode() getBrowseNode()}. Use it, tweak it, and
  419. * send feedback!!!
  420. *
  421. * @param integer $browseNode the node you want to get. If set to 0 (default),
  422. * a random node from the list is returned.
  423. *
  424. * @return BrowseNode|booleanthe requested browse node from the list, or false if the requested
  425. * position of the list does not contain a browse node.
  426. *
  427. * @since version 0.3RC1 {@link BrowseNode} objects are returned instead of strings.
  428. */
  429. function getBrowseNode($browseNode = 0){
  430. if(isset($this->browseList) && sizeof($this->browseList) != 0 && $browseNode <= sizeof($this->browseList)){
  431. if($browseNode == 0){
  432. $number = rand(1, sizeof($this->browseList));
  433. return $this->browseList[$number-1];
  434. }
  435. else{
  436. if(isset($this->browseList[$browseNode-1]))
  437. //return rawurldecode($this->browseList[$browseNode-1]);
  438. return $this->browseList[$browseNode-1];
  439. else
  440. return false;
  441. }
  442. }
  443. else
  444. return false;
  445. }
  446.  
  447. /**
  448. * Retrieves the medium of the product.
  449. *
  450. * The medium can be CD, DVD, VHS, Paperback, Hardcover, etc.
  451. * You can specify images for each medium by modifying the {@link $media} array
  452. * in {@link config.inc.php}. You can also add images for media that do not have any.
  453. *
  454. * The medium can be displayed as an image (if available), as text only, or as both
  455. * by calling the funcion with different parameters.
  456. *
  457. * @param boolean $showImage if set to true (default), the function will return an IMG
  458. * tag displaying the image for the product's medium.
  459. * @param boolean $andText if you want to display the image AND the text, you have to set
  460. * this to true also. If $showImage is set to false, this paramater is not used.
  461. *
  462. * @return string|booleanthe product's medium, either as an image, as text, or both, depending
  463. * on the parameters sent to the function. Or false if no medium was returned by AWS.
  464. */
  465. function getMedia($showImage = true, $andText = false){
  466.  
  467. if(getAmazoopConfig('close_tag_character') == "xhtml")
  468. $closeTag = " />";
  469. else
  470. $closeTag = ">";
  471.  
  472. if(!isset($this->media) || $this->media == "")
  473. return false;
  474.  
  475. switch(rawurldecode($this->media)){
  476. case "VHS Tape":
  477. case "Videokassette":
  478. $medium = "vhs";
  479. break;
  480. case "DVD":
  481. $medium = "dvd";
  482. break;
  483. default:
  484. $medium = "";
  485. break;
  486. }
  487.  
  488. if($showImage && $image = getMediaImage($medium)){
  489. $res = "<img src=\"" . $image[0] . "\" alt=\"" . rawurldecode($this->media) . "\" $image[3] hspace=\"3\" border=\"0\" align=\"absmiddle\"" . $closeTag;
  490. if($andText)
  491. $res .= rawurldecode($this->media);
  492. }
  493. else
  494. $res = rawurldecode($this->media);
  495.  
  496. return $res;
  497. }
  498.  
  499. /**
  500. * Reading level for children's books
  501. *
  502. * @return string|booleanthe reading level for children's books. Or false if no level was returned.
  503. */
  504. function getReadingLevel(){
  505. if(isset($this->readingLevel) && $this->readingLevel != "")
  506. return rawurldecode($this->readingLevel);
  507. else
  508. return false;
  509. }
  510.  
  511. /**
  512. * Displays the publisher of a book.
  513. *
  514. * Since version 0.2, you can add a template that will be applied to the publisher's
  515. * name. This allows to create links, and apply other html transformatin to each
  516. * name in the list.
  517. *
  518. * @param string $template a template to be applied to the publisher's name. The default value
  519. * is "%name%" wich will display the name unmodified. You can submit templates such as
  520. * "<b>%name%</b>", which will display each name in bold characters, but not the separators, or
  521. * something like "<a href=\"/publisher/%rawName%\">%name%</a>", which will create a link to a page
  522. * using the URL encoded publisher's name.
  523. *
  524. * @return string|booleanthe publisher's name, eventually modified by a template.
  525. * Or false if no publisher was returned by Amazon.
  526. *
  527. */
  528. function getPublisher($template="%name%"){
  529. $res = false;
  530.  
  531. if(isset($this->publisher) && $this->publisher != ""){
  532. $publisher = $this->publisher;
  533. $temp = preg_replace("/(%name%)/e", "rawurldecode(\$publisher)", $template);
  534. $res = preg_replace("/(%rawName%)/e", "\$publisher", $temp);
  535. }
  536.  
  537. return $res;
  538. }
  539.  
  540. /**
  541. * The product's media in numerical form.
  542. *
  543. * @return string|booleana number representing the product's type in numerical form.
  544. * Or false if the product's type is not set.
  545. *
  546. */
  547. function getNumMedia(){
  548. if(isset($this->numMedia) && $this->numMedia != "")
  549. return rawurldecode($this->numMedia);
  550. else
  551. return false;
  552. }
  553.  
  554. /**
  555. * Retrieves a book's ISBN or International Standard Book Number.
  556. *
  557. * @return string|booleanthe book's ISBN. Or false if no ISBN is set, which would be the
  558. * case for all product's which are not books.
  559. *
  560. */
  561. function getISBN(){
  562. if(isset($this->isbn) && $this->isbn != "")
  563. return rawurldecode($this->isbn);
  564. else
  565. return false;
  566. }
  567.  
  568. /**
  569. * Gets a feature out of the list of features of an object.
  570. *
  571. * @param integer $feature the feature you want to get. If set to 0 (default),
  572. * a random feature from the list is returned.
  573. *
  574. * @return string|booleanthe requested feature from the list, or false if the requested
  575. * position of the list does not contain a feature.
  576. */
  577. function getFeatures($feature = 0){
  578. if(isset($this->features) && sizeof($this->features) != 0 && $feature <= sizeof($this->features)){
  579. if($feature == 0){
  580. $number = rand(1, sizeof($this->features));
  581. return rawurldecode($this->features[$number-1]);
  582. }
  583. else{
  584. if(isset($this->features[$feature-1]))
  585. return rawurldecode($this->features[$feature-1]);
  586. else
  587. return false;
  588. }
  589. }
  590. else
  591. return false;
  592. }
  593.  
  594. /**
  595. * The total number of features the product has.
  596. *
  597. * @return integer The number of features a product has.
  598. */
  599. function getNoOfFeatures(){
  600. if(isset($this->features))
  601. return sizeof($this->features);
  602. else
  603. return 0;
  604. }
  605.  
  606. /**
  607. * Obtains the list of platforms that support the product.
  608. * This can be Operating Systems for software, or Consoles for video games.
  609. * If a same platform appears several times (e.g. several Windows versions)
  610. * the platform's name appears once and the different version are grouped
  611. * inside parenthesis (e.g. Windows (NT, 2000, 98)).
  612. * This function will create an IMG tag to display the platform's image
  613. * if such an image was set in the {@link $media} array found in the
  614. * {@link config.inc.php} file.
  615. *
  616. * @param string $separator the character(s) used to separate different
  617. * platforms. The default is a comma, followed by a space (", ").
  618. * @param boolean $showImage if set to true, an IMG tag will be created
  619. * if there is an image diffined for the platform in the {@link $media} array.
  620. *
  621. * @return string|booleanthe list of platforms of the current product, either
  622. * as text or as IMG tags. Or false if no platforms are set.
  623. */
  624. function getPlatforms($separator = ", ", $showImage = true){
  625.  
  626. $plats = array();
  627. $res = "";
  628.  
  629. if(!isset($this->platforms))
  630. return false;
  631.  
  632. if(getAmazoopConfig('close_tag_character') == "xhtml")
  633. $closeTag = " />";
  634. else
  635. $closeTag = ">";
  636.  
  637. foreach($this->platforms as $platform){
  638. $platform = rawurldecode($platform);
  639.  
  640. if(strpos($platform, "Windows") === false){
  641. if($platform == "PlayStation2")
  642. $medium = "ps2";
  643. else if(!(strpos($platform, "Mac") === false))
  644. $medium = "macos";
  645. else
  646. $medium = strtolower($platform);
  647.  
  648. $plats[$medium] = $platform;
  649. }
  650. else{
  651. if(!isset($plats["windows"]) || !is_array($plats["windows"]))
  652. $plats["windows"] = array();
  653.  
  654. $temp = explode("Windows", $platform);
  655.  
  656. if(isset($temp[1]) && $temp[1] != "")
  657. $plats["windows"][] = trim($temp[1]);
  658. }
  659. }
  660.  
  661. $i = 0;
  662. foreach($plats as $medium => $versions){
  663. if($showImage && $image = getMediaImage($medium)){
  664. $res .= "<img src=\"" . $image[0] . "\" alt=\"" . rawurldecode($this->media) . "\" $image[3] hspace=\"3\" border=\"0\" align=\"absmiddle\"" . $closeTag;
  665. }
  666.  
  667. if(!is_array($versions))
  668. $res .= $versions;
  669.  
  670. else{
  671. $res .= "Windows";
  672.  
  673. for($j = 0; isset($versions[$j]); $j++){
  674. $version = $versions[$j];
  675. if($j == 0)
  676. $res .= " (";
  677. $res .= $version;
  678. if($j < sizeof($versions)-1)
  679. $res .= ", ";
  680. else
  681. $res .= ")";
  682. }
  683. }
  684. if($i < sizeof($plats)-1)
  685. $res .= ", ";
  686. $i++;
  687. }
  688.  
  689. return $res;
  690. }
  691.  
  692. /**
  693. * Obtains the MPAA rating for a movie.
  694. *
  695. * MPAA ratings are:
  696. * - G: General Audiences (All ages admitted)
  697. * - PG: Parental Guidance Suggested (Some material may not be suitable for children)
  698. * - PG-13: Parents Strongly Cautioned (Some material may be inappropriate for children under 13)
  699. * - R: Restricted (Under 17 requires accompanying parent or adult guardian)
  700. * - NC-17: No one 17 and under admitted
  701. *
  702. * @return string|booleanthe MPAA rating of a DVD or video. Or false if no rating is set.
  703. *
  704. * @link http://www.mpaa.org/movieratings/ MPAA Movie Ratings
  705. */
  706. function getMpaaRating(){
  707. if(isset($this->mpaaRating) && $this->mpaaRating != "")
  708. return rawurldecode($this->mpaaRating);
  709. else
  710. return false;
  711. }
  712.  
  713. /**
  714. * Obtains the ESRB rating for a video game.
  715. *
  716. * ESRB ratings are:
  717. * - EARLY CHILDHOOD:
  718. * Titles rated EC - Early Childhood have content that may be suitable for ages
  719. * 3 and older. Contains no material that parents would find inappropriate.
  720. * - EVERYONE:
  721. * Titles rated E - Everyone have content that may be suitable for persons ages 6
  722. * and older. Titles in this category may contain minimal violence, some comic
  723. * mischief and/or mild language.
  724. * - TEEN:
  725. * Titles rated T - Teen have content that may be suitable for persons ages 13 and
  726. * older. May contain violent content, mild or strong language, and/or suggestive themes.
  727. * - MATURE:
  728. * Titles rated M - Mature have content that may be suitable for persons ages 17
  729. * and older. Titles in this category may contain mature sexual themes, more
  730. * intense violence and/or strong language.
  731. * - ADULTS ONLY:
  732. * Titles rated AO - Adults Only have content suitable only for adults. Titles
  733. * in this category may include graphic depictions of sex and/or violence.
  734. * Adult Only products are not intended for persons under the age of 18.
  735. * - RATING PENDING:
  736. * Titles listed as RP - Rating Pending have been submitted to the ESRB and are
  737. * awaiting final rating.
  738. *
  739. * @return string|booleanthe ESRB rating of a video game. Or false if no rating is set.
  740. *
  741. * @link http://www.esrb.org ESRB Ratings
  742. */
  743. function getEsrbRating(){
  744. if(isset($this->esrbRating) && $this->esrbRating != "")
  745. return rawurldecode($this->esrbRating);
  746. else
  747. return false;
  748. }
  749.  
  750. /**
  751. * Obtains the appropriate age level for toys.
  752. *
  753. * @return string|booleanthe age level for toys. Or false if none is set.
  754. */
  755. function getAgeGroup(){
  756. if(isset($this->ageGroup) && $this->ageGroup != "")
  757. return rawurldecode($this->ageGroup);
  758. else
  759. return false;
  760. }
  761.  
  762. /**
  763. * Get the UPC code of a product.
  764. *
  765. * Currently Amazon only returns UPC codes for items in the music category.
  766. * Although, lately I've seen UPC codes returned for other objects too.
  767. *
  768. * @return string|booleanthe products UPC code. Or false if none is set.
  769. */
  770. function getUPC(){
  771. if(isset($this->upc) && $this->upc != "")
  772. return rawurldecode($this->upc);
  773. else
  774. return false;
  775. }
  776.  
  777. /**
  778. * Gets the name of a track out of the list of tracks in a CD.
  779. *
  780. * @param integer $trackNo the track you want to get. If set to 0 (default),
  781. * a random name from the list is returned.
  782. *
  783. * @return string|booleanthe requested track from the list, or false if the requested
  784. * position of the list does not contain a track.
  785. */
  786. function getTracks($trackNo = 0){
  787. if(isset($this->tracks) && sizeof($this->tracks) != 0 && $trackNo <= sizeof($this->tracks)){
  788. if($trackNo == 0){
  789. $number = rand(1, sizeof($this->tracks));
  790. return rawurldecode($this->tracks[$number-1]);
  791. }
  792. else{
  793. if(isset($this->tracks[$trackNo-1]))
  794. return rawurldecode($this->tracks[$trackNo-1]);
  795. else
  796. return false;
  797. }
  798. }
  799. else
  800. return false;
  801. }
  802.  
  803. /**
  804. * The total number of tracks the product has.
  805. *
  806. * @return integer The number of tracks a product has.
  807. */
  808. function getNoOfTracks(){
  809. if(isset($this->tracks))
  810. return sizeof($this->tracks);
  811. else
  812. return 0;
  813. }
  814.  
  815. /**
  816. * Gets ASINs of accessories for the current product.
  817. *
  818. * As far as I know, the maximum number of ASINs resturned is 5, but
  819. * as usual, this is not well documented.
  820. *
  821. * @param integer $access the accessory you want to get. If set to 0 (default),
  822. * a random ASIN from the list is returned.
  823. *
  824. * @return string|booleanthe ASIN of the requested accessory from the list,
  825. * or false if the requested position of the list does not contain an ASIN.
  826. */
  827. function getAccessories($access = 0){
  828. if(isset($this->accessories) && sizeof($this->accessories) != 0 && $access <= sizeof($this->accessories)){
  829. if($access == 0){
  830. $number = rand(1, sizeof($this->accessories));
  831. return rawurldecode($this->accessories[$number-1]);
  832. }
  833. else{
  834. if(isset($this->accessories[$access-1]))
  835. return rawurldecode($this->accessories[$access-1]);
  836. else
  837. return false;
  838. }
  839. }
  840. else
  841. return false;
  842. }
  843.  
  844. /**
  845. * Obtains the encoding of a DVD or video.
  846. *
  847. * @return string|booleanthe encoding of a DVD or video. Or false if none is set.
  848. */
  849. function getEncoding(){
  850. if(isset($this->encoding) && $this->encoding != "")
  851. return rawurldecode($this->encoding);
  852. else
  853. return false;
  854. }
  855.  
  856. /**
  857. * Gets ASINs of other products sold at Amazon that are similar to the current product.
  858. *
  859. * @param integer $product the ASIN you want to get. If set to 0 (default),
  860. * a random ASIN from the list is returned.
  861. *
  862. * @return string|booleanthe ASIN of the requested product from the list,
  863. * or false if the requested position of the list does not contain an ASIN.
  864. */
  865. function getSimilarProducts($product = 0){
  866. if(isset($this->similar) && sizeof($this->similar) != 0 && $product <= sizeof($this->similar)){
  867. if($product == 0){
  868. $number = rand(1, sizeof($this->similar));
  869. return rawurldecode($this->similar[$number-1]);
  870. }
  871. else{
  872. if(isset($this->similar[$product-1]))
  873. return rawurldecode($this->similar[$product-1]);
  874. else
  875. return false;
  876. }
  877. }
  878. else
  879. return false;
  880. }
  881.  
  882. /**
  883. * Obtains Amazon's Editorial Review for this product.
  884. *
  885. * Not all products return an Editorial Review.
  886. *
  887. * Also, note that the Editorial Review (or Product Description) IS NOT
  888. * the same as the Publisher's Description that appears on the Amazon sites
  889. * for some books.
  890. *
  891. * @param integer $words the number of words you want to get, or 0 if you want
  892. * the whole description.
  893. * @param string $end the character(s) to be appended at the end of the description
  894. * in case the whole text is not returned.
  895. *
  896. * @return string|booleanAmazon's Editorial Review for the current product, or at
  897. * least the number of words requested. Or false if no review is available.
  898. */
  899.  
  900. function getProductDescription($words = 0, $end = "..."){
  901. if(!isset($this->productDescription))
  902. return false;
  903.  
  904. else if($words == 0)
  905. return rawurldecode($this->productDescription);
  906. else{
  907. $wordArray = preg_split("/[\s]/", rawurldecode($this->productDescription));
  908.  
  909. $res = "";
  910. $words = min($words, sizeof($wordArray));
  911. for($i = 0; $i < $words; $i++){
  912. $res .= $wordArray[$i];
  913. if($i != $words-1)
  914. $res .= " ";
  915. }
  916. if($words < sizeof($wordArray))
  917. $res .= $end;
  918. return $res;
  919. }
  920. }
  921.  
  922. /**
  923. * Gets the average review given by Amazon customers.
  924. *
  925. * This is a number between 0 and 5. Where 0 doesn't necessariliy mean
  926. * that the product is terrible, it can also mean that it hasn't been
  927. * reviewed yet.
  928. *
  929. * @return float the average review given to the product by Amazon customers.
  930. */
  931. function getAvgReview(){
  932. if(isset($this->reviews))
  933. return $this->reviews->getAvgReview();
  934. else
  935. return 0;
  936. }
  937.  
  938. /**
  939. * Gets the total number of reviews this item has received, which is not necessarily
  940. * the number of reviews returned, since currently AWS returns at the most 3 reviews.
  941. *
  942. * @return integer the total number of reviews received by the product.
  943. */
  944. function getTotalReviews(){
  945. if(isset($this->reviews))
  946. return $this->reviews->getTotalReviews();
  947. else
  948. return 0;
  949. }
  950.  
  951. /**
  952. * Gets a Customer Review for the current product.
  953. *
  954. * A Customer Review is an object of type {@link CustomerReview} which contains the following
  955. * information:
  956. * - The customer's rating in the scale of 0-5
  957. * - A summary of the customer's review
  958. * - The customer's review
  959. *
  960. * Currently, AWS returns 0-3 reviews for each product.
  961. *
  962. * @param integer $number the product line you want to get from the list. If set to 0 (default),
  963. * a random product line from the list is returned.
  964. *
  965. * @return CustomerReview|booleanthe requested customer review from the list,
  966. * or false if the requested position of the list does not contain a review.
  967. *
  968. * @see CustomerReview
  969. */
  970. function getCustomerReview($number = 0){
  971. if(isset($this->reviews))
  972. return $this->reviews->getCustomerReview($number);
  973. else
  974. return false;
  975. }
  976.  
  977. /**
  978. * The price offered by a Third Party seller for this product, new, including its currency symbol.
  979. *
  980. * @return string|booleanThird Party seller's price for the product. Or false if none is set.
  981. */
  982. function getNewPrice(){
  983. if(isset($this->thirdPartyNewPrice) && $this->thirdPartyNewPrice != "")
  984. return rawurldecode($this->thirdPartyNewPrice);
  985. else
  986. return false;
  987. }
  988.  
  989. /**
  990. * The price offered for a collectible version of this product, including its currency symbol.
  991. *
  992. * @return string|booleanCollectible price for the product. Or false if none is set.
  993. */
  994. function getCollectiblePrice(){
  995. if(isset($this->collectiblePrice) && $this->collectiblePrice != "")
  996. return rawurldecode($this->collectiblePrice);
  997. else
  998. return false;
  999. }
  1000.  
  1001. /**
  1002. * The price offered for a refurbished version of this product, including its currency symbol.
  1003. *
  1004. * @return string|booleanRefurbished price for the product. Or false if none is set.
  1005. */
  1006. function getRefurbishedPrice(){
  1007. if(isset($this->refurbishedPrice) && $this->refurbishedPrice != "")
  1008. return rawurldecode($this->refurbishedPrice);
  1009. else
  1010. return false;
  1011. }
  1012. }
  1013. ?>
 
Documentation generated on Sat, 21 Aug 2004 17:40:33 +0200 by phpDocumentor 1.3.0RC3
hosted by
SourceForge.net Logo