Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion core/models/playlists_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,40 @@ public function search($query, $limit, $offset, $sort_by, $sort_dir, $my = false
$where_strings = [];

if ($query !== '' && $query !== false && $query !== null) {
$where_strings[] = '(name LIKE "%' . $this->db->escape($query) . '%" OR description LIKE "%' . $this->db->escape($query) . '%")';
$query = trim($query);
$query_escape = $this->db->escape($query);

$type_query = null;
$type_query_map = [
'b' => 'standard',
'basic' => 'standard',
'standard' => 'standard',
'pl b' => 'standard',
'playlist basic' => 'standard',
'playlist standard' => 'standard',
'a' => 'advanced',
'advanced' => 'advanced',
'pl a' => 'advanced',
'playlist advanced' => 'advanced',
'la' => 'live_assist',
'live assist' => 'live_assist',
'liveassist' => 'live_assist',
'live_assist' => 'live_assist',
'pl la' => 'live_assist',
'playlist live assist' => 'live_assist',
];

$query_normalized = strtolower($query);
if (isset($type_query_map[$query_normalized])) {
$type_query = $this->db->escape($type_query_map[$query_normalized]);
}

$where = '(name LIKE "%' . $query_escape . '%" OR description LIKE "%' . $query_escape . '%")';
if ($type_query !== null) {
$where .= ' OR type = "' . $type_query . '"';
}

$where_strings[] = '(' . $where . ')';
}
if (!$this->user->check_permission('manage_playlists')) {
$where_strings[] = '(status = "public" or status = "visible" or owner_id = "' . $this->db->escape($this->user->param('id')) . '")';
Expand Down
28 changes: 28 additions & 0 deletions public/js/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ OB.Sidebar.init = function () {
OB.Sidebar.mediaSearchQuery = "";
OB.Sidebar.playlistSearchQuery = "";


OB.Sidebar.sidebarInit = function () {
if (parseInt(OB.Account.userdata.sidebar_display_left)) {
$("body").addClass("sidebar-left");
Expand Down Expand Up @@ -850,6 +851,29 @@ OB.Sidebar.playlistSearchSort = function (sortby) {
OB.Sidebar.playlistSearch();
};

OB.Sidebar.playlistTypeBadges = function (playlistType) {
if (!playlistType) playlistType = "standard";

var iconClass = "fa-list";
var title = "Standard Playlist";

if (playlistType == "advanced") {
iconClass = "fa-cogs";
title = "Advanced Playlist";
} else if (playlistType == "live_assist") {
iconClass = "fa-microphone";
title = "Live Assist Playlist";
}

return (
'<span class="sidebar_search_playlist_type_badges" title="' + title + '">' +
'<i class="fas ' + iconClass + ' sidebar_search_playlist_type_badge sidebar_search_playlist_type_badge_' +
playlistType +
'"></i>' +
"</span>"
);
};

OB.Sidebar.playlistSearch = function (more) {
// if not the result of pagination (new search), reset offset to 0
if (!more) {
Expand Down Expand Up @@ -913,7 +937,10 @@ OB.Sidebar.playlistSearch = function (more) {
playlist[i]["id"] +
'" data-mode="playlist">\
<td class="sidebar_search_playlist_name" data-column="name">' +
OB.Sidebar.playlistTypeBadges(playlist[i]["type"]) +
'<span class="sidebar_search_playlist_name_text">' +
htmlspecialchars(playlist[i]["name"]) +
"</span>" +
'</td>\
<td class="sidebar_search_playlist_description" data-column="description">' +
playlist_description +
Expand Down Expand Up @@ -948,6 +975,7 @@ OB.Sidebar.playlistSearch = function (more) {
"data-can_edit",
playlist[i]["can_edit"],
);
$("#sidebar_search_playlist_result_" + playlist[i]["id"]).attr("data-type", playlist[i]["type"]);

// set up context menu
var menuOptions = new Object();
Expand Down
30 changes: 30 additions & 0 deletions public/scss/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,36 @@ body.sidebar-left .sidebar_search_media_container_detailed #media_detailed_toggl
width: 90px;
}

.sidebar_search_playlist_name_text {
vertical-align: middle;
}

.sidebar_search_playlist_type_badges {
display: inline-flex;
margin-right: 6px;
vertical-align: middle;
}

.sidebar_search_playlist_type_badge {
display: inline-block;
padding: 0 2px;
font-size: 1.1rem;
text-align: center;
}

.sidebar_search_playlist_type_badge_standard,
.sidebar_search_playlist_type_badge_basic {
color: #66d1b6;
}

.sidebar_search_playlist_type_badge_advanced {
color: #87aeea;
}

.sidebar_search_playlist_type_badge_live_assist {
color: #f0b36c;
}

.sidebar_search_playlist_description {
width: 240px;
/* see sidebar.js $(document).ready() */
Expand Down
Loading