version 1.125, 2002/06/20 19:43:50
|
version 1.126, 2002/06/24 15:09:52
|
Line 515 ENDDOCUMENT
|
Line 515 ENDDOCUMENT
|
=item &make_persistent() |
=item &make_persistent() |
|
|
Returns a scalar which holds the current ENV{'form.*'} values in |
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 |
=cut |
|
|
Line 573 is where the $name and $value are used)
|
Line 574 is where the $name and $value are used)
|
|
|
=item &dateboxes() |
=item &dateboxes() |
|
|
|
Returns html selection form elements for the specification of |
|
the day, month, and year. |
|
|
=item &selectbox() |
=item &selectbox() |
|
|
|
Returns html selection form. |
|
|
=back |
=back |
|
|
=cut |
=cut |
Line 674 sub selectbox {
|
Line 680 sub selectbox {
|
|
|
=pod |
=pod |
|
|
=item &advancedsearch() |
=item &advancedsearch() |
|
|
|
Parse advanced search results. |
|
|
=cut |
=cut |
|
|
Line 785 sub advancedsearch {
|
Line 793 sub advancedsearch {
|
$customquery,$customshow); |
$customquery,$customshow); |
} |
} |
&output_results('Advanced',$r,$envhash,$customquery,$reply,$hidden); |
&output_results('Advanced',$r,$envhash,$customquery,$reply,$hidden); |
} |
return OK; |
elsif ($customquery) { |
} elsif ($customquery) { |
my $reply; # reply hash reference |
my $reply; # reply hash reference |
$reply=&Apache::lonnet::metadata_query('', |
$reply=&Apache::lonnet::metadata_query('', |
$customquery,$customshow); |
$customquery,$customshow); |
&output_results('Advanced',$r,$envhash,$customquery,$reply,$hidden); |
&output_results('Advanced',$r,$envhash,$customquery,$reply,$hidden); |
|
return OK; |
} |
} |
# should not get to this point |
# should not get to this point |
return 'Error. Should not have gone to this point.'; |
return 'Error. Should not have gone to this point.'; |
Line 803 sub advancedsearch {
|
Line 812 sub advancedsearch {
|
|
|
=item &basicsearch() |
=item &basicsearch() |
|
|
|
Parse basic search form. |
|
|
=cut |
=cut |
|
|
###################################################################### |
###################################################################### |
Line 837 sub basicsearch {
|
Line 848 sub basicsearch {
|
$query=&build_SQL_query('concat('.$concatarg.')',$ENV{'form.'.'basicexp'}); |
$query=&build_SQL_query('concat('.$concatarg.')',$ENV{'form.'.'basicexp'}); |
|
|
# Get reply (either a hash reference to filehandles or bad connection) |
# 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); |
my $reply=&Apache::lonnet::metadata_query('select * from metadata where '.$query); |
|
# &Apache::lonnet::logthis("metadata query finished:".time); |
# Output search results |
# Output search results |
|
|
&output_results('Basic',$r,$envhash,$query,$reply,$hidden); |
&output_results('Basic',$r,$envhash,$query,$reply,$hidden); |
Line 854 sub basicsearch {
|
Line 866 sub basicsearch {
|
|
|
=item &build_SQL_query() |
=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 |
=cut |
|
|
###################################################################### |
###################################################################### |
Line 876 sub build_SQL_query {
|
Line 891 sub build_SQL_query {
|
|
|
=item &build_custommetadata_query() |
=item &build_custommetadata_query() |
|
|
|
Constructs a custom metadata query using a rather heinous regular |
|
expression. |
|
|
=cut |
=cut |
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
sub build_custommetadata_query { |
sub build_custommetadata_query { |
my ($field_name,$logic_statement)=@_; |
my ($field_name,$logic_statement)=@_; |
&Apache::lonnet::logthis("Entered build_custommetadata_query:". |
|
$field_name.':'.$logic_statement); |
|
my $q=new Text::Query('abc', |
my $q=new Text::Query('abc', |
-parse => 'Text::Query::ParseAdvanced', |
-parse => 'Text::Query::ParseAdvanced', |
-build => 'Text::Query::BuildAdvancedString'); |
-build => 'Text::Query::BuildAdvancedString'); |
Line 898 sub build_custommetadata_query {
|
Line 914 sub build_custommetadata_query {
|
\*$2\[\^\\<\]?# *wordtwo[^\<] |
\*$2\[\^\\<\]?# *wordtwo[^\<] |
\*\\<\\\/$1\\>?# *\<\/wordone\> |
\*\\<\\\/$1\\>?# *\<\/wordone\> |
/g; |
/g; |
&Apache::lonnet::logthis("match expression: ".$matchexp); |
|
return $matchexp; |
return $matchexp; |
} |
} |
|
|
Line 909 sub build_custommetadata_query {
|
Line 924 sub build_custommetadata_query {
|
|
|
=item &recursive_SQL_query_build() |
=item &recursive_SQL_query_build() |
|
|
|
Recursively constructs an SQL query. Takes as input $dkey and $pattern. |
|
|
=cut |
=cut |
|
|
###################################################################### |
###################################################################### |
Line 953 sub recursive_SQL_query_build {
|
Line 970 sub recursive_SQL_query_build {
|
|
|
=item &build_date_queries() |
=item &build_date_queries() |
|
|
|
Builds a SQL logic query to check time/date entries. |
|
Also reports errors (check for /^Incorrect/). |
|
|
=cut |
=cut |
|
|
###################################################################### |
###################################################################### |
Line 1023 contacted, etc.)
|
Line 1043 contacted, etc.)
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
sub output_results { |
sub output_results { |
|
# &Apache::lonnet::logthis("output_results:".time); |
my $fnum; # search result counter |
my $fnum; # search result counter |
my ($mode,$r,$envhash,$query,$replyref,$hidden)=@_; |
my ($mode,$r,$envhash,$query,$replyref,$hidden)=@_; |
my %ENV=%{$envhash}; |
my %ENV=%{$envhash}; |
Line 1088 CATALOGCONTROLS
|
Line 1109 CATALOGCONTROLS
|
## (within the foreach loop below). |
## (within the foreach loop below). |
## |
## |
foreach my $rkey (sort keys %rhash) { |
foreach my $rkey (sort keys %rhash) { |
|
# &Apache::lonnet::logthis("Server $rkey:".time); |
$servercount++; |
$servercount++; |
$tflag=1; |
|
$compiledresult=''; |
$compiledresult=''; |
my $hostname=$rkey; |
|
my $reply=$rhash{$rkey}; |
my $reply=$rhash{$rkey}; |
my @results; |
my @results; |
if ($reply eq 'con_lost') { |
if ($reply eq 'con_lost') { |
Line 1103 CATALOGCONTROLS
|
Line 1123 CATALOGCONTROLS
|
$reply=~/^([\.\w]+)$/; |
$reply=~/^([\.\w]+)$/; |
my $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1; |
my $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1; |
$reply=~/(.*?)\_/; |
$reply=~/(.*?)\_/; |
{ |
for (my $counter=0;$counter<2;$counter++) { |
my $temp=0; |
if (-e $replyfile && ! -e "$replyfile.end") { |
WLOOP: while (1) { |
&popwin_imgupdate($r,$rkey,"srvhalf.gif"); |
if (-e $replyfile && $tflag) { |
&popwin_js($r,'popwin.hc["'.$rkey.'"]='. |
&popwin_imgupdate($r,$rkey,"srvhalf.gif"); |
'"still transferring..."'.';'); |
&popwin_js($r,'popwin.hc["'.$rkey.'"]='. |
} |
'"still transferring..."'.';'); |
# Are we finished transferring data? |
$tflag=0; |
if (-e "$replyfile.end") { |
} |
$serversleft--; |
if (-e "$replyfile.end") { |
delete $rhash{$rkey}; |
$serversleft--; |
if (-s $replyfile) { |
delete $rhash{$rkey}; |
&popwin_imgupdate($r,$rkey,"srvgood.gif"); |
if (-s $replyfile) { |
my $fh; |
&popwin_imgupdate($r,$rkey,"srvgood.gif"); |
unless ($fh=Apache::File->new($replyfile)){ |
my $fh=Apache::File->new($replyfile) or |
# Is it really appropriate to die on this error? |
($r->print('ERROR: file '. |
$r->print('ERROR: file '. |
$replyfile.' cannot be opened') and |
$replyfile.' cannot be opened'); |
return OK); |
return OK; |
@results=<$fh> if $fh; |
} |
$hitcount{$rkey}=@results+0; |
@results=<$fh> if $fh; |
&popwin_js($r,'popwin.hc["'.$rkey.'"]='. |
$hitcount{$rkey}=@results+0; |
$hitcount{$rkey}.';'); |
&popwin_js($r,'popwin.hc["'.$rkey.'"]='. |
$hitcountsum+=$hitcount{$rkey}; |
$hitcount{$rkey}.';'); |
&popwin_js($r,'popwin.document.forms.popremain.'. |
$hitcountsum+=$hitcount{$rkey}; |
'numhits.value='.$hitcountsum.';'); |
&popwin_js($r,'popwin.document.forms.popremain.'. |
} |
'numhits.value='.$hitcountsum.';'); |
else { |
} else { |
&popwin_imgupdate($r,$rkey,"srvempty.gif"); |
&popwin_imgupdate($r,$rkey,"srvempty.gif"); |
&popwin_js($r,'popwin.hc["'.$rkey.'"]=0;'); |
&popwin_js($r,'popwin.hc["'.$rkey.'"]=0;'); |
} |
} |
last WLOOP; |
last; |
} # end of if ( -e "$replyfile.end") |
} # end of if ( -e "$replyfile.end") |
last WLOOP unless $timeremain; |
last unless $timeremain; |
sleep 1; # wait for daemons to write files? |
sleep 1; # wait for daemons to write files? |
$timeremain--; |
$timeremain--; |
$elapsetime++; |
$elapsetime++; |
last WLOOP if ($temp>1); |
&popwin_js($r,"popwin.document.popremain.". |
&popwin_js($r,"popwin.document.popremain.". |
"elapsetime.value=$elapsetime;"); |
"elapsetime.value=$elapsetime;"); |
|
$temp++; |
|
} |
|
} |
} |
&popwin_js($r,'popwin.document.whirly.'. |
&popwin_js($r,'popwin.document.whirly.'. |
'src="/adm/lonIcons/lonanimend.gif";'); |
'src="/adm/lonIcons/lonanimend.gif";'); |
} # end of if ($reply eq 'con_lost') else statement |
} # end of if ($reply eq 'con_lost') else statement |
my $customshow=''; |
my %Fields = undef; # Holds the data to be sent to the various |
my $extrashow=''; |
# *_view routines. |
my @customfields; |
my ($extrashow,$customfields,$customhash) = &handle_custom_fields(\@results); |
if ($ENV{'form.customshow'}) { |
my @customfields = @$customfields; |
$customshow=$ENV{'form.customshow'}; |
my %customhash = %$customhash; |
$customshow=~s/[^\w\s]//g; |
untie %hash if (keys %hash); |
my @fields=map {"<font color=\"#008000\">$_:</font><!-- $_ -->"} |
# |
split(/\s+/,$customshow); |
if (! tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) { |
@customfields=split(/\s+/,$customshow); |
$r->print('<html><head></head><body>Unable to tie hash to db '. |
if ($customshow) { |
'file</body></html>'); |
$extrashow="<ul><li>".join("</li><li>",@fields)."</li></ul>\n"; |
} else { |
} |
|
} |
|
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)) { |
|
if ($ENV{'form.launch'} eq '1') { |
if ($ENV{'form.launch'} eq '1') { |
&start_fresh_session(); |
&start_fresh_session(); |
} |
} |
Line 1183 CATALOGCONTROLS
|
Line 1183 CATALOGCONTROLS
|
next if $result=~/^custom\=/; |
next if $result=~/^custom\=/; |
chomp $result; |
chomp $result; |
next unless $result; |
next unless $result; |
my @fields=map |
%Fields = &parse_raw_result($result,$rkey); |
{&Apache::lonnet::unescape($_)} |
$Fields{'extrashow'}=$extrashow; |
(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; |
|
if ($extrashow) { |
if ($extrashow) { |
foreach my $field (@customfields) { |
foreach my $field (@customfields) { |
my $value=''; |
my $value=''; |
if ($customhash{$url}=~/\<${field}[^\>]*\>(.*?)\<\/${field}[^\>]*\>/s) { |
$value = $1 if ($customhash{$Fields{'url'}}=~/\<{$field}[^\>]*\>(.*?)\<\/{$field}[^\>]*\>/s); |
$value=$1; |
$Fields{'extrashow'}=~s/\<\!\-\- $field \-\-\>/ $value/g; |
} |
} |
$extrashow2=~s/\<\!\-\- $field \-\-\>/ $value/g; |
|
} |
|
} |
} |
|
if ($compiledresult or $servercount!=$servernum) { |
$compiledresult.=<<END if $compiledresult or $servercount!=$servernum; |
$compiledresult.="<hr align='left' width='200' noshade />"; |
<hr align='left' width='200' noshade /> |
} |
END |
$compiledresult.="\n<p>\n"; |
$compiledresult.=<<END; |
if ($ENV{'form.catalogmode'} eq 'interactive') { |
<p> |
my $titleesc=$Fields{'title'}; |
END |
$titleesc=~s/\'/\\'/; # ' |
if ($ENV{'form.catalogmode'} eq 'interactive') { |
$compiledresult.=<<END if ($ENV{'form.catalogmode'} eq 'interactive'); |
my $titleesc=$title; |
|
$titleesc=~s/\'/\\'/; # ' |
|
|
|
$compiledresult.=<<END if ($ENV{'form.catalogmode'} eq 'interactive'); |
|
<font size='-1'><INPUT TYPE="button" NAME="returnvalues" VALUE="SELECT" |
<font size='-1'><INPUT TYPE="button" NAME="returnvalues" VALUE="SELECT" |
onClick="javascript:select_data('$titleesc','$url')"> |
onClick="javascript:select_data('$titleesc','$Fields{'url'}')"> |
</font> |
</font> |
<br /> |
<br /> |
END |
END |
} |
} |
if ($ENV{'form.catalogmode'} eq 'groupsearch') { |
if ($ENV{'form.catalogmode'} eq 'groupsearch') { |
$fnum+=0; |
$fnum+=0; |
$hash{"pre_${fnum}_link"}=$url; |
$hash{"pre_${fnum}_link"}=$Fields{'url'}; |
$hash{"pre_${fnum}_title"}=$title; |
$hash{"pre_${fnum}_title"}=$Fields{'title'}; |
$compiledresult.=<<END; |
$compiledresult.=<<END; |
<font size='-1'> |
<font size='-1'> |
<input type="checkbox" name="returnvalues" value="SELECT" |
<input type="checkbox" name="returnvalues" value="SELECT" |
Line 1251 END
|
Line 1221 END
|
# <input type="hidden" name="url$fnum" value="$url" /> |
# <input type="hidden" name="url$fnum" value="$url" /> |
$fnum++; |
$fnum++; |
} |
} |
my $httphost=$ENV{'HTTP_HOST'}; |
|
|
|
my $viewselect; |
my $viewselect; |
if ($mode eq 'Basic') { |
if ($mode eq 'Basic') { |
$viewselect=$ENV{'form.basicviewselect'}; |
$viewselect=$ENV{'form.basicviewselect'}; |
Line 1260 END
|
Line 1228 END
|
elsif ($mode eq 'Advanced') { |
elsif ($mode eq 'Advanced') { |
$viewselect=$ENV{'form.advancedviewselect'}; |
$viewselect=$ENV{'form.advancedviewselect'}; |
} |
} |
|
|
if ($viewselect eq 'Detailed Citation View') { |
if ($viewselect eq 'Detailed Citation View') { |
$compiledresult.=&detailed_citation_view(@fields, |
$compiledresult.=&detailed_citation_view |
$hostname,$httphost, |
(%Fields, hostname => $rkey ); |
$extrashow2); |
|
} |
} |
elsif ($viewselect eq 'Summary View') { |
elsif ($viewselect eq 'Summary View') { |
$compiledresult.=&summary_view(@fields,$hostname,$httphost, |
$compiledresult.=&summary_view |
$extrashow2); |
(%Fields, hostname => $rkey ); |
} |
} |
elsif ($viewselect eq 'Fielded Format') { |
elsif ($viewselect eq 'Fielded Format') { |
$compiledresult.=&fielded_format_view(@fields,$hostname, |
$compiledresult.=&fielded_format_view |
$httphost,$extrashow2); |
(%Fields, hostname => $rkey ); |
} |
} |
elsif ($viewselect eq 'XML/SGML') { |
elsif ($viewselect eq 'XML/SGML') { |
$compiledresult.=&xml_sgml_view(@fields,$hostname,$httphost, |
$compiledresult.=&xml_sgml_view |
$extrashow2); |
(%Fields, hostname => $rkey ); |
} |
} |
|
|
} |
} |
|
|
untie %hash; |
untie %hash; |
} |
} |
else { |
|
$r->print('<html><head></head><body>Unable to tie hash to db '. |
|
'file</body></html>'); |
|
} |
|
if ($compiledresult) { |
if ($compiledresult) { |
$resultflag=1; |
$resultflag=1; |
|
$r->print($compiledresult); |
} |
} |
|
|
$r->print(<<RESULTS); |
|
$compiledresult |
|
RESULTS |
|
my $percent=sprintf('%3.0f',($servercount/$servernum*100)); |
my $percent=sprintf('%3.0f',($servercount/$servernum*100)); |
} |
} # End of foreach loop over servers remaining |
} |
} # End of big loop - while($serversleft && $timeremain) |
unless ($resultflag) { |
unless ($resultflag) { |
$r->print("\nThere were no results that matched your query\n"); |
$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('<script type="text/javascript">'.'popwin.close()</script>'."\n"); $r->rflush(); |
$r->print(<<RESULTS); |
$r->print("</body>\n</html>\n"); |
</body> |
return; |
</html> |
} |
RESULTS |
|
|
########################################################### |
|
########################################################### |
|
|
|
=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); |
} |
} |
|
|
###################################################################### |
###################################################################### |
Line 1314 RESULTS
|
Line 1392 RESULTS
|
|
|
=item &search_results_header |
=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 |
=cut |
|
|
###################################################################### |
###################################################################### |
Line 1515 ENDPOP
|
Line 1614 ENDPOP
|
Output is a HTML-ified string. |
Output is a HTML-ified string. |
Input arguments are title, author, subject, url, keywords, version, |
Input arguments are title, author, subject, url, keywords, version, |
notes, short abstract, mime, language, creation date, |
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. |
extra custom metadata to show. |
|
|
=over 4 |
=over 4 |
Line 1527 extra custom metadata to show.
|
Line 1626 extra custom metadata to show.
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
sub detailed_citation_view { |
sub detailed_citation_view { |
my ($title,$author,$subject,$url,$keywords,$version, |
my %values = @_; |
$notes,$shortabstract,$mime,$lang, |
|
$creationdate,$lastrevisiondate,$owner,$copyright, |
|
$hostname,$httphost,$extrashow)=@_; |
|
my $result=<<END; |
my $result=<<END; |
<i>$owner</i>, last revised $lastrevisiondate |
<i>$values{'owner'}</i>, last revised $values{'lastrevisiondate'} |
<h3><A HREF="http://$httphost$url" TARGET='search_preview'>$title</A></h3> |
<h3><a href="http://$ENV{'HTTP_HOST'}$values{'url'}" |
<h3>$author</h3> |
target='search_preview'>$values{'title'}</a></h3> |
|
<h3>$values{'author'}</h3> |
</p> |
</p> |
<p> |
<p> |
<b>Subject:</b> $subject<br /> |
<b>Subject:</b> $values{'subject'}<br /> |
<b>Keyword(s):</b> $keywords<br /> |
<b>Keyword(s):</b> $values{'keywords'}<br /> |
<b>Notes:</b> $notes<br /> |
<b>Notes:</b> $values{'notes'}<br /> |
<b>MIME Type:</b> |
<b>MIME Type:</b> |
END |
END |
$result.=&Apache::loncommon::filedescription($mime); |
$result.=&Apache::loncommon::filedescription($values{'mime'}); |
$result.=<<END; |
$result.=<<END; |
<br /> |
<br /> |
<b>Language:</b> |
<b>Language:</b> |
END |
END |
$result.=&Apache::loncommon::languagedescription($lang); |
$result.=&Apache::loncommon::languagedescription($values{'lang'}); |
$result.=<<END; |
$result.=<<END; |
<br /> |
<br /> |
<b>Copyright/Distribution:</b> |
<b>Copyright/Distribution:</b> |
END |
END |
$result.=&Apache::loncommon::copyrightdescription($copyright); |
$result.=&Apache::loncommon::copyrightdescription($values{'copyright'}); |
$result.=<<END; |
$result.=<<END; |
<br /> |
<br /> |
</p> |
</p> |
$extrashow |
$values{'extrashow'} |
<p> |
<p> |
$shortabstract |
$values{'shortabstract'} |
</p> |
</p> |
END |
END |
return $result; |
return $result; |
Line 1576 END
|
Line 1673 END
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
sub summary_view { |
sub summary_view { |
my ($title,$author,$subject,$url,$keywords,$version, |
my %values = @_; |
$notes,$shortabstract,$mime,$lang, |
|
$creationdate,$lastrevisiondate,$owner,$copyright, |
|
$hostname,$httphost,$extrashow)=@_; |
|
my $cprtag=&Apache::loncommon::copyrightdescription($copyright); |
|
my $result=<<END; |
my $result=<<END; |
<a href="http://$httphost$url" TARGET='search_preview'>$author</a><br /> |
<a href="http://$ENV{'HTTP_HOST'}$values{'url'}" |
$title<br /> |
target='search_preview'>$values{'author'}</a><br /> |
$owner -- $lastrevisiondate<br /> |
$values{'title'}<br /> |
$cprtag<br /> |
$values{'owner'} -- $values{'lastrevisiondate'}<br /> |
$extrashow |
$values{'copyrighttag'}<br /> |
|
$values{'extrashow'} |
</p> |
</p> |
END |
END |
return $result; |
return $result; |
Line 1604 END
|
Line 1698 END
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
sub fielded_format_view { |
sub fielded_format_view { |
my ($title,$author,$subject,$url,$keywords,$version, |
my %values = @_; |
$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 $result=<<END; |
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 /> |
<br /> |
<b>Title:</b> $title<br /> |
<b>Title:</b> $values{'title'}<br /> |
<b>Author(s):</b> $author<br /> |
<b>Author(s):</b> $values{'author'}<br /> |
<b>Subject:</b> $subject<br /> |
<b>Subject:</b> $values{'subject'}<br /> |
<b>Keyword(s):</b> $keywords<br /> |
<b>Keyword(s):</b> $values{'keywords'}<br /> |
<b>Notes:</b> $notes<br /> |
<b>Notes:</b> $values{'notes'}<br /> |
<b>MIME Type:</b> $mimetag<br /> |
<b>MIME Type:</b> $values{'mimetag'}<br /> |
<b>Language:</b> $language<br /> |
<b>Language:</b> $values{'language'}<br /> |
<b>Creation Date:</b> $creationdate<br /> |
<b>Creation Date:</b> $values{'creationdate'}<br /> |
<b>Last Revision Date:</b> $lastrevisiondate<br /> |
<b>Last Revision Date:</b> $values{'lastrevisiondate'}<br /> |
<b>Publisher/Owner:</b> $owner<br /> |
<b>Publisher/Owner:</b> $values{'owner'}<br /> |
<b>Copyright/Distribution:</b> $cprtag<br /> |
<b>Copyright/Distribution:</b> $values{'copyrighttag'}<br /> |
<b>Repository Location:</b> $hostname<br /> |
<b>Repository Location:</b> $values{'hostname'}<br /> |
<b>Abstract:</b> $shortabstract<br /> |
<b>Abstract:</b> $values{'shortabstract'}<br /> |
$extrashow |
$values{'extrashow'} |
</p> |
</p> |
END |
END |
return $result; |
return $result; |
Line 1647 END
|
Line 1736 END
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
sub xml_sgml_view { |
sub xml_sgml_view { |
my ($title,$author,$subject,$url,$keywords,$version, |
my %values = @_; |
$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 $result=<<END; |
my $result=<<END; |
<pre> |
<pre> |
<LonCapaResource> |
<LonCapaResource> |
<url>$url</url> |
<url>$values{'url'}</url> |
<title>$title</title> |
<title>$values{'title'}</title> |
<author>$author</author> |
<author>$values{'author'}</author> |
<subject>$subject</subject> |
<subject>$values{'subject'}</subject> |
<keywords>$keywords</keywords> |
<keywords>$values{'keywords'}</keywords> |
<notes>$notes</notes> |
<notes>$values{'notes'}</notes> |
<mimeInfo> |
<mimeInfo> |
<mime>$mime</mime> |
<mime>$values{'mime'}</mime> |
<mimetag>$mimetag</mimetag> |
<mimetag>$values{'mimetag'}</mimetag> |
</mimeInfo> |
</mimeInfo> |
<languageInfo> |
<languageInfo> |
<language>$lang</language> |
<language>$values{'lang'}</language> |
<languagetag>$language</languagetag> |
<languagetag>$values{'language'}</languagetag> |
</languageInfo> |
</languageInfo> |
<creationdate>$creationdate</creationdate> |
<creationdate>$values{'creationdate'}</creationdate> |
<lastrevisiondate>$lastrevisiondate</lastrevisiondate> |
<lastrevisiondate>$values{'lastrevisiondate'}</lastrevisiondate> |
<owner>$owner</owner> |
<owner>$values{'owner'}</owner> |
<copyrightInfo> |
<copyrightInfo> |
<copyright>$copyright</copyright> |
<copyright>$values{'copyright'}</copyright> |
<copyrighttag>$cprtag</copyrighttag> |
<copyrighttag>$values{'copyrighttag'}</copyrighttag> |
</copyrightInfo> |
</copyrightInfo> |
<repositoryLocation>$hostname</repositoryLocation> |
<repositoryLocation>$values{'hostname'}</repositoryLocation> |
<shortabstract>$shortabstract</shortabstract> |
<shortabstract>$values{'shortabstract'}</shortabstract> |
</LonCapaResource> |
</LonCapaResource> |
</pre> |
</pre> |
$extrashow |
$values{'extrashow'} |
END |
END |
return $result; |
return $result; |
} |
} |
Line 1872 __END__
|
Line 1955 __END__
|
|
|
=back |
=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 |
=cut |