Сохранение списков
[mpd-web.git] / ajax / editplaylist.php
1 <?php
2
3 function escapePhpString($target) {
4     $replacements = array(
5             "'" => '\\\'',
6             "\\" => '\\\\',
7             "\r\n" => "\\r\\n",
8             "\n" => "\\n"
9     );
10     return strtr($target, $replacements);
11 }
12
13 include('mpd.php');
14 $dir = $_REQUEST['dir'];
15
16 ?>
17   <div id="playlist_menu">
18         <table>
19                 <tr>
20                         <td><span class="button" onclick="RefreshPlaylist()"><img width="20" src="images/playlist.png"></span><td>
21                         <td><span class="button" onclick="return confirm('Добавить все. Вы уверены?') ? PlaylistEditCommand('addall','<?php echo escapePhpString($dir);?>') : false;" ><img width="20" src="images/addall.png"></span><td>
22                         <td><span class="button" onclick="PlaylistEditItemsCommand('addselected','<?php echo escapePhpString($dir);?>')"><img width="20" src="images/addselected.png"></span><td>
23                 </tr>
24         </table>
25   </div>
26   <div id="items">
27     <table>
28     <tr id="items_heading">
29         <td></td><td>Название</td><th colspan="2">Управление</th>
30     </tr>
31     <?php
32       $dirs=$mpd->GetDir($dir);
33     ?>
34       <tr id="home"><td></td><td><span class="button" onclick="EditPlayList('<?php echo escapePhpString(cut_upperDir($dir));?>')"><img width="20" src="images/left.png"></span></td><td></td><td></td>
35
36      <?php for($i=0;$i<count($dirs);$i++) {?>
37       <tr id="item<?php if($i%2==0) { echo "Even";}else{echo "Odd";}?>">
38           <td id="track_number"> <a name="<?php echo $i;?>"></a></td>
39           <?php if($dirs[$i]['type']=="directory") {?>
40                 <td id="file"><span class="button" onclick="EditPlayList('<?php echo escapePhpString($dirs[$i]['name']);?>')"><?php
41                         if ($dirs[$i]['name']==$dirs[$i]['title']) {
42                                 echo htmlentities(cut_lastDir($dirs[$i]['name']));
43                         } else {
44                                 echo htmlentities($dirs[$i]['title']);
45                         }
46                 ?></span></td><td><span class="button" onclick="PlaylistEditCommand('adddir','<?php echo escapePhpString($dirs[$i]['name']);?>')"><img width="15" src="images/plus.png"></span></td>
47           <?php } else {?>
48                 <td id="file"><?php
49                         if ($dirs[$i]['name']==$dirs[$i]['title']) { 
50                                 echo htmlentities(cut_file($dirs[$i]['name']));
51                         } else {
52                                 echo htmlentities($dirs[$i]['title']);
53                         }
54                 ?></td><td><span class="button" onclick="PlaylistEditCommand('addfile','<?php echo escapePhpString($dirs[$i]['name']);?>')"><img width="15" src="images/plus.png"></span></td>
55           <?php } ?>
56           <td id="checkbox"><input type="checkbox" name="itemlist[]" value="<?php echo $i;?>"></td>
57       </tr>
58     <?php
59       }
60     ?>
61     </table>
62   </div>
63
64    <div id="playlist_menu">
65         <table>
66                 <tr>
67                         <td><span class="button" onclick="RefreshPlaylist()"><img width="20" src="images/playlist.png"></span><td>
68                         <td><span class="button" onclick="return confirm('Добавить все. Вы уверены?') ? PlaylistEditCommand('addall','<?php echo escapePhpString($dir);?>') : false;" ><img width="20" src="images/addall.png"></span><td>
69                         <td><span class="button" onclick="PlaylistEditItemsCommand('addselected','<?php echo escapePhpString($dir);?>')"><img width="20" src="images/addselected.png"></span><td>
70                 </tr>
71         </table>
72   </div>