Mostly working now - as long as I use hacked xmms2
[adorno.git] / www / index.php
blob8e18b286fc2e1755206fb3cfd9f56ded11790587
1 <?php
2 require_once("always.php");
3 require_once("Session.php");
4 require_once("PlayTracks.php");
6 $title = $system_name;
7 require_once("header.php");
9 function track_link( $trk, $link_title, $row_class = "" ) {
10 global $letter_get;
12 $track_link_url = sprintf( "?l=%s&a=%s&t=%s", urlencode($trk->album), urlencode($trk->artist)
13 , urlencode($trk->title) );
14 $safe_title = htmlspecialchars($link_title);
15 $duration = preg_replace( "/^[0:]{1,4}/", "", $trk->duration );
16 $link = <<<EOHTML
17 <tr class="track$row_class">
18 <td class="track$row_class">
19 <a class="track$row_class" href="artist.php$track_link_url$letter_get" title="$trk->path_na
20 me">$safe_title</a>
21 </td>
22 <td class="track$row_class">$duration</td>
23 <th class="track$row_class">
24 <a class="alphabetica" href="edit_track.php$track_link_url" title="Edit Track Info">E</a>
25 </th>
26 </tr>
28 EOHTML;
30 return $link;
34 $album_artist_fmt = <<<EOHTML
36 <tr class="q_headline">
37 <td class="q_cell" colspan="3">
39 </td>
40 </tr>
41 EOHTML;
43 $artist_link_fmt = '<a href="/artist.php?a=%s"><span class="q_artist">%s</span></a>';
44 $album_link_fmt = '<a href="/album.php?l=%s"><span class="q_album">%s</span></a>';
46 $track_fmt = <<<EOHTML
48 <tr class="q_row">
49 <td class="q_cell" title="Position in queue">%d</td>
50 <td class="q_cell" title="Track number and name">
51 <span class="q_title">%d - %s</span>
52 </td>
53 <td class="q_cell" title="When this track will start playing">%s</td>
54 </tr>
55 EOHTML;
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 ) );
85 $when += $v->dur_secs;
88 echo "</table>\n";
91 </body>
92 </html>