--- loncom/interface/lonsearchcat.pm 2001/03/22 14:00:55 1.69
+++ loncom/interface/lonsearchcat.pm 2001/03/27 13:35:35 1.83
@@ -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,15 +555,29 @@ 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 {
@@ -659,7 +684,26 @@ sub output_results {
@results=<$fh>;
}
+ my $customshow='';
+ my $extrashow='';
+ if ($ENV{'form.customshow'}) {
+ $customshow=$ENV{'form.customshow'};
+ $customshow=~s/[^\w\s]//g;
+ my @fields=map {"$_:"}
+ split(/\s+/,$customshow);
+ if ($customshow) {
+ $extrashow="\n";
+ }
+ }
+ my $customdata='';
+ foreach my $result (@results) {
+ if ($result=~/^(custom\=.*)$/) { # grab all custom metadata
+ $customdata.=$result;
+ }
+ }
foreach my $result (@results) {
+ next if $result=~/^custom\=/;
+ chomp $result;
my @fields=map
{&Apache::lonnet::unescape($_)}
(split(/\,/,$result));
@@ -690,17 +734,20 @@ END
if ($viewselect eq 'Detailed Citation View') {
$compiledresult.=&detailed_citation_view(@fields,
- $hostname,$httphost);
+ $hostname,$httphost,
+ $extrashow);
}
elsif ($viewselect eq 'Summary View') {
- $compiledresult.=&summary_view(@fields,$hostname,$httphost);
+ $compiledresult.=&summary_view(@fields,$hostname,$httphost,
+ $extrashow);
}
elsif ($viewselect eq 'Fielded Format') {
$compiledresult.=&fielded_format_view(@fields,$hostname,
- $httphost);
+ $httphost,$extrashow);
}
elsif ($viewselect eq 'XML/SGML') {
- $compiledresult.=&xml_sgml_view(@fields,$hostname,$httphost);
+ $compiledresult.=&xml_sgml_view(@fields,$hostname,$httphost,
+ $extrashow);
}
}
@@ -741,6 +788,7 @@ SCRIPT
Search Catalog
+$extrashow
+
$shortabstract
END
@@ -855,12 +908,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;
@@ -871,7 +925,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
@@ -888,6 +942,7 @@ sub fielded_format_view {
Copyright/Distribution: $cprtag{$copyright}
Repository Location: $hostname
Abstract: $shortabstract
+$extrashow
END
return $result;
@@ -898,7 +953,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>
@@ -927,6 +982,7 @@ sub xml_sgml_view {
<shortabstract>$shortabstract</shortabstract>
</LonCapaResource>
+$extrashow
END
return $result;
}