summaryrefslogtreecommitdiff
path: root/cgi-bin/playlists/tracks.pm
blob: 5e737663b5ba378b44dfea887586b54ec2631933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package tracks;

use strict;
use Globals;
use Globals qw(%PLATTERS);
use Globals qw(@MUSIC);
use Globals qw(@VIDEO);
use Globals qw($target);
use Globals qw($delim);
use Globals qw($bgcolour);

sub new {
    my $self = {
        mime   => "text/html",
        playlist => openTemplate("search"),
        artistSearch => 0,
        count => 0};
        
    # show the logo if this is a new page
    my $logo;
    $logo = '<a href="front.plx"><img src="/platdoc/img/logo.gif" hspace=0 border=0></a>' if ($target eq '_top');
    $self->{playlist} =~ s/%LOGO%/$logo/;
    $self->{playlist} =~ s/%BGCOLOUR%/$bgcolour/g;
    
    bless ($self);
    return $self;
}

sub desc {
    return "Track Search Results";
    }
    
sub header {
    my $self = shift;
    $self->{playlist} .= '<ol>';
}

sub track {
    my $self = shift;
    my ($folder, $trackartist, $album, $year, $track, $url, $platter) = @_;
    
    $self->{count}++;

    $self->{playlist} .=  "<li>";

    #prepare urls
    
	$self->{playlist} .= '<a href="'.makeTrackURL($PLATTERS{$platter}, $url, $folder, $trackartist, $track ).'"><img src="/platdoc/img/filebutton_s.png" border=0 align="middle"></a><a href="'.makeTrackPlaylist($folder, $trackartist, $album, $track, $platter).'"><img src="/platdoc/img/playbutton_s.png" border=0 align="middle"> &quot;'.makeHTML($track)."</a>&quot;<br>";

    # prepare artist info
    foreach(  ($folder, $trackartist) ) {

        $self->{playlist} .= "<a href=\"artist.plx?name=".makeUnNice($_)."&exact=1\">".makeHTML($_)."</a>," if (/.+/);
    }
    chop $self->{playlist}; # remove trailing comma
    
    if (length $album > 0) { # album
        $self->{playlist} .= "<br>from <a href=\"artist.plx?name=".makeUnNice($folder)."&album=".makeUnNice($album)."&exact=1\">";
        $album =~ s/\(\d{4}\)(\/|$)/$1/;
        $self->{playlist} .=  makeHTML($album)."</a>";
        if ($year > 0) { $self->{playlist} .= " <small>($year)</small>" }
    }

    $self->{playlist} .= "<span style=\"font-size:4pt;\"><br>&nbsp;</span></li>\n";
}
    
sub dump {
    my $self = shift;
    $self->{playlist} =~ s/%SHORTCUTS%//;
    if ($self->{count} > 0)
    {
      my $REPORT = "Found ".$self->{count}." matches.";
      $self->{playlist} =~ s/%COUNT%/$REPORT/;
      return $self->{playlist}."</ol><p>$REPORT</body></html>";
    }
    else
    {
      $self->{playlist} =~ s/%COUNT%/<p>Sorry, nothing found./;

      return $self->{playlist}."</ol></body></html>";
    }
}

return 1;