示例#1
0
 public static function get_newest($num = 10)
 {
     return DigiplayDB::select("* FROM audio WHERE type = " . AudioTypes::get("Jingle")->get_id() . " ORDER BY id DESC LIMIT " . $num . ";", "Track", true);
 }
示例#2
0
 public function save()
 {
     if (isset($this->id)) {
         DigiplayDB::update("audio", get_object_vars($this), "id = " . $this->id);
     } else {
         if (!isset($this->md5) || !isset($this->archive) || !isset($this->filetype)) {
             return false;
         }
         if (!isset($this->sustainer)) {
             $this->sustainer = 'f';
         }
         if (!isset($this->censor)) {
             $this->censor = 'f';
         }
         if (!isset($this->creation_date)) {
             $this->creation_date = time();
         }
         if (!isset($this->creator)) {
             $this->creator = 1;
         }
         if (!isset($this->intro_smpl)) {
             $this->intro_smpl = 0;
         }
         if (!isset($this->extro_smpl)) {
             $this->extro_smpl = $this->length_smpl;
         }
         if (!isset($this->end_smpl)) {
             $this->end_smpl = $this->length_smpl;
         }
         if (!isset($this->start_smpl)) {
             $this->start_smpl = 0;
         }
         if (!isset($this->import_date)) {
             $this->import_date = time();
         }
         if (!isset($this->type)) {
             $this->set_type(AudioTypes::get_by_name("Track"));
         }
         $this->id = DigiplayDB::insert("audio", get_object_vars($this), "id");
     }
     return $this->id;
 }
