summaryrefslogtreecommitdiff
path: root/cgi-bin/playlists/artistlist.pm
blob: 5c419c795e804b24efe0e896b874120ab864e918 (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
package artistlist;

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,
        section => undef,
        shortcuts => '<br>',        
        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/;
    
    bless ($self);
    return $self;
}

sub desc {
    return "Artist Search Results";
    }
    
sub header {
    my $self = shift;
}

sub track {
    my ($self, $abc, $artist) = @_;
    $artist = $abc if !$artist;
    my $firstletter = substr($abc, 0, 1);
    if ($firstletter ne $self->{section}) {
        $self->{playlist} .= '<hr style="color:white; clear:both" align="left">' if ($self->{section});
        $self->{playlist} .= '<span class="title">'.$firstletter."</span><a name=\"".uc($firstletter)."\">\n</a><p>";
        $self->{section} = $firstletter;
        $self->{shortcuts} .= '<a href="#'.$firstletter.'"><b>'.$firstletter.'</b></a>&nbsp;';
    }
    my $realength = $artist; 
    $realength=~s/&[^;]*;/x/g;
    $realength = (int(length($realength) / 20) +1)*120;
    $self->{playlist} .= "<div style=\"float:left; width:".$realength."px\">".
        "<a href=\"artist.plx?name=".makeUnNice($artist)."&exact=1\">".makeHTML($artist)."</a>&nbsp;</div>";
    $self->{count}++;
}
    
sub dump {
    my $self = shift;
    $self->{playlist} .= "\n<br style=\"clear:both\">";
    my $shortcuts = $self->{shortcuts};
    $self->{playlist} =~ s/%SHORTCUTS%/$shortcuts/;
    
    if ($self->{count} > 0)
    {
      my $REPORT = "Found ".$self->{count}." artists.";
      $self->{playlist} =~ s/%COUNT%/$REPORT/;
      return $self->{playlist}."</ol><p>$REPORT</body></html>";
    }
    else
    {
      $self->{playlist} =~ s/%COUNT%/<p>Sorry, no-one found./;

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

return 1;