-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrack.php
117 lines (94 loc) · 3.92 KB
/
track.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html>
<head>
<?php include 'header.php' ?>
<?php
// set debugging
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include_once 'backend/artistgraph.php';
$id = $_GET["id"];
$graph = init_graph();
$track = $graph->get_track($id);
if ($track != null)
{
echo "<title>$track->name</title>";
}
?>
</head>
<body>
<?php include 'searchbar.php' ?>
<div class="main">
<div class="artist-section">
<div class="artist-profile">
<div class="song-info">
<?php
if($track != null)
{
$album = $graph->get_album_from_track($track->id);
if ($album != null)
{
// $id = $_GET['id'];
// at this point the track will already be in the db so no need to worry lol
// $track = $graph->get_track($id);
// print_r($album)
if (0 < count($album->images))
{
$image_url = $album->images[1]['url'];
echo <<<EOL
<div class="artist_img">
<img class="artist-profile-img" src="$image_url">
</div>
EOL;
}
// print_r($track);
/* display information about the song as well as a preview link */
}
echo <<<EOL
<div class="artist-info">
<h2 class="black-text">$track->name</h2>
EOL;
echo '<div class="song-artists"><i>';
$i = 0;
foreach($track->artists as $artist)
{
echo "$artist->name";
$i++;
if ($i < count($track->artists))
{
echo ", ";
}
}
echo "</i></div>";
}
?>
</div>
</div>
</div>
<!-- reuse css classes here cause the functionality is the same -->
<div class="artist-profile_songs">
<h3><?php echo "Artists That Appear on '$track->name':"; ?></h3>
<div class="artist-profile_related">
<?php
foreach($track->artists as $artist)
{
echo <<<EOL
<div class="appears-artist">
<a href="/artist.php?id=$artist->id">
<h4>$artist->name</h4>
EOL;
if (0 < count($artist->images))
{
// get biggest image
$url = $artist->images[count($artist->images)-1]['url'];
echo "<img class='related-artist-img' src='$url'>";
}
echo "</a></div>";
}
?>
</div>
</div>
</div>
</body>
</html>