function do_artists_from_database($why, $what, $who) { global $divtype; $singleheader = array(); debuglog("Generating artist " . $who . " from database", "DUMPALBUMS", 7); $singleheader['type'] = 'insertAfter'; $singleheader['where'] = 'fothergill'; $count = 0; if ($result = generic_sql_query(albumartist_sort_query($why))) { while ($obj = $result->fetch(PDO::FETCH_OBJ)) { if ($who == "root") { print artistHeader($why . $what . $obj->Artistindex, $obj->Artistname); $count++; } else { if ($obj->Artistindex != $who) { $singleheader['type'] = 'insertAfter'; $singleheader['where'] = $why . $what . $obj->Artistindex; } else { $singleheader['html'] = artistHeader($why . $what . $obj->Artistindex, $obj->Artistname); return $singleheader; } } $divtype = $divtype == "album1" ? "album2" : "album1"; } } else { print '<h3>' . get_int_text("label_general_error") . '</h3>'; } return $count; }
function getWishlist() { global $mysqlc, $divtype, $prefs; if ($mysqlc === null) { connect_to_database(); } $qstring = 'SELECT wishlist.*, Ratingtable.Rating FROM (SELECT Tracktable.TTindex AS ttindex, Tracktable.Title AS track, Tracktable.TrackNo AS num, Tracktable.Duration AS time, Tracktable.Disc as disc, Artisttable.Artistname AS artist, Albumtable.Albumname AS album, Albumtable.Image AS image, Albumtable.ImgKey AS imgkey FROM Tracktable JOIN Artisttable USING (Artistindex) JOIN Albumtable ON Tracktable.Albumindex = Albumtable.Albumindex WHERE Uri IS NULL AND Hidden = 0 UNION SELECT Tracktable.TTindex AS ttindex, Tracktable.Title AS track, Tracktable.TrackNo AS num, Tracktable.Duration AS time, Tracktable.Disc as disc, Artisttable.Artistname AS artist, "" AS Albumname, NULL as Image, NULL AS ImgKey FROM Tracktable JOIN Artisttable USING (Artistindex) WHERE Albumindex IS NULL AND Uri IS NULL AND Hidden = 0) AS wishlist LEFT JOIN Ratingtable ON Ratingtable.TTindex = wishlist.ttindex ORDER BY '; foreach ($prefs['artistsatstart'] as $a) { $qstring .= "CASE WHEN LOWER(artist) = LOWER('" . $a . "') THEN 1 ELSE 2 END, "; } if (count($prefs['nosortprefixes']) > 0) { $qstring .= "(CASE "; foreach ($prefs['nosortprefixes'] as $p) { $phpisshitsometimes = strlen($p) + 2; $qstring .= "WHEN LOWER(artist) LIKE '" . strtolower($p) . " %' THEN LOWER(SUBSTR(artist," . $phpisshitsometimes . ")) "; } $qstring .= "ELSE LOWER(artist) END)"; } else { $qstring .= "LOWER(artist)"; } $qstring .= ', LOWER (album), num'; $current_artist = ""; $current_album = ""; $count = 0; if ($result = generic_sql_query($qstring)) { while ($obj = $result->fetch(PDO::FETCH_OBJ)) { $bothclosed = false; debuglog("Found Track " . $obj->track, "WISHLIST"); if ($current_artist != $obj->artist) { if ($current_artist != "") { print '</div></div>'; $bothclosed = true; } $current_artist = $obj->artist; print artistHeader("wishlistartist_" . $count, $obj->artist); print '<div id="wishlistartist_' . $count . '" class="dropmenu ' . $divtype . '">'; $count++; $divtype = $divtype == "album1" ? "album2" : "album1"; } if ($current_album != $obj->album) { if (!$bothclosed && $current_album != "") { print '</div>'; } $current_album = $obj->album; print albumHeader($obj->album, null, 'wishlistalbum_' . $count, $obj->image === null ? "no" : "yes", $obj->album == "" ? "yes" : "no", $obj->imgkey, $obj->image, null, null, null); print '<div id="wishlistalbum_' . $count . '" class="dropmenu">'; $count++; } albumTrack(null, $obj->Rating, null, 0, $obj->num, $obj->track, 0, null, null); } } }