/
playlists_view.php
92 lines (80 loc) · 2.76 KB
/
playlists_view.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
<?php
include 'includes/callAPI.php';
// Check if we have a filter parm
if (!empty($_GET["filt"])) {
$filt = $_GET["filt"];
$plfilt = $filt;
} else {
$filt = '';
$plfilt = 'Filter...';
}
// Check if we have an offset value passed for pagination
if (!empty($_GET["ofst"])) {
$offset = $_GET["ofst"];
} else {
$offset = 0;
}
//Set up some offset values for our next and prev buttons
if ($offset == 0) {
$poffset = 0;
} else {
$poffset = $offset - 25;
}
$noffset = $offset + 25;
$get_data = handshakeAPI();
$hshake = json_decode($get_data, true);
$auth=$hshake['auth'];
$get_data = playlistsAPI($auth, $filt, $offset);
$results = json_decode($get_data, true);
$total = count($results['playlist']);
include 'includes/header_iframe.php';
?>
<script>parent.activeMenu(6);</script> <!-- Call js function in parent to highlight the correct active menu item -->
<body>
<div class="ui inverted space segment">
<div class='ui grid'>
<div class="left floated four wide column">
<h1 class="ui smoke header">Playlists <i class="small stream icon"></i></h1>
</div>
<!-- Filter bar -->
<div class="middle aligned four wide column">
<form class="ui form" method="GET" action="playlists_view.php">
<div class="field">
<div class="ui small icon input">
<input name="filt" type="text" placeholder="<?php echo $plfilt;?>" value="<?php echo $filt;?>"><i class="filter icon"></i>
</div>
</div>
</form>
</div>
<div class="right floated right aligned four wide column">
<?php
if ($offset > 0) echo '<a class="icn" href="playlists_view.php?ofst=' . $poffset . '"><i class="arrow circle left icon"></i></a> ';
if ($total == 24) echo '<a class="icn" href="playlists_view.php?ofst=' . $noffset . '"><i class="arrow circle right icon"></i></a>';
?>
</div>
</div>
<?php
$cnt = 0; //Reset our counter to build grid of 24 entries
echo "<div class='ui six column grid container'>";
//Loop 4 rows
for ($i = 1; $i <=4; $i++){
echo "<div class='ui row'>";
//Loop 6 columns
for ($j = 1; $j <=6; $j++){
echo "<div class='ui column'>";
if ($cnt < $total) {
echo '<a class="icn" href="playlist_tracks.php?uid=' . $results['playlist'][$cnt]['id'] . '">';
echo '<h3 class="ui center aligned icon header"><i class="bordered stream icon"></i>';
echo $results['playlist'][$cnt]['name'] . '</h3></a>';
echo '<center>' . $results['playlist'][$cnt]['items'] . ' items in playlist</center>';
}
echo "</div>";
$cnt++; //Increment our counter
}
echo "</div>";
}
echo "</div>";
?>
</div>
</body>
</html>