[LON-CAPA-cvs] cvs: loncom /interface lonsearchcat.pm

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 24 Jun 2002 15:09:52 -0000


This is a MIME encoded message

--matthew1024931392
Content-Type: text/plain

matthew		Mon Jun 24 11:09:52 2002 EDT

  Modified files:              
    /loncom/interface	lonsearchcat.pm 
  Log:
  More POD documentation - still not enough.
  Removed some debugging code from &build_custommetatdata_query.
  &output_results():
      Replaced 'WLOOP' with logically equivalent for loop.
      Changed calling structure for *_view routines - now takes a hash as 
          input instead of an ordered list.
      Moved results parsing to new subroutine &parse_raw_result, which
          returns a hash to be passed to the *_view routines.
      Moved some custom field handling routines to a new subroutine 
          &handle_custom_fields.
      Cleaned up a little of the HTML output.
  &parse_raw_result unescapes (hopefully intelligently) its inputs.
  &detailed_citation_view, &summary_view, &fielded_format_view, and 
      &xml_sgm_view all use the new calling structure (hash).  
  Removed remainder of old POD documentation - most of this was moved to the
  per-function POD documentation.
  
  
--matthew1024931392
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20020624110952.txt"

Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.125 loncom/interface/lonsearchcat.pm:1.126
--- loncom/interface/lonsearchcat.pm:1.125	Thu Jun 20 15:43:50 2002
+++ loncom/interface/lonsearchcat.pm	Mon Jun 24 11:09:52 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.125 2002/06/20 19:43:50 matthew Exp $
+# $Id: lonsearchcat.pm,v 1.126 2002/06/24 15:09:52 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -515,7 +515,8 @@
 =item &make_persistent() 
 
 Returns a scalar which holds the current ENV{'form.*'} values in
-a 'hidden' html input tag.  
+a 'hidden' html input tag.  This allows search interface information
+to be somewhat persistent.
 
 =cut
 
@@ -573,8 +574,13 @@
 
 =item &dateboxes()
 
+Returns html selection form elements for the specification of 
+the day, month, and year.
+
 =item &selectbox()
 
+Returns html selection form.
+
 =back 
 
 =cut
@@ -674,7 +680,9 @@
 
 =pod 
 
-=item &advancedsearch() 
+=item &advancedsearch()
+
+Parse advanced search results.
 
 =cut
 
@@ -785,12 +793,13 @@
 						   $customquery,$customshow);
 	}
 	&output_results('Advanced',$r,$envhash,$customquery,$reply,$hidden);
-    }
-    elsif ($customquery) {
+        return OK;
+    } elsif ($customquery) {
 	my $reply; # reply hash reference
 	$reply=&Apache::lonnet::metadata_query('',
 					       $customquery,$customshow);
 	&output_results('Advanced',$r,$envhash,$customquery,$reply,$hidden);
+        return OK;
     }
     # should not get to this point
     return 'Error.  Should not have gone to this point.';
@@ -803,6 +812,8 @@
 
 =item &basicsearch() 
 
+Parse basic search form.
+
 =cut
 
 ######################################################################
@@ -837,8 +848,9 @@
     $query=&build_SQL_query('concat('.$concatarg.')',$ENV{'form.'.'basicexp'});
 
     # Get reply (either a hash reference to filehandles or bad connection)
+#    &Apache::lonnet::logthis("metadata query started:".time);
     my $reply=&Apache::lonnet::metadata_query('select * from metadata where '.$query);
-
+#    &Apache::lonnet::logthis("metadata query finished:".time);
     # Output search results
 
     &output_results('Basic',$r,$envhash,$query,$reply,$hidden);
@@ -854,6 +866,9 @@
 
 =item &build_SQL_query() 
 
+Builds a SQL query string from a logical expression with AND/OR keywords
+using Text::Query and &recursive_SQL_query_builder()
+
 =cut
 
 ######################################################################
@@ -876,14 +891,15 @@
 
 =item &build_custommetadata_query() 
 
+Constructs a custom metadata query using a rather heinous regular
+expression.
+
 =cut
 
 ######################################################################
 ######################################################################
 sub build_custommetadata_query {
     my ($field_name,$logic_statement)=@_;
-    &Apache::lonnet::logthis("Entered build_custommetadata_query:".
-                             $field_name.':'.$logic_statement);
     my $q=new Text::Query('abc',
 			  -parse => 'Text::Query::ParseAdvanced',
 			  -build => 'Text::Query::BuildAdvancedString');
@@ -898,7 +914,6 @@
                    \*$2\[\^\\<\]?#           *wordtwo[^\<]
                    \*\\<\\\/$1\\>?#                        *\<\/wordone\>
                    /g;
-    &Apache::lonnet::logthis("match expression: ".$matchexp);
     return $matchexp;
 }
 
