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

Source for file parser.class.php

Documentation is available at parser.class.php

  1. <?php
  2. /**
  3. * This file contains the XML parser used to parse AWS feeds.
  4. *
  5. * @author Mauricio Diaz <madd0@users.sourceforge.net>
  6. * @copyright 2004 (c) Mauricio Diaz Orlich
  7. * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
  8. * @version 0.3RC1
  9. *
  10. * @package amazOOP
  11. */
  12.  
  13. /**
  14. * This file is required to access of the user's preferences
  15. * @access private
  16. */
  17. require_once(CORE_PATH . "config/config.inc.php");
  18.  
  19. /**
  20. * This is the class that connects to {@link http://www.amazon.com/gp/browse.html/?node=3434641 Amazon Web}
  21. * Services}, requests a document, downloads it and parses it.
  22. *
  23. * The data obtained from {@link http://www.amazon.com/gp/browse.html/?node=3434641 AWS} is parsed
  24. * and stored in different types of objects depending on the type of request made:
  25. * - A {@tutorial manual.blended.pkg Blended Search} will return an object of type {@link BlendedSearch};
  26. * - A query to a {@tutorial manual.cart.pkg Remote Shopping Cart} will return an object of type
  27. * {@link ShoppingCart};
  28. * - And finally, all {@tutorial manual.search.pkg other possible searches} will return an object
  29. * of type {@link ProductInfo}.
  30. *
  31. * This class is private and is only meant to be called from withing amazOOP
  32. * and not by the end-user, who should rather take a look at the {@link AmazonQuery}
  33. * class.
  34. *
  35. * @see AmazonQuery
  36. *
  37. * @author Mauricio Diaz <madd0@users.sourceforge.net>
  38. * @copyright 2004 (c) Mauricio Diaz Orlich
  39. * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
  40. * @version 0.3RC1
  41. *
  42. * @package amazOOP
  43. */
  44. class AmazonParser {
  45. /**#@+
  46. * @access private
  47. */
  48. /**
  49. * Holds handle referencing the XML parser that will be used to parse the feed.
  50. * @var resource
  51. */
  52. var $parser;
  53. /**
  54. * Holds result object to be returned after parsing.
  55. * @var ProductInfo|BlendedSearch
  56. */
  57. var $result;
  58. /**
  59. * Holds a reference to the custoemr review that is being modified
  60. * @var CustomerReview
  61. */
  62. var $currReview;
  63. /**
  64. * This is used to deal with the problem of features and tracks that contain
  65. * the '&' character being split into separate features or tracks.
  66. * @var boolean
  67. */
  68. var $ampersand;
  69. /**#@-*/
  70.  
  71.  
  72. /**
  73. * Deafult constrcutor for the AmazonParser.
  74. *
  75. * It prepares the parser by setting up the functions that will handle opening tags,
  76. * closing tags and character data.
  77. *
  78. * It also initializes some attributes.
  79. *
  80. * @return AmazonParser an XML parser for AWS feeds.
  81. *
  82. * @access private
  83. */
  84. function AmazonParser() {
  85. // Creates new XML parser
  86. if(getAmazoopConfig('UTF-8_encode'))
  87. $this->parser = xml_parser_create("UTF-8");
  88. else
  89. $this->parser = xml_parser_create();
  90.  
  91. // Sets AmazonParser as parser
  92. xml_set_object($this->parser, $this);
  93.  
  94. // Sets functions that will handle opening and closing tags
  95. // These function are tagOpen and tagClose, which can be found
  96. // below. These handle opening and closing tags, respectively.
  97. xml_set_element_handler($this->parser, "tagOpen", "tagClose");
  98.  
  99. // Sets function that will handle character data.
  100. xml_set_character_data_handler($this->parser, "cdata");
  101.  
  102. $ampersand = false;
  103. }
  104.  
  105. /**
  106. * This function handles the parsing of a feed returned by AWS.
  107. *
  108. * @param string $url the URL of the feed that has to be parsed.
  109. * @param string $type the type of request you are making to AWS. This can
  110. * be either "heavy" or "lite".
  111. *
  112. * @return BlendedSearch|ProductInfoan object containing the information
  113. * returned by AWS.
  114. *
  115. * @access private
  116. */
  117. function parse($url, $type = "lite") {
  118. global $isHeavy, $allowsettimelimit;
  119.  
  120. if($allowsettimelimit) set_time_limit(60);
  121.  
  122. if($type == "lite")
  123. $isHeavy = false;
  124. else
  125. $isHeavy = true;
  126.  
  127. $wait = 1;
  128. // Downloads response from Amazon
  129. for($i = 0; $i < 3; $i++){
  130. while(!inTime())
  131. sleep(1);
  132. if($fp = fopen($url, "r"))
  133. break;
  134. sleep($wait);
  135. $wait *= 2;
  136. }
  137.  
  138. if(!$fp)
  139. return false;
  140.  
  141. $tmpDir = getAmazoopConfig('temporary_directory');
  142.  
  143. // Creates new temporary filename
  144. $tempName = tempnam($tmpDir, "tmp");
  145. // Opens (creates) new tepmorary file for writing
  146. $amazonInfo = fopen($tempName, "w");
  147.  
  148. // Writes response to temporary file
  149. while($data = fread($fp, 1024))
  150. fwrite($amazonInfo, $data);
  151. // Closes link to Amazon
  152. fclose($amazonInfo);
  153. // Closes temporary file
  154. fclose($fp);
  155.  
  156. // Opens temporary file for reading
  157. $fp = fopen($tempName, "r");
  158. // Extracts all data
  159. $data = fread($fp, filesize($tempName));
  160. // And parses it
  161. xml_parse($this->parser, $data, feof($fp));
  162. //or die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser)));
  163.  
  164. // Frees parser
  165. xml_parser_free($this->parser);
  166.  
  167. // Closes temporary file
  168. fclose($fp);
  169. // And deletes temporary file
  170. unlink($tempName);
  171.  
  172. if($allowsettimelimit) set_time_limit(30);
  173.  
  174. // Returns an object with the parsed response
  175. // This object may be of type ProductInfo or BlendedSearch
  176. // Take a look at these objects for functions to tell them apart
  177. return $this->result;
  178. }
  179.  
  180. /**#@+
  181. * @access private
  182. */
  183. /**
  184. * This function handles opening tags.
  185. *
  186. * @param resource $parser is a reference to the parser doing the parsing.
  187. * @param string $name is the name of the tag that is being opened.
  188. * @param array $attrs is an array of attributes that the tag may have.
  189. */
  190. function tagOpen($parser, $name, $attrs) {
  191. // These global variables determine whether the response is a Blended
  192. // Search (isBlended = true) or a normal search (isBlended = false
  193. // curTag holds the current tag being analysed (used when analysing cdata)
  194. global $isBlended, $curTag, $isHeavy;
  195.  
  196. // Sets curTag to current tag's name
  197. $curTag = $name;
  198.  
  199. // $result references object to be returned after parsing
  200. $result =& $this->result;
  201. // $request references the request object from the result
  202. $request =& $result->request;
  203.  
  204. // The following lines determine where the products' details depending on
  205. // whether the search is normal or blended
  206. // If the search is not blended and an array of details has been created
  207. //if(!$isBlended && isset($result->details))
  208. if(isset($result->blendedSearch) && !$result->isBlendedSearch() && isset($result->details))
  209. // $details references the next free field of the array which is stored
  210. // in $result since the latter is of type ProductInfo
  211. $details =& $result->details[$result->itemCount];
  212. // If it is a blended search
  213. else if($isBlended){
  214. // If an array of Product Lines has been created
  215. if(isset($result->productLines))
  216. // $productLine references the next free field of this array
  217. // in which a new product line from the search results will
  218. // be stored
  219. $productLine =& $result->productLines[$result->itemCount];
  220. // If an array of details has been created in the current product line
  221. if(isset($productLine->productInfo->details))
  222. // $details will reference the next free field in this array
  223. $details =& $productLine->productInfo->details[$productLine->productInfo->itemCount];
  224. }
  225.  
  226. switch($name){
  227. // If the tag is BlendedSearch
  228. case "BLENDEDSEARCH":
  229. $isBlended = true; // $isBlended is set to true
  230. $result = new BlendedSearch(); // and a new BlendedSearch object is created
  231. // to be returned as the result of parsing
  232. $result->productLines = array(); // Also, the productLines array is set
  233. break;
  234. // If the tag is ProductLine
  235. case "PRODUCTLINE":
  236. $productLine = new ProductLine(); // A new Product line object is created in th BlendedSearch object
  237. break;
  238. // If the tag is ProductInfo
  239. case "PRODUCTINFO":
  240. // If it is NOT a Blended search
  241. if(!$isBlended){
  242. $result = new ProductInfo(); // A new ProductInfo object is created
  243. // to be returned as the result of parsing
  244. $result->details = array(); // Also, the details array is set
  245. }
  246. // If it IS a Blended search
  247. else{
  248. // The ProductInfo object is created as part of the currently selected Product Line
  249. // see $productLine above
  250. $productLine->productInfo = new ProductInfo();
  251. // Aditionally, the details array of the ProductInfo object is set
  252. $productLine->productInfo->details = array();
  253. }
  254. break;
  255. // If the tag is Request
  256. case "REQUEST":
  257. // A new Request object is created to hold the parameters of the request
  258. //$request = new Request();
  259. $request = array();
  260. break;
  261. // If the tag is Args
  262. case "ARGS":
  263. // The array args of the Request object is initialized
  264. //$request = array();
  265. break;
  266. // If the tag is Arg
  267. case "ARG":
  268. // The parameter is added to the array using the parameter's name as key
  269. $request[strtoupper($attrs['NAME'])] = rawurlencode($attrs['VALUE']);
  270. break;
  271.  
  272. // If the tag is Details
  273. case "DETAILS":
  274. // A new Details object is created, based on whether the search
  275. // was lite or heavy
  276. if($isHeavy)
  277. $details = new HeavyDetails();
  278. else
  279. $details = new LiteDetails();
  280. // The URL to the product is stored in the url attribute
  281. $details->url = rawurlencode($attrs['URL']);
  282. break;
  283. // If the tag is Artists
  284. case "ARTISTS":
  285. // The array of artists is initialized
  286. $details->artists = array();
  287. break;
  288. // If the tag is Authors
  289. case "AUTHORS":
  290. // The array of authors is initialized
  291. $details->authors = array();
  292. break;
  293. // If the tag is Lists
  294. case "LISTS":
  295. // An array of ListMania lists is initialized
  296. $details->lists = array();
  297. break;
  298. // If the tag is Features
  299. case "FEATURES":
  300. // An array of features is initialized
  301. $details->features = array();
  302. break;
  303. // If the tag is Accessories
  304. case "ACCESSORIES":
  305. // An array of accerories' ASINs is created
  306. $details->accessories = array();
  307. break;
  308. // If the tag is SimilarProducts
  309. case "SIMILARPRODUCTS":
  310. // An array of similar products' ASINs is created
  311. if($result->isShoppingCart())
  312. $result->similarProducts = array();
  313. else
  314. $details->similarProducts = array();
  315. break;
  316. // If the tag is Reviews
  317. case "REVIEWS":
  318. // An object to hold reviews is created
  319. $details->reviews = new Reviews();
  320. break;
  321. // If the tag is CustomerReview
  322. case "CUSTOMERREVIEW":
  323. // A new customerReview object is created and referenced
  324. // as the current Review
  325. /*$numOfReviews = sizeof($details->reviews->customerReviews);
  326. $details->reviews->customerReviews[$numOfReviews] = new CustomerReview;
  327. $this->currReview =& $details->reviews->customerReviews[$numOfReviews];*/
  328. $details->reviews->customerReviews[] = new CustomerReview;
  329. $this->currReview =& array_last($details->reviews->customerReviews);
  330. break;
  331. // If the tag is Platforms
  332. case "PLATFORMS":
  333. // An array of similar products' ASINs is created
  334. $details->platforms = array();
  335. break;
  336. // If the tag is Starring
  337. case "STARRING":
  338. // An array of actors is created
  339. $details->starring = array();
  340. break;
  341. // If the tag is Directors
  342. case "DIRECTORS":
  343. // An array of directos is created
  344. $details->directors = array();
  345. break;
  346. // If the tag is Tracks
  347. case "TRACKS":
  348. // An array of rawurlencoded track names is created
  349. $details->tracks = array();
  350. break;
  351. // If the tag is BrowseList
  352. case "BROWSELIST":
  353. // An array is created
  354. $details->browseList = array();
  355. break;
  356. // If th tag is BrowseNode
  357. case "BROWSENODE":
  358. $details->browseList[] = new BrowseNode;
  359. break;
  360. // If the tag is ShoppingCartResponse
  361. case "SHOPPINGCARTRESPONSE":
  362. $result = new ShoppingCart();
  363. break;
  364. // If the tag is Items
  365. case "ITEMS":
  366. $result->items = array();
  367. break;
  368. // If the tag is Item
  369. case "ITEM":
  370. $result->items[] = new CartItem();
  371. break;
  372. }
  373. }
  374.  
  375. /**
  376. * This function handles closing tags.
  377. *
  378. * @param resource $parser is a reference to the parser doing the parsing.
  379. * @param string $name is the name of the tag that is being closed.
  380. */
  381. function tagClose($parser, $name) {
  382. // These global variables determine whether the response is a Blended
  383. // Search (isBlended = true) or a normal search (isBlended = false
  384. // curTag holds the current tag being analysed (used when analysing cdata)
  385. global $isBlended, $curTag;
  386.  
  387. // $result references object to be returned after parsing
  388. $result =& $this->result;
  389. // $request references the request object from the result
  390. $request =& $result->request;
  391.  
  392. // The following lines determine where the products' details depending on
  393. // whether the search is normal or blended
  394. // If the search is not blended and an array of details has been created
  395. if(!$isBlended && isset($result->details))
  396. // $details references the next free field of the array which is stored
  397. // in $result since the latter is of type ProductInfo
  398. $details =& $result->details[$result->itemCount];
  399. // If it is a blended search
  400. else if($isBlended){
  401. // If an array of Product Lines has been created
  402. if(isset($result->productLines))
  403. // $productLine references the next free field of this array
  404. // in which a new product line from the search results will
  405. // be stored
  406. $productLine =& $result->productLines[$result->itemCount];
  407. // If an array of details has been created in the current product line
  408. if(isset($productLine->productInfo->details))
  409. // $details will reference the next free field in this array
  410. $details =& $productLine->productInfo->details[$productLine->productInfo->itemCount];
  411. }
  412.  
  413. switch($name){
  414. // If the tag is Detils
  415. case "DETAILS":
  416. // If it is a blended search
  417. if($isBlended)
  418. // The amount of products is increased in the proper productInfo object
  419. $productLine->productInfo->itemCount++;
  420. // If it is a normal search
  421. else
  422. // The amount of products is increased in the object to be returned
  423. $result->itemCount++;
  424. break;
  425. // If the tag is ProductLine
  426. case "PRODUCTLINE":
  427. // The search has to be Blended
  428. // so the amount of lines is increased in the object to be returned
  429. $result->itemCount++;
  430. break;
  431. }
  432. // The current tag is set to empty to avoid confusion
  433. $curTag = "";
  434. }
  435.  
  436. /**
  437. * This function handles character data.
  438. *
  439. * Character data is the text that is found between tags (e.g. <tag>character data</tag>)
  440. *
  441. * @param resource $parser is a reference to the parser doing the parsing.
  442. * @param string $data is the character data that has to be handled.
  443. */
  444. function cdata($parser, $data) {
  445. // These global variables determine whether the response is a Blended
  446. // Search (isBlended = true) or a normal search (isBlended = false
  447. // curTag holds the current tag being analysed (used when analysing cdata)
  448. global $isBlended, $curTag;
  449.  
  450. // Converts UTF-8 Unicode to ISO-8859-1
  451. if(!getAmazoopConfig('UTF-8_encode'))
  452. $data = utf8_decode($data);
  453.  
  454. $data = ereg_replace(" +", " ", $data);
  455.  
  456. // $result references object to be returned after parsing
  457. $result =& $this->result;
  458. // $request references the request object from the result
  459. $request =& $result->request;
  460.  
  461. // The following lines determine where the products' details depending on
  462. // whether the search is normal or blended
  463. // If the search is not blended and an array of details has been created
  464. if(!$isBlended && isset($result->details))
  465. // $details references the next free field of the array which is stored
  466. // in $result since the latter is of type ProductInfo
  467. $details =& $result->details[$result->itemCount];
  468. // If it is a blended search
  469. else if($isBlended){
  470. // If an array of Product Lines has been created
  471. if(isset($result->productLines))
  472. // $productLine references the next free field of this array
  473. // in which a new product line from the search results will
  474. // be stored
  475. $productLine =& $result->productLines[$result->itemCount];
  476.  
  477. // If an array of details has been created in the current product line
  478. if(isset($productLine->productInfo->details))
  479. // $details will reference the next free field in this array
  480. $details =& $productLine->productInfo->details[$productLine->productInfo->itemCount];
  481. }
  482.  
  483. switch($curTag){
  484. // If the current tag is Mode
  485. case "MODE":
  486. // The name of the mode is stored in the current product line
  487. $productLine->mode = rawurlencode($data);
  488. break;
  489. // If the current tag is ErrorMsg
  490. case "ERRORMSG":
  491. // The message is stored in the object to be returned
  492. $result->errorMsg = rawurlencode($data);
  493. break;
  494. // If the current tag is TotalResults
  495. case "TOTALRESULTS":
  496. // The number of total results is stored in the object to be returned
  497. if(!$isBlended)
  498. $result->totalResults = rawurlencode($data);
  499. else
  500. $productLine->productInfo->totalResults = rawurlencode($data);
  501. break;
  502. // If the current tag is TotalPages
  503. case "TOTALPAGES":
  504. // The number of pages is stored in the object to be returned
  505. if(!$isBlended)
  506. $result->totalPages = rawurlencode($data);
  507. else
  508. $productLine->productInfo->totalPages = rawurlencode($data);
  509. break;
  510. // If the current tag is Asin
  511. case "ASIN":
  512. // The ASIN is stored in the current product's details
  513. if($result->isShoppingCart()){
  514. $currItem =& array_last($result->items);
  515. $currItem->asin = rawurlencode($data);
  516. }
  517. else
  518. $details->asin = rawurlencode($data);
  519. break;
  520. // If the current tag is ProductName
  521. case "PRODUCTNAME":
  522. // The product's name is stored in the current product's details
  523. if($result->isShoppingCart()){
  524. $currItem =& array_last($result->items);
  525. $currItem->productName .= rawurlencode($data);
  526. }
  527. else
  528. $details->productName .= rawurlencode($data);
  529. break;
  530. // If the current tag is Catalog
  531. case "CATALOG":
  532. // The catalog is stored in the current product's details
  533. $details->catalog .= rawurlencode($data);
  534. break;
  535. // If the current tag is Artist
  536. case "ARTIST":
  537. // The artist's name is added at the end of the list of artists
  538. // of the current product
  539. if(strpos($data, "&") === false){
  540. $artists = explode("/", $data);
  541. foreach($artists as $artist)
  542. $details->artists[] = rawurlencode(trim($artist));
  543. }
  544. break;
  545. // If the current tag is Author
  546. case "AUTHOR":
  547. // The author's name is added at the end of the list of authors
  548. // of the current product
  549. $details->authors[] = rawurlencode($data);
  550. break;
  551. // If the current tag is Release date
  552. case "RELEASEDATE":
  553. // The product's release date is stored in the current product's details
  554. $details->releaseDate = rawurlencode($data);
  555. break;
  556. // If the current tag is Manufacturer
  557. case "MANUFACTURER":
  558. // The manufacturer is stored in the current product's details
  559. $details->manufacturer = rawurlencode($data);
  560. break;
  561. // If the current tag is ImageUrlSmall
  562. case "IMAGEURLSMALL":
  563. // The small image's URL is stored in the current product's details
  564. $details->imageUrl['small'] = rawurlencode($data);
  565. break;
  566. // If the current tag is ImageUrlMedium
  567. case "IMAGEURLMEDIUM":
  568. $details->imageUrl['medium'] = rawurlencode($data);
  569. break;
  570. // The medium image's URL is stored in the current product's details
  571. break;
  572. // If the current tag is ImageUrlLarge
  573. case "IMAGEURLLARGE":
  574. $details->imageUrl['large'] = rawurlencode($data);
  575. // The large image's URL is stored in the current product's details
  576. break;
  577. // If the current tag is ListPrice
  578. case "LISTPRICE":
  579. if($result->isShoppingCart()){
  580. $currItem =& array_last($result->items);
  581. $currItem->listPrice = rawurlencode($data);
  582. }
  583. else
  584. $details->listPrice = rawurlencode($data);
  585. // The product's list price is stored in the current product's details
  586. break;
  587. // If the current tag is ImageUrlSmall
  588. case "OURPRICE":
  589. if($result->isShoppingCart()){
  590. $currItem =& array_last($result->items);
  591. $currItem->ourPrice = rawurlencode($data);
  592. }
  593. else
  594. $details->ourPrice = rawurlencode($data);
  595. // The Amazon's price is stored in the current product's details
  596. break;
  597. // If the current tag is ImageUrlSmall
  598. case "USEDPRICE":
  599. $details->usedPrice = rawurlencode($data);
  600. // The lowest marketplace price is stored in the current product's details
  601. break;
  602. // If the current tag is ImageUrlSmall
  603. case "STATUS":
  604. $details->status = rawurlencode($data);
  605. // The status of this product's details
  606. break;
  607. // If the current tag is SalesRank
  608. case "SALESRANK":
  609. $details->salesRank = rawurlencode($data);
  610. break;
  611. // If the current tag is ListId
  612. case "LISTID":
  613. // The ListMania list ID is added at the end of the list of lists
  614. // of the current product
  615. $details->lists[] = rawurlencode($data);
  616. break;
  617. // If the current tag is Media
  618. case "MEDIA":
  619. // The media type is stored
  620. $details->media .= rawurlencode($data);
  621. break;
  622. // If the current tag is NumMedia
  623. case "NUMMEDIA":
  624. // The media type is stored
  625. $details->numMedia = rawurlencode($data);
  626. break;
  627. // If the current tag is Feature
  628. case "FEATURE":
  629. // The rawurlencoded text of the feature is stored in its array
  630. $numOfFeatures = sizeof($details->features);
  631. if($data == "&"){
  632. if($numOfFeatures == 0)
  633. $details->features[] .= rawurlencode('&');
  634. else
  635. $details->features[$numOfFeatures-1] .= rawurlencode('&');
  636. $this->ampersand = true;
  637. }
  638. else if($this->ampersand){
  639. $details->features[$numOfFeatures-1] .= rawurlencode($data);
  640. $this->ampersand = false;
  641. }
  642. else
  643. $details->features[$numOfFeatures] = rawurlencode($data);
  644. break;
  645. // If the current tag is Availability
  646. case "AVAILABILITY":
  647. // The product's availability is stored
  648. $details->availability .= rawurlencode($data);
  649. break;
  650. // If the current tag is Accessory
  651. case "ACCESSORY":
  652. // The the ASIN is stored
  653. $details->accessories[] = rawurlencode($data);
  654. break;
  655. // If the current tag is Product
  656. case "PRODUCT":
  657. // The ASIN is stored
  658. if($result->isShoppingCart())
  659. $result->similarProducts[] = $data;
  660. else
  661. $details->similarProducts[] = rawurlencode($data);
  662. break;
  663. // If the current tag is AvgCustomerRating
  664. case "AVGCUSTOMERRATING":
  665. // The average customer rating is added to the current review object
  666. $details->reviews->avgReview = rawurlencode($data);
  667. break;
  668. // If the current tag is TotalCustomerReviews
  669. case "TOTALCUSTOMERREVIEWS":
  670. // The number of reviews is added to the current review object
  671. $details->reviews->totalReviews = rawurlencode($data);
  672. break;
  673. // If the current tag is Rating
  674. case "RATING":
  675. // The rating is added to the current Customer Review
  676. $review =& array_last($details->reviews->customerReviews);
  677. $review->rating = rawurlencode($data);
  678. //$this->currReview->rating = rawurlencode($data);
  679. break;
  680. // If the current tag is Summary
  681. case "SUMMARY":
  682. // The rawurlencoded summary is added to the current Customer Review
  683. $this->currReview->summary = rawurlencode($data);
  684. break;
  685. // If the current tag is Comment
  686. case "COMMENT":
  687. // The rawurlencoded comment is added to the current Customer Review
  688. $this->currReview->comment .= rawurlencode($data);
  689. break;
  690. // If the current tag is Upc
  691. case "UPC":
  692. // The UPC number is stored
  693. $details->upc = rawurlencode($data);
  694. break;
  695. // If the current tag is Platform
  696. case "PLATFORM":
  697. // The platform is stored
  698. $details->platforms[] = rawurlencode($data);
  699. break;
  700. // If the current tag is EsrbRating
  701. case "ESRBRATING":
  702. // The rating is stored
  703. $details->esrbRating = rawurlencode($data);
  704. break;
  705. // If the current tag is MpaaRating
  706. case "MPAARATING":
  707. // The rating is stored
  708. $details->mpaaRating = rawurlencode($data);
  709. break;
  710. // If the current tag is TheatricalReleaseDate
  711. case "THEATRICALRELEASEDATE":
  712. // The date the movie was released in theaters is stored
  713. $details->theatricalReleaseDate = rawurlencode($data);
  714. break;
  715. // If the current tag is Actor
  716. case "ACTOR":
  717. // The the actor/actress is added to the list
  718. $details->starring[] = rawurlencode($data);
  719. break;
  720. // If the current tag is Director
  721. case "DIRECTOR":
  722. // The the director is added to the list
  723. $details->directors[] = rawurlencode($data);
  724. break;
  725. // If the current tag is Isbn
  726. case "ISBN":
  727. // The ISBN is stored in the current product's details
  728. $details->isbn = rawurlencode($data);
  729. break;
  730. // If the current tag is Track
  731. case "TRACK":
  732. // The the rawurlencoded name of the track is added to the list
  733. $numOfTracks = sizeof($details->tracks);
  734. if($data == "&"){
  735. $details->tracks[$numOfTracks-1] .= rawurlencode(' &amp; ');
  736. $this->ampersand = true;
  737. }
  738. else if($this->ampersand){
  739. $details->tracks[$numOfTracks-1] .= rawurlencode($data);
  740. $this->ampersand = false;
  741. }
  742. else
  743. $details->tracks[$numOfTracks] = rawurlencode($data);
  744. break;
  745. // If the current tag is ProductDescription
  746. case "PRODUCTDESCRIPTION":
  747. // The description is stored
  748. $details->productDescription .= rawurlencode($data);
  749. break;
  750. // If the current tag is BrowseName
  751. case "BROWSENAME":
  752. // The browse node's name is added to the browseList
  753. $browseNode =& array_last($details->browseList);
  754.  
  755. if($data == "&"){
  756. $browseNode->nodeName .= rawurlencode(' &amp; ');
  757. $this->ampersand = true;
  758. }
  759. elseif($this->ampersand){
  760. $browseNode->nodeName .= rawurlencode($data);
  761. $this->ampersand = false;
  762. }
  763. else
  764. $browseNode->nodeName = rawurlencode($data);
  765. break;
  766. // If the current tag is BrowseId
  767. case "BROWSEID":
  768. $browseNode =& array_last($details->browseList);
  769. $browseNode->nodeId = $data;
  770. break;
  771. // If the current tag is Encoding
  772. case "ENCODING":
  773. $details->encoding = rawurlencode($data);
  774. break;
  775. // If the current tag is MerchantId
  776. case "MERCHANTID":
  777. $details->merchantid = rawurlencode($data);
  778. break;
  779. // If the current tag is MinPrice
  780. case "MINPRICE":
  781. $details->minPrice = rawurlencode($data);
  782. break;
  783. // If the current tag is MaxPrice
  784. case "MAXPRICE":
  785. $details->maxPrice = rawurlencode($data);
  786. break;
  787. // If the current tag is ThirdPartyNewPrice
  788. case "THIRDPARTYNEWPRICE":
  789. $details->thirdPartyNewPrice = rawurlencode($data);
  790. break;
  791. // If the current tag is CollectiblePrice
  792. case "COLLECTIBLEPRICE":
  793. $details->collectiblePrice = rawurlencode($data);
  794. break;
  795. // If the current tag is RefurbishedPrice
  796. case "REFURBISHEDPRICE":
  797. $details->refurbishedPrice = rawurlencode($data);
  798. break;
  799.  
  800. case "ITEMID":
  801. $currItem =& array_last($result->items);
  802. $currItem->itemId = rawurlencode($data);
  803. break;
  804. case "QUANTITY":
  805. $currItem =& array_last($result->items);
  806. $currItem->qty = rawurlencode($data);
  807. break;
  808. case "CARTID":
  809. $result->cartID = rawurlencode($data);
  810. break;
  811. case "HMAC":
  812. $result->HMAC = rawurlencode($data);
  813. break;
  814. case "PURCHASEURL":
  815. $result->purchaseURL = rawurlencode($data);
  816. break;
  817. }
  818. }
  819. /**#@-*/
  820. }
  821. ?>
 
Documentation generated on Sat, 21 Aug 2004 17:40:45 +0200 by phpDocumentor 1.3.0RC3
hosted by
SourceForge.net Logo