Skip to content
Closed
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
29 changes: 26 additions & 3 deletions core/models/playlists_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,35 @@ public function search($query, $limit, $offset, $sort_by, $sort_dir, $my = false
$where_strings = [];

if ($query !== '' && $query !== false && $query !== null) {
// If query is numeric, also search by ID
$query = trim($query);
$query_escape = $this->db->escape($query);

$type_query = null;
$type_query_map = [
'standard' => 'standard',
'advanced' => 'advanced',
'live assist' => 'live_assist',
'liveassist' => 'live_assist',
'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]);
}

// Build the base WHERE: name/description LIKE, plus ID match if numeric
if (is_numeric($query)) {
$where_strings[] = '(id = "' . $this->db->escape($query) . '" OR name LIKE "%' . $this->db->escape($query) . '%" OR description LIKE "%' . $this->db->escape($query) . '%")';
$where = '(id = "' . $query_escape . '" OR name LIKE "%' . $query_escape . '%" OR description LIKE "%' . $query_escape . '%")';
} else {
$where_strings[] = '(name LIKE "%' . $this->db->escape($query) . '%" OR description LIKE "%' . $this->db->escape($query) . '%")';
$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
1 change: 1 addition & 0 deletions public/html/sidebar/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<table id="sidebar_search_playlist_headings">
<thead>
<tr>
<th class="sidebar_search_playlist_type" data-column="type">&nbsp;</th>
<th class="sidebar_search_playlist_name" data-column="name">
<a href="javascript:OB.Sidebar.playlistSearchSort('name');" data-t>Name</a>
</th>
Expand Down
22 changes: 22 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,23 @@ 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 '<i class="fas ' + iconClass + '" title="' + title + '"></i>';
};

OB.Sidebar.playlistSearch = function (more) {
// if not the result of pagination (new search), reset offset to 0
if (!more) {
Expand Down Expand Up @@ -912,6 +930,9 @@ OB.Sidebar.playlistSearch = function (more) {
<tr class="sidebar_search_playlist_result" id="sidebar_search_playlist_result_' +
playlist[i]["id"] +
'" data-mode="playlist">\
<td class="sidebar_search_playlist_type" data-column="type">' +
OB.Sidebar.playlistTypeBadges(playlist[i]["type"]) +
'</td>\
<td class="sidebar_search_playlist_name" data-column="name">' +
htmlspecialchars(playlist[i]["name"]) +
'</td>\
Expand Down Expand Up @@ -948,6 +969,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
22 changes: 20 additions & 2 deletions public/scss/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,26 @@ body.sidebar-left .sidebar_search_media_container_detailed #media_detailed_toggl
width: 30px;
}

.sidebar_search_playlist_name {
width: 90px;
#sidebar_search_playlist_results .sidebar_search_playlist_type {
width: 12px;
overflow: hidden;
}

#sidebar_search_playlist_results .sidebar_search_playlist_type i {
position: relative;
left: 3px;
}

.sidebar_search_playlist_type i.fa-list {
color: #66d1b6;
}

.sidebar_search_playlist_type i.fa-cogs {
color: #87aeea;
}

.sidebar_search_playlist_type i.fa-microphone {
color: #f0b36c;
}

.sidebar_search_playlist_description {
Expand Down
2 changes: 1 addition & 1 deletion public/themes/dark_on_light/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/themes/dark_on_light_hc/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/themes/default/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/themes/light_on_dark_hc/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/themes/openbroadcaster/style.css

Large diffs are not rendered by default.

Loading