-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax-favorite-arrange-MPD.php
148 lines (125 loc) · 6.4 KB
/
ajax-favorite-arrange-MPD.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
// +------------------------------------------------------------------------+
// | O!MPD, Copyright © 2015-2019 Artur Sierzant |
// | http://www.ompd.pl |
// | |
// | |
// | This program is free software: you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation, either version 3 of the License, or |
// | (at your option) any later version. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program. If not, see <http://www.gnu.org/licenses/>. |
// +------------------------------------------------------------------------+
require_once('include/initialize.inc.php');
require_once('include/library.inc.php');
require_once('include/play.inc.php');
global $cfg, $db;
authenticate('access_favorite');
$action = $_POST['action'];
$favorite_id = $_POST['favorite_id'];
$fromPosition = $_POST['fromPosition'];
$toPosition = $_POST['toPosition'];
$isMoveToTop = $_POST['isMoveToTop'];
$data = array();
$query1=mysqli_query($db,'SELECT player.player_name as pl, player_host, player_port, player_pass FROM player, session WHERE (sid = BINARY "' . cookie('netjukebox_sid') . '") and player.player_id=session.player_id');
$session1 = mysqli_fetch_assoc($query1);
$cfg['player_host'] = $session1['player_host'];
$cfg['player_port'] = $session1['player_port'];
$cfg['player_pass'] = $session1['player_pass'];
if ($action == 'moveItem') {
if ($isMoveToTop == 'true') {
mpd('playlistmove "' . $favorite_id . '" ' . $fromPosition . ' 0');
}
else {
if ($fromPosition > $toPosition) $toPosition++;
mpd('playlistmove "' . $favorite_id . '" ' . $fromPosition . ' ' . $toPosition);
}
}
elseif ($action == 'removeItem') {
$pl = mpd('playlistdelete "' . $favorite_id . '" ' . $fromPosition);
}
$playlist = mpd('listplaylistinfo "' . $favorite_id . '"');
?>
<script type="text/javascript">
$('[id^="add_"]').click(function(){
addClick();
});
</script>
<table width="100%" cellspacing="0" cellpadding="0" class="border">
<tr class="header">
<td class="icon"></td><!-- optional play -->
<td<?php if ($cfg['access_play']) echo' class="space"'; ?>></td>
<td>Artist</td>
<td class="textspace"></td>
<td>Title/file</td>
<td></td><!-- delete -->
</tr>
<?php
//$cfg['access_play'] = true;
$bottom = count($playlist['file']);
if ($bottom > 0) $bottom--;
$i = 0;
for ($i = 0; $i < count($playlist['file']); $i++) {
$artist = $playlist['Artist'][$i];
$title = (isset($playlist['Title'][$i]) ? $playlist['Title'][$i] : $playlist['file'][$i]);
//$title = $playlist['Title'][$i];
?>
<tr class="<?php echo ($i & 1) ? 'even' : 'odd'; ?> mouseover" id="track<?php echo $i; ?>" style="display:table-row;">
<td><?php if ($cfg['access_play']) {
echo '<a href="javascript:ajaxRequest(\'play.php?action=addSelect&menu=favorite&filepath=' . myUrlencode($playlist['file'][$i]) . '&track_id=' . $i . '\',evaluateAdd);" onMouseOver="return overlib(\'Add track\');" onMouseOut="return nd();"><i id="add_' . $i . '" class="fa fa-plus-circle fa-fw icon-small"></i></a>';
}
?></td>
<td><?php // echo $artist; ?></td>
<?php
$artist_array = explode(" ", $artist);
$lengths = array_map('strlen', $artist_array);
if (max($lengths) > 30) {
$break_method = 'break-all';
}
else {
$break_method = 'break-word';
}
?>
<td class="<?php echo $break_method;?>"><?php echo html($artist); ?></td>
<td></td>
<td><?php
if ($cfg['access_play']) {
echo '<a href="javascript:ajaxRequest(\'play.php?action=insertSelect&playAfterInsert=yes&filepath=' . myUrlencode($playlist['file'][$i]) . '&menu=favorite\',evaluateAdd);" onMouseOver="return overlib(\'play track\');" onMouseOut="return nd();">' . html($title) . '</a>';
}
else echo html($title); ?></td>
<td align="right" class="iconDel" style="position: relative">
<div id="menu-icon-div<?php echo $i ?>" <?php echo 'onclick="toggleMenuSub(' . $i . ');"'; ?>>
<i id="menu-icon<?php echo $i ?>" class="fa fa-fw fa-bars sign"></i>
</div>
<div id="menu-insert-div<?php echo $i ?>" style="display: none; position: absolute; bottom: 0;" onclick="arrangeFavItemMPD(<?php echo ($i >= $bottom ? $bottom : $i); ?>,-1,false, '<?php echo $favorite_id; ?>')">
<i class="fa fa-fw fa-angle-down sign"></i>
</div>
</td>
</tr>
<tr id="track-line<?php echo $i; ?>" class="line"><td colspan="12"></td></tr>
<tr id="track-menu<?php echo $i; ?>">
<td colspan="12">
<div class="menuSubRight" id="menu-sub-track<?php echo $i ?>" onclick='offMenuSub(<?php echo $i ?>);'>
<div class="icon-anchor" id="track<?php echo $i; ?>_delete" <?php if ($cfg['access_play'])
echo 'onclick="javascript:arrangeFavItemMPD(-1,' . $i . ',false,' . chr(39) . $favorite_id . chr(39) . ');"'; ?>>
Remove <i class="fa fa-times-circle fa-fw icon-small"></i></a>
</div>
<div class="icon-anchor" id="track<?php echo $i; ?>_move_top" <?php if ($cfg['access_play'])
echo 'onclick="javascript:arrangeFavItemMPD(0,' . $i . ',true,' . chr(39) . $favorite_id . chr(39) . ');"'; ?>>Move to top<i class="fa fa-long-arrow-up fa-fw icon-small"></i></div>
<div class="icon-anchor" id="track<?php echo $i; ?>_move" <?php if ($cfg['access_play'])
echo 'onclick="javascript:toggleInsert(\'on\',' . $i . ',false,' . chr(39) . $favorite_id . chr(39) . ')"'; ?>>Move <i class="fa fa-arrows-v fa-fw icon-small"></i></div>
<div class="icon-anchor" id="track<?php echo $i; ?>_move_bottom" <?php if ($cfg['access_play'])
echo 'onclick="javascript:arrangeFavItemMPD(' . $bottom . ',' . $i . ',false,' . chr(39) . $favorite_id . chr(39) . ');"'; ?>>Move to bottom<i class="fa fa-long-arrow-down fa-fw icon-small"></i></div>
</div>
</td>
</tr>
<?php
} ?>
</table>