--- loncom/interface/lonsearchcat.pm 2002/07/03 19:11:09 1.134
+++ loncom/interface/lonsearchcat.pm 2002/07/08 14:52:19 1.138
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.134 2002/07/03 19:11:09 matthew Exp $
+# $Id: lonsearchcat.pm,v 1.138 2002/07/08 14:52:19 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -375,22 +375,13 @@ $hidden
ENDHEADER
- $scrout.=&searchphrasefield('title','title',
- $ENV{'form.title'});
- $scrout.=&searchphrasefield('author','author',
- $ENV{'form.author'});
- $scrout.=&searchphrasefield('subject','subject',
- $ENV{'form.subject'});
- $scrout.=&searchphrasefield('keywords','keywords',
- $ENV{'form.keywords'});
- $scrout.=&searchphrasefield('URL','url',
- $ENV{'form.url'});
-# $scrout.=&searchphrasefield('Limit by version','version',
-# $ENV{'form.version'});
- $scrout.=&searchphrasefield('notes','notes',
- $ENV{'form.notes'});
- $scrout.=&searchphrasefield('abstract','abstract',
- $ENV{'form.abstract'});
+ $scrout.=&searchphrasefield('title', 'title' ,$ENV{'form.title'});
+ $scrout.=&searchphrasefield('author', 'author' ,$ENV{'form.author'});
+ $scrout.=&searchphrasefield('subject', 'subject' ,$ENV{'form.subject'});
+ $scrout.=&searchphrasefield('keywords','keywords',$ENV{'form.keywords'});
+ $scrout.=&searchphrasefield('URL', 'url' ,$ENV{'form.url'});
+ $scrout.=&searchphrasefield('notes', 'notes' ,$ENV{'form.notes'});
+ $scrout.=&searchphrasefield('abstract','abstract',$ENV{'form.abstract'});
# Hack - an empty table row.
$scrout.="
| |
\n";
$scrout.=&searchphrasefield('file
extension','mime',
@@ -438,8 +429,6 @@ ENDHEADER
$scrout.="\n";
}
#----------------------------------------------------------------
- #
- #
$scrout.=&selectbox('Limit by language','language',
$ENV{'form.language'},'any','Any Language',
\&{Apache::loncommon::languagedescription},
@@ -803,6 +792,10 @@ sub parse_advanced_search {
push @queries,&build_SQL_query($field,$ENV{'form.'.$field});
}
}
+ # I dislike the hack below.
+ if ($ENV{'form.category'}) {
+ $ENV{'form.mime'}='';
+ }
# Evaluate option lists
if ($ENV{'form.language'} and $ENV{'form.language'} ne 'any') {
push @queries,"(language like \"$ENV{'form.language'}\")";
@@ -1114,13 +1107,32 @@ sub output_results {
my $elapsetime=0;
my $resultflag=0;
my $tflag=1;
- my $viewselect=$ENV{'form.viewselect'};
+ ##
+ ## Set viewing function
+ ##
+ my $viewfunction = undef;
+ if ($ENV{'form.viewselect'} eq 'Detailed Citation View') {
+ $viewfunction = \&detailed_citation_view;
+ } elsif ($ENV{'form.viewselect'} eq 'Summary View') {
+ $viewfunction = \&summary_view;
+ } elsif ($ENV{'form.viewselect'} eq 'Fielded Format') {
+ $viewfunction = \&fielded_format_view;
+ } elsif ($ENV{'form.viewselect'} eq 'XML/SGML') {
+ $viewfunction = \&xml_sgml_view;
+ }
+ if (!defined($viewfunction)) {
+ $r->print("Internal Error - Bad view selected.\n");
+ $r->rflush();
+ return;
+ }
#
# make query information persistent to allow for subsequent revision
my $persistent=&make_persistent(\%ENV);
- # spit out the results header
+ #
+ # Begin producing output
$r->print(&search_results_header($mode));
$r->rflush();
+ #
# begin showing the cataloged results
my $action = "/adm/searchcat";
if ($mode eq 'Basic') {
@@ -1141,7 +1153,6 @@ $persistent
CATALOGCONTROLS
#
# make the pop-up window for status
- #
$r->print(&make_popwin(%rhash));
$r->rflush();
##
@@ -1218,7 +1229,8 @@ CATALOGCONTROLS
} # end of if ($reply eq 'con_lost') else statement
my %Fields = undef; # Holds the data to be sent to the various
# *_view routines.
- my ($extrashow,$customfields,$customhash) = &handle_custom_fields(\@results);
+ my ($extrashow,$customfields,$customhash) =
+ &handle_custom_fields(\@results);
my @customfields = @$customfields;
my %customhash = %$customhash;
untie %hash if (keys %hash);
@@ -1235,6 +1247,21 @@ CATALOGCONTROLS
chomp $result;
next unless $result;
%Fields = &parse_raw_result($result,$rkey);
+ #
+ # Check copyright tags and skip results the user cannot use
+ my (undef,undef,$resdom,$resname) = split('/',$Fields{'url'});
+ # Check for priv
+ if (($Fields{'copyright'} eq 'priv') &&
+ (($ENV{'user.name'} ne $resname) &&
+ ($ENV{'user.domain'} ne $resdom))) {
+ next;
+ }
+ # Check for domain
+ if (($Fields{'copyright'} eq 'domain') &&
+ ($ENV{'user.domain'} ne $resdom)) {
+ next;
+ }
+ #
$Fields{'extrashow'}=$extrashow;
if ($extrashow) {
foreach my $field (@customfields) {
@@ -1269,22 +1296,8 @@ END
#
$fnum++;
}
- if ($viewselect eq 'Detailed Citation View') {
- $compiledresult.=&detailed_citation_view
- (%Fields, hostname => $rkey );
- }
- elsif ($viewselect eq 'Summary View') {
- $compiledresult.=&summary_view
- (%Fields, hostname => $rkey );
- }
- elsif ($viewselect eq 'Fielded Format') {
- $compiledresult.=&fielded_format_view
- (%Fields, hostname => $rkey );
- }
- elsif ($viewselect eq 'XML/SGML') {
- $compiledresult.=&xml_sgml_view
- (%Fields, hostname => $rkey );
- }
+ # Render the result into html
+ $compiledresult.= &$viewfunction(%Fields, hostname => $rkey );
if ($compiledresult or $servercount!=$servernum) {
$compiledresult.="
";
}
@@ -1295,14 +1308,15 @@ END
$resultflag=1;
$r->print($compiledresult);
}
- 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(''."\n"); $r->rflush();
+ $r->print(''.
+ "\n");
$r->print("