Move always.php into web root directory and rewrite.
[adorno.git] / inc / menu.php
blob4f4c9742032c69bae552031a1a3ac768c446e1a9
1 <?php
2 require_once("LinkClass.php");
3 require_once("DataEntry.php");
5 // Here's a bit of misdirection that ensures the URL always has a ?var=value at the beginning.
6 if ( ! strpos( $refresh_url, '?' ) ) $refresh_url .= "?s=" . substr( md5(rand(1,50000)), 1, 3 );
8 $url = ' <a href="'.str_replace('%','%%',$refresh_url).'&submit=a&action=%s">';
9 $url .= '<img src="/img/%s" title="%s" /></a>'."\n";
10 $controls = "";
12 $controls .= sprintf( $url, "pause", "pause.png", "Pause the playback");
13 $controls .= sprintf( $url, "resume", "resume.png", "Resume the paused playback");
14 $controls .= sprintf( $url, "next", "next.png", "Skip ahead to the next track");
15 $controls .= sprintf( $url, "clear", "clear.png", "Clear the currently queued tracks");
16 $controls .= sprintf( $url, "off", "off.png", "Shut music server down and turn off");
18 $url = "";
19 if ( "$lltr" <> "" ) $url .= "&lltr=" . urlencode($lltr);
20 if ( "$a" <> "" ) $url .= "&a=" . urlencode($a);
21 elseif ( "$l" <> "" ) $url .= "&l=" . urlencode($l);
22 $ltrtype = "artist";
23 if ( preg_match( '/album.php/', $REQUEST_URI) ) $ltrtype = "album";
25 $url = $PHP_SELF . ereg_replace( '^&', '?', $url . '&' );
26 if ( !ereg( '/(artist|album)\.php', $url) ) {
27 error_log( "$sysabbr: DBG: >>$url<< " . (ereg('/(artist|album)\.php', $url)? 'true':'false') );
28 $url = ereg_replace( '/[a-z0-9_-]+\.php', '/artist.php', $url );
30 $ls = new LinkSet( '<a href="'.str_replace('%','%%',$url).'altr=%s"%s%s>%s</a>', 'alphabetica' );
31 error_log( "$sysabbr: DBG: >>$ls->template<<" );
33 $menubar = '<table width="100%" border="0"><tr class="tr_menu"><td class="h3">'.ucfirst($ltrtype).'s:</td><td>';
34 $qry = new PgQuery("SELECT letter, pattern, $ltrtype"."_count AS count FROM letter_groups ORDER BY 1;");
35 if ( $qry->Exec("artist") && $qry->rows > 0 ) {
36 while ( $letter = $qry->Fetch() ) {
37 $help = "Display $letter->count $ltrtype"."s beginning with the letter '$letter->letter'.";
38 $display = $letter->letter;
39 if ( trim("$letter->letter") == "#" ) {
40 $help = 'List all '."$letter->count $ltrtype".'s not beginning with an alphabetic character.';
42 $menubar .= $ls->Link( urlencode($letter->pattern), $display, $help );
45 $menubar .= '</td>';
46 // $menubar .= '<td class="h3">Search:</td>';
47 $sf = new EntryForm( $refresh_url, $GLOBALS, true );
48 $sf->TrivialForm();
49 $menubar .= $sf->StartForm(array('method' => 'get'));
50 if ( isset($lltr) ) $menubar .= $sf->HiddenField( 'lltr', $lltr );
51 if ( isset($altr) ) $menubar .= $sf->HiddenField( 'altr', $altr );
52 if ( isset($a) ) $menubar .= $sf->HiddenField( 'a', $a );
53 else if ( isset($l) ) $menubar .= $sf->HiddenField( 'l', $l );
54 $f = new EntryField( 'text', 'search',
55 array( 'title' => 'Enter a regular expression to search for artists / albums that match that',
56 'size' => '15', 'class' => 'search_field'),
57 "$search" );
58 $menubar .= '<td align="right">'.$f->Render().'</td>';
59 $menubar .= '<td>'.$sf->SubmitButton("submit","Search").'</td>';
60 $menubar .= $sf->EndForm();
62 $ls = new LinkSet("", "alphabetica");
63 $menubar .= '<td align="right">';
64 $menubar .= $ls->Link("/", "Home");
65 $menubar .= $ls->Link("/artist.php", "Artist");
66 $menubar .= $ls->Link("/album.php", "Album");
67 // $menubar .= $ls->Link("/genre.php", "Genre");
68 // $menubar .= $ls->Link("/stream.php", "Streams");
69 $menubar .= '</td>';
71 $menubar .= '</tr></table>';
73 // $menubar .= '<hr class="thin_hr">';
75 echo <<<EOHTML
76 <body>
77 <table id="header">
78 <tr>
79 <td id="now_playing">
80 <span class="track_title">$current_track->title</span>
81 <span class="album_title">$current_track->album</span>
82 <span class="artist_name">$current_track->artist</span>
83 </td>
84 <td id="controls">
85 $controls </td>
86 </tr>
87 </table>
88 <div id="menu">
89 $menubar
90 </div>
91 <div id="playurl">
92 <form id="urlform" method="POST"><input name="url" class="playurl" type="text"><input class="submit" type="submit" name="act" value="Play URL"></form>
93 </div>
94 <div id="content">
96 EOHTML;