| 10 |
- |
1 |
<?php
|
| 20 |
- |
2 |
error_reporting(E_ALL);
|
| 10 |
- |
3 |
|
|
|
4 |
// BUGBUG {"message": "You are making requests too quickly."}
|
|
|
5 |
function findDiscogsMaster($str) {
|
|
|
6 |
$vendors = Vendors::getInstance();
|
|
|
7 |
$config = $vendors->getVendor(Vendors::DISCOGS);
|
| 45 |
- |
8 |
$maxMasterCount = $config['maxMasters'];
|
| 13 |
- |
9 |
|
| 10 |
- |
10 |
$_SESSION["discogs"] = "";
|
|
|
11 |
|
|
|
12 |
$url = "https://api.discogs.com/database/search?";
|
|
|
13 |
$url .= "token=";
|
|
|
14 |
$url .= $config['token'];
|
|
|
15 |
if (empty($_SESSION["barcode"]['Type'])) {
|
| 46 |
- |
16 |
$url .= "&type=All";
|
|
|
17 |
|
|
|
18 |
if (!empty($_SESSION["discogsTitle"]) || !empty($_SESSION["discogsArtist"])) {
|
|
|
19 |
if (!empty($_SESSION["discogsTitle"])) {
|
|
|
20 |
$url .= "&release_title=" . $_SESSION["discogsTitle"];
|
|
|
21 |
}
|
| 57 |
- |
22 |
|
| 46 |
- |
23 |
if (!empty($_SESSION["discogsArtist"])) {
|
|
|
24 |
$url .= "&artist=" . $_SESSION["discogsArtist"];
|
|
|
25 |
}
|
| 65 |
- |
26 |
}
|
|
|
27 |
else {
|
| 58 |
- |
28 |
$url .= "&query=";
|
| 46 |
- |
29 |
$url .= ($str == "***RANDOM***" ? mt_rand($config['minRelease'], $config['maxRelease']) : urlencode($str));
|
|
|
30 |
}
|
| 65 |
- |
31 |
}
|
|
|
32 |
else {
|
| 10 |
- |
33 |
$url .= "&barcode=";
|
|
|
34 |
$url .= $_SESSION["barcode"]['Value'];
|
|
|
35 |
}
|
|
|
36 |
|
| 65 |
- |
37 |
$searchResp = getUrl($url, $config['userAgent']);
|
|
|
38 |
$searchResp = utf8_encode($searchResp);
|
|
|
39 |
$searchResp = json_decode($searchResp);
|
| 10 |
- |
40 |
|
| 13 |
- |
41 |
$_SESSION["discogs"] = "";
|
| 10 |
- |
42 |
|
| 43 |
- |
43 |
if (empty($searchResp)) {
|
|
|
44 |
return;
|
|
|
45 |
}
|
|
|
46 |
|
| 10 |
- |
47 |
if (!empty($searchResp->{'message'})) {
|
|
|
48 |
if ($searchResp->{'message'} == "You are making requests too quickly.") {
|
| 65 |
- |
49 |
// bugbug
|
| 10 |
- |
50 |
return;
|
|
|
51 |
}
|
| 14 |
- |
52 |
return;
|
| 10 |
- |
53 |
}
|
|
|
54 |
|
|
|
55 |
if ($searchResp->{'pagination'}->{'items'} < 1) {
|
| 38 |
- |
56 |
if ($str == "***RANDOM***") { // must find something
|
| 45 |
- |
57 |
findDiscogsMaster("***RANDOM***", !empty($_SESSION['sessData']['userLoggedIn']));
|
| 38 |
- |
58 |
}
|
|
|
59 |
|
| 10 |
- |
60 |
return;
|
|
|
61 |
}
|
|
|
62 |
|
| 64 |
- |
63 |
$_SESSION["discogs"] .= "<div class=\"container-fluid bg-secondary\">";
|
| 57 |
- |
64 |
$_SESSION["discogs"] .= "<h4 class=\"text-center py-2\">" . ($str == "***RANDOM***" ? "Random " : "Matching ") . "Albums</h4>";
|
| 60 |
- |
65 |
$_SESSION["discogs"] .= "<form method=\"post\" action=\"/index.php\">";
|
| 64 |
- |
66 |
$_SESSION["discogs"] .= "<input type=\"hidden\" name=\"sessionTab\" value=\"" . MySessionHandler::getSessionTab() . "\">";
|
|
|
67 |
$_SESSION["discogs"] .= "<input id=\"discogsTitle\" type=\"hidden\" name=\"discogsTitle\" value=\"\">";
|
|
|
68 |
$_SESSION["discogs"] .= "<input id=\"discogsArtist\" type=\"hidden\" name=\"discogsArtist\" value=\"\">";
|
|
|
69 |
$_SESSION["discogs"] .= "<input id=\"discogsBarcode\" type=\"hidden\" name=\"discogsBarcode\" value=\"\">";
|
| 43 |
- |
70 |
$_SESSION["discogs"] .= "<div id=\"discogsDeck\" class=\"card-deck\">";
|
| 13 |
- |
71 |
|
| 10 |
- |
72 |
$masterCount = 0;
|
|
|
73 |
$processedMasters = [];
|
| 38 |
- |
74 |
|
| 10 |
- |
75 |
foreach ($searchResp->{'results'} as $searchey => $searchValue) {
|
| 65 |
- |
76 |
if (!in_array($searchValue->{'type'}, array(
|
|
|
77 |
"master",
|
|
|
78 |
"release"
|
|
|
79 |
)) && empty($_SESSION["barcode"]['Type'])) {
|
| 10 |
- |
80 |
continue;
|
|
|
81 |
}
|
|
|
82 |
|
| 50 |
- |
83 |
if (empty($_SESSION["barcode"]['Type']) && $searchValue->{'type'} == "release" && $searchValue->{'master_id'} > 0) {
|
| 10 |
- |
84 |
continue;
|
|
|
85 |
}
|
| 57 |
- |
86 |
|
| 47 |
- |
87 |
if ($searchValue->{'master_id'} > 0 && in_array($searchValue->{'master_id'}, $processedMasters)) {
|
|
|
88 |
continue;
|
|
|
89 |
}
|
| 10 |
- |
90 |
$processedMasters[] = $searchValue->{'master_id'};
|
|
|
91 |
|
| 50 |
- |
92 |
if (++$masterCount > $maxMasterCount) {
|
|
|
93 |
break;
|
|
|
94 |
}
|
|
|
95 |
|
| 65 |
- |
96 |
$masterResp = getUrl($searchValue->{'master_id'} != 0 ? $searchValue->{'master_url'} : $searchValue->{'resource_url'}, $config['userAgent']);
|
|
|
97 |
$masterResp = utf8_encode($masterResp);
|
|
|
98 |
$masterResp = json_decode($masterResp);
|
| 10 |
- |
99 |
|
| 45 |
- |
100 |
if (!empty($masterResp->{'message'})) {
|
|
|
101 |
if ($masterResp->{'message'} == "You are making requests too quickly.") {
|
| 65 |
- |
102 |
// bugbug
|
| 10 |
- |
103 |
return;
|
|
|
104 |
}
|
| 17 |
- |
105 |
|
| 14 |
- |
106 |
return;
|
| 10 |
- |
107 |
}
|
|
|
108 |
|
| 43 |
- |
109 |
if (!empty($masterResp)) {
|
| 46 |
- |
110 |
$_SESSION["discogs"] .= processMaster($masterResp, $searchValue->{'type'}, $searchValue->{'thumb'}, $searchValue->{'cover_image'}, $masterCount);
|
| 17 |
- |
111 |
}
|
| 10 |
- |
112 |
}
|
|
|
113 |
|
|
|
114 |
$_SESSION["discogs"] .= "</div>";
|
| 60 |
- |
115 |
$_SESSION["discogs"] .= "</form>";
|
| 13 |
- |
116 |
$_SESSION["discogs"] .= "</div>";
|
| 38 |
- |
117 |
if ($str == "***RANDOM***") {
|
| 64 |
- |
118 |
$_SESSION["discogs"] .= '<div class="container-fluid text-center bg-secondary">';
|
| 38 |
- |
119 |
$_SESSION["discogs"] .= ' <form method="post" action="/index.php">';
|
|
|
120 |
$_SESSION["discogs"] .= ' <input type="hidden" name="sessionTab" value="' . MySessionHandler::getSessionTab() . '">';
|
|
|
121 |
$_SESSION["discogs"] .= ' <input type="hidden" name="searchTerm" value="' . getSV("searchTerm") . '">';
|
|
|
122 |
$_SESSION["discogs"] .= ' <input type="hidden" name="buyerZip" value="' . $_SESSION["buyer"]["Zip"] . '">';
|
| 43 |
- |
123 |
$_SESSION["discogs"] .= ' <button id="randomBtn" type="submit" class="btn btn-success m-2 rounded" name="submit" value="random">More Random Album Suggestions</button>';
|
| 38 |
- |
124 |
$_SESSION["discogs"] .= ' </form>';
|
|
|
125 |
$_SESSION["discogs"] .= '</div>';
|
|
|
126 |
}
|
| 10 |
- |
127 |
|
|
|
128 |
return;
|
|
|
129 |
}
|
|
|
130 |
|
| 46 |
- |
131 |
function processMaster($master, $type, $thumbnail, $coverImage, $cnt) {
|
| 10 |
- |
132 |
$artists = [];
|
|
|
133 |
foreach ($master->{'artists'} as $key => $value) {
|
| 20 |
- |
134 |
$artists[] = trim(preg_replace('/\([0-9]+\)$/', "", (string)$value->{'name'}));
|
| 10 |
- |
135 |
}
|
|
|
136 |
|
|
|
137 |
$genres = [];
|
|
|
138 |
foreach ($master->{'genres'} as $key => $value) {
|
| 65 |
- |
139 |
$genres[] = (string)$value;
|
| 10 |
- |
140 |
}
|
|
|
141 |
|
| 20 |
- |
142 |
$labels = [];
|
|
|
143 |
if (isset($master->{'labels'})) {
|
|
|
144 |
foreach ($master->{'labels'} as $key => $value) {
|
|
|
145 |
$labels[] = trim(preg_replace('/\([0-9]+\)$/', "", (string)$value->{'name'}));
|
|
|
146 |
}
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
$formats = [];
|
|
|
150 |
if (isset($master->{'formats'})) {
|
|
|
151 |
foreach ($master->{'formats'} as $key => $value) {
|
|
|
152 |
$formats[] = trim(preg_replace('/\([0-9]+\)$/', "", (string)$value->{'name'}));
|
|
|
153 |
}
|
|
|
154 |
}
|
| 38 |
- |
155 |
|
| 20 |
- |
156 |
$country = '';
|
|
|
157 |
if (isset($master->{'country'})) {
|
|
|
158 |
$country = (string)$master->{'country'};
|
|
|
159 |
}
|
|
|
160 |
|
| 62 |
- |
161 |
$modal = "";
|
| 61 |
- |
162 |
$str = "<div class=\"card mx-auto discogs-card\">";
|
| 64 |
- |
163 |
$str .= "<div class=\"card-header bg-info d-flex h-100\">";
|
| 65 |
- |
164 |
$str .= "<p class=\"card-title font-weight-bold small flex-grow-1\">" . (string)$master->{'title'} . " by ";
|
| 17 |
- |
165 |
$searchArtists = "";
|
| 20 |
- |
166 |
if (count($artists) < 5) {
|
| 47 |
- |
167 |
$wlArtists = join(", ", $artists);
|
| 65 |
- |
168 |
if ($artists[0] != 'Various') {
|
|
|
169 |
$searchArtists = join(" ", $artists);
|
|
|
170 |
}
|
|
|
171 |
}
|
|
|
172 |
else {
|
| 47 |
- |
173 |
$wlArtists = "Various Artists";
|
| 14 |
- |
174 |
}
|
| 47 |
- |
175 |
$str .= $wlArtists;
|
| 61 |
- |
176 |
$str .= "</p>";
|
| 14 |
- |
177 |
$str .= "</div>";
|
|
|
178 |
if (empty($thumbnail)) {
|
|
|
179 |
$thumbnail = "images/no-image-available.jpg";
|
|
|
180 |
}
|
| 64 |
- |
181 |
$str .= "<div class=\"card-body bg-light mx-auto p-0 m-0\">";
|
| 62 |
- |
182 |
$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=\"Discogs Cover Thumbnail\">";
|
| 43 |
- |
183 |
$str .= "</div>";
|
| 64 |
- |
184 |
$str .= "<div class=\"card-footer bg-dark p-0 m-0\">";
|
| 61 |
- |
185 |
$str .= "<div class=\"container clearfix p-0 m-0\">";
|
| 60 |
- |
186 |
$str .= "<span class=\"float-left\">";
|
| 65 |
- |
187 |
$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>";
|
| 45 |
- |
188 |
|
|
|
189 |
if (isset($master->{'videos'})) {
|
| 65 |
- |
190 |
$str .= "<button type=\"button\" class=\"btn btn-primary m-1 btn-sm\" data-toggle=\"modal\" data-target=\"#videoModal" . $cnt . "\" title=\"Videos\" data-toggle2=\"tooltip\"><i class=\"fas fa-video\"></i></button>";
|
| 61 |
- |
191 |
//$str .= "<i role=\"button\" class=\"fab fa-youtube fa-2x btn-youtube btn m-1 btn-sm\" data-toggle=\"modal\" data-target=\"#videoModal" . $cnt . "\" title=\"Videos\" data-toggle2=\"tooltip\"></i>";
|
| 62 |
- |
192 |
$modal .= "<div id=\"videoModal" . $cnt . "\" class=\"modal\">";
|
|
|
193 |
$modal .= "<div class=\"modal-dialog\">";
|
|
|
194 |
$modal .= "<div class=\"modal-content\">";
|
|
|
195 |
$modal .= "<div class=\"modal-header bg-primary\">";
|
| 65 |
- |
196 |
$modal .= "<h4 class=\"modal-title mx-auto\">" . (string)$master->{'title'} . " by ";
|
| 57 |
- |
197 |
if (count($artists) < 5) {
|
| 62 |
- |
198 |
$modal .= join(", ", $artists);
|
| 65 |
- |
199 |
}
|
|
|
200 |
else {
|
| 62 |
- |
201 |
$modal .= "Various Artists";
|
| 57 |
- |
202 |
}
|
| 62 |
- |
203 |
$modal .= "</h4>";
|
|
|
204 |
$modal .= "<button type=\"button\" class=\"close\" data-dismiss=\"modal\"><i class=\"fas fa-window-close btn-dismiss\"></i></button>";
|
|
|
205 |
$modal .= "</div>";
|
| 57 |
- |
206 |
|
| 68 |
- |
207 |
$modal .= "<div class=\"modal-body bg-white mx-auto\">";
|
|
|
208 |
$modal .= "<h4><i class=\"fab fa-youtube youtube\"></i> Videos</h4>";
|
|
|
209 |
$modal .= "<ul class=\"list-group\">";
|
| 57 |
- |
210 |
|
| 45 |
- |
211 |
foreach ($master->{'videos'} as $video) {
|
| 68 |
- |
212 |
$modal .= "<li class=\"list-group-item\"><a href=\"" . $video->uri . "\" target=\"_blank\" class=\"btn btn-info text-left\" role=\"button\">" . $video->title . " [" . gmdate('H:i:s', $video->duration) . "]</a></li>";
|
| 57 |
- |
213 |
// bugbug too many videos don't run embedded
|
|
|
214 |
// $videoParam = basename($video->uri);
|
|
|
215 |
// $videoIdx = strpos($videoParam, "=") + 1;
|
| 56 |
- |
216 |
// $str .= "<iframe width=\"280\" height=\"158\" src=\"https://www.youtube-nocookie.com/embed/" . substr($videoParam, $videoIdx) . "?rel=0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>";
|
| 65 |
- |
217 |
|
| 45 |
- |
218 |
}
|
| 57 |
- |
219 |
|
| 62 |
- |
220 |
$modal .= "</ul>";
|
|
|
221 |
$modal .= "</div>";
|
|
|
222 |
$modal .= "<div class=\"modal-footer bg-white justify-content-between\">";
|
|
|
223 |
$modal .= "<span class=\"font-weight-lighter small\">Data provided by <a href=\"" . (string)$master->{'uri'} . "\" target=\"_blank\">Discogs</a></span>";
|
|
|
224 |
$modal .= "<span class=\"float-right\"><button type=\"button\" class=\"btn btn-danger\" data-dismiss=\"modal\">Close</button></span>";
|
|
|
225 |
$modal .= "</div>";
|
|
|
226 |
$modal .= "</div>";
|
|
|
227 |
$modal .= "</div>";
|
|
|
228 |
$modal .= "</div>";
|
| 45 |
- |
229 |
}
|
|
|
230 |
|
| 62 |
- |
231 |
$str .= "</span>";
|
|
|
232 |
|
| 59 |
- |
233 |
$str .= "<span class=\"float-right\">";
|
| 45 |
- |
234 |
|
| 50 |
- |
235 |
$barcode = "";
|
|
|
236 |
if (empty($_SESSION["barcode"]['Type']) && !empty($master->{'identifiers'})) {
|
|
|
237 |
foreach ($master->{'identifiers'} as $identifier) {
|
|
|
238 |
if ($identifier->{'type'} == 'Barcode') {
|
|
|
239 |
$tmpBarcode = preg_replace("/[^0-9]/", "", $identifier->{'value'});
|
|
|
240 |
$barcodeType = clsLibGTIN::GTINCheck($tmpBarcode, false, 1);
|
|
|
241 |
if (!empty($barcodeType)) {
|
| 65 |
- |
242 |
$barcode = $tmpBarcode;
|
| 50 |
- |
243 |
}
|
|
|
244 |
}
|
|
|
245 |
}
|
| 65 |
- |
246 |
}
|
|
|
247 |
else if (!empty($_SESSION["barcode"]['Type'])) {
|
| 50 |
- |
248 |
$barcode = $_SESSION["barcode"]['Value'];
|
|
|
249 |
}
|
|
|
250 |
|
| 46 |
- |
251 |
if (isLoggedIn() && !checkWishlist($type, $master->{'id'})) {
|
| 65 |
- |
252 |
$wlArr = array(
|
|
|
253 |
($type == "master" ? 'mid' : 'rid') => $master->{'id'},
|
|
|
254 |
'title' => (string)$master->{'title'},
|
|
|
255 |
'artist' => $wlArtists,
|
|
|
256 |
'barcode' => $barcode,
|
|
|
257 |
'thumbnail' => $thumbnail,
|
|
|
258 |
'url' => (string)$master->{'uri'}
|
|
|
259 |
);
|
| 46 |
- |
260 |
$wl = base64_encode(json_encode($wlArr));
|
| 65 |
- |
261 |
$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>";
|
| 45 |
- |
262 |
}
|
|
|
263 |
|
| 52 |
- |
264 |
$searchTitle = 'Searching for:<br><br><strong>' . (string)$master->{'title'} . ' by ' . (empty($searchArtists) ? 'Various Artists' : $searchArtists) . '</strong>';
|
| 50 |
- |
265 |
if (!empty($barcode)) {
|
|
|
266 |
$searchTitle .= " (" . displayBarcode($barcode) . ")";
|
|
|
267 |
}
|
|
|
268 |
|
| 65 |
- |
269 |
$str .= " <button type=\"submit\" name=\"submit\" value=\"discogsSearch\" class=\"btn btn-primary m-1 btn-sm\" onclick=\"document.getElementById('discogsTitle').value = '" . addslashes((string)$master->{'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>";
|
| 60 |
- |
270 |
$str .= "</span>";
|
|
|
271 |
$str .= "</div>";
|
| 52 |
- |
272 |
$str .= "<span id=\"wishlistAdd" . $cnt . "\"></span>";
|
| 14 |
- |
273 |
$str .= "</div>";
|
|
|
274 |
|
| 62 |
- |
275 |
$modal .= "<div id=\"masterModal" . $cnt . "\" class=\"modal\">";
|
|
|
276 |
$modal .= "<div class=\"modal-dialog\">";
|
|
|
277 |
$modal .= "<div class=\"modal-content\">";
|
|
|
278 |
$modal .= "<div class=\"modal-header bg-primary\">";
|
| 65 |
- |
279 |
$modal .= "<h4 class=\"modal-title mx-auto\">" . (string)$master->{'title'} . " by ";
|
| 20 |
- |
280 |
if (count($artists) < 5) {
|
| 62 |
- |
281 |
$modal .= join(", ", $artists);
|
| 65 |
- |
282 |
}
|
|
|
283 |
else {
|
| 62 |
- |
284 |
$modal .= "Various Artists";
|
| 14 |
- |
285 |
}
|
| 62 |
- |
286 |
$modal .= "</h4>";
|
|
|
287 |
$modal .= "<button type=\"button\" class=\"close\" data-dismiss=\"modal\"><i class=\"fas fa-window-close btn-dismiss\"></i></button>";
|
|
|
288 |
$modal .= "</div>";
|
| 14 |
- |
289 |
|
| 62 |
- |
290 |
$modal .= "<div class=\"modal-body bg-white mx-auto\">";
|
| 14 |
- |
291 |
|
| 43 |
- |
292 |
if (!empty($coverImage)) {
|
| 62 |
- |
293 |
$modal .= "<img class=\"responsive-image mx-auto mb-4\" src=\"" . $coverImage . "\" alt=\"Discogs Cover\">";
|
| 43 |
- |
294 |
}
|
|
|
295 |
|
| 62 |
- |
296 |
$modal .= "<table class=\"table-borderless table-condensed small mx-auto\">";
|
|
|
297 |
$modal .= "<tr><td class=\"px-1\">Title:</td><td class=\"px-1\">" . (string)$master->{'title'} . "</td></tr>";
|
| 14 |
- |
298 |
|
| 62 |
- |
299 |
$modal .= "<tr><td class=\"px-1\">Artist:</td><td class=\"px-1\">" . join(", ", $artists) . "</td></tr>";
|
| 14 |
- |
300 |
|
| 50 |
- |
301 |
if (!empty($barcode)) {
|
| 62 |
- |
302 |
$modal .= "<tr><td class=\"px-1\">Barcode:</td><td class=\"px-1\">" . displayBarcode($barcode) . "</td></tr>";
|
| 50 |
- |
303 |
}
|
|
|
304 |
|
| 20 |
- |
305 |
if (!empty($labels)) {
|
| 62 |
- |
306 |
$modal .= "<tr><td class=\"px-1\">Label:</td><td class=\"px-1\">" . $labels[0] . "</td></tr>";
|
| 20 |
- |
307 |
}
|
|
|
308 |
|
|
|
309 |
if (!empty($formats)) {
|
| 62 |
- |
310 |
$modal .= "<tr><td class=\"px-1\">Format:</td><td class=\"px-1\">" . join(", ", $formats) . "</td></tr>";
|
| 20 |
- |
311 |
}
|
|
|
312 |
|
|
|
313 |
if (!empty($country)) {
|
| 62 |
- |
314 |
$modal .= "<tr><td class=\"px-1\">Country:</td><td class=\"px-1\">" . $country . "</td></tr>";
|
| 20 |
- |
315 |
}
|
|
|
316 |
|
| 14 |
- |
317 |
if ($master->{'year'} > 0) {
|
| 62 |
- |
318 |
$modal .= "<tr><td class=\"px-1\">Year:</td><td class=\"px-1\">" . (string)$master->{'year'} . "</td></tr>";
|
| 14 |
- |
319 |
}
|
|
|
320 |
|
| 62 |
- |
321 |
$modal .= "<tr><td class=\"px-1\">Genre:</td><td class=\"px-1\">" . join(", ", $genres) . "</td></tr>";
|
| 14 |
- |
322 |
|
| 10 |
- |
323 |
if (isset($master->{'styles'})) {
|
|
|
324 |
$styles = [];
|
|
|
325 |
foreach ($master->{'styles'} as $key => $value) {
|
|
|
326 |
$styles[] = $value;
|
|
|
327 |
}
|
| 62 |
- |
328 |
$modal .= "<tr><td class=\"px-1\">Style:</td><td class=\"px-1\">" . join(", ", $styles) . "</td></tr>";
|
| 10 |
- |
329 |
}
|
| 14 |
- |
330 |
|
|
|
331 |
if (is_array($master->{'tracklist'})) {
|
| 62 |
- |
332 |
$modal .= "<tr><td colspan=\"2\" class=\"px-1\">Tracks:</td></tr>";
|
|
|
333 |
$modal .= "<tr><td colspan=\"2\">";
|
|
|
334 |
$modal .= "<ul class=\"pl-3 pt-0 small list-unstyled\">";
|
| 14 |
- |
335 |
foreach ($master->{'tracklist'} as $key => $value) {
|
| 20 |
- |
336 |
if ((string)$value->{'type_'} == "heading") {
|
| 62 |
- |
337 |
$modal .= "<li class=\"font-weight-bold\">" . (string)$value->{'title'} . "</li>";
|
| 65 |
- |
338 |
}
|
|
|
339 |
else if ((string)$value->{'type_'} == "index") {
|
| 62 |
- |
340 |
$modal .= "<li><span class=\"font-italic\">" . (string)$value->{'title'} . "</span>";
|
| 14 |
- |
341 |
foreach ($value->{'sub_tracks'} as $subkey => $subvalue) {
|
| 62 |
- |
342 |
$modal .= "<ul class=\"pl-3 pt-0 list-unstyled\">";
|
|
|
343 |
$modal .= processTrack($subvalue, false);
|
|
|
344 |
$modal .= "</ul>";
|
| 17 |
- |
345 |
}
|
| 62 |
- |
346 |
$modal .= "</li>";
|
| 65 |
- |
347 |
}
|
|
|
348 |
else if ((string)$value->{'type_'} == "track") {
|
| 62 |
- |
349 |
$modal .= processTrack($value, true);
|
| 14 |
- |
350 |
}
|
|
|
351 |
}
|
| 62 |
- |
352 |
$modal .= "</ul>";
|
|
|
353 |
$modal .= "</td></tr>";
|
| 17 |
- |
354 |
}
|
| 14 |
- |
355 |
|
| 62 |
- |
356 |
$modal .= "</table>";
|
|
|
357 |
$modal .= "</div>";
|
|
|
358 |
$modal .= "<div class=\"modal-footer bg-white justify-content-between\">";
|
|
|
359 |
$modal .= "<span class=\"font-weight-lighter small\">Data provided by <a href=\"" . (string)$master->{'uri'} . "\" target=\"_blank\">Discogs</a></span>";
|
|
|
360 |
$modal .= "<span class=\"float-right\"><button type=\"button\" class=\"btn btn-danger\" data-dismiss=\"modal\">Close</button></span>";
|
|
|
361 |
$modal .= "</div>";
|
|
|
362 |
$modal .= "</div>";
|
|
|
363 |
$modal .= "</div>";
|
|
|
364 |
$modal .= "</div>";
|
|
|
365 |
$str .= $modal;
|
| 64 |
- |
366 |
$str .= "</div>";
|
| 10 |
- |
367 |
|
| 14 |
- |
368 |
return $str;
|
|
|
369 |
}
|
| 10 |
- |
370 |
|
| 14 |
- |
371 |
function processTrack($value, $posFlag) {
|
|
|
372 |
$str = "<li>";
|
|
|
373 |
if ($posFlag && !empty($value->{'position'})) {
|
| 20 |
- |
374 |
if (!preg_match("/^[a-zA-Z][0-9]/", (string)$value->{'position'}) && !preg_match("/^[a-zA-Z]$/", (string)$value->{'position'})) {
|
|
|
375 |
$str .= (string)$value->{'position'} . '. ';
|
| 10 |
- |
376 |
}
|
| 14 |
- |
377 |
}
|
| 17 |
- |
378 |
|
| 20 |
- |
379 |
$str .= (string)$value->{'title'};
|
| 10 |
- |
380 |
|
| 14 |
- |
381 |
$trackArtists = [];
|
|
|
382 |
if (isset($value->{'artists'})) {
|
|
|
383 |
foreach ($value->{'artists'} as $taKey => $taValue) {
|
| 20 |
- |
384 |
$trackArtists[] = trim(preg_replace('/\([0-9]+\)$/', "", (string)$taValue->{'name'}));
|
| 10 |
- |
385 |
}
|
| 14 |
- |
386 |
if (count($trackArtists)) {
|
|
|
387 |
$str .= " - " . join(", ", $trackArtists);
|
|
|
388 |
}
|
|
|
389 |
}
|
| 10 |
- |
390 |
|
| 14 |
- |
391 |
if (!empty($value->{'duration'})) {
|
| 20 |
- |
392 |
$str .= " [" . (string)$value->{'duration'} . "]";
|
| 10 |
- |
393 |
}
|
| 13 |
- |
394 |
|
| 14 |
- |
395 |
$str .= "</li>";
|
|
|
396 |
|
| 17 |
- |
397 |
return $str;
|
| 14 |
- |
398 |
}
|