@@ -909,6 +924,8 @@
 
 =item &recursive_SQL_query_build() 
 
+Recursively constructs an SQL query.  Takes as input $dkey and $pattern.
+
 =cut
 
 ######################################################################
@@ -953,6 +970,9 @@
 
 =item &build_date_queries() 
 
+Builds a SQL logic query to check time/date entries.
+Also reports errors (check for /^Incorrect/).
+
 =cut
 
 ######################################################################
@@ -1023,6 +1043,7 @@
 ######################################################################
 ######################################################################
 sub output_results {
+#    &Apache::lonnet::logthis("output_results:".time);
     my $fnum; # search result counter
     my ($mode,$r,$envhash,$query,$replyref,$hidden)=@_;
     my %ENV=%{$envhash};
@@ -1088,10 +1109,9 @@
       ## (within the foreach loop below).
       ##
       foreach my $rkey (sort keys %rhash) {
+#        &Apache::lonnet::logthis("Server $rkey:".time);
 	$servercount++;
-	$tflag=1;
 	$compiledresult='';
-	my $hostname=$rkey;
 	my $reply=$rhash{$rkey};
 	my @results;
 	if ($reply eq 'con_lost') {
@@ -1103,79 +1123,59 @@
 	    $reply=~/^([\.\w]+)$/; 
 	    my $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1;
 	    $reply=~/(.*?)\_/;
-	    {
-		my $temp=0;
-	      WLOOP: while (1) {
-		  if (-e $replyfile && $tflag) {
-		      &popwin_imgupdate($r,$rkey,"srvhalf.gif");
-		      &popwin_js($r,'popwin.hc["'.$rkey.'"]='.
-				 '"still transferring..."'.';');
-		      $tflag=0;
-		  }
-		  if (-e "$replyfile.end") {
-		      $serversleft--;
-                      delete $rhash{$rkey};
-		      if (-s $replyfile) {
-			  &popwin_imgupdate($r,$rkey,"srvgood.gif");
-			  my $fh=Apache::File->new($replyfile) or 
-			      ($r->print('ERROR: file '.
-					 $replyfile.' cannot be opened') and
-			       return OK);
-			  @results=<$fh> if $fh;
-			  $hitcount{$rkey}=@results+0;
-			  &popwin_js($r,'popwin.hc["'.$rkey.'"]='.
-				    $hitcount{$rkey}.';');
-			  $hitcountsum+=$hitcount{$rkey};
-			  &popwin_js($r,'popwin.document.forms.popremain.'.
-				    'numhits.value='.$hitcountsum.';');
-		      }
-		      else {
-			  &popwin_imgupdate($r,$rkey,"srvempty.gif");
-			  &popwin_js($r,'popwin.hc["'.$rkey.'"]=0;');
-		      }
-		      last WLOOP;
-		  } # end of if ( -e "$replyfile.end")
-		  last WLOOP unless $timeremain;
-		  sleep 1;    # wait for daemons to write files?
-		  $timeremain--;
-		  $elapsetime++;
-		  last WLOOP if ($temp>1);
-		  &popwin_js($r,"popwin.document.popremain.".
-			       "elapsetime.value=$elapsetime;");
-		  $temp++;
-	      }
+            for (my $counter=0;$counter<2;$counter++) {
+                if (-e $replyfile && ! -e "$replyfile.end") {
+                    &popwin_imgupdate($r,$rkey,"srvhalf.gif");
+                    &popwin_js($r,'popwin.hc["'.$rkey.'"]='.
+                               '"still transferring..."'.';');
+                }
+                # Are we finished transferring data?
+                if (-e "$replyfile.end") {
+                    $serversleft--;
+                    delete $rhash{$rkey};
+                    if (-s $replyfile) {
+                        &popwin_imgupdate($r,$rkey,"srvgood.gif");
+                        my $fh;
+                        unless ($fh=Apache::File->new($replyfile)){ 
+                            # Is it really appropriate to die on this error?
+                            $r->print('ERROR: file '.
+                                      $replyfile.' cannot be opened');
+                            return OK;
+                        }
+                        @results=<$fh> if $fh;
+                        $hitcount{$rkey}=@results+0;
+                        &popwin_js($r,'popwin.hc["'.$rkey.'"]='.
+                                   $hitcount{$rkey}.';');
+                        $hitcountsum+=$hitcount{$rkey};
+                        &popwin_js($r,'popwin.document.forms.popremain.'.
+                                   'numhits.value='.$hitcountsum.';');
+                    } else {
+                        &popwin_imgupdate($r,$rkey,"srvempty.gif");
+                        &popwin_js($r,'popwin.hc["'.$rkey.'"]=0;');
+                    }
+                    last;
+                } # end of if ( -e "$replyfile.end")
+                last unless $timeremain;
+                sleep 1;    # wait for daemons to write files?
+                $timeremain--;
+                $elapsetime++;
+                &popwin_js($r,"popwin.document.popremain.".
+                           "elapsetime.value=$elapsetime;");
 	    }
 	    &popwin_js($r,'popwin.document.whirly.'.
 		       'src="/adm/lonIcons/lonanimend.gif";');
 	} # end of if ($reply eq 'con_lost') else statement
-	my $customshow='';
-	my $extrashow='';
-	my @customfields;
-	if ($ENV{'form.customshow'}) {
-	    $customshow=$ENV{'form.customshow'};
-	    $customshow=~s/[^\w\s]//g;
-	    my @fields=map {"<font color=\"#008000\">$_:</font><!-- $_ -->"} 
-	    split(/\s+/,$customshow);
-	    @customfields=split(/\s+/,$customshow);
-	    if ($customshow) {
-		$extrashow="<ul><li>".join("</li><li>",@fields)."</li></ul>\n";
-	    }
-	}
-	my $customdata='';
-	my %customhash;
-	foreach my $result (@results) {
-	    if ($result=~/^(custom\=.*)$/) { # grab all custom metadata
-		my $tmp=$result;
-		$tmp=~s/^custom\=//;
-		my ($k,$v)=map {&Apache::lonnet::unescape($_);
-			    } split(/\,/,$tmp);
-		$customhash{$k}=$v;
-	    }
-	}
-	if (keys %hash) {
-	    untie %hash;
-	}
-	if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) {
+        my %Fields = undef;     # Holds the data to be sent to the various 
+                                # *_view routines.
+        my ($extrashow,$customfields,$customhash) = &handle_custom_fields(\@results);
+        my @customfields = @$customfields;
+        my %customhash   = %$customhash;
+	untie %hash if (keys %hash);
+        #
+	if (! tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) {
+	    $r->print('<html><head></head><body>Unable to tie hash to db '.
+                      'file</body></html>');
+        } else {
 	    if ($ENV{'form.launch'} eq '1') {
 		&start_fresh_session();
 	    }
@@ -1183,63 +1183,33 @@
 		next if $result=~/^custom\=/;
 		chomp $result;
 		next unless $result;
-		my @fields=map
-		{&Apache::lonnet::unescape($_)}
-		(split(/\,/,$result));
-		my ($title,$author,$subject,$url,$keywords,$version,
-		    $notes,$abstract,$mime,$lang,
-		    $creationdate,$lastrevisiondate,$owner,$copyright)=@fields;
-                unless ($title =~ /^\s*$/ ) { $title='<i>Untitled</i>'; }
-		unless ($ENV{'user.adv'}) {
-		    $keywords='<i>- not displayed -</i>';
-		    $fields[4]=$keywords;
-		    $notes='<i>- not displayed -</i>';
-		    $fields[6]=$notes;
-		    $abstract='<i>- not displayed -</i>';
-		    $fields[7]=$abstract;
-		    $subject='<i>- not displayed -</i>';
-		    $fields[2]=$subject;
-		}
-
-		my $shortabstract=$abstract;
-		$shortabstract=substr($abstract,0,200).'...' if length($abstract)>200;
-		$fields[7]=$shortabstract;
-		my $shortkeywords=$keywords;
-		$shortkeywords=substr($keywords,0,200).'...' if length($keywords)>200;
-		$fields[4]=$shortkeywords;
-
-		my $extrashow2=$extrashow;
+                %Fields = &parse_raw_result($result,$rkey);
+		$Fields{'extrashow'}=$extrashow;
 		if ($extrashow) {
 		    foreach my $field (@customfields) {
 			my $value='';
-			if ($customhash{$url}=~/\<${field}[^\>]*\>(.*?)\<\/${field}[^\>]*\>/s) {
-		            $value=$1;
-			}
-		        $extrashow2=~s/\<\!\-\- $field \-\-\>/ $value/g;
-	            }
+			$value = $1 if ($customhash{$Fields{'url'}}=~/\<{$field}[^\>]*\>(.*?)\<\/{$field}[^\>]*\>/s);
+                        $Fields{'extrashow'}=~s/\<\!\-\- $field \-\-\>/ $value/g;
+                    }
                 }
-	
-	        $compiledresult.=<<END if $compiledresult or $servercount!=$servernum;
-<hr align='left' width='200' noshade />
-END
-                $compiledresult.=<<END;
-<p>
-END
-               if ($ENV{'form.catalogmode'} eq 'interactive') {
-		   my $titleesc=$title;
-		   $titleesc=~s/\'/\\'/; # '
-
-                   $compiledresult.=<<END if ($ENV{'form.catalogmode'} eq 'interactive');
+                if ($compiledresult or $servercount!=$servernum) {
+                    $compiledresult.="<hr align='left' width='200' noshade />";
+                }
+                $compiledresult.="\n<p>\n";
+                if ($ENV{'form.catalogmode'} eq 'interactive') {
+                    my $titleesc=$Fields{'title'};
+                    $titleesc=~s/\'/\\'/; # '
+                    $compiledresult.=<<END if ($ENV{'form.catalogmode'} eq 'interactive');
 <font size='-1'><INPUT TYPE="button" NAME="returnvalues" VALUE="SELECT"
-onClick="javascript:select_data('$titleesc','$url')">
+onClick="javascript:select_data('$titleesc','$Fields{'url'}')">
 </font>
 <br />
 END
                 }
                 if ($ENV{'form.catalogmode'} eq 'groupsearch') {
 		    $fnum+=0;
-		    $hash{"pre_${fnum}_link"}=$url;
-		    $hash{"pre_${fnum}_title"}=$title;
+		    $hash{"pre_${fnum}_link"}=$Fields{'url'};
+		    $hash{"pre_${fnum}_title"}=$Fields{'title'};
 		    $compiledresult.=<<END;
 <font size='-1'>
 <input type="checkbox" name="returnvalues" value="SELECT"
@@ -1251,8 +1221,6 @@
 # <input type="hidden" name="url$fnum" value="$url" />
                     $fnum++;
 		}
-	        my $httphost=$ENV{'HTTP_HOST'};
-
 	        my $viewselect;
 	        if ($mode eq 'Basic') {
 		    $viewselect=$ENV{'form.basicviewselect'};
@@ -1260,51 +1228,161 @@
 	        elsif ($mode eq 'Advanced') {
 		    $viewselect=$ENV{'form.advancedviewselect'};
 		}
-
 	        if ($viewselect eq 'Detailed Citation View') {
-		    $compiledresult.=&detailed_citation_view(@fields,
-						 $hostname,$httphost,
-						 $extrashow2);
+		    $compiledresult.=&detailed_citation_view
+                        (%Fields, hostname => $rkey );
 		}
                 elsif ($viewselect eq 'Summary View') {
-		    $compiledresult.=&summary_view(@fields,$hostname,$httphost,
-				       $extrashow2);
+		    $compiledresult.=&summary_view
+                        (%Fields, hostname => $rkey );
 	        }
                 elsif ($viewselect eq 'Fielded Format') {
-		    $compiledresult.=&fielded_format_view(@fields,$hostname,
-					      $httphost,$extrashow2);
+		    $compiledresult.=&fielded_format_view
+                        (%Fields, hostname => $rkey );
 	        }
                 elsif ($viewselect eq 'XML/SGML') {
-		    $compiledresult.=&xml_sgml_view(@fields,$hostname,$httphost,
-					$extrashow2);
+		    $compiledresult.=&xml_sgml_view
+                        (%Fields, hostname => $rkey );
 		}
-    
             }
-
             untie %hash;
         }
-        else {
-	    $r->print('<html><head></head><body>Unable to tie hash to db '.
-		  'file</body></html>');
-	}
 	if ($compiledresult) {
 	    $resultflag=1;
+            $r->print($compiledresult);
 	}
-
-	$r->print(<<RESULTS);
-$compiledresult
-RESULTS
         my $percent=sprintf('%3.0f',($servercount/$servernum*100));
-    }
-  }
+      } # End of foreach loop over servers remaining
+    }   # End of big loop - while($serversleft && $timeremain)
     unless ($resultflag) {
         $r->print("\nThere were no results that matched your query\n");
     }
 #    $r->print('<script type="text/javascript">'.'popwin.close()</script>'."\n"); $r->rflush(); 
