| 81 |
- |
1 |
<?php
|
|
|
2 |
include_once ('php/constants.php');
|
|
|
3 |
|
|
|
4 |
error_reporting(E_ALL);
|
|
|
5 |
|
|
|
6 |
// Get itunes listings
|
|
|
7 |
function get_amazon($query, $searchCondition) {
|
|
|
8 |
$vendors = Vendors::getInstance();
|
|
|
9 |
$config = $vendors->getVendor(Vendors::AMAZON);
|
|
|
10 |
|
|
|
11 |
$needMatches = empty($_SESSION["discogs"]);
|
|
|
12 |
$arrMusic = [];
|
|
|
13 |
$arrDigital = [];
|
| 82 |
- |
14 |
$arrBooks = [];
|
| 81 |
- |
15 |
|
|
|
16 |
// Music
|
|
|
17 |
$arrMusic = get_amazonCategory($config, $query, "Music", $needMatches);
|
|
|
18 |
|
|
|
19 |
// Digital Music
|
|
|
20 |
if ($_SESSION["filterMediaType"]["Digital"]) {
|
|
|
21 |
$arrDigital = get_amazonCategory($config, $query, "MP3Downloads");
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
if ($_SESSION["filterMediaType"]["Book"]) {
|
|
|
25 |
// Books
|
|
|
26 |
$arrBooks = get_amazonCategory($config, $query, "Books");
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
return (array_merge($arrMusic, $arrDigital, $arrBooks));
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
// Get Amazon listings
|
|
|
33 |
function get_amazonCategory($config, $query, $searchIndex, $needMatches = false) {
|
|
|
34 |
// API request variables
|
|
|
35 |
$access_key_id = $config["access_key_id"];
|
|
|
36 |
$secret_key = $config["secret_key"];
|
|
|
37 |
$endpoint = $config["endpoint"];
|
|
|
38 |
$uri = $config["uri"];
|
|
|
39 |
$associate_tag = $config["associate_tag"];
|
| 94 |
- |
40 |
$numResults = $config['numResults'];
|
| 81 |
- |
41 |
|
|
|
42 |
if ($needMatches) {
|
|
|
43 |
$_SESSION["discogs"] = "";
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
$params = array(
|
|
|
47 |
"Service" => "AWSECommerceService",
|
|
|
48 |
"Operation" => "ItemSearch",
|
|
|
49 |
"AWSAccessKeyId" => $access_key_id,
|
|
|
50 |
"AssociateTag" => $associate_tag,
|
|
|
51 |
"SearchIndex" => $searchIndex,
|
|
|
52 |
"Keywords" => $query,
|
|
|
53 |
"ResponseGroup" => "ItemAttributes,Images,Offers,OfferFull,Tracks",
|
|
|
54 |
"Condition" => "All", /* New, Used, Collectible, Refurbished */
|
|
|
55 |
"Sort" => "price",
|
|
|
56 |
"Availability" => "Available",
|
|
|
57 |
"Timestamp" => gmdate('Y-m-d\TH:i:s\Z')
|
|
|
58 |
);
|
|
|
59 |
|
|
|
60 |
// Sort the parameters by key
|
|
|
61 |
ksort($params);
|
|
|
62 |
|
|
|
63 |
$pairs = array();
|
|
|
64 |
|
|
|
65 |
foreach ($params as $key => $value) {
|
|
|
66 |
array_push($pairs, rawurlencode($key)."=".rawurlencode($value));
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
// Generate the canonical query
|
|
|
70 |
$canonical_query_string = join("&", $pairs);
|
|
|
71 |
|
|
|
72 |
// Generate the string to be signed
|
|
|
73 |
$string_to_sign = "GET\n".$endpoint."\n".$uri."\n".$canonical_query_string;
|
|
|
74 |
|
|
|
75 |
// Generate the signature required by the Product Advertising API
|
|
|
76 |
$signature = base64_encode(hash_hmac("sha256", $string_to_sign, $secret_key, true));
|
|
|
77 |
|
|
|
78 |
// Generate the signed URL
|
|
|
79 |
$url = 'https://'.$endpoint.$uri.'?'.$canonical_query_string.'&Signature='.rawurlencode($signature);
|
|
|
80 |
|
|
|
81 |
$result = getUrl($url);
|
|
|
82 |
$parsed_xml = simplexml_load_string($result);
|
|
|
83 |
|
|
|
84 |
$arr = [];
|
|
|
85 |
|
| 82 |
- |
86 |
// echo "<br><br>$url<br><pre>";print_r($parsed_xml);echo "</pre>";
|
| 81 |
- |
87 |
// Check to see if the request found any results
|
|
|
88 |
if (!empty($parsed_xml->Items->Request->IsValid)) {
|
|
|
89 |
$valid = (bool)(string)$parsed_xml->Items->Request->IsValid;
|
|
|
90 |
}else {
|
|
|
91 |
$valid = false;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
if ($valid) {
|
|
|
95 |
if ($needMatches) {
|
|
|
96 |
$cnt = 0;
|
|
|
97 |
$_SESSION["discogs"] = startMatches();
|
|
|
98 |
}
|
|
|
99 |
|
| 94 |
- |
100 |
$listings = 0;
|
| 81 |
- |
101 |
// If the response was loaded, parse it and store in array
|
|
|
102 |
foreach($parsed_xml->Items->Item as $current){
|
| 82 |
- |
103 |
// [ProductGroup] => Digital Music Album
|
|
|
104 |
if ($searchIndex == "MP3Downloads" && !empty($current->ItemAttributes->TrackSequence)) {
|
|
|
105 |
continue; // skip individual songs
|
|
|
106 |
}
|
|
|
107 |
|
| 81 |
- |
108 |
if (isset($current->ItemAttributes->UPC)) {
|
|
|
109 |
$barcode = (string)$current->ItemAttributes->UPC;
|
|
|
110 |
} else if (isset($current->ItemAttributes->EAN)) {
|
|
|
111 |
$barcode = (string)$current->ItemAttributes->EAN;
|
|
|
112 |
} else if (isset($current->ItemAttributes->ISBN)) {
|
|
|
113 |
$barcode = (string)$current->ItemAttributes->ISBN;
|
|
|
114 |
} else if (isset($current->ItemAttributes->EISBN)) {
|
|
|
115 |
$barcode = (string)$current->ItemAttributes->EISBN;
|
|
|
116 |
} else {
|
|
|
117 |
$barcode = "";
|
|
|
118 |
}
|
|
|
119 |
$barcodeType = clsLibGTIN::GTINCheck($barcode, false, 1);
|
|
|
120 |
|
|
|
121 |
$pic = str_replace('http://', 'https://', (string)$current->MediumImage->URL);
|
|
|
122 |
if (empty($pic)) {
|
|
|
123 |
continue;
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
if (strpos($current->ItemAttributes->Binding, "CD") !== false) {
|
|
|
127 |
$mediaType = "CD";
|
|
|
128 |
} else if (strpos($current->ItemAttributes->Binding, "MP3") !== false) {
|
|
|
129 |
$mediaType = "Digital";
|
|
|
130 |
} else if (strpos($current->ItemAttributes->Binding, "Vinyl") !== false) {
|
|
|
131 |
$mediaType = "Record";
|
| 82 |
- |
132 |
} else if (strpos($current->ItemAttributes->Binding, "Paperback") !== false ||
|
|
|
133 |
strpos($current->ItemAttributes->Binding, "Sheet") !== false ||
|
|
|
134 |
strpos($current->ItemAttributes->Binding, "Hardcover") !== false) {
|
|
|
135 |
$mediaType = "Book";
|
| 81 |
- |
136 |
} else {
|
| 82 |
- |
137 |
continue;
|
| 81 |
- |
138 |
}
|
|
|
139 |
|
|
|
140 |
if ($needMatches) {
|
|
|
141 |
// bugbug: check maxMasterCnt?
|
|
|
142 |
$_SESSION["discogs"] .= addMatch($current, ++$cnt, $mediaType);
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
$title = (string)$current->ItemAttributes->Title;
|
|
|
146 |
$artists = getArtists($current);
|
|
|
147 |
$creators = getCreators($current);
|
|
|
148 |
if (!empty($artists)) {
|
|
|
149 |
$title .= " by " . join(", ", $artists);
|
|
|
150 |
} else if (!empty($creators)) {
|
|
|
151 |
$title .= " by " . join(", ", $creators);
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
$url = str_replace('http://', 'https://', (string)$current->DetailPageURL);
|
|
|
155 |
|
|
|
156 |
if (empty($url)) {
|
|
|
157 |
continue;
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
$country = 'US';
|
|
|
161 |
$bestOffer = false;
|
|
|
162 |
|
|
|
163 |
foreach($current->ItemLinks->ItemLink as $link) {
|
|
|
164 |
if ($link->Description == "All Offers") {
|
|
|
165 |
$url = str_replace('http://', 'https://', (string)$link->URL);
|
|
|
166 |
$url .= "&condition=";
|
|
|
167 |
}
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
if (!empty($current->Offers->Offer)) {
|
|
|
171 |
foreach($current->Offers->Offer as $offer){
|
|
|
172 |
$merchantName = "Amazon";
|
|
|
173 |
if (strpos($offer->Merchant->Name, "Amazon") === false) {
|
|
|
174 |
$merchantName .= " Marketplace";
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
$condition = (string)$offer->OfferAttributes->Condition;
|
|
|
178 |
$url .= $condition;
|
|
|
179 |
$detailCondition = $condition;
|
|
|
180 |
if ($condition == "Collectible") { $condition = 'Used'; $detailCondition = "Collectible"; }
|
| 86 |
- |
181 |
if ($condition == "Refurbished") { $condition = 'Used'; $detailCondition = "Refurbished"; }
|
| 81 |
- |
182 |
$currency = (string)$offer->OfferListing->Price->CurrencyCode;
|
|
|
183 |
$price = number_format(floatval($offer->OfferListing->Price->Amount) / 100.00, 2, '.', '');
|
|
|
184 |
|
|
|
185 |
if ($price <= "0.00") {
|
|
|
186 |
continue;
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
$timeLeft = 0;
|
|
|
190 |
$listingType = 'Fixed';
|
|
|
191 |
$location = 'US';
|
|
|
192 |
$zip = '';
|
|
|
193 |
$feedbackScore = -1;
|
|
|
194 |
$feedbackPercent = -1;
|
|
|
195 |
$sellerName = "";
|
|
|
196 |
if ($offer->OfferListing->AvailabilityAttributes->MaximumHours == 0) {
|
|
|
197 |
$handlingTime = 1;
|
|
|
198 |
} else {
|
|
|
199 |
$handlingTime = (int)($offer->OfferListing->AvailabilityAttributes->MaximumHours / 24);
|
|
|
200 |
}
|
|
|
201 |
if (!empty($offer->OfferListing->IsEligibleForPrime)) {
|
|
|
202 |
$sellerName = "Prime";
|
|
|
203 |
}
|
|
|
204 |
if ($mediaType == "Digital") {
|
|
|
205 |
$shippingCost = 0.00;
|
|
|
206 |
$shippingEstimated = false;
|
|
|
207 |
$shippingCurrency = 'USD';
|
|
|
208 |
} else {
|
|
|
209 |
$shippingCost = 3.99; // bugbug
|
|
|
210 |
$shippingEstimated = true; // bugbug
|
|
|
211 |
$shippingCurrency = 'USD';
|
|
|
212 |
}
|
|
|
213 |
$freeShippingCap = !empty($offer->OfferListing->IsEligibleForSuperSaverShipping) ? 25 : 0;
|
| 94 |
- |
214 |
|
|
|
215 |
if (++$listings > $numResults) {
|
|
|
216 |
continue;
|
|
|
217 |
}
|
| 81 |
- |
218 |
|
|
|
219 |
$arr[] = array(
|
|
|
220 |
"Merchant" => $merchantName,
|
|
|
221 |
"Condition" => $condition,
|
|
|
222 |
"Title" => $title,
|
|
|
223 |
"Barcode" => $barcode,
|
|
|
224 |
"BarcodeType" => $barcodeType,
|
|
|
225 |
"Image" => $pic,
|
|
|
226 |
"URL" => $url,
|
|
|
227 |
"MediaType" => $mediaType,
|
|
|
228 |
"DetailCondition" => $detailCondition,
|
|
|
229 |
"Country" => $country,
|
|
|
230 |
"BestOffer" => $bestOffer,
|
|
|
231 |
"TimeLeft" => $timeLeft,
|
|
|
232 |
"Price" => $price,
|
|
|
233 |
"Currency" => $currency,
|
|
|
234 |
"ListingType" => $listingType,
|
|
|
235 |
"Location" => $location,
|
|
|
236 |
"Zip" => $zip,
|
|
|
237 |
"FeedbackScore" => $feedbackScore,
|
|
|
238 |
"FeedbackPercent" => $feedbackPercent,
|
|
|
239 |
"SellerName" => $sellerName,
|
|
|
240 |
"HandlingTime" => $handlingTime,
|
|
|
241 |
"ShippingCost" => $shippingCost,
|
|
|
242 |
"ShippingEstimated" => $shippingEstimated,
|
|
|
243 |
"ShippingCurrency" => $shippingCurrency,
|
|
|
244 |
"FreeShippingCap" => $freeShippingCap,
|
|
|
245 |
"Show" => true
|
|
|
246 |
);
|
|
|
247 |
}
|
|
|
248 |
}
|
|
|
249 |
}
|
|
|
250 |
|
|
|
251 |
if ($needMatches) {
|
|
|
252 |
if ($cnt = 0) {
|
|
|
253 |
$_SESSION["discogs"] = "";
|
|
|
254 |
} else {
|
|
|
255 |
$_SESSION["discogs"] .= endMatches();
|
|
|
256 |
}
|
|
|
257 |
}
|
|
|
258 |
}
|
|
|
259 |
// If the response does not indicate 'Success,' log the error(s)
|
|
|
260 |
else {
|
|
|
261 |
error_log($url);
|
|
|
262 |
if (!empty($parsed_xml->OperationRequest->Errors)) {
|
|
|
263 |
foreach($parsed_xml->OperationRequest->Errors->Error as $error){
|
|
|
264 |
error_log($error->Message . " (" . $error->Code . ")");
|
|
|
265 |
}
|
|
|
266 |
} else if (!empty($parsed_xml->Errors)) {
|
|
|
267 |
foreach($parsed_xml->OperationRequest->Errors->Error as $error){
|
|
|
268 |
error_log($error->Message . " (" . $error->Code . ")");
|
|
|
269 |
}
|
|
|
270 |
} else if (!empty($parsed_xml->Error)) {
|
|
|
271 |
error_log($parsed_xml->Error->Message . " (" . $parsed_xml->Error->Code . ")");
|
|
|
272 |
} else {
|
|
|
273 |
error_log(print_r($result, 1));
|
|
|
274 |
}
|
|
|
275 |
}
|
|
|
276 |
|
|
|
277 |
return $arr;
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
function startMatches() {
|
|
|
281 |
$str = "<div class=\"container-fluid bg-secondary\">";
|
|
|
282 |
$str .= "<h4 class=\"text-center py-2\">Matching Albums</h4>";
|
|
|
283 |
$str .= "<form method=\"post\" action=\"/index.php\">";
|
|
|
284 |
$str .= "<input type=\"hidden\" name=\"sessionTab\" value=\"" . MySessionHandler::getSessionTab() . "\">";
|
|
|
285 |
$str .= "<input id=\"discogsTitle\" type=\"hidden\" name=\"discogsTitle\" value=\"\">";
|
|
|
286 |
$str .= "<input id=\"discogsArtist\" type=\"hidden\" name=\"discogsArtist\" value=\"\">";
|
|
|
287 |
$str .= "<input id=\"discogsBarcode\" type=\"hidden\" name=\"discogsBarcode\" value=\"\">";
|
|
|
288 |
$str .= "<div id=\"discogsDeck\" class=\"card-deck\">";
|
|
|
289 |
|
|
|
290 |
return $str;
|
|
|
291 |
}
|
|
|
292 |
|
|
|
293 |
function endMatches() {
|
|
|
294 |
$str = "</div>";
|
|
|
295 |
$str .= "</form>";
|
|
|
296 |
$str .= "</div>";
|
|
|
297 |
|
|
|
298 |
|
|
|
299 |
return $str;
|
|
|
300 |
}
|
|
|
301 |
|
|
|
302 |
function addMatch($item, $cnt, $mediaType) {
|
|
|
303 |
$artists = getArtists($item);
|
|
|
304 |
|
|
|
305 |
$creators = getCreators($item);
|
|
|
306 |
|
|
|
307 |
$actors = [];
|
|
|
308 |
if (!empty($item->ItemAttributes->Actor)) {
|
|
|
309 |
foreach($item->ItemAttributes->Actor as $actor) {
|
|
|
310 |
$actors[] = $actor;
|
|
|
311 |
}
|
|
|
312 |
}
|
|
|
313 |
|
|
|
314 |
$authors = [];
|
|
|
315 |
if (!empty($item->ItemAttributes->Author)) {
|
|
|
316 |
foreach($item->ItemAttributes->Author as $author) {
|
|
|
317 |
$authors[] = $author;
|
|
|
318 |
}
|
|
|
319 |
}
|
|
|
320 |
|
|
|
321 |
$directors = [];
|
|
|
322 |
if (!empty($item->ItemAttributes->Director)) {
|
|
|
323 |
foreach($item->ItemAttributes->Director as $director) {
|
|
|
324 |
$directors[] = $director;
|
|
|
325 |
}
|
|
|
326 |
}
|
|
|
327 |
|
|
|
328 |
$genres = [];
|
|
|
329 |
if (!empty($item->ItemAttributes->Genre)) {
|
|
|
330 |
foreach($item->ItemAttributes->Genre as $genre) {
|
|
|
331 |
$genres[] = join(" ", array_map('ucfirst', explode('-', $genre)));
|
|
|
332 |
}
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
$labels = [];
|
|
|
336 |
if (!empty($item->ItemAttributes->Label)) {
|
|
|
337 |
foreach($item->ItemAttributes->Label as $label) {
|
|
|
338 |
$labels[] = $label;
|
|
|
339 |
}
|
|
|
340 |
}
|
|
|
341 |
|
|
|
342 |
$languages = [];
|
|
|
343 |
if (!empty($item->ItemAttributes->Languages->Language)) {
|
|
|
344 |
foreach($item->ItemAttributes->Languages->Language as $language) {
|
|
|
345 |
if ((string)$language->Type != "Unknown") {
|
|
|
346 |
$languages[] = $language->Name . " (" . $language->Type . ")";
|
|
|
347 |
}
|
|
|
348 |
}
|
|
|
349 |
}
|
|
|
350 |
|
|
|
351 |
$runningTime = "";
|
|
|
352 |
if (!empty($item->ItemAttributes->RunningTime)) {
|
|
|
353 |
if ($mediaType != 'Digital') {
|
|
|
354 |
$runningTime = (string)$item->ItemAttributes->RunningTime . " minutes";
|
|
|
355 |
} else {
|
|
|
356 |
$runningTime = gmdate("H:i:s", (int)$item->ItemAttributes->RunningTime);
|
|
|
357 |
}
|
|
|
358 |
}
|
|
|
359 |
|
|
|
360 |
$modal = "";
|
|
|
361 |
$str = "<div class=\"card mx-auto discogs-card\">";
|
|
|
362 |
$str .= "<div class=\"card-header bg-info d-flex h-100\">";
|
|
|
363 |
$str .= "<p class=\"card-title font-weight-bold small flex-grow-1\">" . (string)$item->ItemAttributes->Title . " by ";
|
|
|
364 |
$searchArtists = "";
|
|
|
365 |
if (count($artists) < 5) {
|
|
|
366 |
$wlArtists = join(", ", $artists);
|
|
|
367 |
if (!empty($artists) && $artists[0] != 'Various') {
|
|
|
368 |
$searchArtists = join(" ", $artists);
|
|
|
369 |
}
|
|
|
370 |
}
|
|
|
371 |
else {
|
|
|
372 |
$wlArtists = "Various Artists";
|
|
|
373 |
}
|
|
|
374 |
$str .= $wlArtists;
|
|
|
375 |
$str .= "</p>";
|
|
|
376 |
$str .= "</div>";
|
|
|
377 |
|
|
|
378 |
$thumbnail = !empty($item->MediumImage->URL) ? (string)$item->MediumImage->URL : "images/no-image-available.jpg";
|
|
|
379 |
|
|
|
380 |
$str .= "<div class=\"card-body bg-light mx-auto p-0 m-0\">";
|
|
|
381 |
$str .= "<img class=\"btn responsive-image p-0 m-0\" src=\"" . $thumbnail . "\" data-toggle=\"modal\" data-target=\"#masterModal" . $cnt . "\" title=\"Album Information\" data-toggle2=\"tooltip\" alt=\"Cover Thumbnail\">";
|
|
|
382 |
$str .= "</div>";
|
|
|
383 |
$str .= "<div class=\"card-footer bg-dark p-0 m-0\">";
|
|
|
384 |
$str .= "<div class=\"container clearfix p-0 m-0\">";
|
|
|
385 |
$str .= "<span class=\"float-left\">";
|
|
|
386 |
$str .= "<button type=\"button\" class=\"btn btn-primary m-1 btn-sm\" data-toggle=\"modal\" data-target=\"#masterModal" . $cnt . "\" title=\"Album Information\" data-toggle2=\"tooltip\"><i class=\"fas fa-info\"></i></button>";
|
|
|
387 |
|
|
|
388 |
$str .= "</span>";
|
|
|
389 |
|
|
|
390 |
$str .= "<span class=\"float-right\">";
|
|
|
391 |
|
|
|
392 |
$barcode = "";
|
|
|
393 |
$tmpBarcode = "";
|
|
|
394 |
if (!empty($item->ItemAttributes->UPC)) {
|
|
|
395 |
$tmpBarcode = (string)$item->ItemAttributes->UPC;
|
|
|
396 |
} else if (!empty($item->ItemAttributes->EAN)) {
|
|
|
397 |
$tmpBarcode = (string)$item->ItemAttributes->EAN;
|
|
|
398 |
} else if (!empty($item->ItemAttributes->ISBN)) {
|
|
|
399 |
$tmpBarcode = (string)$item->ItemAttributes->ISBN;
|
|
|
400 |
} else if (!empty($item->ItemAttributes->EISBN)) {
|
|
|
401 |
$tmpBarcode = (string)$item->ItemAttributes->EISBN;
|
|
|
402 |
}
|
|
|
403 |
$barcodeType = clsLibGTIN::GTINCheck($tmpBarcode, false, 1);
|
|
|
404 |
if (!empty($barcodeType)) {
|
|
|
405 |
$barcode = $tmpBarcode;
|
|
|
406 |
}
|
|
|
407 |
|
|
|
408 |
if (isLoggedIn() && !checkWishlist('asin', $item->ASIN)) {
|
|
|
409 |
$wlArr = array(
|
|
|
410 |
'asin' => (string)$item->ASIN,
|
|
|
411 |
'title' => (string)$item->ItemAttributes->Title,
|
|
|
412 |
'artist' => $wlArtists,
|
|
|
413 |
'barcode' => $barcode,
|
|
|
414 |
'thumbnail' => $thumbnail,
|
|
|
415 |
'url' => (string)$item->DetailPageURL
|
|
|
416 |
);
|
|
|
417 |
$wl = base64_encode(json_encode($wlArr));
|
|
|
418 |
$str .= " <button type=\"button\" class=\"btn btn-primary m-1 btn-sm\" onclick=\"addWishlist('" . $_SESSION['sessData']['userID'] . "',this," . $cnt . ",'" . $wl . "');\" title=\"Add to Wishlist\" data-toggle=\"tooltip\"><i class=\"fas fa-bookmark\"></i></button>";
|
|
|
419 |
}
|
|
|
420 |
|
|
|
421 |
$searchTitle = 'Searching for:<br><br><strong>' . (string)$item->ItemAttributes->Title . ' by' . $wlArtists . '</strong>';
|
|
|
422 |
if (!empty($barcode)) {
|
|
|
423 |
$searchTitle .= " (" . displayBarcode($barcode) . ")";
|
|
|
424 |
}
|
|
|
425 |
|
| 86 |
- |
426 |
$str .= " <button type=\"submit\" name=\"submit\" value=\"discogsSearch\" class=\"btn btn-primary m-1 btn-sm\" onclick=\"document.getElementById('discogsTitle').value = '" . addslashes((string)$item->ItemAttributes->Title) . "';document.getElementById('discogsArtist').value = '" . addslashes($searchArtists) . "';document.getElementById('discogsBarcode').value = '" . $barcode . "';progressBar('" . sanitizeInput2($searchTitle) . "');\" title=\"Search for Store Offers\" data-toggle=\"tooltip\"><i class=\"fas fa-search\"></i></button>";
|
| 81 |
- |
427 |
$str .= "</span>";
|
|
|
428 |
$str .= "</div>";
|
|
|
429 |
$str .= "<span id=\"wishlistAdd" . $cnt . "\"></span>";
|
|
|
430 |
$str .= "</div>";
|
|
|
431 |
|
|
|
432 |
$modal .= "<div id=\"masterModal" . $cnt . "\" class=\"modal\">";
|
|
|
433 |
$modal .= "<div class=\"modal-dialog\">";
|
|
|
434 |
$modal .= "<div class=\"modal-content\">";
|
|
|
435 |
$modal .= "<div class=\"modal-header bg-primary\">";
|
|
|
436 |
$modal .= "<h4 class=\"modal-title mx-auto\">" . (string)$item->ItemAttributes->Title . " by " . $wlArtists . "</h4>";
|
|
|
437 |
$modal .= "<button type=\"button\" class=\"close\" data-dismiss=\"modal\"><i class=\"fas fa-window-close btn-dismiss\"></i></button>";
|
|
|
438 |
$modal .= "</div>";
|
|
|
439 |
|
|
|
440 |
$modal .= "<div class=\"modal-body bg-white mx-auto\">";
|
|
|
441 |
|
|
|
442 |
if (!empty($item->LargeImage->URL)) {
|
|
|
443 |
$modal .= "<img class=\"responsive-image mx-auto mb-4\" src=\"" . (string)$item->LargeImage->URL . "\" alt=\"Cover Image\">";
|
|
|
444 |
}
|
|
|
445 |
|
|
|
446 |
$modal .= "<table class=\"table-borderless table-condensed small mx-auto\">";
|
|
|
447 |
$modal .= "<tr><td class=\"px-1\">Title:</td><td class=\"px-1\">" . (string)$item->ItemAttributes->Title . "</td></tr>";
|
|
|
448 |
|
|
|
449 |
$modal .= "<tr><td class=\"px-1\">Artist:</td><td class=\"px-1\">" . join(", ", $artists) . "</td></tr>";
|
|
|
450 |
if (!empty($creators)) {
|
|
|
451 |
$modal .= "<tr><td class=\"px-1\">Creator:</td><td class=\"px-1\">" . join(", ", $creators) . "</td></tr>";
|
|
|
452 |
}
|
|
|
453 |
|
|
|
454 |
if (!empty($actors)) {
|
|
|
455 |
$modal .= "<tr><td class=\"px-1\">Actor:</td><td class=\"px-1\">" . join(", ", $actors) . "</td></tr>";
|
|
|
456 |
}
|
|
|
457 |
|
|
|
458 |
if (!empty($directors)) {
|
|
|
459 |
$modal .= "<tr><td class=\"px-1\">Director:</td><td class=\"px-1\">" . join(", ", $directors) . "</td></tr>";
|
|
|
460 |
}
|
|
|
461 |
|
|
|
462 |
if (!empty($authors)) {
|
|
|
463 |
$modal .= "<tr><td class=\"px-1\">Author:</td><td class=\"px-1\">" . join(", ", $authors) . "</td></tr>";
|
|
|
464 |
}
|
|
|
465 |
|
|
|
466 |
if (!empty($item->ItemAttributes->Binding)) {
|
|
|
467 |
$modal .= "<tr><td class=\"px-1\">Type:</td><td class=\"px-1\">" . (string)$item->ItemAttributes->Binding . "</td></tr>";
|
|
|
468 |
}
|
|
|
469 |
|
|
|
470 |
if (!empty($item->ItemAttributes->MediaType)) {
|
|
|
471 |
$modal .= "<tr><td class=\"px-1\">Media Type:</td><td class=\"px-1\">" . (string)$item->ItemAttributes->MediaType . "</td></tr>";
|
|
|
472 |
}
|
|
|
473 |
|
|
|
474 |
if (!empty($barcode)) {
|
|
|
475 |
$modal .= "<tr><td class=\"px-1\">Barcode:</td><td class=\"px-1\">" . displayBarcode($barcode) . "</td></tr>";
|
|
|
476 |
}
|
|
|
477 |
|
|
|
478 |
if (!empty($labels)) {
|
|
|
479 |
$modal .= "<tr><td class=\"px-1\">Label:</td><td class=\"px-1\">" . $labels[0] . "</td></tr>";
|
|
|
480 |
} else if (!empty($item->ItemAttributes->Publisher)) {
|
|
|
481 |
$modal .= "<tr><td class=\"px-1\">Publisher:</td><td class=\"px-1\">" . (string)$item->ItemAttributes->Publisher . "</td></tr>";
|
|
|
482 |
} else if (!empty($item->ItemAttributes->Studio)) {
|
|
|
483 |
$modal .= "<tr><td class=\"px-1\">Studio:</td><td class=\"px-1\">" . (string)$item->ItemAttributes->Studio . "</td></tr>";
|
|
|
484 |
}
|
|
|
485 |
|
|
|
486 |
if (!empty($languages)) {
|
|
|
487 |
$modal .= "<tr><td class=\"px-1\">Languages:</td><td class=\"px-1\">" . join(", ", $languages) . "</td></tr>";
|
|
|
488 |
}
|
|
|
489 |
|
|
|
490 |
if (!empty($item->ItemAttributes->PublicationDate)) {
|
|
|
491 |
$modal .= "<tr><td class=\"px-1\">Publication Date:</td><td class=\"px-1\">" . (string)$item->ItemAttributes->PublicationDate . "</td></tr>";
|
|
|
492 |
}
|
|
|
493 |
|
|
|
494 |
if (!empty($item->ItemAttributes->ReleaseDate)) {
|
|
|
495 |
$modal .= "<tr><td class=\"px-1\">Release Date:</td><td class=\"px-1\">" . (string)$item->ItemAttributes->ReleaseDate . "</td></tr>";
|
|
|
496 |
}
|
|
|
497 |
|
|
|
498 |
if (!empty($genres)) {
|
|
|
499 |
$modal .= "<tr><td class=\"px-1\">Genre:</td><td class=\"px-1\">" . join(", ", $genres) . "</td></tr>";
|
|
|
500 |
}
|
|
|
501 |
|
|
|
502 |
if (!empty($item->ItemAttributes->NumberOfDiscs)) {
|
|
|
503 |
$modal .= "<tr><td class=\"px-1\">Number of Discs:</td><td class=\"px-1\">" . (string)$item->ItemAttributes->NumberOfDiscs . "</td></tr>";
|
|
|
504 |
}
|
|
|
505 |
|
|
|
506 |
if (!empty($item->ItemAttributes->NumberOfPages)) {
|
|
|
507 |
$modal .= "<tr><td class=\"px-1\">Number of Pages:</td><td class=\"px-1\">" . (string)$item->ItemAttributes->NumberOfPages . "</td></tr>";
|
|
|
508 |
}
|
|
|
509 |
|
|
|
510 |
if (!empty($item->ItemAttributes->RunningTime)) {
|
|
|
511 |
$modal .= "<tr><td class=\"px-1\">Running Time:</td><td class=\"px-1\">" . $runningTime . "</td></tr>";
|
|
|
512 |
}
|
|
|
513 |
|
|
|
514 |
if (!empty($item->ItemAttributes->Edition)) {
|
|
|
515 |
$modal .= "<tr><td class=\"px-1\">Edition:</td><td class=\"px-1\">" . (string)$item->ItemAttributes->Edition . "</td></tr>";
|
|
|
516 |
}
|
|
|
517 |
|
|
|
518 |
if (!empty($item->ItemAttributes->AudienceRating)) {
|
|
|
519 |
$modal .= "<tr><td class=\"px-1\">Rating:</td><td class=\"px-1\">" . (string)$item->ItemAttributes->AudienceRating . "</td></tr>";
|
|
|
520 |
}
|
|
|
521 |
|
|
|
522 |
if (!empty($item->ItemAttributes->RegionCode)) {
|
|
|
523 |
$modal .= "<tr><td class=\"px-1\">Region Code:</td><td class=\"px-1\">" . (string)$item->ItemAttributes->RegionCode . "</td></tr>";
|
|
|
524 |
}
|
|
|
525 |
|
|
|
526 |
if (!empty($item->Tracks)) {
|
|
|
527 |
$modal .= "<tr><td colspan=\"2\" class=\"px-1\">Tracks:</td></tr>";
|
|
|
528 |
$modal .= "<tr><td colspan=\"2\">";
|
|
|
529 |
$modal .= "<ul class=\"pl-3 pt-0 small list-unstyled\">";
|
|
|
530 |
foreach ($item->Tracks->Disc as $disc) {
|
| 95 |
- |
531 |
if ((int)$item->ItemAttributes->NumberOfDiscs > 1 && !empty($disc->attributes())) {
|
| 81 |
- |
532 |
$modal .= "<li class=\"font-weight-bold\">Disc " . $disc->attributes() . ":</li>";
|
|
|
533 |
}
|
|
|
534 |
|
|
|
535 |
foreach($disc->Track as $track) {
|
| 95 |
- |
536 |
$modal .= "<li>" . (!empty($track->attributes()) ? $track->attributes() . ") " : "") . $track . "</li>";
|
| 81 |
- |
537 |
}
|
|
|
538 |
}
|
|
|
539 |
$modal .= "</ul>";
|
|
|
540 |
$modal .= "</td></tr>";
|
|
|
541 |
}
|
|
|
542 |
|
|
|
543 |
$modal .= "</table>";
|
|
|
544 |
$modal .= "</div>";
|
|
|
545 |
$modal .= "<div class=\"modal-footer bg-white justify-content-between\">";
|
|
|
546 |
$modal .= "<span class=\"float-right\"><button type=\"button\" class=\"btn btn-danger\" data-dismiss=\"modal\">Close</button></span>";
|
|
|
547 |
$modal .= "</div>";
|
|
|
548 |
$modal .= "</div>";
|
|
|
549 |
$modal .= "</div>";
|
|
|
550 |
$modal .= "</div>";
|
|
|
551 |
$str .= $modal;
|
|
|
552 |
$str .= "</div>";
|
|
|
553 |
|
|
|
554 |
return $str;
|
|
|
555 |
}
|
|
|
556 |
|
|
|
557 |
function getArtists($item) {
|
|
|
558 |
$artists = [];
|
|
|
559 |
|
|
|
560 |
if (!empty($item->ItemAttributes->Artist)) {
|
|
|
561 |
foreach($item->ItemAttributes->Artist as $artist) {
|
|
|
562 |
$artists[] = $artist;
|
|
|
563 |
}
|
|
|
564 |
}
|
|
|
565 |
|
|
|
566 |
return $artists;
|
|
|
567 |
}
|
|
|
568 |
|
|
|
569 |
function getCreators($item) {
|
|
|
570 |
$creators = [];
|
|
|
571 |
|
|
|
572 |
if (!empty($item->ItemAttributes->Creator)) {
|
|
|
573 |
foreach($item->ItemAttributes->Creator as $creator) {
|
|
|
574 |
if ((string)$creator->attributes() == "Primary Contributor") {
|
| 82 |
- |
575 |
$creators[] = $creator;
|
| 81 |
- |
576 |
} else {
|
|
|
577 |
$creators[] = $creator . " (" . $creator->attributes() . ")";
|
|
|
578 |
}
|
|
|
579 |
}
|
|
|
580 |
}
|
|
|
581 |
|
|
|
582 |
return $creators;
|
|
|
583 |
}
|