本文整理汇总了PHP中Search::tracks方法的典型用法代码示例。如果您正苦于以下问题:PHP Search::tracks方法的具体用法?PHP Search::tracks怎么用?PHP Search::tracks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search::tracks方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
<?php
Output::set_title("Library Search");
$query = $_REQUEST["q"];
$index = isset($_REQUEST["i"]) ? explode(",", $_REQUEST["i"]) : array("title", "artist", "album");
$limit = isset($_GET["n"]) && is_numeric($_REQUEST["n"]) ? $_GET["n"] : 10;
$page = isset($_REQUEST["p"]) && is_numeric($_REQUEST["p"]) ? $_REQUEST["p"] : 1;
MainTemplate::set_subtitle("Find a track in the database, edit track details");
if ($query) {
$search = Search::tracks($query, $index, $limit, ($page - 1) * $limit);
}
$tracks = $search["results"];
if ($tracks) {
$pages = new Paginator();
$pages->items_per_page = $limit;
$pages->querystring = $query;
$pages->index = implode(",", $index);
$pages->mid_range = 5;
$pages->items_total = $search["total"];
$pages->paginate();
$low = ($page - 1) * $limit + 1;
$high = $low + $limit - 1 > $search["total"] ? $search["total"] : $low + $limit - 1;
echo "<script>\r\n\t\t\$(function () {\r\n\t\t\t\$('.track-info').popover({\r\n\t\t\t\t'html': true, \r\n\t\t\t\t'trigger': 'hover',\r\n\t\t\t\t'title': function() { \r\n\t\t\t\t\treturn(\$(this).parent().parent().find('.title').html())\r\n\t\t\t\t},\r\n\t\t\t\t'content': function() {\r\n\t\t\t\t\treturn(\$(this).parent().find('.hover-info').html());\r\n\t\t\t\t}\r\n\t\t\t});\r\n" . (Session::is_group_user("Playlist Admin") ? "\r\n\t\tvar item;\r\n\t\t\$('.playlist-add').click(function() {\r\n\t\t\titem = \$(this).parent().parent();\r\n\t\t\tplaylists = \$(this).attr('data-playlists-in').split(',');\r\n\t\t\t\$('.playlist-select').parent().removeClass('active');\r\n\t\t\t\$('.playlist-select').find('span').removeClass('glyphicon-minus').addClass('glyphicon-plus');\r\n\t\t\t\$('.playlist-select').each(function() {\r\n\t\t\t\tif(\$.inArray(\$(this).attr('data-playlist-id'),playlists) > -1) {\r\n\t\t\t\t\t\$(this).find('span').removeClass('icon-plus').addClass('glyphicon-minus');\r\n\t\t\t\t\t\$(this).parent().addClass('active');\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t});\r\n\r\n\t\t\$('.playlist-select').click(function() {\r\n\t\t\tobj = \$(this);\r\n\t\t\tif(\$(this).parent().hasClass('active')) {\r\n\t\t\t\t\$(this).find('span').removeClass('glyphicon-minus').addClass('glyphicon-refresh');\r\n\t\t\t\t\$.ajax({\r\n\t\t\t\t\turl: '" . LINK_ABS . "ajax/track-playlist-update.php',\r\n\t\t\t\t\tdata: 'trackid='+item.attr('id')+'&playlistid='+obj.attr('data-playlist-id')+'&action=del',\r\n\t\t\t\t\ttype: 'POST',\r\n\t\t\t\t\terror: function(xhr,text,error) {\r\n\t\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\r\n\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-minus');\r\n\t\t\t\t\t\talert(value.error);\r\n\t\t\t\t\t},\r\n\t\t\t\t\tsuccess: function(data,text,xhr) {\r\n\t\t\t\t\t\tvalues = \$.parseJSON(data);\r\n\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-plus');\r\n\t\t\t\t\t\tobj.parent().removeClass('active');\r\n\t\t\t\t\t\titem.find('.playlist-add').attr('data-playlists-in',values.playlists.join(','));\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\t\$(this).find('span').removeClass('glyphicon-plus').addClass('glyphicon-refresh');\r\n\t\t\t\t\$.ajax({\r\n\t\t\t\t\turl: '" . LINK_ABS . "ajax/track-playlist-update.php',\r\n\t\t\t\t\tdata: 'trackid='+item.attr('id')+'&playlistid='+obj.attr('data-playlist-id')+'&action=add',\r\n\t\t\t\t\ttype: 'POST',\r\n\t\t\t\t\terror: function(xhr,text,error) {\r\n\t\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\r\n\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-plus');\r\n\t\t\t\t\t\talert(value.error);\r\n\t\t\t\t\t},\r\n\t\t\t\t\tsuccess: function(data,text,xhr) {\r\n\t\t\t\t\t\tvalues = \$.parseJSON(data);\r\n\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-minus');\r\n\t\t\t\t\t\tobj.parent().addClass('active');\r\n\t\t\t\t\t\titem.find('.playlist-add').attr('data-playlists-in',values.playlists.join(','));\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t\t\$(this).parent().addClass('active');\r\n\t\t\t\t\$(this).find('span').removeClass('glyphicon-plus').addClass('glyphicon-minus');\r\n\t\t\t}\r\n\t\t});\t\t\r\n" : "") . (Session::is_group_user("Music Admin") ? "\r\n\t\tvar trackid;\r\n\t\t\$('.track-delete').click(function() {\r\n\t\t\t\$('.delete-track-title').html(\$(this).parent().parent().find('.title').html());\r\n\t\t\ttrackid = \$(this).attr('data-dps-id');\r\n\t\t});\r\n\r\n\t\t\$('.yes-definitely-delete').click(function() {\r\n\t\t\t\$.ajax({\r\n\t\t\t\turl: '" . LINK_ABS . "ajax/delete-track.php',\r\n\t\t\t\tdata: 'id='+trackid,\r\n\t\t\t\ttype: 'POST',\r\n\t\t\t\terror: function(xhr,text,error) {\r\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\r\n\t\t\t\t\talert(value.error);\r\n\t\t\t\t},\r\n\t\t\t\tsuccess: function(data,text,xhr) {\r\n\t\t\t\t\twindow.location.reload(true); \r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n" : "") . "\t\t});\r\n\t</script>";
$indexes = implode(", ", $index);
echo "<h3>" . $search["total"] . " results for " . $query . "<small> searching in " . $indexes . "</small></h3>";
echo "<div class=\"row\"><div class=\"col-lg-5\"><h5>Showing results " . $low . " to " . $high . "</h5></div><div class=\"pull-right\">" . $pages->display_jump_menu() . $pages->display_items_per_page() . "</div></div>";
echo "<table class=\"table table-striped\" cellspacing=\"0\">\r\n\t<thead>\r\n\t\t<tr>\r\n\t\t\t<th class=\"icon\"> </th>\r\n\t\t\t<th class=\"artist\">Artist</th>\r\n\t\t\t<th class=\"title\">Title</th>\r\n\t\t\t<th class=\"album\">Album</th>\r\n\t\t\t<th class=\"length nowrap\">Length</th> \r\n\t\t\t" . (Session::is_group_user("Playlist Admin") ? "<th class=\"icon\"></th>" : "") . "\r\n\t\t\t" . (Session::is_group_user("Music Admin") ? "<th class=\"icon\"></th>" : "") . "\r\n\t\t</tr>\r\n\t</thead>";
foreach ($tracks as $track_id) {
$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")) {
示例2: preg_replace
<?php
$search_str = preg_replace('/[^a-z0-9]+/i', ' ', trim(preg_replace('/\\s*\\([^)]*\\)/', '', $_REQUEST["title"] . " " . $_REQUEST["artist"])));
$similar_tracks = Search::tracks($search_str);
if ($similar_tracks) {
echo json_encode(array("response" => "fail", "q" => $search_str, "tracks" => $similar_tracks["results"]));
} else {
echo json_encode(array("response" => "success"));
}
示例3: array
<?php
Output::set_template();
$query = $_REQUEST['q'];
if ($query) {
$search = Search::tracks(str_replace(" ", " | ", $query), array("title"), 5);
}
$tracks = $search["results"];
$tracks_array = array();
if ($tracks) {
foreach ($tracks as $track_id) {
$track_object = Tracks::get($track_id);
$track = array('id' => $track_object->get_id(), 'title' => $track_object->get_title(), 'by' => $track_object->get_artists_str(), 'href' => LINK_ABS . "music/detail/" . $track_object->get_id());
array_push($tracks_array, $track);
}
}
if ($query) {
$search = Search::artists($query, 5);
}
$artists = $search["results"];
$artists_array = array();
if ($artists) {
foreach ($artists as $artist) {
$artist_object = Artists::get_by_id($artist);
if ($artist_object) {
$artist = array('id' => $artist_object->get_id(), 'title' => $artist_object->get_name(), 'href' => LINK_ABS . "music/search/?q=%22" . urlencode($artist_object->get_name()) . "%22&i=artist");
array_push($artists_array, $artist);
}
}
}
if ($query) {
示例4: foreach
<?php
if (Session::is_user()) {
$query = $_REQUEST['q'];
if ($query) {
$search = Search::tracks($query);
$tracks = $search["results"];
$jinglesearch = Search::jingles($query);
$jingles = $jinglesearch["results"];
// $advertsearch = Search::adverts($query);
// $advert = $advertsearch['results'];
$count = 1;
}
foreach ($jingles as $jingleid) {
$jingle = Jingles::get($jingleid);
echo "<div style=\"background-color: rgb(18,137,192);\" id=\"track-draggable-" . $count . "\" class=\"ui-draggable dps-aw-item\" data-dps-aw-style=\"118\" data-dps-audio-id=\"" . $jingle->get_id() . "\">\r\n\t\t<span class=\"text\">" . $jingle->get_title() . "</span>\r\n\t\t</div><br>";
}
// foreach ($adverts as $advertid){
// $advert = Advertss::get($advertid);
// echo "<div style=\"background-color: orange;\" id=\"track-draggable-".$count."\" class=\"ui-draggable dps-aw-item\" data-dps-aw-style=\"118\" data-dps-audio-id=\"".$advert->get_id()."\">
// <span class=\"text\">".$advert->get_title()."</span>
// </div><br>";
// }
foreach ($tracks as $track_id) {
$track = Tracks::get($track_id);
echo "<div style=\"background-color: rgb(18,137,192);\" id=\"track-draggable-" . $count . "\" class=\"ui-draggable dps-aw-item\" data-dps-aw-style=\"118\" data-dps-audio-id=\"" . $track->get_id() . "\">\r\n\t\t<span class=\"text\">" . $track->get_title() . "</span>\r\n\t\t</div><br>";
$count = $count + 1;
}
}
示例5: array
break;
case "search":
$index = array();
$query = $_REQUEST["search-text"];
if (isset($_REQUEST["search-title"]) && $_REQUEST["search-title"] == "on") {
$index[] = "title";
}
if (isset($_REQUEST["search-artist"]) && $_REQUEST["search-artist"] == "on") {
$index[] = "artist";
}
if (isset($_REQUEST["search-album"]) && $_REQUEST["search-album"] == "on") {
$index[] = "album";
}
$search_limit = Configs::get_system_param("search_limit");
if ($query && count($index) >= 1) {
$search = Search::tracks($query, $index, $search_limit);
}
if (isset($search)) {
$return = "<table class=\"table table-hover\" cellspacing=\"0\">\r\n\t\t\t\t<thead>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<th class=\"icon\"></th>\r\n\t\t\t\t\t\t<th class=\"artist\">Artist</th>\r\n\t\t\t\t\t\t<th class=\"title\">Title</th>\r\n\t\t\t\t\t\t<th class=\"album\">Album</th>\r\n\t\t\t\t\t\t<th class=\"length\">Length</th>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</thead>\r\n\t\t\t\t<tbody>";
if (Configs::get_system_param("censor_start") < date("H") && date("H") < Configs::get_system_param("censor_end")) {
$censor_time = true;
} else {
$censor_time = false;
}
foreach ($search["results"] as $track) {
$track = Tracks::get($track);
$lastLogged = LogItems::get_by_audioid($track->get_id());
$trackHotness = "";
// default at 0
if (isset($lastLogged)) {
$lastPlay = $lastLogged->get_datetime();