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