Example #1
0
function sidebar()
{
    foreach (Playlists::get_all(false) as $playlist) {
        foreach ($playlist->get_tracks() as $track) {
            $tracks++;
            $total_length += $track->get_length();
        }
    }
    $return .= "\r\n\t<h4>Sustainer Service</h4>\r\n\t<dl>\r\n\t\t<dt>Tracks on Sustainer</dt>\r\n\t\t<dd>" . Sustainer::get_total_tracks() . "</dd>\r\n\t\t<dt>Length of Sustainer Playlist</dt>\r\n\t\t<dd>" . Sustainer::get_total_length_formatted() . "</dd>\r\n\t</dl>";
    return $return;
}
Example #2
0
        $track = Tracks::get($track_id);
        echo "\r\n\t\t<tr id=\"" . $track->get_id() . "\">\r\n\t\t\t<td class=\"icon\">\r\n\t\t\t\t<a href=\"" . LINK_ABS . "music/detail/" . $track->get_id() . "\" class=\"track-info\">\r\n\t\t\t\t\t" . Bootstrap::glyphicon("info-sign") . "\r\n\t\t\t\t</a>\r\n\t\t\t\t<div class=\"hover-info\">\r\n\t\t\t\t\t<strong>Artist:</strong> " . $track->get_artists_str() . "<br />\r\n\t\t\t\t\t<strong>Album:</strong> " . $track->get_album()->get_name() . "<br />\r\n\t\t\t\t\t<strong>Year:</strong> " . $track->get_year() . "<br />\r\n\t\t\t\t\t<strong>Length:</strong> " . Time::format_succinct($track->get_length()) . "<br />\r\n\t\t\t\t\t<strong>Origin:</strong> " . $track->get_origin() . "<br />\r\n\t\t\t\t\t" . ($track->get_reclibid() ? "<strong>Reclib ID:</strong> " . $track->get_reclibid() . "<br />" : "") . "\r\n\t\t\t\t\t<strong>Censored:</strong> " . ($track->is_censored() ? "Yes" : "No") . "<br /> \r\n\t\t\t\t</div>\r\n\t\t\t</td>\r\n\t\t\t<td class=\"artist\">" . $track->get_artists_str() . "</td>\r\n\t\t\t<td class=\"title\">" . $track->get_title() . "</td>\r\n\t\t\t<td class=\"album\">" . $track->get_album()->get_name() . "</td>\r\n\t\t\t<td class=\"length nowrap\">" . Time::format_succinct($track->get_length()) . "</td>";
        if (Session::is_group_user("Playlist Admin")) {
            $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::glyphicon("plus-sign") . "</a></td>";
        }
        echo (Session::is_group_user("Music Admin") ? "<td class=\"icon\"><a href=\"#\" data-toggle=\"modal\" data-target=\"#delete-modal\" data-backdrop=\"true\" data-keyboard=\"true\" data-dps-id=\"" . $track->get_id() . "\" class=\"track-delete\" title=\"Delete this track\" rel=\"twipsy\">" . Bootstrap::glyphicon("remove-sign") . "</a></td>" : "") . "\r\n\t\t</tr>";
    }
    echo "</table>";
    echo $pages->return;
} else {
    if ($query) {
        echo "<h3>Sorry, no results for " . $query . "</h3>";
        echo "<h4>Try a more generic search term.</h4>";
    }
    echo "<h4>Enter keywords below to search for tracks:</h4>\r\n\t<form action=\"" . LINK_ABS . "music/search\" method=\"GET\" class=\"form-inline\">\r\n\t\t<input type=\"text\" placeholder=\"Search Tracks\" name=\"q\" class=\"col-9\">\r\n       \t<input type=\"submit\" class=\"btn btn-primary\" value=\"Search\" class=\"col-2 col-offset-1\">\r\n    </form>";
}
if (Session::is_group_user("Playlist Admin")) {
    $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::glyphicon("plus") . $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("Music Admin")) {
    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>");
}
Example #3
0
<?php

