This repository has been archived by the owner on Dec 4, 2018. It is now read-only.
/
index.php
executable file
·244 lines (233 loc) · 10.3 KB
/
index.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<?php
Output::set_title("Music Library");
echo("<script>
$(function () {
$('.track-info').popover({
'html': true,
'trigger': 'hover',
'title': function() {
return($(this).parent().parent().find('.title').html())
},
'content': function() {
return($(this).parent().find('.hover-info').html());
}
});
".(Session::is_group_user("Playlist Editor") ? "
var item;
$('.playlist-add').click(function() {
item = $(this).parent().parent();
playlists = $(this).attr('data-playlists-in').split(',');
$('.playlist-select').parent().removeClass('active');
$('.playlist-select').find('span').removeClass('glyphicon-minus').addClass('glyphicon-plus');
$('.playlist-select').each(function() {
if($.inArray($(this).attr('data-playlist-id'),playlists) > -1) {
$(this).find('span').removeClass('icon-plus').addClass('glyphicon-minus');
$(this).parent().addClass('active');
}
})
});
$('.playlist-select').click(function() {
obj = $(this);
if($(this).parent().hasClass('active')) {
$(this).find('span').removeClass('glyphicon-minus').addClass('glyphicon-refresh');
$.ajax({
url: '".LINK_ABS."ajax/track-playlist-update.php',
data: 'trackid='+item.attr('id')+'&playlistid='+obj.attr('data-playlist-id')+'&action=del',
type: 'POST',
error: function(xhr,text,error) {
value = $.parseJSON(xhr.responseText);
obj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-minus');
alert(value.error);
},
success: function(data,text,xhr) {
values = $.parseJSON(data);
obj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-plus');
obj.parent().removeClass('active');
item.find('.playlist-add').attr('data-playlists-in',values.playlists.join(','));
}
});
} else {
$(this).find('span').removeClass('glyphicon-plus').addClass('glyphicon-refresh');
$.ajax({
url: '".LINK_ABS."ajax/track-playlist-update.php',
data: 'trackid='+item.attr('id')+'&playlistid='+obj.attr('data-playlist-id')+'&action=add',
type: 'POST',
error: function(xhr,text,error) {
value = $.parseJSON(xhr.responseText);
obj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-plus');
alert(value.error);
},
success: function(data,text,xhr) {
values = $.parseJSON(data);
obj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-minus');
obj.parent().addClass('active');
item.find('.playlist-add').attr('data-playlists-in',values.playlists.join(','));
}
});
$(this).parent().addClass('active');
$(this).find('span').removeClass('glyphicon-plus').addClass('glyphicon-minus');
}
});
" : "").
(Session::is_group_user("Librarian") ? "
var trackid;
$('.track-delete').click(function() {
$('.delete-track-title').html($(this).parent().parent().find('.title').html());
trackid = $(this).attr('data-dps-id');
});
$('.yes-definitely-delete').click(function() {
$.ajax({
url: '".LINK_ABS."ajax/delete-track.php',
data: 'id='+trackid,
type: 'POST',
error: function(xhr,text,error) {
value = $.parseJSON(xhr.responseText);
alert(value.error);
},
success: function(data,text,xhr) {
window.location.reload(true);
}
});
});
" : "").
" });
</script>");
MainTemplate::set_subtitle("Add and remove tracks, edit track details");
if(($flagged = Tracks::get_flagged()) && Session::is_group_user("Censor")) echo(Bootstrap::alert_message_basic("warning","<a href=\"".LINK_ABS."music/censor\">Click here to view them.</a>", "Tracks have been flagged for censorship."));
echo("
<div class=\"row\">
<div class=\"col-sm-5\">
<h3>Library Statistics</h3>
<dl>
<dt>Tracks Stored</dt>
<dd>".number_format(Tracks::get_total_tracks())."</dd>
<dt>Length of Tracks</dt>
<dd>".Time::format_pretty(Tracks::get_total_length())."</dd>
<dt>Playlisted Tracks</dt>
<dd>".count(Tracks::get_playlisted())."</dd>
</dl>
</div>
<div class=\"col-sm-7\">
<h3>New Music</h3>
<p>
Have some music that you want added to Digiplay?<br>
Send an email to <a href='mailto:music@radio.warwick.ac.uk'>music@radio.warwick.ac.uk</a> with your music attached at least 48 hours before your show. <b>Make sure the music is high quality!</b><br>
Be sure to include the following in the email
<ul>
<li>Track Name</li>
<li>Artist Name</li>
<li>Album Name</li>
<li>Does the track contain explcit content?</li>
</ul>
</p>
</div>
");
// <div class=\"col-sm-7\">
// <h3>Requested Tracks</h3>
// ");
// if($requested = Requests::get_latest(3)) {
// echo("
// <table class=\"table table-striped table-condensed\" cellspacing=\"0\">
// <thead>
// <tr>
// <th class=\"icon\"></th>
// <th class=\"artist\">Artist</th>
// <th class=\"title\">Title</th>".(Session::is_group_user("Requests Admin")? "
// <th class=\"icon\"></th>" : "")."
// </tr>
// </thead>");
// foreach($requested as $request) {
// echo("
// <tr id=\"".$request->get_id()."\">
// <td class=\"icon\">
// <a href=\"#\" class=\"track-info\">
// ".Bootstrap::fontawesome("info-circle")."
// </a>
// <div class=\"hover-info\">
// <strong>Artist:</strong> ".$request->get_artist_name()."<br />
// <strong>Title:</strong> ".$request->get_name()."<br />
// <strong>Date Requested:</strong> ".date("d/m/Y H:i",$request->get_date())."<br />
// <strong>Requester:</strong> ".$request->get_user()->get_username()."<br />
// </div>
// </td>
// <td class=\"artist\">".$request->get_artist_name()."</td>
// <td class=\"title\">".$request->get_name()."</td>
// ".(Session::is_group_user("Requests Admin")? "<td class=\"icon\"><a href=\"".LINK_ABS."music/request/delete?id=".$request->get_id()."\" class=\"request-delete\" title=\"Delete this request\" rel=\"twipsy\">".Bootstrap::glyphicon("minus-sign")."</td>" : "")."
// </tr>");
// }
// echo("
// </table>");
// $total_requests = Requests::count();
// if($total_requests <= count($requested)) {
// echo("<a href=\"".LINK_ABS."music/request\">» Go to requests</a>");
// } else {
// echo("<a href=\"".LINK_ABS."music/request\">» See ".($total_requests - count($requested))." more requests</a>");
// }
// } else {
// echo("
// <strong>No new requested tracks.</strong><br />
// <a href=\"".LINK_ABS."music/request\">» Go to requests</a>");
// }
// echo("
// </div>
echo("</div>
<hr />
");
$tracks = Tracks::get_newest();
if($tracks) {
echo("<h3>10 newest tracks</h3>");
echo("<div class=\"table-responsive\"><table class=\"table table-striped\" cellspacing=\"0\">
<thead>
<tr>
<th class=\"icon\"> </th>
<th class=\"artist\">Artist</th>
<th class=\"title\">Title</th>
<th class=\"date-added nowrap\">Date Added</th>
<th class=\"length nowrap\">Length</th>
".(Session::is_group_user("Playlist Editor")? "<th class=\"icon\"></th>" : "")."
".(Session::is_group_user("Librarian")? "<th class=\"icon\"></th>" : "")."
</tr>
</thead>");
foreach($tracks as $track) {
$import_date = date("d/m/Y H:i",$track->get_import_date());
echo("
<tr id=\"".$track->get_id()."\">
<td class=\"icon\">
<a href=\"".LINK_ABS."music/detail/".$track->get_id()."\" class=\"track-info\">
".Bootstrap::fontawesome("info-circle")."
</a>
<div class=\"hover-info\">
<strong>Artist:</strong> ".$track->get_artists_str()."<br />
<strong>Album:</strong> ".$track->get_album()->get_name()."<br />
<strong>Year:</strong> ".$track->get_year()."<br />
<strong>Length:</strong> ".Time::format_succinct($track->get_length())."<br />
<strong>Origin:</strong> ".$track->get_origin()."<br />
".($track->get_reclibid()? "<strong>Reclib ID:</strong> ".$track->get_reclibid()."<br />" : "")."
<strong>Censored:</strong> ".($track->is_censored()? "Yes" : "No")."<br />
</div>
</td>
<td class=\"artist\">".$track->get_artists_str()."</td>
<td class=\"title\">".$track->get_title()."</td>
<td class=\"date-added nowrap\">".$import_date."</td>
<td class=\"length nowrap\">".Time::format_succinct($track->get_length())."</td>
");
if(Session::is_group_user("Playlist Editor")) {
$playlists = array();
foreach($track->get_playlists_in() as $playlist) $playlists[] = $playlist->get_id();
echo("<td class=\"icon\"><a href=\"#\" data-toggle=\"modal\" data-target=\"#playlist-modal\" data-backdrop=\"true\" data-keyboard=\"true\" data-dps-id=\"".$track->get_id()."\" data-playlists-in=\"".implode(",",$playlists)."\" class=\"playlist-add\" title=\"Add to playlist\" rel=\"twipsy\">".Bootstrap::fontawesome("plus-circle")."</i></a></td>");
}
echo((Session::is_group_user("Librarian")? "<td class=\"icon\"><a href=\"#\" data-toggle=\"modal\" data-target=\"#delete-modal\" data-dps-id=\"".$track->get_id()."\" class=\"track-delete\" title=\"Delete this track\" rel=\"twipsy\">".Bootstrap::fontawesome("times-circle")."</i></a></td>" : "")."
</tr>");
}
echo("</table></div>");
} else {
echo("Sorry, no results");
}
if(Session::is_group_user("Playlist Editor")) {
$playlist_modal_content = "<p>Select a playlist to add/remove <span class=\"playlist-track-title\">this track</span> to/from:</p><ul class=\"nav nav-pills nav-stacked\">";
foreach(Playlists::get_all() as $playlist) $playlist_modal_content .= "<li><a href=\"#\" class=\"playlist-select\" data-playlist-id=\"".$playlist->get_id()."\">".Bootstrap::fontawesome("plus-circle").$playlist->get_name()."</a></li>";
$playlist_modal_content .= "</ul>";
echo(Bootstrap::modal("playlist-modal", $playlist_modal_content, "Add to playlist", "<a href=\"#\" class=\"btn btn-primary\" data-dismiss=\"modal\">Done</a> <a href=\"".LINK_ABS."playlists\" class=\"btn btn-default\">Manage playlists</a>"));
}
if(Session::is_group_user("Librarian")) echo(Bootstrap::modal("delete-modal", "<p>Are you sure you want to move <span class=\"delete-track-title\">this track</span> to the trash?</p>", "Delete track", "<a href=\"#\" class=\"btn btn-primary yes-definitely-delete\">Yes</a> <a href=\"#\" class=\"btn btn-default\" data-dismiss=\"modal\">No</a>"));
?>