#!/DOCUMENT_ROOT/OCEAN_PLANET/SUPPORT_PROGRAMS/perl # Get the document root from the path to perl. ($dr) = $^X =~ m@^(.*)/OCEAN_PLANET/@; require "$dr/OCEAN_PLANET/SUPPORT_PROGRAMS/cgi-lib.pl"; print <<"--"; Content-type: text/html Ocean Planet Image Catalog Search Results

Ocean Planet Image Catalog Search Results


-- # The following is a mapping between the 1st letter of an image ID and the # type of image class it represents. This mapping also appears in the # form that calls this method. Make sure they remain consistent with each # other. %classes = ( "G","Photographs", "O","Objects/Artifacts", "I","Illustrations" ); &ReadParse; # Decode information passed in from the form. # The user should leave at least one image class selected. if(defined($in{"image_class"})){ # Build a regular expression that will operate (via eval) on each caption # selected by the regular expression, $pattern, which is built below. # Save the image ID (e.g. G-538) in the variable, $id. @classes = split(/\\0/,$in{"image_class"}); $classes = ''; for($i = $[ ; $i <= $#classes; $i++){ $classes .= $classes{$classes[$i]} . '
'; } $img_id = '($id) = /([' . join('',@classes) . ']-[0-9]+[a-z]?)/'; } # If the user doesn't leave at least one image class selected # then signal that an error message should be printed (see below). else{ $img_id = ''; } if($in{"andor"} eq "and") { $andor = '&&'; } # contains all keywords else { $andor = '||'; } # contains at least one if($in{"case"} eq "ignore") { $case = 'i'; } # ignore case else { $case = ''; } # case specific if($in{"bound"} eq "subword") { $bound = ''; } # subword matches else { $bound = '\b'; } # no subword matches # Build the regular expression that will find the right captions. $keywords = join(' ',$in{"listkeys"},$in{"typedkeys"},$in{"photographers"}); $keywords =~ s/\\0/ /g; $pattern = "/$bound" . join("$bound/$case$andor/$bound",split(' ',$keywords)) . "$bound/$case"; $capdir = "$dr/OCEAN_PLANET/CAPTIONS"; open(CAPTIONS, "$capdir/ocean_planet_captions_objects.text") || die "Could not open ocean_planet/ocean_planet_captions_objects.text"; $/ = "\n

\n"; # Split captions file on this pattern @captions = ; $/ = "\n"; grep(s/\n

\n$// && 0, @captions); # Remove "\n

\n" from all captions close CAPTIONS; $prefix = "/OCEAN_PLANET/IMAGES/"; print "

"; if($andor eq "&&") { print "
Each caption contains all of the specified keywords
\n"; } else { print "
Each caption contains at least one of the specified keywords
\n"; } if($case eq "i") {print "
Case ignored during search
\n";} else {print "
Search was case-sensitive
\n";} print <<"--";
Search keywords
$keywords
Image Classes
$classes

-- while($_ = shift(@captions)){ @markups = /<[^>]*>/g; # Save any hypertext markup tags. s/<[^>]*>/$;/g; # Hide the markup tags. if(eval($pattern)){ if(eval($img_id)){ $found_one = 1; $gif = $prefix . $id . ".gif"; $thumbnail = $prefix . $id . ".thumbnail.gif"; print " $id\n

\n"; s/$id//; foreach $keyword (split(' ', $keywords)){ if($case) { s@($keyword)@$1@gi; } else { s@($keyword)@$1@g; } } while($markup = shift(@markups)){ # Restore the markup tags s/$;/$markup/; # before printing out the caption. } print; print "

\n"; } } } if($img_id eq ''){ print ""; print "You have deselected all of the image classes. "; print "You must leave at least one of them selected."; print "


"; } elsif(!defined($found_one)){ print "

Nothing found


"; } print <<"--";

Ocean Planet Exhibition Floorplan

Gene Carl Feldman (gene@seawifs.gsfc.nasa.gov) &
Judith Gradwohl (Curator/Ocean Planet)
--