-    $r->print(<<RESULTS);
-</body>
-</html>
-RESULTS
+    $r->print("</body>\n</html>\n");
+    return;
+}
+
+###########################################################
+###########################################################
+
+=pod
+
+=item &parse_raw_result()
+
+Takes a line from the file of results and parse it.  Returns a hash 
+with keys for the following fields:
+'title', 'author', 'subject', 'url', 'keywords', 'version', 'notes', 
+'abstract', 'mime', 'lang', 'owner', 'copyright', 'creationdate', 
+'lastrevisiondate'.
+
+In addition, the following tags are set by calling the appropriate 
+lonnet function: 'language', 'cprtag', 'mimetag'.
+
+The 'title' field is set to "Untitled" if the title field is blank.
+
+'abstract' and 'keywords' are truncated to 200 characters.
+
+=cut
+
+###########################################################
+###########################################################
+sub parse_raw_result {
+    my ($result,$hostname) = @_;
+    # Check for a comma - if it is there then we do not need to unescape the
+    # string.  There seems to be some kind of problem with some items in
+    # the database - the entire string gets sent out unescaped...?
+    unless ($result =~ /,/) {
+        $result = &Apache::lonnet::unescape($result);
+    }
+    my @fields=map {
+        &Apache::lonnet::unescape($_);
+    } (split(/\,/,$result));
+    my ($title,$author,$subject,$url,$keywords,$version,
+        $notes,$abstract,$mime,$lang,
+        $creationdate,$lastrevisiondate,$owner,$copyright)=@fields;
+    my %Fields = 
+        ( title     => &Apache::lonnet::unescape($title),
+          author    => &Apache::lonnet::unescape($author),
+          subject   => &Apache::lonnet::unescape($subject),
+          url       => &Apache::lonnet::unescape($url),
+          keywords  => &Apache::lonnet::unescape($keywords),
+          version   => &Apache::lonnet::unescape($version),
+          notes     => &Apache::lonnet::unescape($notes),
+          abstract  => &Apache::lonnet::unescape($abstract),
+          mime      => &Apache::lonnet::unescape($mime),
+          lang      => &Apache::lonnet::unescape($lang),
+          owner     => &Apache::lonnet::unescape($owner),
+          copyright => &Apache::lonnet::unescape($copyright),
+          creationdate     => &Apache::lonnet::unescape($creationdate),
+          lastrevisiondate => &Apache::lonnet::unescape($lastrevisiondate)
+        );
+    $Fields{'language'} = 
+        &Apache::loncommon::languagedescription($Fields{'lang'});
+    $Fields{'copyrighttag'} =
+        &Apache::loncommon::copyrightdescription($Fields{'copyright'});
+    $Fields{'mimetag'} =
+        &Apache::loncommon::filedescription($Fields{'mime'});
+    # Put spaces in the keyword list, if needed.
+    $Fields{'keywords'}=~ s/,([A-z])/, $1/g; 
+    if ($Fields{'title'}=~ /^\s*$/ ) { 
+        $Fields{'title'}='Untitled'; 
+    }
+    unless ($ENV{'user.adv'}) {
+        $Fields{'keywords'} = '- not displayed -';
+        $Fields{'notes'}    = '- not displayed -';
+        $Fields{'abstract'} = '- not displayed -';
+        $Fields{'subject'}  = '- not displayed -';
+    }
+    if (length($Fields{'abstract'})>200) {
+        $Fields{'abstract'} = 
+            substr($Fields{'abstract'},0,200).'...';
+    }
+    if (length($Fields{'keywords'})>200) {
+        $Fields{'keywords'} =
+            substr($Fields{'keywords'},0,200).'...';
+    }
+    return %Fields;
+}
+
+###########################################################
+###########################################################
+
+=pod
+
+=item &handle_custom_fields()
+
+=cut
+
+###########################################################
+###########################################################
+sub handle_custom_fields {
+    my @results = @{shift()};
+    my $customshow='';
+    my $extrashow='';
+    my @customfields;
+    if ($ENV{'form.customshow'}) {
+        $customshow=$ENV{'form.customshow'};
+        $customshow=~s/[^\w\s]//g;
+        my @fields=map {
+            "<font color=\"#008000\">$_:</font><!-- $_ -->";
+        } split(/\s+/,$customshow);
+        @customfields=split(/\s+/,$customshow);
+        if ($customshow) {
+            $extrashow="<ul><li>".join("</li><li>",@fields)."</li></ul>\n";
+        }
+    }
+    my $customdata='';
+    my %customhash;
+    foreach my $result (@results) {
+        if ($result=~/^(custom\=.*)$/) { # grab all custom metadata
+            my $tmp=$result;
+            $tmp=~s/^custom\=//;
+            my ($k,$v)=map {&Apache::lonnet::unescape($_);
+                        } split(/\,/,$tmp);
+            $customhash{$k}=$v;
+        }
+    }
+    return ($extrashow,\@customfields,\%customhash);
 }
 
 ######################################################################
