--- loncom/interface/lonsearchcat.pm 2001/03/27 02:48:02 1.79 +++ loncom/interface/lonsearchcat.pm 2001/03/27 21:41:06 1.89 @@ -560,21 +560,33 @@ sub advancedsearch { $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=''; - unless ($customquery) { + unless ($customquery or $customshow) { $reply=&Apache::lonnet::metadata_query($query); } else { - $reply=&Apache::lonnet::metadata_query($query,$customquery); + $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; } @@ -678,20 +690,32 @@ sub output_results { my $customshow=''; my $extrashow=''; + my @customfields; if ($ENV{'form.customshow'}) { $customshow=$ENV{'form.customshow'}; $customshow=~s/[^\w\s]//g; - my @fields=map {"$_:"} + my @fields=map {"$_:"} split(/\s+/,$customshow); - $extrashow="\n"; + @customfields=split(/\s+/,$customshow); + if ($customshow) { + $extrashow="\n"; + } } my $customdata=''; + my %customhash; foreach my $result (@results) { - $result=~/(\&custom.*)$/; # grab all custom metadata - $custom=$1; - $result=~s/\&custom.*$//; # remove custom metadata + 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)); @@ -701,6 +725,20 @@ 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 $compiledresult.=< END @@ -723,19 +761,19 @@ END if ($viewselect eq 'Detailed Citation View') { $compiledresult.=&detailed_citation_view(@fields, $hostname,$httphost, - $extrashow); + $extrashow2); } elsif ($viewselect eq 'Summary View') { $compiledresult.=&summary_view(@fields,$hostname,$httphost, - $extrashow); + $extrashow2); } elsif ($viewselect eq 'Fielded Format') { $compiledresult.=&fielded_format_view(@fields,$hostname, - $httphost,$extrashow); + $httphost,$extrashow2); } elsif ($viewselect eq 'XML/SGML') { $compiledresult.=&xml_sgml_view(@fields,$hostname,$httphost, - $extrashow); + $extrashow2); } } @@ -776,7 +814,7 @@ SCRIPT

Search Catalog

-$custom +$customdata $closebutton @@ -831,7 +869,7 @@ sub build_custommetadata_query { # quick fix to change literal into xml tag-matching # will eventually have to write a separate builder module my $oldmatchexp=$matchexp; - $matchexp=~s/(\w+)\\\=(\w+)/\\\<$1\\\>\[\^\\\<\]\*$2\[\^\\\<\]\*\\\<\\\/$1\\\>/g; + $matchexp=~s/(\w+)\\\=([\w\\\+]+)/\\\<$1\\\>\[\^\\\<\]\*$2\[\^\\\<\]\*\\\<\\\/$1\\\>/g; return $matchexp; }