diff options
Diffstat (limited to 'cgi-bin/artist.plx')
| -rw-r--r-- | cgi-bin/artist.plx | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/cgi-bin/artist.plx b/cgi-bin/artist.plx new file mode 100644 index 0000000..cb6ea29 --- /dev/null +++ b/cgi-bin/artist.plx @@ -0,0 +1,141 @@ +#!c:/perl/bin/perl + +use CGI; +use strict; +use Search; +use Globals; +use Globals qw($delim); +use Globals qw($debug); +use Globals qw(%PLATTERS); +use Globals qw($target); +use Globals qw($bgcolour); + +my $query = CGI::new(); +my $artist = $query->param( "name" ); +$artist =~ s/(The |)(.*?)(, The|)/$2/; +my $reqAlbum = $query->param( "album" ); +my $inv = $query->param( "inv" ); +my $target = $query->cookie("target"); +my $webpage; + +if ( $target =~ /narrow/ ) +{ + $webpage = openTemplate("artistNarrow"); +} +else +{ + $webpage = openTemplate("artist"); +} + +Search::setArtist($artist); +Search::searchFor('album'); +Search::setExact(1); +if (length $inv > 0) { Search::setInv(split(',', $inv)) } +else { Search::setInv(keys %PLATTERS) } + +my @albums = Search::go() unless !$artist; + +my $albumlist; +my $hasMisc; +my $init; +my $index; +my $albumcount; +my $countreport; +my $firstAlbum; +foreach( @albums ) { + my ($year, $album, $platter) = split($delim); + my $selected; + print "$year, $album, $platter\n" if ($debug); + my $link = 'search.plx?artist='.makeUnNice($artist).'&album='.makeUnNice($album). + '&exact=1&searchFor=track&inv='.$platter; + + if ($album =~ /^\Q$reqAlbum\E$/) { + $init = $link.'&output=album'; + $selected = ' selected'; $reqAlbum = 'found'; + } + + $albumcount++; + + if ($album =~ /^Miscellany$/) { + if (!$hasMisc) { + $index = $link.'&output=album'; + $hasMisc = 1; + } + } + else { + + $firstAlbum = $link.'&output=album' if (!$firstAlbum); + $albumlist .= "\n<option value=\"$link\&output=album\"$selected>".makeNice($album); + + } +} + +if ($hasMisc) { + $albumlist = "<option value=\"$index\">Info & Miscellany\n$albumlist"; +} +else { + $index = '/platdoc/emptyAlbum.html' ; + if ($firstAlbum && !$init) { + $init = $firstAlbum; + } +} +$albumlist = "$albumlist\n<option value=\"search.plx?artist=".makeUnNice($artist)."&exact=1&searchFor=track&output=album\">Show all"; + +if ($albumlist) { + $albumlist = '<select onChange="switchAlbum(this.options[this.selectedIndex].value)">">'.$albumlist."</select></br>"; + $countreport = "$albumcount found"; +} +else { + $countreport = "None"; +} + +$init = $index if (!$init); + +# abcmanager links +my $rejig; +my %ABCS = getABCs(); +my $thisabc = $ABCS{$artist}; +if ($artist =~ / / || defined $thisabc) { + + $rejig = '<img src="/platdoc/img/editbutton.png" width=32 height=32 alt="Edit" align="left"><nobr><small>Currently indexed as <br><strong>'; + + if (defined $thisabc ) { + $thisabc =~ s/\.abc.*//; + $rejig .= makeHTML($thisabc).'</strong><br>'. + '<a href="abcmanager.plx?artist='.makeUnNice($artist).'&action=remove">Clear</a></small></nobr>'; + } + else { + my $newabc = $artist; + $newabc =~ s/(.*) (.*?)$/$2 $1/; + $rejig .= makeHTML($artist).'</strong><br>'. + '<a href="abcmanager.plx?artist='.makeUnNice($artist).'&abc='.makeUnNice($newabc).'&action=add">Index as '.makeHTML($newabc).'</a></small></nobr>'; + } +} +$webpage =~ s/%INDEX%/$index/g; +$webpage =~ s/%SECTIONS%/$albumlist/g; +$webpage =~ s/%COUNT%/$countreport/g; +$webpage =~ s/%ABC%/$rejig/g; + +$init =~ s/'/\\'/g; +$webpage =~ s/%INIT%/$init/g; + +$webpage =~ s/%ARTIST%/$artist/g; + +my $urlartist = makeUnNice($artist); +$webpage =~ s/%URLARTIST%/$urlartist/g; + +$artist =~ s/'/\\'/g; +$webpage =~ s/%JSARTIST%/$artist/g; + +$webpage =~ s/%BGCOLOUR%/$bgcolour/g; + +print $webpage; + + + + + + + + + |
