Changeset 4919
- Timestamp:
- 01/12/08 01:54:06 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OpenPNE/trunk/webapp/lib/db/review.php
r4856 r4919 95 95 } 96 96 97 include_once 'Services/Amazon.php'; 98 $amazon =& new Services_Amazon(AMAZON_TOKEN, AMAZON_AFFID, AMAZON_LOCALE, AMAZON_BASEURL); 97 // 暫定的に、旧カテゴリとSearchIndexの対応テーブルを用いる 98 $category2index = array( 99 'books-jp' => 'Books', 100 'books-us' => 'ForeignBooks', 101 'music-jp' => 'Music', 102 'classical-jp' => 'Classical', 103 'dvd-jp' => 'Music', 104 'videogames-jp' => 'Music', 105 'software-jp' => 'Software', 106 'electronics-jp' => 'Electronics', 107 'kitchen-jp' => 'Kitchen', 108 'toys-jp' => 'Toys', 109 'sporting-goods-jp' => 'SportingGoods', 110 'hpc-jp' => 'HealthPersonalCare', 111 ); 112 113 include_once 'Services/AmazonECS4.php'; 114 $amazon =& new Services_AmazonECS4(AMAZON_TOKEN, AMAZON_AFFID); 115 $amazon->setLocale(AMAZON_LOCALE); 116 // $amazon->setBaseUrl(AMAZON_BASEURL); 99 117 if (OPENPNE_USE_HTTP_PROXY) { 100 118 $amazon->setProxy(OPENPNE_HTTP_PROXY_HOST, OPENPNE_HTTP_PROXY_PORT); 101 119 } 102 $products = $amazon->searchKeyword($keyword, $category, $page); 120 121 $options = array( 122 'Keywords' => $keyword, 123 'ItemPage' => $page, 124 'ResponseGroup' => 'Large', 125 ); 126 $products = $amazon->ItemSearch($category2index[$category], $options); 127 103 128 if (PEAR::isError($products)) { 104 129 return null; 105 130 } 106 if (empty($products[' totalresults'])) {131 if (empty($products['Request']['IsValid']) || $products['Request']['IsValid'] !== 'True') { 107 132 return null; 108 133 } 109 134 110 foreach ($products as $key => $value) { 111 if (is_array($value['authors'])) { 112 $authors = array_unique($value['authors']); 113 $products[$key]['author'] = implode(', ', $authors); 114 } 115 if (is_array($value['artists'])) { 116 $artists = array_unique($value['artists']); 117 $products[$key]['artist'] = implode(', ', $artists); 118 } 119 } 120 121 $product_page = $products['page']; 122 $product_pages = $products['pages']; 123 $total_num = $products['totalresults']; 124 unset($products[0]); 125 unset($products['page']); 126 unset($products['pages']); 127 unset($products['totalresults']); 128 129 return array($products, $product_page, $product_pages, $total_num); 135 foreach ($products['Item'] as $key => $value) { 136 if (is_array($value['ItemAttributes']['Author'])) { 137 $authors = array_unique($value['ItemAttributes']['Author']); 138 $products['Item'][$key]['author'] = implode(', ', $authors); 139 } 140 if (is_array($value['ItemAttributes']['Aritst'])) { 141 $artists = array_unique($value['ItemAttributes']['Artist']); 142 $products['Item'][$key]['artist'] = implode(', ', $artists); 143 } 144 } 145 146 $product_page = $products['Request']['ItemSearchRequest']['ItemPage']; 147 $product_pages = $products['TotalPages']; 148 $total_num = $products['TotalResults']; 149 150 return array($products['Item'], $product_page, $product_pages, $total_num); 130 151 } 131 152 132 153 function db_review_write_product4asin($asin) 133 154 { 134 include_once 'Services/Amazon.php'; 135 $amazon =& new Services_Amazon(AMAZON_TOKEN, AMAZON_AFFID, AMAZON_LOCALE, AMAZON_BASEURL); 155 include_once 'Services/AmazonECS4.php'; 156 $amazon =& new Services_AmazonECS4(AMAZON_TOKEN, AMAZON_AFFID); 157 $amazon->setLocale(AMAZON_LOCALE); 158 // $amazon->setBaseUrl(AMAZON_BASEURL); 136 159 if (OPENPNE_USE_HTTP_PROXY) { 137 160 $amazon->setProxy(OPENPNE_HTTP_PROXY_HOST, OPENPNE_HTTP_PROXY_PORT); … … 139 162 $keyword = mb_convert_encoding($keyword, "UTF-8", "auto"); 140 163 141 $result = $amazon->searchAsin($asin); 164 $options = array(); 165 $options['ResponseGroup'] = 'Large'; 166 $result = $amazon->ItemLookup($asin, $options); 142 167 if (PEAR::isError($result)) { 143 168 return false; 144 169 } 145 146 $product =$result[1]; 147 if ($result[1]['authors']) { 148 $product['author'] = implode(',', $result[1]['authors']); 149 } 150 151 if (!is_array($product)) { 152 return false; 153 } 154 foreach ($product as $key => $value) { 155 $product[$key] = mb_convert_encoding($value, 'UTF-8', 'auto'); 170 if (empty($result['Request']['IsValid']) || $result['Request']['IsValid'] !== 'True') { 171 return null; 172 } 173 174 $product = $result['Item'][0]; 175 if (is_array($product['ItemAttributes']['Author'])) { 176 $authors = array_unique($product['ItemAttributes']['Author']); 177 $product['author'] = implode(', ', $authors); 178 } 179 if (is_array($product['ItemAttributes']['Aritst'])) { 180 $artists = array_unique($product['ItemAttributes']['Artist']); 181 $product['artist'] = implode(', ', $artists); 156 182 } 157 183 … … 509 535 { 510 536 $sql = 'SELECT c_review_id FROM c_review WHERE asin = ?'; 511 $params = array($product[' asin']);537 $params = array($product['ASIN']); 512 538 if ($c_review_id = db_get_one($sql, $params)) { 513 539 return $c_review_id; … … 515 541 516 542 $data = array( 517 'title' => $product[' name'],518 'release_date' => $product[' release'],519 'manufacturer' => $product[' manufacturer'],543 'title' => $product['ItemAttributes']['Title'], 544 'release_date' => $product['ItemAttributes']['PublicationDate'], 545 'manufacturer' => $product['ItemAttributes']['Manufacturer'], 520 546 'author' => $product['author'], 521 547 'c_review_category_id' => intval($c_review_category_id), 522 'image_small' => $product[' imagesmall'],523 'image_medium' => $product[' imagemedium'],524 'image_large' => $product[' imagelarge'],525 'url' => $product[' url'],526 'asin' => $product[' asin'],527 'list_price' => $product[' listprice'],528 'retail_price' => $product[' ourprice'],548 'image_small' => $product['MediumImage']['URL'], 549 'image_medium' => $product['MediumImage']['URL'], 550 'image_large' => $product['MediumImage']['URL'], 551 'url' => $product['DetailPageURL'], 552 'asin' => $product['ASIN'], 553 'list_price' => $product['ListPrice']['FormattedPrice'], 554 'retail_price' => $product['OfferSummary']['LowestUsedPrice']['FormattedPrice'], 529 555 'r_datetime' => db_now(), 530 556 ); OpenPNE/trunk/webapp/modules/pc/templates/h_review_add.tpl
r4274 r4919 180 180 <div class="padding_s"> 181 181 182 <a href="({$product. url})" target="_blank"><img src="({if $product.imagemedium})({$product.imagemedium})({else})./skin/dummy.gif({/if})"><br>詳細を見る</a>182 <a href="({$product.DetailPageURL})" target="_blank"><img src="({if $product.MediumImage})({$product.MediumImage.URL})({else})./skin/dummy.gif({/if})"><br>詳細を見る</a> 183 183 184 184 </div> … … 208 208 <div class="padding_s"> 209 209 210 <span class="b_b">({$product. name})</span>210 <span class="b_b">({$product.ItemAttributes.Title})</span> 211 211 212 212 </div> … … 240 240 <div class="padding_s"> 241 241 242 ({$product. release})<br>243 ({$product. manufacturer})<br>242 ({$product.ItemAttributes.PublicationDate})<br> 243 ({$product.ItemAttributes.Manufacturer})<br> 244 244 ({$product.artist})({$product.author}) 245 245 … … 262 262 <div class="padding_s"> 263 263 264 <a href="({t_url m=pc a=page_h_review_add_write})&category_id=({$category_id})&asin=({$product. asin})">レビューを書く</a>264 <a href="({t_url m=pc a=page_h_review_add_write})&category_id=({$category_id})&asin=({$product.ASIN})">レビューを書く</a> 265 265 266 266 </div> OpenPNE/trunk/webapp/modules/pc/templates/h_review_add_write.tpl
r4274 r4919 46 46 <td class="bg_02" style="width:180px;" align="center" rowspan="7"> 47 47 48 <a href="({$product. url})" target="_blank"><img src="({$product.imagemedium})"><br>詳細を見る</a>48 <a href="({$product.DetailPageURL})" target="_blank"><img src="({if $product.MediumImage})({$product.MediumImage.URL})({else})./skin/dummy.gif({/if})"><br>詳細を見る</a> 49 49 50 50 </td> … … 64 64 <div class="padding_s"> 65 65 66 ({$product. name})66 ({$product.ItemAttributes.Title}) 67 67 68 68 </div> … … 93 93 <div class="padding_s"> 94 94 95 ({$product. release})<br>96 ({$product. manufacturer})<br>97 ({$product.artist})({$product.author}) <br>95 ({$product.ItemAttributes.PublicationDate})<br> 96 ({$product.ItemAttributes.Manufacturer})<br> 97 ({$product.artist})({$product.author}) 98 98 99 99 </div>