Subversion Repositories cheapmusic

Rev

Rev 82 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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