Add a dequeue image.
[adorno.git] / www / index.php
blob04be0482ef5f41f1445c1d423fc4b6ef694094cd
1 <?php
2 include('always.php');
3 require_once("Session.php");
5 require_once("home-header.php");
7 function track_link( $trk, $link_title, $row_class = "" ) {
8 global $letter_get;
10 $track_link_url = sprintf( "?l=%s&a=%s&t=%s", urlencode($trk->album),
11 urlencode($trk->artist), urlencode($trk->title) );
12 $safe_title = htmlspecialchars($link_title);
13 $duration = preg_replace( "/^[0:]{1,4}/", "", $trk->duration );
14 $link = <<<EOHTML
15 <tr class="track$row_class">
16 <td class="track$row_class">
17 <a class="track$row_class" href="artist.php$track_link_url$letter_get" title="$trk->path_name">$safe_title</a>
18 </td>
19 <td class="track$row_class">$duration</td>
20 <th class="track$row_class">
21 <a class="alphabetica" href="edit_track.php$track_link_url" title="Edit Track Info">E</a>
22 </th>
23 </tr>
25 EOHTML;
27 return $link;
31 $album_artist_fmt = <<<EOHTML
33 <tr class="q_headline">
34 <td class="q_cell" colspan="3">
36 </td>
37 </tr>
38 EOHTML;
40 $artist_link_fmt = '<a href="/?type=artist&a=%s"><span class="q_artist">%s</span></a>';
41 $album_link_fmt = '<a href="/?type=album&l=%s"><span class="q_album">%s</span></a>';
43 $track_fmt = <<<EOHTML
45 <tr class="q_row">
46 <td class="q_cell" title="Position in queue">%d</td>
47 <td class="q_cell" title="Track number and name">
48 <span class="q_title">%d - %s</span>
49 </td>
50 <td class="q_cell" title="When this track will start playing">%s</td>
51 <td class="q_cell"><a href="/?i=%d&d=up">up</a> <a href="/?i=%d&d=dn">dn</a></td>
52 </tr>
53 EOHTML;
55 echo '<table width="100%"><tr valign="top"><td width="50%">';
57 $current_track = current_track();
58 $tracks = current_queue();
59 echo '<table id="queue">';
60 $last_artist = "";
61 $last_album = "";
62 $when = $current_track->finishing;
63 for( $k=0; isset($tracks[$k]); $k++ ) {
64 $v = $tracks[$k];
65 $position = $k + 1;
66 $escape_artist = urlencode($v->artist);
67 $escape_album = urlencode($v->album);
69 if ( $escape_artist != $last_artist || $escape_album != $last_album ) {
70 if ( $escape_artist != $last_artist && $escape_album != $last_album ) {
71 $links = sprintf( $album_link_fmt, $escape_album, $v->album);
72 $links .= "/" . sprintf( $artist_link_fmt, $escape_artist, $v->artist );
74 else if ( $escape_artist != $last_artist ) {
75 $links = sprintf( $artist_link_fmt, $escape_artist, $v->artist );
77 else if ( $escape_album != $last_album ) {
78 $links = sprintf( $album_link_fmt, $escape_album, $v->album);
80 printf( $album_artist_fmt, $links );
81 $last_artist = $escape_artist;
82 $last_album = $escape_album;
84 printf( $track_fmt, $position, $v->tracknum, $v->title, date('H:i:s', $when ), $position, $position );
85 $when += $v->dur_secs;
88 echo "</table>\n";
89 echo '</td><td width="50%">';
91 if ( isset($a) ) include('show-artist.php');
92 if ( isset($l) ) include('show-album.php');
94 include($ltrtype . '-list.php');
97 </td></tr></table>
98 </body>
99 </html>