示例#3
0
} else {
    $disabled = "";
}
echo "\n\t<script>\n\t\t\$(function () {\n\t\t\t\$('.track-detail-form').submit(function(event) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsubmit = \$(this).find('button[type=\"submit\"]');\n\t\t\t\tsubmit.find('span').removeClass('glyphicon-save').addClass('glyphicon-refresh');\n\t\t\t\t\$.ajax({\n\t\t\t\t\turl: '" . LINK_ABS . "ajax/track-detail-update.php',\n\t\t\t\t\tdata: \$(this).serialize(),\n\t\t\t\t\ttype: 'POST',\n\t\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\t\tsubmit.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-save');\n\t\t\t\t\t\t\$('h3').after('" . Bootstrap::alert_message_basic("danger", "'+value.error+'", "Error!") . "');\n\t\t\t\t\t\tconsole.error(value.detail);\n\t\t\t\t\t\t\$('.alert-message').alert();\n\t\t\t\t\t},\n\t\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\t\tvalues = \$.parseJSON(data);\n\t\t\t\t\t\tsubmit.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-save');\n\t\t\t\t\t\t\$('h3').after('" . Bootstrap::alert_message_basic("success", "Track details altered.", "Success!", false) . "');\n\t\t\t\t\t\t\$('[id=new_artist]').val('');\n\t\t\t\t\t\t\$('[id=artist\\\\[\\\\]]').parent('.col-md-10').remove();\n\t\t\t\t\t\tartists_str = '';\n\t\t\t\t\t\tfirst = true;\n\t\t\t\t\t\t\$.each(values.artists, function(i, val) {\n\t\t\t\t\t\t\tartists_str += '<div class=\"col-md-10'+(first? '' : ' col-md-offset-2')+'\"><input type=\"text\" id=\"artist[]\" name=\"artist[]\" class=\"form-control" . $disabled . "\" value=\"'+val+'\"></div>';\n\t\t\t\t\t\t\tfirst = false;\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\$('[for=artist]').after(artists_str);\n\t\t\t\t\t\t\$('[id=new_keyword]').val('');\n\t\t\t\t\t\t\$('.keyword').parent().remove();\n\t\t\t\t\t\tkeywords_str = '';\n\t\t\t\t\t\t\$.each(values.keywords, function(i, val) {\n\t\t\t\t\t\t\tkeywords_str += '<div class=\"input-group\"><span class=\"input-group-addon\"><a class=\"keyword-remove\" href=\"" . LINK_ABS . "ajax/del-keywords.php?track_id=" . $track->get_id() . "&keyword='+val+'\">" . Bootstrap::glyphicon("remove-sign") . "</a></span><input type=\"text\" class=\"form-control\" disabled value=\"'+val+'\"></div></div>'\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\$('.for-keywords').html(keywords_str);\n\t\t\t\t\t\tsetTimeout(function() {\n    \t\t\t\t\t\t\$('.alert').hide('fast', function(){\n        \t\t\t\t\t\t\$(this).remove(); \n           \t\t\t\t});},4000);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\n\t\t\t\$('.keyword-remove').on(\"click\", function(event) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tparent = \$(this).parent().parent();\n\t\t\t\t\$.get(\$(this).attr('href'), function(data) {\n\t\t\t\t\tif(data == \"success\") {\n\t\t\t\t\t\tparent.remove();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\$('h3').after('" . Bootstrap::alert_message_basic("danger", "'+data+'", "Error!") . "');\n\t\t\t\t\t\t\$('.alert-message').show('fast').alert();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t});\n\n\t\t\t\$('[id=flag]').click(function() {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tt = \$(this);\n\t\t\t\tt.find('.censor-flag').removeClass('glyphicon-warning-sign').addClass('glyphicon-refresh');\n\t\t\t\t\$.ajax({\n\t\t\t\t\turl: '" . LINK_ABS . "ajax/flag.php',\n\t\t\t\t\tdata: 'id=" . $track->get_id() . "&flag=toggle',\n\t\t\t\t\ttype: 'GET',\n\t\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\t\t\$('h3').after('" . Bootstrap::alert_message_basic("danger", "'+value.error+'", "Error!") . "');\n\t\t\t\t\t\t\$('.alert-message').alert();\n\t\t\t\t\t\tt.find('.censor-flag').removeClass('glyphicon-refresh').addClass('glyphicon-warning-sign');\n\t\t\t\t\t},\n\t\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\t\t\tt.find('.censor-flag').removeClass('glyphicon-refresh').addClass('glyphicon-warning-sign');\n\t\t\t\t\t\t\tif(value.response == 'flagged') {\n\t\t\t\t\t\t\t\tt.addClass('active');\n\t\t\t\t\t\t\t\tresponse = 'This track has been flagged for censorship and will be reviewed in due course.';\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tt.removeClass('active');\n\t\t\t\t\t\t\t\tresponse = 'This track has been unflagged.';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\$('h3').after('" . Bootstrap::alert_message_basic("warning", "'+response+'", "Success!", false) . "'); \n\t\t\t\t\t\t\tsetTimeout(function() {\n\t    \t\t\t\t\t\t\$('.alert').hide('fast', function(){\n\t        \t\t\t\t\t\t\$(this).remove(); \n\t           \t\t\t\t});},4000);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n" . (Session::is_group_user("Playlist Editor") ? "\n\t\t\tvar item;\n\t\t\t\$('.playlist-add').click(function() {\n\t\t\t\titem = \$(this);\n\t\t\t\tplaylists = \$(this).attr('data-playlists-in').split(',');\n\t\t\t\t\$('.playlist-select').parent().removeClass('active');\n\t\t\t\t\$('.playlist-select').find('span').removeClass('glyphicon-minus').addClass('glyphicon-plus');\n\t\t\t\t\$('.playlist-select').each(function() {\n\t\t\t\t\tif(\$.inArray(\$(this).attr('data-playlist-id'),playlists) > -1) {\n\t\t\t\t\t\t\$(this).find('span').removeClass('icon-plus').addClass('glyphicon-minus');\n\t\t\t\t\t\t\$(this).parent().addClass('active');\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t});\n\n\t\t\t\$('.playlist-select').click(function() {\n\t\t\t\tobj = \$(this);\n\t\t\t\tif(\$(this).parent().hasClass('active')) {\n\t\t\t\t\t\$(this).find('span').removeClass('glyphicon-minus').addClass('glyphicon-refresh');\n\t\t\t\t\t\$.ajax({\n\t\t\t\t\t\turl: '" . LINK_ABS . "ajax/track-playlist-update.php',\n\t\t\t\t\t\tdata: 'trackid='+item.attr('data-dps-id')+'&playlistid='+obj.attr('data-playlist-id')+'&action=del',\n\t\t\t\t\t\ttype: 'POST',\n\t\t\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-minus');\n\t\t\t\t\t\t\talert(value.error);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\t\t\tvalues = \$.parseJSON(data);\n\t\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-plus');\n\t\t\t\t\t\t\tobj.parent().removeClass('active');\n\t\t\t\t\t\t\titem.attr('data-playlists-in',values.playlists.join(','));\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\t\$(this).find('span').removeClass('glyphicon-plus').addClass('glyphicon-refresh');\n\t\t\t\t\t\$.ajax({\n\t\t\t\t\t\turl: '" . LINK_ABS . "ajax/track-playlist-update.php',\n\t\t\t\t\t\tdata: 'trackid='+item.attr('data-dps-id')+'&playlistid='+obj.attr('data-playlist-id')+'&action=add',\n\t\t\t\t\t\ttype: 'POST',\n\t\t\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-plus');\n\t\t\t\t\t\t\talert(value.error);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\t\t\tvalues = \$.parseJSON(data);\n\t\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-minus');\n\t\t\t\t\t\t\tobj.parent().addClass('active');\n\t\t\t\t\t\t\titem.attr('data-playlists-in',values.playlists.join(','));\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\t\$(this).parent().addClass('active');\n\t\t\t\t\t\$(this).find('span').removeClass('glyphicon-plus').addClass('glyphicon-minus');\n\t\t\t\t}\n\t\t\t});\t\t\n" : "") . "\n\t\t});\n\t</script>\n\t<h3>Edit Track: " . $track->get_id() . " <small>Added " . date("d/m/Y H:i", $track->get_import_date()) . "</small></h3>\n\t" . (Session::is_group_user("Music Admin") ? "" : Bootstrap::alert_message_basic("info", "You can't edit the details of this track, because you aren't a Music Admin.", "Notice:"));
echo $track->player() . "\n\t<form class=\"track-detail-form\" action=\"\" method=\"post\">\n\t\t<fieldset>\n\t\t\t<div class=\"row\">\n\t\t\t\t<div class=\"col-md-7 form-horizontal\">\n\t\t\t\t\t<input type=\"hidden\" id=\"id\" name=\"id\" value=\"" . $track->get_id() . "\">\n\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t<label class=\"control-label col-md-2\" for=\"title\">Title</label>\n\t\t\t\t\t\t<div class=\"col-md-10\">\n\t\t\t\t\t\t\t<input type=\"text\" id=\"title\" name=\"title\" class=\"form-control\" " . $disabled . " value=\"" . $track->get_title() . "\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t<label class=\"control-label col-md-2\" for=\"artist\">Artists</label>";
$first = true;
foreach ($track->get_artists() as $key => $artist) {
    echo "\n\t\t\t\t\t\t<div class=\"col-md-10" . (!$first ? " col-md-offset-2" : "") . "\">\n\t\t\t\t\t\t\t<input type=\"text\" id=\"artist[]\"  name=\"artist[]\" class=\"form-control\" " . $disabled . " value=\"" . $artist->get_name() . "\">\n\t\t\t\t\t\t</div>";
    $first = false;
}
echo "\n\t\t\t\t\t\t<div class=\"col-md-10 col-md-offset-2\">\n\t\t\t\t\t\t\t<input type=\"text\" id=\"new_artist\" name=\"new-artist\" class=\"form-control\" " . $disabled . " placeholder=\"Add new artist...\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t<label class=\"control-label col-md-2\" for=\"album\">Album</label>\n\t\t\t\t\t\t<div class=\"col-md-10\">\n\t\t\t\t\t\t\t<input type=\"text\" id=\"album\" name=\"album\" class=\"form-control\" " . $disabled . " value=\"" . $track->get_album()->get_name() . "\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t<label class=\"control-label col-md-2\" for=\"year\">Year</label>\n\t\t\t\t\t\t<div class=\"col-md-10\">\n\t\t\t\t\t\t\t<input type=\"text\" class=\"form-control\" id=\"year\" name=\"year\" " . $disabled . " value=\"" . $track->get_year() . "\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t<label class=\"control-label col-md-2\" for=\"length\">Length</label>\n\t\t\t\t\t\t<div class=\"col-md-10\">\n\t\t\t\t\t\t\t<p class=\"form-control-static\">" . Time::format_succinct($track->get_length()) . "</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t<label class=\"control-label col-md-2\" for=\"origin\">Origin</label>\n\t\t\t\t\t\t<div class=\"col-md-10\">\n\t\t\t\t\t\t\t<input type=\"text\" id=\"origin\" name=\"origin\" class=\"form-control\" " . $disabled . " value=\"" . $track->get_origin() . "\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t<div class=\"col-md-10 col-md-offset-2\">\n\t\t\t\t\t\t\t<div class=\"checkbox\">\n\t\t\t\t\t\t\t\t<label for=\"censored\">\n\t\t\t\t\t\t\t\t\t<input type=\"checkbox\" id=\"censored\" name=\"censored\" " . $disabled . " " . ($track->is_censored() ? "checked" : "") . ">\n\t\t\t\t\t\t\t\t\tExplicit\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t<div class=\"col-md-10 col-md-offset-2\">\n\t\t\t\t\t\t\t<button type=\"submit\" class=\"btn btn-primary btn-block\">\n\t\t\t\t\t\t\t\t" . Bootstrap::glyphicon("save save") . "\n\t\t\t\t\t\t\t\tSave\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"col-md-5 form\">\n\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t<label for=\"notes\">Notes</label>\n\t\t\t\t\t\t<textarea class=\"form-control\" id=\"notes\" name=\"notes\" " . $disabled . ">" . $track->get_notes() . "</textarea>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t<label for=\"keyword\">Keywords</label>\n\t\t\t\t\t\t<div class=\"for-keywords\">";
foreach ($track->get_keywords() as $keyword) {
    echo "\n\t\t\t\t\t\t\t\t<div class=\"input-group\">\n\t\t\t\t\t\t\t\t\t<span class=\"input-group-addon\"><a class=\"keyword-remove\" href=\"" . LINK_ABS . "ajax/del-keywords.php?track_id=" . $track->get_id() . "&keyword=" . $keyword->get_text() . "\">" . Bootstrap::glyphicon("remove-sign") . "</a></span>\n\t\t\t\t\t\t\t\t\t<input type=\"text\" class=\"form-control\" disabled value=\"" . $keyword->get_text() . "\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t";
}
echo "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"input-group\">\n\t\t\t\t\t\t\t<span class=\"input-group-addon\">" . Bootstrap::glyphicon("tag") . "</span>\n\t\t\t\t\t\t\t<input type=\"text\" id=\"new_keyword\" name=\"new_keyword\" class=\"form-control\" " . $disabled . " placeholder=\"Add new keyword...\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t<label for=\"type\">Audio Type</label>\n\t\t\t\t\t\t<select class=\"selectpicker\" id=\"type\" name=\"type\" data-width=\"100%\" " . $disabled . ">";
foreach (AudioTypes::get_all() as $audiotype) {
    if ($audiotype->get_id() == $track->get_type()->get_id()) {
        echo "<option value=\"" . $audiotype->get_id() . "\" selected=\"selected\">" . $audiotype->get_name() . "</option>";
    } else {
        echo "<option value=\"" . $audiotype->get_id() . "\">" . $audiotype->get_name() . "</option>";
    }
}
echo "</select>\n\t\t\t\t\t</div>\n\t\t\t\t\t<hr />\n\t\t\t\t\t";
if (Session::is_group_user("Playlist Editor")) {
    $playlists = array();
    foreach ($track->get_playlists_in() as $playlist) {
        $playlists[] = $playlist->get_id();
    }
    echo "<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) . "\" id=\"playlists\" class=\"playlist-add btn btn-primary btn-block\">" . Bootstrap::glyphicon("th-list") . " Playlists</a>";
}
echo "\n\t\t\t\t\t<a href=\"#\" id=\"flag\" class=\"btn btn-danger btn-block" . ($track->is_flagged() ? " active" : "") . "\">" . Bootstrap::glyphicon("warning-sign censor-flag") . " Flag for censorship</a>\n\t\t\t\t\t" . (Session::is_group_user("Music Admin") ? "<hr /><a href=\"" . LINK_ABS . "audio/get/" . $track->get_id() . ".flac\" class=\"btn btn-primary btn-block\">" . Bootstrap::glyphicon("download-alt") . " Download FLAC</a>" : "") . "\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</fieldset>\n\t</form>\n";
 $track = Tracks::get_by_id($_REQUEST["id"]);
 if (!$_REQUEST["title"]) {
     exit(json_encode(array("error" => "You did not specify a title.")));
 }
 if ($_REQUEST["title"] != $track->get_title()) {
     $track->set_title($_REQUEST["title"]);
 }
 $curr_artists_obj = $track->get_artists();
 $curr_artists_arr = array();
 foreach ($curr_artists_obj as $artist) {
     $curr_artists_arr[] = $artist->get_name();
 }
 $track->del_artists(array_diff($curr_artists_arr, $_REQUEST["artist"]));
 $track->add_artists(array_diff($_REQUEST["artist"], $curr_artists_arr));
 if ($_REQUEST["type"]) {
     $track->set_type(AudioTypes::get_by_id($_REQUEST["type"]));
 }
 if ($_REQUEST["new-artist"]) {
     $track->add_artists($_REQUEST["new-artist"]);
 }
 if (!$_REQUEST["album"]) {
     $_REQUEST["album"] = "(none)";
 }
 if ($_REQUEST["album"] != $track->get_album()->get_name()) {
     $track->set_album($_REQUEST["album"]);
 }
 if ($_REQUEST["year"] != $track->get_year()) {
     $track->set_year($_REQUEST["year"]);
 }
 if (!$_REQUEST["origin"]) {
     exit(json_encode(array("error" => "You did not specify an origin.")));
示例#5
0
 public static function get_censored($limit = 0, $offset = 0)
 {
     $limit = $limit > 0 ? " LIMIT " . $limit : "";
     $offset = $offset > 0 ? " OFFSET " . $offset : "";
     return DigiplayDB::select("* FROM audio WHERE type = " . AudioTypes::get("Track")->get_id() . " AND censor = 't' ORDER BY id DESC" . $limit . $offset, "Track", true);
 }