#!/usr/bin/perl use Pg; use CGI qw(:standard); use CGI qw(:cgi-lib); use CGI::Carp qw(fatalsToBrowser); ########################################################### # Copyright Paul Barrette and the Trajan Column Project, # # 1999. # # Interested parties may use parts and/or adapt # # this script for their own NON-COMMERCIAL projects # # provided that this copywrite notice is kept intact # # at the head of the CGI script. # # Thank you. # # Paul Barrette, barretp@mcmaster.ca # ########################################################### print header; #ReadParse(); #pass the spiral number and the letter, e.g. 02a $cartnum=$ARGV[0]; #set some vars for the images below: if ($cartnum <10){ $spiralname="images/pics0".$cartnum.".gif"; $scene = "images/picp0".$cartnum.".gif"; $numonly=substr $cartnum, 0,1; }else{ $spiralname="images/pics".$cartnum.".gif"; $scene = "images/picp".$cartnum.".gif"; $numonly=substr $cartnum, 0,2; } #get header and footer $header=`cat stndheader.txt`; $footer=`cat stndfooter.txt`; #extract the letter at the end, don't chop it we may need it $ofst = length $cartnum; $letter = substr $cartnum, $ofst -1,1; $capletter=uc $letter; #build links for the panel map cart1a.htm -cart1d.htm $panel1="buildcartoon.cgi?".$numonly."a"; $panel2="buildcartoon.cgi?".$numonly."b"; $panel3="buildcartoon.cgi?".$numonly."c"; $panel4="buildcartoon.cgi?".$numonly."d"; #next and previous panels if ($numonly > 1 && $numonly < 24) { $panel5="buildcartoon.cgi?".($numonly -1)."d"; #previous panel/spiral $panel6="buildcartoon.cgi?".($numonly +1)."a"; #next panel/spiral }elsif ($numonly == 1){ $panel5="buildcartoon.cgi?24a"; #previous panel/spiral $panel6="buildcartoon.cgi?".($numonly +1)."a"; #next panel/spiral }elsif ($numonly == 24){ $panel5="buildcartoon.cgi?".($numonly -1)."d"; #previous panel/spiral $panel2="buildcartoon.cgi?1a"; #next panel/spiralk NB only one scene in 24 } #navagation bar #next or previous spirals if ($numonly > 1 && $numonly < 24) { $previous="buildcartoon.cgi?".($numonly -1)."a"; $next="buildcartoon.cgi?".($numonly + 1)."a"; } elsif ($numonly == 24) { $previous="buildcartoon.cgi?23d"; $next="buildcartoon.cgi?1a"; } elsif ($numonly == 1) { $previous="buildcartoon.cgi?24a"; $next="buildcartoon.cgi?2a"; } #now find out whether we are a,b,c or d and set the previous & next #build a hash, check the hash and then launch the appropriate sub handler %LETTERS = ( 'a' => \&loadA, 'b' => \&loadB, 'c' => \&loadC, 'd' => \&loadD ); #check the hash, the block checks for the key letter and fires off the sub assciated with it. if ($LETTERS{$letter}) {$LETTERS{$letter}->();} #sub handlers sub loadA {$nextscene=$panel2; $previousscene=$panel5;} sub loadB {$nextscene=$panel3; $previousscene=$panel1;} sub loadC {$nextscene=$panel4; $previousscene=$panel2;} sub loadD {$nextscene=$panel6; $previousscene=$panel3;} #set up main spiral map here, 23-24 are on the same map! if ($numonly <23 ){ #use this map for <23 $mainspiralmap="\n\n\n\n\n"; }else { $mainspiralmap="\n\n\n\n\n\n"; } #when we sort out what images are in which panel, set #$panelmap here #method: #1. call db, sql = "SELECT map from trajmap where spiral=\'$cartnum\'" #2 figure out whether we can pass it in the same stream as below and extract it #3 test output for "nomap" = no imagemap available for this panel, otherwise build a map #set source for panel below to # # # #################################### #CONNECT TO THE DATABASE and grab related images to this spiral #================================ $sql ="SELECT key,vwdescription,drumnumber,sideofcolumn from traj where drumnumber ~'^$numonly,'"; $sql2 = "SELECT map from trajmap where spiral=\'$cartnum\'"; $conn = Pg::connectdb("dbname=trajan"); #execute the query Pg::doQuery($conn, $sql, \@ary); Pg::doQuery($conn, $sql2, \@ary2); #================================ #build the links for these images for $i(0..@ary){ #build spiral and panel refs #strip spaces $sideofcolumn=$ary[$i][3]; $sideofcolumn=~s/ //g; if ($sideofcolumn eq "1-2"){ $apanel="a-b";} if ($sideofcolumn eq "2-3"){ $apanel="b-c";} if ($sideofcolumn eq "3-4"){ $apanel="c-d";} if ($sideofcolumn eq "1-4"){ $apanel="a-d";} #now set abcd if ($sideofcolumn eq "1"){ $apanel="a";} if ($sideofcolumn eq "2"){ $apanel="b";} if ($sideofcolumn eq "3"){ $apanel="c";} if ($sideofcolumn eq "4"){ $apanel="d";} @assocspirals=split ",", $ary[$i][2]; ############ #this works well comment out for now until image maps are done #if ($ary[$i][2]) { #$dbimages.="