--- loncom/interface/lonsearchcat.pm 2001/03/22 14:19:17 1.74
+++ loncom/interface/lonsearchcat.pm 2001/03/27 21:18:55 1.88
@@ -229,9 +229,9 @@ LASTREVISIONDATEEND
# ------------------------------------------- Compute customized metadata field
$scrout.=<
-LIMIT BY OTHER METADATA FIELDS:
+LIMIT BY SPECIAL METADATA FIELDS:
-For author-specific metadata, enter in an expression in the form of
+For resource-specific metadata, enter in an expression in the form of
key=value separated by operators such as AND or OR.
Example: grandmother=75 OR grandfather=85
@@ -239,6 +239,17 @@ CUSTOMMETADATA
$scrout.=&simpletextfield('custommetadata',$ENV{'form.custommetadata'});
$scrout.=' initial users of this system do not need to worry about this option';
+ $scrout.=<
+SHOW SPECIAL METADATA FIELDS:
+
+Enter in a space-separated list of special metadata fields to show
+in a fielded listing for each record result.
+
+CUSTOMSHOW
+$scrout.=&simpletextfield('customshow',$ENV{'form.customshow'});
+$scrout.=' initial users of this system do not need to worry about this option';
+
# ---------------------------------------------------------------- Print screen
$r->print(<
@@ -487,7 +498,7 @@ sub advancedsearch {
'lastrevisiondatestart_year','lastrevisiondateend_month',
'lastrevisiondateend_day','lastrevisiondateend_year',
'notes','abstract','mime','language','owner',
- 'custommetadata') {
+ 'custommetadata','customshow') {
$ENV{"form.$field"}=~s/[^\w\s\(\)\=\-\"\']//g;
}
for my $field ('title','author','subject','keywords','url','version',
@@ -544,20 +555,38 @@ sub advancedsearch {
elsif ($datequery) {
push @queries,$datequery;
}
- my $customquery;
+ my $customquery='';
if ($ENV{'form.custommetadata'}) {
$customquery=&build_custommetadata_query('custommetadata',
$ENV{'form.custommetadata'});
}
+ my $customshow='';
+ if ($ENV{'form.customshow'}) {
+ $customshow=$ENV{'form.customshow'};
+ $customshow=~s/[^\w\s]//g;
+ my @fields=split(/\s+/,$customshow);
+ $customshow=join(" ",@fields);
+ }
if (@queries) {
$query=join(" AND ",@queries);
$query="select * from metadata where $query";
- my $reply=&Apache::lonnet::metadata_query($query);
+ my $reply='';
+ unless ($customquery or $customshow) {
+ $reply=&Apache::lonnet::metadata_query($query);
+ }
+ else {
+ $reply=&Apache::lonnet::metadata_query($query,
+ $customquery,$customshow);
+ }
&output_results('Advanced',$r,$envhash,$customquery,$reply);
}
- else {
- &output_results('Advanced',$r,$envhash,$query);
+ elsif ($customquery) {
+ my $reply='';
+ $reply=&Apache::lonnet::metadata_query('',
+ $customquery,$customshow);
+ &output_results('Advanced',$r,$envhash,$customquery,$reply);
}
+ $r->print(' '); # just in case.. hrrmm..
return OK;
}
@@ -659,7 +688,34 @@ sub output_results {
@results=<$fh>;
}
+ my $customshow='';
+ my $extrashow='';
+ my @customfields;
+ if ($ENV{'form.customshow'}) {
+ $customshow=$ENV{'form.customshow'};
+ $customshow=~s/[^\w\s]//g;
+ my @fields=map {"$_:"}
+ split(/\s+/,$customshow);
+ @customfields=split(/\s+/,$customshow);
+ if ($customshow) {
+ $extrashow="\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;
+ }
+ }
+ foreach my $result (@results) {
+ next if $result=~/^custom\=/;
+ chomp $result;
+ next unless $result;
my @fields=map
{&Apache::lonnet::unescape($_)}
(split(/\,/,$result));
@@ -669,6 +725,16 @@ sub output_results {
my $shortabstract=$abstract;
$shortabstract=substr($abstract,0,200) if length($abstract)>200;
$fields[7]=$shortabstract;
+ my $extrashow2=$extrashow;
+ if ($extrashow) {
+ foreach my $field (@customfields) {
+ my $value='';
+ if ($customhash{$url}=~/\<${field}[^\>]*\>(.*?)\<\/${field}[^\>]*\>/s) {
+ $value=$1;
+ }
+ $extrashow2=~s/\<\!\-\- $field \-\-\>/ $value/g;
+ }
+ }
$compiledresult.=<
END
@@ -690,17 +756,20 @@ END
if ($viewselect eq 'Detailed Citation View') {
$compiledresult.=&detailed_citation_view(@fields,
- $hostname,$httphost);
+ $hostname,$httphost,
+ $extrashow2);
}
elsif ($viewselect eq 'Summary View') {
- $compiledresult.=&summary_view(@fields,$hostname,$httphost);
+ $compiledresult.=&summary_view(@fields,$hostname,$httphost,
+ $extrashow2);
}
elsif ($viewselect eq 'Fielded Format') {
$compiledresult.=&fielded_format_view(@fields,$hostname,
- $httphost);
+ $httphost,$extrashow2);
}
elsif ($viewselect eq 'XML/SGML') {
- $compiledresult.=&xml_sgml_view(@fields,$hostname,$httphost);
+ $compiledresult.=&xml_sgml_view(@fields,$hostname,$httphost,
+ $extrashow2);
}
}
@@ -741,6 +810,7 @@ SCRIPT
Search Catalog
+$extrashow
+
$shortabstract
END
@@ -856,12 +930,13 @@ sub summary_view {
my ($title,$author,$subject,$url,$keywords,$version,
$notes,$shortabstract,$mime,$lang,
$creationdate,$lastrevisiondate,$owner,$copyright,
- $hostname,$httphost)=@_;
+ $hostname,$httphost,$extrashow)=@_;
my $result=<$author
$title
$owner -- $lastrevisiondate
$cprtag{$copyright}
+$extrashow
END
return $result;
@@ -872,7 +947,7 @@ sub fielded_format_view {
my ($title,$author,$subject,$url,$keywords,$version,
$notes,$shortabstract,$mime,$lang,
$creationdate,$lastrevisiondate,$owner,$copyright,
- $hostname,$httphost)=@_;
+ $hostname,$httphost,$extrashow)=@_;
my $result=<URL: $url
@@ -889,6 +964,7 @@ sub fielded_format_view {
Copyright/Distribution: $cprtag{$copyright}
Repository Location: $hostname
Abstract: $shortabstract
+$extrashow
END
return $result;
@@ -899,7 +975,7 @@ sub xml_sgml_view {
my ($title,$author,$subject,$url,$keywords,$version,
$notes,$shortabstract,$mime,$lang,
$creationdate,$lastrevisiondate,$owner,$copyright,
- $hostname,$httphost)=@_;
+ $hostname,$httphost,$extrashow)=@_;
my $result=<
<LonCapaResource>
@@ -928,6 +1004,7 @@ sub xml_sgml_view {
<shortabstract>$shortabstract</shortabstract>
</LonCapaResource>
+$extrashow
END
return $result;
}
500 Internal Server Error
Internal Server Error
The server encountered an internal error or
misconfiguration and was unable to complete
your request.
Please contact the server administrator at
root@localhost to inform them of the time this error occurred,
and the actions you performed just before this error.
More information about this error may be available
in the server error log.