#!/usr/local/bin/perl #NB: on Demon, needs to be #!/bin/perl #NB: on Dolly, needs to be #!/usr/local/bin/perl # please do a chmod 755 on me when you've uploaded #what do we need then? require 'D:\wwwroot\San Diego Museum of Art\www.sdmart.org\image\cogapp-cgi-lib.pl'; #Read in my arguments &ReadParse(*theForm); $sendMail = $theForm{'sendMail'}; $highlightAtoZ = $theForm{'highlightAtoZ'}; $highlightCatSubSection = $theForm{'highlightCatSubSection'}; $pageTitle = $theForm{'pageTitle'}; #set to default below after script has run. $queryartist = $theForm{'artist'}; $queryartists = $theForm{'artists'}; $queryterm = $theForm{'term'}; $queryterms = $theForm{'terms'}; $querysubject = $theForm{'subject'}; $querycatalogue = $theForm{'catalogue'}; $querysubjects = $theForm{'subjects'}; $querypainting = $theForm{'painting'}; $queryblowup = $theForm{'blowup'}; $querydetail = $theForm{'detail'}; $queryglossary = $theForm{'glossary'}; $queryhowbig = $theForm{'howbig'}; $querywheremade = $theForm{'wheremade'}; $queryalink = $theForm{'alink'}; $queryelink = $theForm{'elink'}; $thisaxis = $theForm{'axis'}; $queryreturn = $theForm{'return'}; $queryscript = $theForm{'script'}; $wotmode = $theForm{'mode'}; $swfDisplay = $theForm{'swfDisplay'}; $querysearch = $theForm{'search'}; $searchmode = $theForm{'searchmode'}; $searchtype = $theForm{'searchtype'}; $image = $theForm{'Image'}; $collection = $theForm{'Collection'}; $searchStr = $theForm{'Search'}; $start = $theForm{'Start'}; $end = $theForm{'End'}; $searchMode = $theForm{'SearchMode'}; $onlyOneMatch = $theForm{'onlyOneMatch'}; # where do I look for things? if ( "$ENV{'HTTP_HOST'}" =~ 'dolly' ) { # testing on Dolly $docs = 'templates/';#'../docs/uk/'; $dbs = 'dbs/';#'../docs/uk/'; if ( $wotmode eq 'test' ) { $cgipath = 'image.pl'; } else { $cgipath = 'image.pl'; } $imagePath = 'images/'; } elsif ( "$ENV{'HTTP_HOST'}" =~ 'sdmart.org' ) { # probable final location on Demon (www.sdmart.org) if ( $wotmode eq 'test' ) { $docs = 'D:\wwwroot\SanDiego Museum of Art\www.sdmart.org\image\templatesdev\\'; $dbs = 'D:\wwwroot\San Diego Museum of Art\www.sdmart.org\image\dbsdev\\'; $cgipath = 'http://cgi.www.sandiegomuseum.org/cgi-bin/www.sandiegomuseum.org/imagedev.pl'; } else { $docs = 'D:\wwwroot\San Diego Museum of Art\www.sdmart.org\image\templates\\'; $dbs = 'D:\wwwroot\San Diego Museum of Art\www.sdmart.org\image\dbs\\'; $cgipath = 'http://www.sdmart.org/image/image.pl'; } $imagePath = 'http://www.sdmart.org/image/images/'; } else { # initial public location at sdmart.com if ( $wotmode eq 'test' ) { $docs = '../secure_html/templatesdev/'; $dbs = '../secure_html/dbsdev/'; $cgipath = 'image.pl'; } else { $docs = '../secure_html/templates/'; $dbs = '../secure_html/dbs/'; $cgipath = 'image.pl'; } $imagePath = 'http://www.sandiegomuseum.org/imageimages/'; } $mapsPath = $imagePath.'maps/'; $fullsizes = $imagePath.'fullsize/'; $thumbs = $imagePath.'thumbs/'; $navImages = $imagePath.'nav/'; $thdetails = $thumbs.'details/'; $fsdetails = $fullsizes.'details/'; $movies = $imagePath.'movies/'; $todaysSelections = $dbs.'todaysSelections/'; #assign file names $moviesdb = $dbs.'movies.db'; $artistdb = $dbs.'artist.db'; $encyclodb = $dbs.'encyclo.db'; $subjectdb = $dbs.'subject.db'; $scriptdb = $dbs.'script.db'; $glossarydb = $dbs.'glossary.db'; $worksdb = $dbs.'works.db'; $imagesdb = $dbs.'image.db'; $mapsdb = $dbs.'maps.db'; $linksdb = $dbs.'links.db'; $hotaxes = $dbs.'hotaxes.db'; $coldaxes = $dbs.'coldaxes.db'; $sectionsdb = $dbs.'sections.db'; $cataloguedb = $dbs.'catalogue.db'; $buttonsdb = $dbs.'buttons.db'; $header = $docs.'header.html'; $indexpicker = $docs.'indexpicker.html'; $footer = $docs.'footer.html'; $aIndexTemplate = $docs.'aIndex.html'; $eIndexTemplate = $docs.'eIndex.html'; $sIndexTemplate = $docs.'sIndex.html'; $artistTemplate = $docs.'artist.html'; $termTemplate = $docs.'term.html'; $subjectTemplate= $docs.'subject.html'; $thumbTemplate = $docs.'thumb.html'; $workTemplate = $docs.'work.html'; $scriptTemplate = $docs.'script.html'; $blowupTemplate = $docs.'blowup.html'; $fsPicTemplate = $docs.'fspic.html'; $buPicTemplate = $docs.'bupic.html'; $detPicTemplate = $docs.'detpic.html'; $probTemplate = $docs.'problem.html'; $glossTemplate = $docs.'glossary.html'; $howbigTemplate = $docs.'howbig.html'; $wheremadeTemplate = $docs.'wheremade.html'; $catTemplate = $docs.'catalogueList.html'; $searchresult = $docs.'searchresult.html'; $searchChoice = $docs.'searchChoice.html'; $detailTemplate = $docs.'detail.html'; $labelTemplate = $docs.'label.html'; $prevTemplate = $docs.'prev.html'; $nextTemplate = $docs.'next.html'; $featureTemplate= $docs.'feature.html'; $swfPlacerTemplate = $docs.'swfPlacer.html'; $swfMovieTemplate = $docs.'swfMovie.html'; $todaysSelectionTemplateFile = $docs.'todaysSelection.html'; # things to go into row 4 of the header $row4picker = $docs.'row4picker.html'; $row4cat = $docs.'row4cat.html'; $row4search = $docs.'row4search.html'; $row4artist = $docs.'row4artist.html'; $row4work = $docs.'row4work.html'; $row4term = $docs.'row4term.html'; $row4subject = $docs.'row4subject.html'; # some html tags $ss = ''; $se = ''; $p = '
';
$fs = '';
$fs = '';
$fs2 = '';
$fe = '';
# some globals
$newAxis = time();
$protectedAxes = 2; # AllMuseums and AllArtists
$keepAxes = 60*60*24; # 24 hours
#this is the standin image name for pictures not to show on the web
$defaultImage = "NotForWeb.gif";
$contentType = "Content-type: text/html\n\n";
$contentType = "Content-type: text/plain\n\n";
$htmlReturn = &GenericProblem( $query );
$DisplayAtATime = 20;
%gBtnArray = ( '','' );
%gBtnArrayAltTags = ( '','' );
$noofbtns = &ButtonsArray();
@sectionPicker = ( 'artist', 'subject', 'catalogue', 'term', 'search' );
@azPicker = split( '', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' );
@catalogueSubSectionPicker = ( 'american', 'european', 'farEastern', 'modern', 'southAsian', 'printsAndDrawings' );
%catalogueSubSectionGivesImageNames = ( 'AMERICAN ART','american', 'EUROPEAN ART','european', 'FAR EASTERN ART','farEastern', 'MODERN ART','modern', 'SOUTH ASIAN ART','southAsian', 'PRINTS & DRAWINGS','printsAndDrawings' );
$htmextn = '.htm';
$htmlextn = '.html';
$oCurly = '{';
$cCurly = '}';
# debug stuff
$DEBUG = 'variables';
$DEBUG = 'false';
#this is the scale image used in 'How big is it?'
$manpix = "scale.gif";
#dimensions (pixels & cms of the man in the howbigisit popup)
$manwidthpix = 184;
$manheightpix = 291;
$manheightin = 72;
$manheightcm = 200;
$popupborder = 45;
#############################
#are we doing a GET )if not what are we doing?)
if ($ENV{'REQUEST_METHOD'} eq "POST" || $ENV{'REQUEST_METHOD'} eq "GET") {
if ( $DEBUG eq 'variables' ) {
print &GenericProblem( "{Request method=$ENV{'REQUEST_METHOD'}} /g;
$text = &ZParseLinks( $text );
$body =~ s/text/$text/;
# go find some picture links
local( $links ) = &GetList( "$code\t", $linksdb );
local( @piclinks ) = split( "\n", $links );
local( $thumb ) = &ReadTemplate( $thumbTemplate, "", "" );
local( $axes ) = "";
local( $c ) = 0;
# for all the picture links
for ($[ .. $#piclinks) {
local( @onework ) = &WorkDetails( $piclinks[$_] );
local( @oneimag ) = &ImageDetails( $onework[0] );
#remember - a work will not appear in the imagedb if it is not to be shown on the web
#in this case substitute the default image
local( $imageFileName, $imageAltTag ) = &GetImageOrDefaultInfo( $oneimag[2], $onework[2] );
$body =~ s/debug/$oneimag[0],$oneimag[1],$oneimag[2],$oneimag[3],$oneimag[4],$oneimag[5],$oneimag[6]/;
# substitute the template into the first holder in the html
$body =~ s/pic/$thumb/;
$body =~ s/thtitle/$onework[2]/g;
$body =~ s/altTag/$imageAltTag/g;
$body =~ s/date/$onework[3]/;
$body =~ s/name/$onework[5]/;
local( $th ) = "$thumbs$imageFileName";
$body =~ s/imag/$th/;
local( $width ) = &GetPhraseWidth( $oneimag[4] );
$body =~ s/w/$width/;
local( $height ) = &GetPhraseHeight( $oneimag[3] );
$body =~ s/h/$height/;
$body =~ s/actn/$cgipath?mode=mode&painting=$onework[0]insertAxis/;
$axes .= "$oneimag[0]," if ($oneimag[0] ne '');
$c++;
}
# loop up to 10 to empty any remaining tags
$body =~ s/pic//g;
# process the navigation
if ( $axis ne '' ) {
$temp = "$cgipath?mode=mode&artist=" . &GoAlongAxis( $query, -1, $axis ) . "&axis=$axis";
$prev =~ s/hot/$temp/;
$body =~ s/prev/$prev/;
$temp = "$cgipath?mode=mode&artist=" . &GoAlongAxis( $query, 1, $axis ) . "&axis=$axis";
$next =~ s/hot/$temp/;
$body =~ s/next/$next/;
} else {
$body =~ s/prev//;
$body =~ s/next//;
}
chop( $axes );
if ( $c > 1 ) {
# store the axis
$body =~ s/insertAxis/&axis=$newaxis/g;
$error = &WriteFile( "$newaxis\t$axes", "\n", $hotaxes );
} else {
$body =~ s/insertAxis//g;
}
$pageTitle = $attrib;
return &PrintHeader() . $body;
}
sub GetCatalogue {
local( $query, $axis, $newaxis, $s, $e, $highlightCatSubSection ) = @_;
local( $axes ) = '';
local( $c ) = 0;
# match the artist id
local( $term ) = &GetOneEntry( $query, $cataloguedb );
local( @oneterm ) = split( "\t", $term );
local( $code, $indexchar, $sortName, $upTitle, $subTitle, $sound, $text ) = @oneterm;
# read in the templates
local( $head ) = &ReadTemplate( $header, $upTitle, "" );
$head = &DoButtons( 'catalogue', $head, @sectionPicker );
local( $row4 ) = &ReadTemplate( $row4cat, "", "" );
#makes sub-articles stay highlighted
$highlightCatSubSection = &GetCatSubSectionName( $upTitle ) if ( $highlightCatSubSection eq '' );
$row4 = &DoButtons( $highlightCatSubSection, $row4, @catalogueSubSectionPicker );
local( $body ) = &ReadTemplate( $catTemplate, "", "" );
local( $foot ) = &ReadTemplate( $footer, "", "" );
# substitute some details into the templates
$head =~ s/row4/$row4/;
$body =~ s/header/$head/;
$body =~ s/footer/$foot/;
$body =~ s/name/$upTitle/;
$text =~ s// /g;
$text = &ZParseLinks( $text );
$body =~ s/text/$text/;
# go find some picture links
local( $links ) = &GetList( "$code\t", $linksdb );
local( @piclinks ) = split( "\n", $links );
local( $thumb ) = &ReadTemplate( $thumbTemplate, "", "" );
# for all the picture links
for ($[ .. $#piclinks) {
local( @onework ) = &WorkDetails( $piclinks[$_] );
local( @oneimag ) = &ImageDetails( $onework[0] );
#if there is no imagedb entry for this work or oneimag[2] is empty then use the default.
local( $imageFileName, $imageAltTag ) = &GetImageOrDefaultInfo( $oneimag[2], $onework[2] );
# substitute the template into the first holder in the html
$body =~ s/pic/$thumb/;
$body =~ s/thtitle/$onework[2]/g;
$body =~ s/altTag/$imageAltTag/g;
$body =~ s/date/$onework[3]/;
$body =~ s/name/$onework[5]/;
#if there is no imagedb entry for this work or oneimag[2] is empty then use the default.
local( $th ) = "$thumbs$imageFileName";
$body =~ s/imag/$th/;
local( $width ) = &GetPhraseWidth( $oneimag[4] );
$body =~ s/w/$width/;
local( $height ) = &GetPhraseHeight( $oneimag[3] );
$body =~ s/h/$height/;
#actn line apparently lost sometime 19/7 - 31/7; restored 1/8/00 bhr
$body =~ s/actn/$cgipath?mode=mode&painting=$onework[0]insertAxis/;
# generate some axes
$axes .= "$onework[0]," if ($onework[0] ne '');
$c++;
}
# loop up to 10 to empty any remaining tags
$body =~ s/pic//g;
# process the navigation
if ( $axis ne '' ) {
$temp = "$cgipath?mode=mode&subject=" . &GoAlongAxis( $query, -1, $axis ) . "&axis=$axis";
$prev =~ s/hot/$temp/;
$body =~ s/prev/$prev/;
$temp = "$cgipath?mode=mode&subject=" . &GoAlongAxis( $query, 1, $axis ) . "&axis=$axis";
$next =~ s/hot/$temp/;
$body =~ s/next/$next/;
} else {
$body =~ s/prev//;
$body =~ s/next//;
}
chop( $axes );
if ( $c > 1 ) {
$body =~ s/insertAxis/&axis=$newaxis/g;
# store the axis
$error = &WriteFile( "$newaxis\t$axes", "\n", $hotaxes );
# &CullAxes();
} else {
$body =~ s/insertAxis//g;
}
$upTitle = &GetCatSubSectionTitleName( $highlightCatSubSection ) if ( $upTitle eq '' );
$pageTitle = $upTitle;
return &PrintHeader() . $body;
}
sub GetCatSubSectionName{
local( $sectionName ) = @_;
local( $imageName ) = $catalogueSubSectionGivesImageNames{ $sectionName };
return $imageName;
}
sub GetCatSubSectionTitleName{
local( $imageName ) = @_;
local( %catalogueSubSectionGivesSectionNames ) = reverse %catalogueSubSectionGivesImageNames;
local( $sectionName ) = $catalogueSubSectionGivesSectionNames{ $imageName };
return $sectionName;
}
sub GetDailyChoice {
local( $indexType, $indexDB, $body ) = @_;
local( @todaysSelectionDetails ) = &GetDailyChoiceInfo( $indexType, $indexDB );
local( $todaysSelectionTemplate ) = &ReadTemplate( $todaysSelectionTemplateFile, "", "" );
$body =~ s/todaysSelection/$todaysSelectionTemplate/;
$body =~ s/todaysTitle/$todaysSelectionDetails[8]/;
local( $attrib ) = $todaysSelectionDetails[2] ;
local( $pictureTitle ) = $todaysSelectionDetails[3] ;
local( $thumbName ) = $todaysSelectionDetails[4] ;
local( $thumbWidth ) = $todaysSelectionDetails[5] ;
local( $thumbHeight ) = $todaysSelectionDetails[6] ;
local( $hotlink ) = $todaysSelectionDetails[7] ;
local( $altTag ) = $todaysSelectionDetails[9] ;
$body =~ s/attrib/$attrib/;
$body =~ s/pictureTitle/$pictureTitle/;
$body =~ s/thumbName/$thumbName/;
$body =~ s/thumbWidth/$thumbWidth/;
$body =~ s/thumbHeight/$thumbHeight/;
$body =~ s/hotlink/$hotlink/;
$body =~ s/altTag/$altTag/;
return $body;
}
#if file already exists with todays random selection then return that
#if no file exists then make a random selection and store it in a file
sub GetDailyChoiceInfo {
local( $indexType, $indexDB ) = @_;
local( $todaysDate ) = &Date();
local( $fileName ) = $todaysSelections . $indexType . ".txt";
local( $noOfPossibles ) = '';
local( $randomChoiceNumber, $initialRandomTime, $nonZeroRandom ) = '';
local( @randomChoice ) = '';
#get the first line of the stored info then close so can be opened again fresh.
open( RANDOMSTORE, $fileName );
local( $firstline ) = /g;
return &PrintHeader() . $template;
}
sub GetHeader {
local( $themeid, $title, $row4, $section ) = @_;
# read in the files we need
local( $head ) = &ReadTemplate( $header, '', '' );
$head = &DoButtons( $section, $head, @sectionPicker );
local( $row4 ) = &ReadTemplate( $row4, '', '' );
$head =~ s/row4/$row4/;
return $head;
}
sub GetHowBigIsIt {
local( $query, $axis ) = @_;
local( $temp ) = &GetOneEntry( $query, $worksdb );
local( @onework ) = split( "\t", $temp );
local( $template ) = &ReadTemplate( $howbigTemplate, $onework[3], "" );
local( $imagename, $imageh, $imagew ) = &GetNameAndDimsHowBig( $query );
$template =~ s/imagename/$imagename/;
$template =~ s/manpix/$manpix/;
$template =~ s/manwidthpix/$manwidthpix/;
$template =~ s/manheightpix/$manheightpix/;
$template =~ s/imageh/$imageh/;
$template =~ s/imagew/$imagew/;
$template =~ s/debug//;
$template =~ s// /g;
return &PrintHeader() . $template;
}
sub GetIndex {
local( $db, $query, $axis, $newaxis, $s, $e ) = @_;
local( %wot ) = '';
if ( $db eq $artistdb ) {
%wot = ( 'label','Artist Index', 'template',$aIndexTemplate, 'link','artist', 'coldaxis','Artists', 'nom','6', 'id','0', 'row4',$row4picker, '','', '','', '','' );
} elsif ( $db eq $encyclodb ) {
%wot = ( 'label','Encyclopedia', 'template',$eIndexTemplate, 'link','term', 'coldaxis','Terms', 'nom','3', 'id','0', 'row4',$row4picker, '','', '','', '','' );
} elsif ( $db eq $subjectdb ) {
%wot = ( 'label','Subject Index', 'template',$sIndexTemplate, 'link','subject', 'coldaxis','Subjects', 'nom','3', 'id','0', 'row4',$row4picker, '','', '','', '','' );
} else {
%wot = ( 'label','Artist Index', 'template',$aIndexTemplate, 'link','artist', 'coldaxis','Artists', 'nom','6', 'id','0', '','', '','', '','', '','' );
}
# match the string /g;
$text = &ZParseLinks( $text );
$body =~ s/text/$text/;
$body =~ s/row4//; # blank for now
# go find some picture links
local( $links ) = &GetList( "$code\t", $linksdb );
local( @piclinks ) = split( "\n", $links );
local( $thumb ) = &ReadTemplate( $thumbTemplate, "", "" );
local( $axes ) = "";
local( $c ) = 0;
# for all the picture links
for ($[ .. $#piclinks) {
local( @onework ) = &WorkDetails( $piclinks[$_] );
local( @oneimag ) = &ImageDetails( $onework[0] );
#if there is no imagedb entry for this work or oneimag[2] is empty then use the default.
local( $imageFileName, $imageAltTag ) = &GetImageOrDefaultInfo( $oneimag[2], $onework[2] );
# substitute the template into the first holder in the html
$body =~ s/pic/$thumb/;
$body =~ s/thtitle/$onework[2]/g;
$body =~ s/altTag/$imageAltTag/g;
$body =~ s/date/$onework[3]/;
$body =~ s/name/$onework[5]/;
local( $th ) = "$thumbs$imageFileName";
$body =~ s/imag/$th/;
local( $width ) = &GetPhraseWidth( $oneimag[4] );
$body =~ s/w/$width/;
local( $height ) = &GetPhraseHeight( $oneimag[3] );
$body =~ s/h/$height/;
$body =~ s/actn/$cgipath?mode=mode&painting=$onework[0]insertAxis/;
$axes .= "$oneimag[0]," if ($oneimag[0] ne '');
$c++;
}
# loop up to 10 to empty any remaining tags
$body =~ s/pic//g;
# process the navigation
if ( $axis ne '' ) {
$temp = "$cgipath?mode=mode&subject=" . &GoAlongAxis( $query, -1, $axis ) . "&axis=$axis";
$prev =~ s/hot/$temp/;
$body =~ s/prev/$prev/;
$temp = "$cgipath?mode=mode&subject=" . &GoAlongAxis( $query, 1, $axis ) . "&axis=$axis";
$next =~ s/hot/$temp/;
$body =~ s/next/$next/;
} else {
$body =~ s/prev//;
$body =~ s/next//;
}
chop( $axes );
if ( $c > 1 ) {
$body =~ s/insertAxis/&axis=$newaxis/g;
# store the axis
$error = &WriteFile( "$newaxis\t$axes", "\n", $hotaxes );
# &CullAxes();
} else {
$body =~ s/insertAxis//g;
}
$pageTitle = $displaytitle;
return &PrintHeader() . $body;
}
sub GetTerm {
local( $query, $axis, $newaxis, $s, $e, $highlightAtoZ ) = @_;
# match the artist id
local( $term ) = &GetOneEntry( $query, $encyclodb );
local( @oneterm ) = split( "\t", $term );
local( $head ) = '';
local( $code, $indexchar, $sortName, $upTitle, $subTitle, $attribution, $text ) = @oneterm;
local( $body ) = &ReadTemplate( $termTemplate, "", "" );
local( $foot ) = &ReadTemplate( $footer, "", "" );
local( $prev ) = &ReadTemplate( $prevTemplate, "", "" );
local( $next ) = &ReadTemplate( $nextTemplate, "", "" );
$body = &PutInHeaderAndRow4( $body, $query, 'Encyclopedia', 'term', 'Terms', $highlightAtoZ, $row4term );
# substitute some details into the templates
$body =~ s/footer/$foot/;
$body =~ s/name/$upTitle/;
$body =~ s/dates/$subTitle/;
$text =~ s// /g;
$text = &ZParseLinks( $text );
$body =~ s/text/$text/;
# go find some picture links
local( $links ) = &GetList( "$code\t", $linksdb );
local( @piclinks ) = split( "\n", $links );
local( $thumb ) = &ReadTemplate( $thumbTemplate, "", "" );
local( $axes ) = "";
local( $c ) = 0;
# for all the picture links
for ($[ .. $#piclinks) {
local( @onework ) = &WorkDetails( $piclinks[$_] );
local( @oneimag ) = &ImageDetails( $onework[0] );
#if there is no imagedb entry for this work or oneimag[2] is empty then use the default.
local( $imageFileName, $imageAltTag ) = &GetImageOrDefaultInfo( $oneimag[2], $onework[2] );
$body =~ s/debug/$oneimag[0],$oneimag[1],$oneimag[2],$oneimag[3],$oneimag[4],$oneimag[5],$oneimag[6]/;
# substitute the template into the first holder in the html
$body =~ s/pic/$thumb/;
$body =~ s/thtitle/$onework[2]/g;
$body =~ s/altTag/$imageAltTag/g;
$body =~ s/date/$onework[3]/;
$body =~ s/name/$onework[5]/;
#if there is no imagedb entry for this work or oneimag[2] is empty then use the default.
local( $th ) = "$thumbs$imageFileName";
$body =~ s/imag/$th/;
local( $width ) = &GetPhraseWidth( $oneimag[4] );
$body =~ s/w/$width/;
local( $height ) = &GetPhraseHeight( $oneimag[3] );
$body =~ s/h/$height/;
$body =~ s/actn/$cgipath?mode=mode&painting=$onework[0]insertAxis/;
$axes .= "$oneimag[0]," if ($oneimag[0] ne '');
$c++;
}
# loop up to 10 to empty any remaining tags
$body =~ s/pic//g;
# process the navigation
if ( $axis ne '' ) {
$temp = "$cgipath?mode=mode&term=" . &GoAlongAxis( $query, -1, $axis ) . "&axis=$axis";
$prev =~ s/hot/$temp/;
$body =~ s/prev/$prev/;
$temp = "$cgipath?mode=mode&term=" . &GoAlongAxis( $query, 1, $axis ) . "&axis=$axis";
$next =~ s/hot/$temp/;
$body =~ s/next/$next/;
} else {
$body =~ s/prev//;
$body =~ s/next//;
}
chop( $axes );
if ( $c > 1 ) {
$body =~ s/insertAxis/&axis=$newaxis/g;
# store the axis
$error = &WriteFile( "$newaxis\t$axes", "\n", $hotaxes );
# &CullAxes();
} else {
$body =~ s/insertAxis//g;
}
$pageTitle = $upTitle;
return &PrintHeader() . $body;
}
sub GetWhereIsItMade {
local( $query, $axis ) = @_;
local( $temp ) = &GetOneEntry( $query, $worksdb );
local( @onework ) = split( "\t", $temp );
local( $template ) = &ReadTemplate( $wheremadeTemplate, $onework[3], "" );
local( $map1, $map1h, $map1w, $map2, $map2h, $map2w ) = &GetNameAndDimsWhereMade( $query );
$template =~ s/map1/$map1/g;
$template =~ s/map1w/$map1w/g;
$template =~ s/map1h/$map1h/g;
$template =~ s/map2/$map2/g;
$template =~ s/map2w/$map2w/g;
$template =~ s/map2h/$map2h/g;
$template =~ s// /g;
return &PrintHeader() . $template;
}
sub GetWork {
local( $query, $pictemplate, $workTemplate, $axis, $newaxis ) = @_;
# match the artist id
local( $work ) = &GetOneEntry( $query, $worksdb );
local( @onework ) = split( "\t", $work );
local( $code, $accession, $title, $datettext, $sortdate, $name, $wheremade, $period, $construction, $dimensions, $donorcredit, $department, $maps, $imageid, $height, $width ) = @onework;
local( $head ) = '';
# read in the templates
if ( $onlyOneMatch ) {
$head = &GetHeader( '', $query, '', '' );
} else {
$head = &GetHeader( '', $query, $row4work, '' );
}
local( $body ) = &ReadTemplate( $workTemplate, "", "" );
local( $foot ) = &ReadTemplate( $footer, "", "" );
local( $fs ) = &ReadTemplate( $pictemplate, "", "" );
local( $prev ) = &ReadTemplate( $prevTemplate, "", "" );
local( $next ) = &ReadTemplate( $nextTemplate, "", "" );
local( $feat ) = &ReadTemplate( $featureTemplate, "", "" );
# substitute some details into the templates
$body =~ s/pic/$fs/;
$body =~ s/header/$head/;
$body =~ s/footer/$foot/;
#$body =~ s/row4//; # blank out for the moment
local( $datettextANDwheremade ) = '';
if ( $datettext ne '' && $wheremade ne '' ) {
$datettextANDwheremade = "$datettext, $wheremade"
} else {
$datettextANDwheremade = "$datettext$wheremade"
}
$body =~ s/accession/$accession/;
$body =~ s/datettextANDwheremade/$datettextANDwheremade/;
$body =~ s/sortdate/$sortdate/;
$body =~ s/name/$name/;
$body =~ s/period/$period/;
$body =~ s/construction/$construction/;
$body =~ s/dimensions/$dimensions/;
$body =~ s/donorcredit/$donorcredit/;
$body =~ s/department/$department/;
#the command to make a how big popup of the right size
local( $imagename, $imageh, $imagew ) = &GetNameAndDimsHowBig( $code );
local( $wid ) = int( $imagew + $manwidthpix + $popupborder );
local( $hei ) = '';
if ($imageh > $manheightpix) {
$hei = $imageh + $popupborder;
} else {
$hei = $manheightpix + $popupborder;
}
$body =~ s/howbigisit/How big is it?<\/A>/;
#the command to make a map popup of the right size
local( $map1, $map1h, $map1w, $map2, $map2h, $map2w ) = &GetNameAndDimsWhereMade( $code );
local( $hei ) = int( $map1h + $map2h + $popupborder );
if ($map1w > $map2w) {
$wid = $map1w + $popupborder;
} else {
$wid = $map2w + $popupborder;
}
$body =~ s/wheremade/Where was it made?<\/A>/;
local( @oneimag ) = &ImageDetails( $onework[0] );
#put in the title of the work in the list of info
$body =~ s/worktitle/$onework[2]/g;
#if there is no imagedb entry for this work or oneimag[2] is empty then use the default.
local( $imageFileName, $imageAltTag ) = &GetImageOrDefaultInfo( $oneimag[2], $onework[2] );
$body =~ s/worktitleAlt/$imageAltTag/g;
local( $fs ) = "$fullsizes$imageFileName";
$body =~ s/imag/$fs/;
if ( $query eq $querypainting ) {
# if its a painting shrink it and make it hot
#if picture not allowed on web set dimensions of picture to default values and don't make it hot
if ($oneimag[2] eq '') {
$oneimag[5] = 340;
$oneimag[6] = 400;
$body =~ s/actn//;
} else {
$oneimag[5] = int($oneimag[5] / 2);
$oneimag[6] = int($oneimag[6] / 2);
$body =~ s/actn//;
}
}
local( $thisWidth ) = &GetPhraseWidth( $oneimag[6] );
$body =~ s/w/$thisWidth/;
local( $thisHeight ) = &GetPhraseHeight( $oneimag[5] );
$body =~ s/h/$thisHeight/;
# finally get the script
local( $script ) = &GetOneEntry( $code, $linksdb );
local( @script ) = split( "\t", $script );
local( $text ) = &ScriptDetails( $script[1] );
if ( $text ne '' ) {
local( $passOnTitle ) = $title;
$passOnTitle =~ s/ /+/g;
$feat =~ s/hot/$cgipath?mode=mode&script=$script[1]&pageTitle=$passOnTitle/;
$body =~ s/feature/$feat/;
} else {
$body =~ s/feature//;
}
# get the links to other sections
local( $links ) = &GetList( "\t$code\t", $linksdb );
local( @links ) = split( "\n", $links );
local( $linklist ) = '';
foreach $link (@links) {
local ( @onelink ) = split( "\t", $link );
local ( @linkdetails ) = &LinkDetails( $onelink[3] );
local ( $linkname ) = &LinkName( $onelink[0], $dbs.$linkdetails[2] );
$linklist .= " $t";
}
# Translate the string to a code stored in the codes file, returns the $arg element of the matched line
sub TranslateCode {
local( $code, $wotfile, $arg, $chop ) = @_;
# open the db
open( CODEREF, $wotfile );
$found = '';
$code .= "\t";
while(
{noofbtns=$noofbtns}
{axis=$thisaxis}
{newAxis=$newAxis}
{search=$searchStr}
{image=$image}
{collection=$collection}
{start=$start}
{SearchMode=$searchMode}
{end=$end}
Date: ".&Date() );
exit;
}
if ( $queryartists ne '' ) {
# artist index request
$htmlReturn = &GetIndex( $artistdb, $queryartists, $thisaxis, $newAxis, $start, $end );
} elsif ( $queryterms ne '' ) {
# terms index request
$htmlReturn = &GetIndex( $encyclodb, $queryterms, $thisaxis, $newAxis, $start, $end );
} elsif ( $querysubjects ne '' ) {
# subject index request
$htmlReturn = &GetIndex( $subjectdb, $querysubjects, $thisaxis, $newAxis, $start, $end );
} elsif ( $queryartist ne '' ) {
# artist request
$htmlReturn = &GetArtist( $queryartist, $thisaxis, $newAxis, $start, $end, $highlightAtoZ );
} elsif ( $queryterm ne '' ) {
# encyclopedia request
$htmlReturn = &GetTerm( $queryterm, $thisaxis, $newAxis, $start, $end, $highlightAtoZ );
} elsif ( $querysubject ne '' ) {
# subject request
$htmlReturn = &GetSubject( $querysubject, $thisaxis, $newAxis, $start, $end, $highlightAtoZ );
} elsif ( $querypainting ne '' ) {
# its an image
$htmlReturn = &GetWork( $querypainting, $fsPicTemplate, $workTemplate, $thisaxis, $newAxis );
} elsif ( $queryscript ne '' ) {
# its an image
$htmlReturn = &GetScript( $queryscript, $thisaxis, $newAxis );
} elsif ( $queryblowup ne '' ) {
# its an image
$htmlReturn = &GetWork( $queryblowup, $buPicTemplate, $blowupTemplate, $thisaxis, $newAxis );
} elsif ( $querydetail ne '' ) {
# its an image
$htmlReturn = &GetDetail( $querydetail, $detPicTemplate, $buPicTemplate );
} elsif ( $queryglossary ne '' ) {
# its a glossary popup
$htmlReturn = &GetGlossary( $queryglossary, $thisaxis );
} elsif ( $queryhowbig ne '' ) {
# its a how big is it popup
$htmlReturn = &GetHowBigIsIt( $queryhowbig, $thisaxis );
} elsif ( $querywheremade ne '' ) {
# its a how big is it popup
$htmlReturn = &GetWhereIsItMade( $querywheremade, $thisaxis );
} elsif ( $querycatalogue ne '' ) {
# its a catalogue
$htmlReturn = &GetCatalogue( $querycatalogue, $thisaxis, $newAxis, $start, $end, $highlightCatSubSection );
} elsif ( $queryalink ne '' ) {
# its a link
$htmlReturn = &GetArtist( $queryalink, "Artists" ); # force the axis to be 'Artists'
$htmlReturn = &GetTerm( $queryalink, "Terms" ) if ($htmlReturn eq ''); # force the axis to be 'Terms'
} elsif ( $queryelink ne '' ) {
# its an encyclopedia
$htmlReturn = &GetTerm( $queryelink, "Terms" ); # force the axis to be 'Terms'
} elsif ( $querysearch ne '' ) {
$htmlReturn = &SendSearchResults( $querysearch, $searchmode, $searchtype, $thisaxis, $newAxis, $start, $end );
} elsif ( $queryreturn ne '' ) {
$htmlReturn = &ReturnFile( $queryreturn, $thisaxis );
} elsif ( $collection ne '' ) {
# $htmlReturn = &GenericProblem( "requesting collection:
{request method=$ENV{'REQUEST_METHOD'}}
{query=$query}
{axis=$thisaxis}
{newAxis=$newAxis}
{search=$searchStr}
{image=$image}
{collection=$collection}
{start=$start}
{end=$end}
Date: ".&Date() );
# its an image
$htmlReturn = &RequestCollection( $collection, $axis );
} elsif ( $swfDisplay ne '' ) {
$htmlReturn = &SwfDisplay( $swfDisplay );
} elsif ( $sendMail ne '' ) {
$htmlReturn = &SendMail( $sendMail );
} else {
#default - added 1/8/00 bhr
$htmlReturn = &ReturnFile( 'index', $thisaxis );
}
local( $sendURLToAFriend ) = &SendURLToAFriend();
$htmlReturn =~ s/sendURLToAFriend/testing: $sendURLToAFriend/g;
$htmlReturn =~ s/cgipath/$cgipath/g;
$htmlReturn =~ s/navImages/$navImages/g;
$htmlReturn =~ s/mode/$wotmode/g;
$pageTitle = 'IMAGE On The Web' if ( $pageTitle eq '' );
$pageTitle = "SDMA: $pageTitle";
$htmlReturn =~ s/pageTitle/$pageTitle/g;
# return a message
print &Charsubs( $htmlReturn );
}
exit;
######################### Subroutines listed alphabetically #################################
#UNDER DEVELOPMENT FOR NEXT ROUND - USES NEW FOOTER.HTML
#the hot link to put at the bottom of each page
sub SendURLToAFriend {
local( $url ) = &GetThisURL();
local( $sendURLToAFriend ) = "Click here to send this URL to a friend<\/A>";
return $sendURLToAFriend;
}
sub SendMail {
local( $url ) = @_;
$url =~ s/ZZFS/\./g;
$url =~ s/ZZQM/\?/g;
$url =~ s/ZZFM/\&/g;
$url =~ s/ZZEQ/\=/g;
local( $template ) = &ReadTemplate( $probTemplate );
local( $temp ) = &ReadTemplate( $header, "", "" );
$temp = &DoButtons( '', $temp, @sectionPicker );
$template =~ s/header/$temp/;
$temp = &ReadTemplate( $footer, "", "" );
$template =~ s/footer/$temp/;
$template =~ s/problem/url=$url/;
return &PrintHeader() . $template;
}
sub GetThisURL {
local( $url ) = "$cgipath?mode=mode";
$url .= "&highlightAtoZ=$highlightAtoZ" if ( $highlightAtoZ ne '' );
$url .= "&highlightCatSubSection=$highlightCatSubSection" if ( $highlightCatSubSection ne '' );
$url .= "&pageTitle=$pageTitle" if ( $pageTitle ne '' );
$url .= "&artist=$queryartist" if ( $queryartist ne '' );
$url .= "&artists=$queryartists" if ( $queryartists ne '' );
$url .= "&term=$queryterm" if ( $queryterm ne '' );
$url .= "&terms=$queryterms" if ( $queryterms ne '' );
$url .= "&subject=$querysubject" if ( $querysubject ne '' );
$url .= "&subjects=$querysubjects" if ( $querysubjects ne '' );
$url .= "&catalogue=$querycatalogue" if ( $querycatalogue ne '' );
$url .= "&catalogue=$querycatalogue" if ( $querycatalogue ne '' );
$url .= "&painting=$querypainting" if ( $querypainting ne '' );
$url .= "&blowup=$queryblowup" if ( $queryblowup ne '' );
$url .= "&detail=$querydetail" if ( $querydetail ne '' );
$url .= "&glossary=$queryglossary" if ( $queryglossary ne '' );
$url .= "&howbig=$queryhowbig" if ( $queryhowbig ne '' );
$url .= "&wheremade=$querywheremade" if ( $querywheremade ne '' );
$url .= "&alink=$queryalink" if ( $queryalink ne '' );
$url .= "&elink=$queryelink" if ( $queryelink ne '' );
$url .= "&axis=$thisaxis" if ( $thisaxis ne '' );
$url .= "&return=$queryreturn" if ( $queryreturn ne '' );
$url .= "&script=$queryscript" if ( $queryscript ne '' );
$url .= "&mode=$wotmode" if ( $wotmode ne '' );
$url .= "&swfDisplay=$swfDisplay" if ( $swfDisplay ne '' );
$url .= "&search=$querysearch" if ( $querysearch ne '' );
$url .= "&searchmode=$searchmode" if ( $searchmode ne '' );
$url .= "&searchtype=$searchtype" if ( $searchtype ne '' );
$url .= "&Image=$image" if ( $image ne '' );
$url .= "&Collection=$collection" if ( $collection ne '' );
$url .= "&Search=$searchStr" if ( $searchStr ne '' );
$url .= "&Start=$start" if ( $start ne '' );
$url .= "&End=$end" if ( $end ne '' );
$url .= "&SearchMode=$searchMode" if ( $searchMode ne '' );
$url .= "&onlyOneMatch=$onlyOneMatch" if ( $onlyOneMatch ne '' );
$url =~ s/\./ZZFS/g;
$url =~ s/\?/ZZQM/g;
$url =~ s/\&/ZZFM/g;
$url =~ s/\=/ZZEQ/g;
$url =~ s/ /+/g;
return $url;
}
#END OF UNDER DEVELOPMENT
sub ButtonsArray {
local( $temp ) = &ReadTemplate( $buttonsdb );
local( @btns ) = split( "\n", $temp );
local( $c ) = '';
foreach $btn (@btns ) {
local( @atm ) = split( "\t", $btn );
$gBtnArray{$atm[0]} = $atm[1];
$gBtnArrayAltTags{$atm[0]} = $atm[2];
$c++;
}
return $c;
}
# Do some substitutions in case we missed any
sub Charsubs {
local( $t ) = @_;
$t =~ s//-/g;
$t =~ s//-/g;
$t =~ s//é/g;
$t =~ s//É/g;
$t =~ s//á/g;
$t =~ s//Á/g;
$t =~ s//è/g;
$t =~ s//È/g;
$t =~ s//à/g;
$t =~ s//À/g;
$t =~ s//'/g;
$t =~ s//'/g;
$t =~ s//£;/g;
$t =~ s//¨/g;
$t =~ s//&Uml;/g;
$t =~ s//ç/g;
$t =~ s//.../g;
$t =~ s//ó/g;
return $t;
}
# take out the 'funny' chars for search purposes
sub CharSubsNormalize {
local( $t ) = @_;
$t =~ s//e/g;
$t =~ s//E/g;
$t =~ s//a/g;
$t =~ s//A/g;
$t =~ s//e/g;
$t =~ s//E/g;
$t =~ s//a/g;
$t =~ s//A/g;
$t =~ s//u/g;
$t =~ s//U/g;
$t =~ s//c/g;
$t =~ s//o/g;
$t =~ s/é/e/g;
$t =~ s/É/E/g;
$t =~ s/á/a/g;
$t =~ s/Á/A/g;
$t =~ s/è/e/g;
$t =~ s/È/E/g;
$t =~ s/à/a/g;
$t =~ s/À/A/g;
$t =~ s/¨/u/g;
$t =~ s/&Uml;/U/g;
$t =~ s/ç/c/g;
$t =~ s/ó/o/g;
return $t;
}
# CheckAxis
# Checks for a standard axis first then for a dynamic axis
sub CheckAxis {
local( $id, $wotaxis ) = @_;
local( $thisAxis ) = '';
local( $axis ) = '';
if ( $wotaxis ne '' ) {
$thisAxis = &TranslateCode( $wotaxis, $coldaxes, 0, 0 );
if ( $thisAxis eq '' ) {
# return "$wotaxis in $id";
$axis = &TranslateCode( $wotaxis, $hotaxes, 0, 0 );
}
}
# check if there's more than one in the list
local( @noof ) = split( ',', $axis );
if ( $#noof > 0 ) {
return $thisAxis;
} else {
return '';
}
}
# CullAxes
# To handle the axes we have a file that axes are written to when a selection or search is made
# An axis consists of a label (the time in seconds plus a character) then a comma separated list of ids.
# There are several protected axes that have names not numbers (AllArtists, AllMuseums). The axis label
# is used to purge the axis file by deleting old axes. Axes last 24 hours.
sub CullAxes {
# open the db and read it all in
open( AXESREF, $hotaxes );
local( $t ) = '';
local( @temp) = '';
while(
($err)$se$fe";
$template =~ s/problem/$ret/;
return &PrintHeader() . $template;
}
sub GetArtist {
local( $query, $axis, $newaxis, $s, $e, $highlightAtoZ ) = @_;
# match the artist id
local( $art ) = &GetOneEntry( $query, $artistdb );
local( $head ) = '';
return '' if ( $art eq '' );
local( @oneartist ) = split( "\t", $art );
local( $code, $indexchar, $sortName, $attrib, $attribUp, $surname, $name, $dates, $sound, $text ) = @oneartist;
local( $body ) = &ReadTemplate( $artistTemplate, "", "" );
local( $foot ) = &ReadTemplate( $footer, "", "" );
local( $prev ) = &ReadTemplate( $prevTemplate, "", "" );
local( $next ) = &ReadTemplate( $nextTemplate, "", "" );
$body = &PutInHeaderAndRow4( $body, $query, 'Artist Index', 'artist', 'Artists', $highlightAtoZ, $row4artist );
# substitute some details into the templates
$body =~ s/footer/$foot/;
$body =~ s/name/$attrib/;
$body =~ s/dates/$dates/;
$text =~ s//$wotcell[0]\n$wotcell[1] \n";
}
$body =~ s/prev//;
$body =~ s/next//;
$body =~ s/text/$html/;
#$pageTitle is set by URL line from hot link on prev. page ie. set in &GetWork
return &PrintHeader() . $body;
}
sub GetSubject {
local( $query, $axis, $newaxis, $s, $e, $highlightAtoZ ) = @_;
# match the artist id
local( $term ) = &GetOneEntry( $query, $subjectdb );
local( @oneterm ) = split( "\t", $term );
local( $head ) = '';
local( $code, $indexchar, $sortName, $upTitle, $subTitle, $displaytitle, $text ) = @oneterm;
local( $body ) = &ReadTemplate( $subjectTemplate, "", "" );
local( $foot ) = &ReadTemplate( $footer, "", "" );
local( $prev ) = &ReadTemplate( $prevTemplate, "", "" );
local( $next ) = &ReadTemplate( $nextTemplate, "", "" );
$body = &PutInHeaderAndRow4( $body, $query, 'Subject Index', 'subject', 'Subjects', $highlightAtoZ, $row4term );
# substitute some details into the templates
$body =~ s/footer/$foot/;
$body =~ s/name/$displaytitle/;
$body =~ s/dates/$subTitle/;
$text =~ s//
{fname=$fname}
{axis=$thisaxis}
{newAxis=$newAxis}
{search=$searchStr}
{image=$image}
{collection=$collection}
{start=$start}
{SearchMode=$searchMode}
{end=$end}
Date: ".&Date() );
open( FILEREF, $fname ) ;
while(
';
}
# save these ##############
$c++;
$oneOnly = $_; #save it
$axes .= "$link[0]," if ($link[0] ne '');
# # # # # # # #
}
}
}
close(FILEREF);
}
$start++;
$end++;
$end = $c if ( $end > $c );
if ( $c == 1 ) {
$template =~ s/found/Found $c match for \"$unpat\"/g;
$ret = &HotRef( $lastLink0, $lastEntryf, $lasthot, $lastaxisid, '&onlyOneMatch=true' ) . '
';
} else {
$template =~ s/found/Found $c matches for \"$unpat\" - displaying $start to $end/g;
}
$template =~ s/list/$ret/;
$start--;
$end--;
# is there a next?
if ( $c > $end + 1) {
local( $news ) = $start + $DisplayAtATime;
local( $newe ) = $end + $DisplayAtATime;
$newe = $c if ( $newe > $c );
local( $next ) = "Next >>>";
$template =~ s/nextsearch/\| $next/g;
} else {
$template =~ s/nextsearch//g;
}
# is there a prev?
if ( $start > 0 ) {
local( $news ) = $start - $DisplayAtATime;
local( $newe ) = $news + $DisplayAtATime - 1;
local( $prev ) = "<<< Prev";
$template =~ s/prevsearch/$prev/g;
} else {
$template =~ s/prevsearch//g;
}
chop( $axes );
if ( $c > 1 ) {
# store the axis
$error = &WriteFile( "$axisID\t$axes", "\n", $hotaxes );
&CullAxes();
return $template;
} elsif ( $c == 1 ) {
return $template;
} else {
return '';
}
}
# Given a code and a db find anywhere
sub MatchOneEntry {
local( $pat, $fname ) = @_;
local( $t ) = "";
open( ENTRYREF, $fname );
while(