Output::set_title("Playlists");
Output::add_script(LINK_ABS . "js/jquery-ui-1.10.3.custom.min.js");
MainTemplate::set_subtitle("View and edit music playlists");
echo "<script type=\"text/javascript\">\n\$(function() {\n\t\$('.table-striped tbody').sortable({ \n\t\taxis: 'y',\n\t\thandle: '.move',\n\t\thelper: function(e, tr){\n\t\t\tvar originals = tr.children();\n\t\t\tvar helper = tr.clone();\n\t\t\thelper.children().each(function(index) {\n\t\t\t\t\$(this).width(originals.eq(index).width())\n\t\t\t});\n\t\t\treturn helper;\n\t\t},\n\t\tupdate : function () { \n\t\t\t\$('.move').removeClass('.glyphicon-move').addClass('.glyphicon-refresh');\n            \$.ajax({\n                type: 'POST',\n                url: '" . LINK_ABS . "/ajax/update-playlist-sortorder.php',\n                data: \$('.sortorder').serialize(),\n                success: function(data) {\n                \tif(data != 'success') {\n                \t\t\$('.sortorder').before('" . Bootstrap::alert_message_basic("error", "'+data+'", "Error!") . "');\n                \t\t\$('.alert-message').alert();\n                \t}\n                \t\$('.move').removeClass('.glyphicon-refresh').addClass('.glyphicon-move');\n                }\n            });\n        }\n\t}).disableSelection();\n\n\t\$('.info').popover({\n\t\t'html': true, \n\t\t'trigger': 'hover',\n\t\t'title': function() { \n\t\t\treturn(\$(this).parent().parent().find('.title').html()+' tracks')\n\t\t},\n\t\t'content': function() {\n\t\t\treturn(\$(this).parent().find('.hover-info').html());\n\t\t}\n\t});\n\tif(window.location.hash == '#add') {\n\t\t\$('#add').click();\n\t}\n\t\$('a[href=\"" . LINK_ABS . "playlists/index.php#add\"]').click(function() {\n\t\tevent.preventDefault();\n\t\t\$('#add').click();\n\t});\n" . (Session::is_group_user("Playlist Admin") ? "\n\t\tvar playlist_id;\n\t\t\$('.delete-playlist').click(function() {\n\t\t\t\$('.delete-playlist-title').html(\$(this).parent().parent().find('.title').html());\n\t\t\tplaylist_id = \$(this).attr('data-dps-id');\n\t\t});\n\n\t\t\$('.edit-playlist').click(function() {\n\t\t\t\$('.playlist-edit-name').val(\$(this).parent().parent().find('.title').html());\n\t\t\t\$('.update-id').val(\$(this).attr('data-dps-id'));\n\t\t});\n\n\t\t\$('.yes-definitely-delete').click(function() {\n\t\t\t\$.ajax({\n\t\t\t\turl: '" . LINK_ABS . "ajax/delete-playlist.php',\n\t\t\t\tdata: 'id='+playlist_id,\n\t\t\t\ttype: 'POST',\n\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\talert(value.error);\n\t\t\t\t},\n\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\twindow.location.reload(true); \n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t\$('.add-playlist').click(function() {\n\t\t\t\$.ajax({\n\t\t\t\turl: '" . LINK_ABS . "ajax/add-update-playlist.php',\n\t\t\t\tdata: 'name='+\$('.playlist-name').val(),\n\t\t\t\ttype: 'POST',\n\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\talert(value.error);\n\t\t\t\t},\n\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\twindow.location.reload(true); \n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t\$('.playlist-name').keypress(function(e) { if(e.keyCode == 13) { e.preventDefault(); \$('.add-playlist').click(); }});\n\n\n\n\t\t\$('.update-playlist').click(function() {\n\t\t\t\$.ajax({\n\t\t\t\turl: '" . LINK_ABS . "ajax/add-update-playlist.php',\n\t\t\t\tdata: 'id='+\$('.update-id').val()+'&name='+\$('.playlist-edit-name').val(),\n\t\t\t\ttype: 'POST',\n\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\talert(value.error);\n\t\t\t\t},\n\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\twindow.location.reload(true); \n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t\$('.playlist-edit-name').keypress(function(e) { if(e.keyCode == 13) { e.preventDefault(); \$('.update-playlist').click(); }});\n" : "") . "});\n</script>";
echo "<h3>Current playlists:</h3>";
echo "\n<form class=\"sortorder\">\n<div class=\"table-responsive\">\n<table class=\"table table-striped\">\n\t<thead>\n\t\t<tr>\n\t\t\t<th class=\"icon\"></th>\n\t\t\t<th>Title</th>\n\t\t\t<th class=\"icon\">Items</th>\n\t\t\t";
if (Session::is_group_user("Playlist Admin")) {
    echo "\n\t\t\t<th class=\"icon\"></th>\n\t\t\t<th class=\"icon\"></th>\n\t\t\t<th class=\"icon\"></th>\n\t";
}
echo "\n\t\t</tr>\n\t</thead>\n\t<tbody>\n";
foreach (Playlists::get_all(false) as $playlist) {
    echo "\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t<a href=\"" . LINK_ABS . "playlists/detail/" . $playlist->get_id() . "\" class=\"info\">\n\t\t\t\t\t" . Bootstrap::glyphicon("info-sign") . "\n\t\t\t\t\t<input type=\"hidden\" name=\"id[]\" value=\"" . $playlist->get_id() . "\">\n\t\t\t\t</a>\n\t\t\t\t<div class=\"hover-info\">\n\t\t\t\t";
    $count = $playlist->count_tracks();
    foreach ($playlist->get_tracks(10) as $track) {
        echo "<strong>" . $track->get_title() . "</strong> by " . $track->get_artists_str() . "<br />";
    }
    if ($count > 10) {
        echo "<br />and <strong>" . ($count - 10) . " more...<br />";
    }
    echo "\n\t\t\t\t</div>\n\t\t\t</td>\n\t\t\t<td class=\"title\">" . $playlist->get_name() . "</td>\n\t\t\t<td>" . count($playlist->get_tracks()) . "</td>\n\t";
    if (Session::is_group_user("Playlist Admin")) {
        echo "\n\t\t\t<td>\n\t\t\t\t<a href=\"#\" data-toggle=\"modal\" data-target=\"#update-modal\" data-dps-id=\"" . $playlist->get_id() . "\" class=\"edit-playlist\" title=\"Edit playlist name\" rel=\"twipsy\">\n\t\t\t\t\t" . Bootstrap::glyphicon("pencil") . "\n\t\t\t\t</a>\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<a href=\"#\" data-toggle=\"modal\" data-target=\"#delete-modal\" data-dps-id=\"" . $playlist->get_id() . "\" class=\"delete-playlist\" title=\"Delete this playlist\" rel=\"twipsy\">\n\t\t\t\t\t" . Bootstrap::glyphicon("remove-sign") . "\n\t\t\t\t</a>\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<a href=\"#\" class=\"move\">\n\t\t\t\t\t" . Bootstrap::glyphicon("move move") . "\n\t\t\t\t</a>\n\t\t\t</td>\n\t\t";
    }
    echo "\n\t\t</tr>";
}
echo "\n\t</tbody>\n</table>\n</div>\n</form>\n";
if (Session::is_group_user("Playlist Admin")) {
    echo "<h3>Sustainer playlists:</h3>";
    echo "\n\t<div class=\"table-responsive\">\n\t<table class=\"table table-striped\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th class=\"icon\"></th>\n\t\t\t\t<th>Title</th>\n\t\t\t\t<th class=\"icon\">Items</th>\n\t\t\t\t<th class=\"icon\"></th>\n\t\t\t\t<th class=\"icon\"></th>\n\t\t\t\t<th class=\"icon\"></th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t";
Example #4
0
 case "messages":
     $emails = Emails::get(NULL, NULL, NULL, 25, NULL);
     $return = "<table class=\"table table-striped table-hover\">\r\n\t\t\t<thead>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th class=\"icon\"></th>\r\n\t\t\t\t\t<th class=\"from\">From</th>\r\n\t\t\t\t\t<th class=\"subject\">Subject</th>\r\n\t\t\t\t\t<th class=\"datetime\">Date/Time</th>\r\n\t\t\t\t</tr>\r\n\t\t\t</thead>\r\n\t\t\t<tbody>";
     foreach ($emails as $email) {
         $return .= "<tr data-message-id=\"" . $email->get_id() . "\">\r\n\t\t\t\t<td class=\"icon\">" . ($email->get_new_flag() ? Bootstrap::glyphicon("envelope") : "") . "</td>\r\n\t\t\t\t<td class=\"from nowrap\">" . $email->get_sender() . "</td>\r\n\t\t\t\t<td class=\"subject nowrap\">" . $email->get_subject() . "</td>\r\n\t\t\t\t<td class=\"datetime nowrap\">" . date("d/m/y H:i", $email->get_datetime()) . "</td>\r\n\t\t\t</tr>";
     }
     $return .= "</tbody></table>";
     echo $return;
     break;
 case "message":
     $message = Emails::get_by_id($_REQUEST['id']);
     echo $message->get_body_formatted();
     $message->mark_as_read();
     break;
 case "playlists":
     $playlists = Playlists::get_all(false);
     $return = "";
     foreach ($playlists as $playlist) {
         $return .= "\r\n\t\t\t\t<div class=\"panel panel-default\">\r\n\t\t\t\t\t<div class=\"panel-heading\" data-toggle=\"collapse\" href=\"#playlist-" . $playlist->get_id() . "\">\r\n\t\t\t\t\t\t<h4 class=\"panel-title\">" . Bootstrap::glyphicon("play-circle") . $playlist->get_name() . "</h4>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div id=\"playlist-" . $playlist->get_id() . "\" class=\"panel-collapse collapse\">\r\n\t\t\t\t\t\t<table class=\"table table-striped table-hover\">\r\n\t\t\t\t\t\t\t<thead>\r\n\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t<th class=\"icon\"></th>\r\n\t\t\t\t\t\t\t\t\t<th class=\"artist\">Artist</th>\r\n\t\t\t\t\t\t\t\t\t<th class=\"title\">Title</th>\r\n\t\t\t\t\t\t\t\t\t<th class=\"album\">Album</th>\r\n\t\t\t\t\t\t\t\t\t<th class=\"length\">Length</th>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t</thead>\r\n\t\t\t\t\t\t\t<tbody>";
         foreach ($playlist->get_tracks() as $track) {
             $lastLogged = LogItems::get_by_audioid($track->get_id());
             $trackHotness = "";
             // default at 0
             if (isset($lastLogged)) {
                 $lastPlay = $lastLogged->get_datetime();
                 if ($lastPlay > time() - 604800) {
                     $trackHotness = "active";
                 }
                 // 1 week
                 if ($lastPlay > time() - 86400) {
                     $trackHotness = "info";