@@ -1314,6 +1392,27 @@
 
 =item &search_results_header
 
+Output the proper javascript code to deal with different calling modes.
+
+Takes inputs directly from from %ENV.  The following environment variables
+are checked:
+
+=over 4
+
+=item 'form.catalogmode' 
+
+Checked for 'interactive' and 'groupsearch'.
+
+=item 'form.mode'
+
+Checked for existance & 'edit' mode.
+
+=item 'form.form'
+
+=item 'form.element'
+
+=back
+
 =cut
 
 ######################################################################
@@ -1515,7 +1614,7 @@
 Output is a HTML-ified string.
 Input arguments are title, author, subject, url, keywords, version,
 notes, short abstract, mime, language, creation date,
-last revision date, owner, copyright, hostname, httphost, and
+last revision date, owner, copyright, hostname, and
 extra custom metadata to show.
 
 =over 4
@@ -1527,38 +1626,36 @@
 ######################################################################
 ######################################################################
 sub detailed_citation_view {
-    my ($title,$author,$subject,$url,$keywords,$version,
-	$notes,$shortabstract,$mime,$lang,
-	$creationdate,$lastrevisiondate,$owner,$copyright,
-	$hostname,$httphost,$extrashow)=@_;
+    my %values = @_;
     my $result=<<END;
-<i>$owner</i>, last revised $lastrevisiondate
-<h3><A HREF="http://$httphost$url" TARGET='search_preview'>$title</A></h3>
-<h3>$author</h3>
+<i>$values{'owner'}</i>, last revised $values{'lastrevisiondate'}
+<h3><a href="http://$ENV{'HTTP_HOST'}$values{'url'}" 
+    target='search_preview'>$values{'title'}</a></h3>
+<h3>$values{'author'}</h3>
 </p>
 <p>
-<b>Subject:</b> $subject<br />
-<b>Keyword(s):</b> $keywords<br />
-<b>Notes:</b> $notes<br />
+<b>Subject:</b> $values{'subject'}<br />
+<b>Keyword(s):</b> $values{'keywords'}<br />
+<b>Notes:</b> $values{'notes'}<br />
 <b>MIME Type:</b>
 END
-    $result.=&Apache::loncommon::filedescription($mime);
+    $result.=&Apache::loncommon::filedescription($values{'mime'});
     $result.=<<END;
 <br />
 <b>Language:</b> 
 END
-    $result.=&Apache::loncommon::languagedescription($lang);
+    $result.=&Apache::loncommon::languagedescription($values{'lang'});
     $result.=<<END;
 <br />
 <b>Copyright/Distribution:</b> 
 END
-    $result.=&Apache::loncommon::copyrightdescription($copyright);
+    $result.=&Apache::loncommon::copyrightdescription($values{'copyright'});
     $result.=<<END;
 <br />
 </p>
-$extrashow
+$values{'extrashow'}
 <p>
-$shortabstract
+$values{'shortabstract'}
 </p>
 END
     return $result;
@@ -1576,17 +1673,14 @@
 ######################################################################
 ######################################################################
 sub summary_view {
-    my ($title,$author,$subject,$url,$keywords,$version,
-	$notes,$shortabstract,$mime,$lang,
-	$creationdate,$lastrevisiondate,$owner,$copyright,
-	$hostname,$httphost,$extrashow)=@_;
-    my $cprtag=&Apache::loncommon::copyrightdescription($copyright);
+    my %values = @_;
     my $result=<<END;
-<a href="http://$httphost$url" TARGET='search_preview'>$author</a><br />
-$title<br />
-$owner -- $lastrevisiondate<br />
-$cprtag<br />
-$extrashow
+<a href="http://$ENV{'HTTP_HOST'}$values{'url'}" 
+   target='search_preview'>$values{'author'}</a><br />
+$values{'title'}<br />
+$values{'owner'} -- $values{'lastrevisiondate'}<br />
+$values{'copyrighttag'}<br />
+$values{'extrashow'}
 </p>
 END
     return $result;
@@ -1604,30 +1698,25 @@
 ######################################################################
 ######################################################################
 sub fielded_format_view {
-    my ($title,$author,$subject,$url,$keywords,$version,
-	$notes,$shortabstract,$mime,$lang,
-	$creationdate,$lastrevisiondate,$owner,$copyright,
-	$hostname,$httphost,$extrashow)=@_;
-    my $mimetag=&Apache::loncommon::filedescription($mime);
-    my $language=&Apache::loncommon::languagedescription($lang);
-    my $cprtag=&Apache::loncommon::copyrightdescription($copyright);
+    my %values = @_;
     my $result=<<END;
-<b>URL: </b> <A HREF="http://$httphost$url" TARGET='search_preview'>$url</A>
+<b>URL: </b> <a href="http://$ENV{'HTTP_HOST'}$values{'url'}" 
+              target='search_preview'>$values{'url'}</a>
 <br />
-<b>Title:</b> $title<br />
-<b>Author(s):</b> $author<br />
-<b>Subject:</b> $subject<br />
-<b>Keyword(s):</b> $keywords<br />
-<b>Notes:</b> $notes<br />
-<b>MIME Type:</b> $mimetag<br />
-<b>Language:</b> $language<br />
-<b>Creation Date:</b> $creationdate<br />
-<b>Last Revision Date:</b> $lastrevisiondate<br />
-<b>Publisher/Owner:</b> $owner<br />
-<b>Copyright/Distribution:</b> $cprtag<br />
-<b>Repository Location:</b> $hostname<br />
-<b>Abstract:</b> $shortabstract<br />
-$extrashow
+<b>Title:</b> $values{'title'}<br />
+<b>Author(s):</b> $values{'author'}<br />
+<b>Subject:</b> $values{'subject'}<br />
+<b>Keyword(s):</b> $values{'keywords'}<br />
+<b>Notes:</b> $values{'notes'}<br />
+<b>MIME Type:</b> $values{'mimetag'}<br />
+<b>Language:</b> $values{'language'}<br />
+<b>Creation Date:</b> $values{'creationdate'}<br />
+<b>Last Revision Date:</b> $values{'lastrevisiondate'}<br />
+<b>Publisher/Owner:</b> $values{'owner'}<br />
+<b>Copyright/Distribution:</b> $values{'copyrighttag'}<br />
+<b>Repository Location:</b> $values{'hostname'}<br />
+<b>Abstract:</b> $values{'shortabstract'}<br />
+$values{'extrashow'}
 </p>
 END
     return $result;
@@ -1647,42 +1736,36 @@
 ######################################################################
 ######################################################################
 sub xml_sgml_view {
-    my ($title,$author,$subject,$url,$keywords,$version,
-	$notes,$shortabstract,$mime,$lang,
-	$creationdate,$lastrevisiondate,$owner,$copyright,
-	$hostname,$httphost,$extrashow)=@_;
-    my $cprtag=&Apache::loncommon::copyrightdescription($copyright);
-    my $mimetag=&Apache::loncommon::filedescription($mime);
-    my $language=&Apache::loncommon::languagedescription($lang);
+    my %values = @_;
     my $result=<<END;
 <pre>
 &lt;LonCapaResource&gt;
-&lt;url&gt;$url&lt;/url&gt;
-&lt;title&gt;$title&lt;/title&gt;
-&lt;author&gt;$author&lt;/author&gt;
-&lt;subject&gt;$subject&lt;/subject&gt;
-&lt;keywords&gt;$keywords&lt;/keywords&gt;
-&lt;notes&gt;$notes&lt;/notes&gt;
+&lt;url&gt;$values{'url'}&lt;/url&gt;
+&lt;title&gt;$values{'title'}&lt;/title&gt;
+&lt;author&gt;$values{'author'}&lt;/author&gt;
+&lt;subject&gt;$values{'subject'}&lt;/subject&gt;
+&lt;keywords&gt;$values{'keywords'}&lt;/keywords&gt;
+&lt;notes&gt;$values{'notes'}&lt;/notes&gt;
 &lt;mimeInfo&gt;
-&lt;mime&gt;$mime&lt;/mime&gt;
-&lt;mimetag&gt;$mimetag&lt;/mimetag&gt;
+&lt;mime&gt;$values{'mime'}&lt;/mime&gt;
+&lt;mimetag&gt;$values{'mimetag'}&lt;/mimetag&gt;
 &lt;/mimeInfo&gt;
 &lt;languageInfo&gt;
-&lt;language&gt;$lang&lt;/language&gt;
-&lt;languagetag&gt;$language&lt;/languagetag&gt;
+&lt;language&gt;$values{'lang'}&lt;/language&gt;
+&lt;languagetag&gt;$values{'language'}&lt;/languagetag&gt;
 &lt;/languageInfo&gt;
-&lt;creationdate&gt;$creationdate&lt;/creationdate&gt;
-&lt;lastrevisiondate&gt;$lastrevisiondate&lt;/lastrevisiondate&gt;
-&lt;owner&gt;$owner&lt;/owner&gt;
+&lt;creationdate&gt;$values{'creationdate'}&lt;/creationdate&gt;
+&lt;lastrevisiondate&gt;$values{'lastrevisiondate'}&lt;/lastrevisiondate&gt;
+&lt;owner&gt;$values{'owner'}&lt;/owner&gt;
 &lt;copyrightInfo&gt;
-&lt;copyright&gt;$copyright&lt;/copyright&gt;
-&lt;copyrighttag&gt;$cprtag&lt;/copyrighttag&gt;
+&lt;copyright&gt;$values{'copyright'}&lt;/copyright&gt;
+&lt;copyrighttag&gt;$values{'copyrighttag'}&lt;/copyrighttag&gt;
 &lt;/copyrightInfo&gt;
-&lt;repositoryLocation&gt;$hostname&lt;/repositoryLocation&gt;
-&lt;shortabstract&gt;$shortabstract&lt;/shortabstract&gt;
+&lt;repositoryLocation&gt;$values{'hostname'}&lt;/repositoryLocation&gt;
+&lt;shortabstract&gt;$values{'shortabstract'}&lt;/shortabstract&gt;
 &lt;/LonCapaResource&gt;
 </pre>
-$extrashow
+$values{'extrashow'}
 END
     return $result;
 }
@@ -1871,200 +1954,5 @@
 =pod
 
 =back 
-
-=over 4
-
-=head1 HANDLER SUBROUTINE
-
-This routine is called by Apache and mod_perl.
-
-=over 4
-
-=item *
-
-configure dynamic components of interface
-
-=item *
-
-determine current user
-
-=item *
-
-see if a search invocation should be done
-
-=item *
-
-else, begin building search interface to output
-
-=item *
-
-compute date selection boxes
-
-=item *
-
-compute customized metadata field
-
-=item *
-
-print screen
-
-=back
-
-=head1 OTHER SUBROUTINES
-
-=over 4
-
-=item *
-
-get_unprocessed_cgi() : reads in critical name/value pairs that may have not
-been processed and passed into %ENV by the web server
-
-=item *
-
-make_persistent() : makes a set of hidden HTML fields to make
-SQL search interface information to be persistent
-
-=back
-
-WEB INTERFACE COMPONENT FUNCTIONS
-
-=over 4
-
-=item *
-
-simpletextfield(name,value) : returns HTML formatted string for simple text
-field
-
-=item *
-
-simplecheckbox(name,value) : returns HTML formatted string for simple
-checkbox
-
-=item *
-
-searchphrasefield(title,name,value) : returns HTML formatted string for
-a search expression phrase field
-
-=item *
-
-dateboxes(name, defaultmonth, defaultday, defaultyear) : returns HTML
-formatted string for a calendar date
-
-=item *
-
-selectbox(title,name,value,%HASH=options) : returns HTML formatted string for
-a selection box field
-
-=back
-
-SEARCH FUNCTIONS
-
-=over 4
-
-=item *
-
-advancedsearch(server reference, environment reference) : perform a complex
-multi-field logical query
-
-=item *
-
-basicsearch(server reference, environment reference) : perform a simple
-single-field logical query
-
-=item *
-
-build_SQL_query(field name, logic) : builds a SQL query string from a
-logical expression with AND/OR keywords
-
-=item *
-
-build_custommetadata_query(field_name, logic_statement) : builds a perl
-regular expression from a logical expression with AND/OR keywords
-
-=item *
-
-recursive_SQL_query_build(field name, reverse notation expression) : 
-builds a SQL query string from a reverse notation expression
-logical expression with AND/OR keywords
-
-=item *
-
-build_date_queries(cmonth1, cday1, cyear1, cmonth2, cday2, cyear2,
-lmonth1, lday1, lyear1, lmonth2, lday2, lyear2) :
-Builds a SQL logic query to check time/date entries.
-
-=back
-
-OUTPUTTING RESULTS FUNCTION
-
-=over 4
-
-=item *
-
-output_results(output mode, server reference, environment reference,
-reply list reference) : outputs results from search
-
-=back
-
-DIFFERENT WAYS TO VIEW METADATA RECORDS
-
-=over 4
-
-=item *
-
-detailed_citation_view(ORDERED METADATA LIST FOR A RESULT OBJECT INSTANCE) :
-see metadata viewing notes below 
-
-=item *
-
-summary_view(ORDERED METADATA LIST FOR A RESULT OBJECT INSTANCE) :
-see metadata viewing notes below 
-
-=item *
-
-fielded_format_view(ORDERED METADATA LIST FOR A RESULT OBJECT INSTANCE) :
-see metadata viewing notes below 
-
-=item *
-
-xml_sgml_view(ORDERED METADATA LIST FOR A RESULT OBJECT INSTANCE) :
-see metadata viewing notes below 
-
-=back
-
-  _____________________________________________________________________
- | * Metadata viewing notes                                            |
- | Output is a HTML-ified string.                                      |
- | Input arguments are title, author, subject, url, keywords, version, |
- | notes, short abstract, mime, language, creation date,               |
- | last revision date, owner, copyright, hostname, httphost, and       |
- | extra custom metadata to show.                                      |
-  ---------------------------------------------------------------------
-
-TEST CONDITIONAL FUNCTIONS
-
-=over 4
-
-=item *
-
-filled(field) : determines whether a given field has been filled
-
-=back
-
-ERROR FUNCTIONS
-
-=over 4
-
-=item *
-
-output_blank_field_error(server reference) : outputs a message saying that
-more fields need to be filled in
-
-=item *
-
-output_date_error(server reference, error message) : 
-
-
-=back
 
 =cut

--matthew1024931392--