Fix queue ordering, and handling of queue containing repeated tracks.
[adorno.git] / inc / album-list.php
blob0f88a5a5e773844f6e000c8a607fcba54c13f332
1 <?php
2 /**
3 * List albums
4 */
5 echo "<h3>Albums</h3>\n<p>";
6 $where = '';
7 $params = array();
8 if ( isset($search) ) {
9 $where = "(artist ~* :search OR album ~* :search OR title ~* :search OR path_name ~* :search) ";
10 $params[':search'] = $search;
12 if ( isset($altr) ) {
13 $altr = trim($altr);
14 $where .= ($where == ''? '' : ' AND ');
15 $where .= '(album ~ :album_match)';
16 $params[':album_match'] = '^'.$altr;
18 if ( $where != '' ) $where = 'WHERE '. $where;
19 $sql = 'SELECT distinct ON (lower(album)) album FROM tracks '.$where.' ORDER BY lower(album)';
20 $qry = new AwlQuery( $sql, $params );
22 if ( $qry->Exec('album') && $qry->rows() > 0 ) {
23 while ( $album = $qry->Fetch() ) {
24 $display = htmlspecialchars($album->album);
25 if ( trim($display) == "" ) $display = "&laquo;unknown&raquo;";
26 echo " <a href=\"?type=album&l=" . urlencode($album->album) . "$letter_get\" class=\"album\">$display</a>\n";