version 1.126, 2002/06/24 15:09:52
|
version 1.129, 2002/06/25 15:08:59
|
Line 67 search (on a server basis) is displayed
|
Line 67 search (on a server basis) is displayed
|
############################################################################### |
############################################################################### |
############################################################################### |
############################################################################### |
|
|
|
############################################################################### |
## ## |
## ## |
## ORGANIZATION OF THIS PERL MODULE ## |
## ORGANIZATION OF THIS PERL MODULE ## |
## ## |
## ## |
## 1. Modules used by this module ## |
## 1. Modules used by this module ## |
## 2. Choices for different output views (detailed, summary, xml, etc) ## |
## 2. Variables used throughout the module ## |
## 3. BEGIN block (to be run once after compilation) ## |
## 3. handler subroutine called via Apache and mod_perl ## |
## 4. Handling routine called via Apache and mod_perl ## |
## 4. Other subroutines ## |
## 5. Other subroutines ## |
|
## ## |
## ## |
############################################################################### |
############################################################################### |
|
|
Line 101 use Apache::loncommon();
|
Line 101 use Apache::loncommon();
|
|
|
=over 4 |
=over 4 |
|
|
=item %hostdomains |
|
|
|
matches host name to host domain |
|
|
|
=item %hostips |
|
|
|
matches host name to host ip |
|
|
|
=item %hitcount |
|
|
|
stores number of hits per host |
|
|
|
=item $closebutton |
=item $closebutton |
|
|
button that closes the search window |
button that closes the search window |
Line 137 used in &handler() and is also used in &
|
Line 125 used in &handler() and is also used in &
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
|
|
# -- information holders |
|
my %hostdomains; # matches host name to host domain |
|
my %hostips; # matches host name to host ip |
|
my %hitcount; # stores number of hits per host |
|
|
|
# -- dynamically rendered interface components |
# -- dynamically rendered interface components |
my $closebutton; # button that closes the search window |
my $closebutton; # button that closes the search window |
my $importbutton; # button to take the selected results and go to group sorting |
my $importbutton; # button to take the selected results and go to group sorting |
|
|
# -- miscellaneous variables |
# -- miscellaneous variables |
my $yourself; # allows for quickly limiting to oneself |
|
my %hash; # database hash |
my %hash; # database hash |
|
my $diropendb = ""; # db file |
# ------------------------------------------ choices for different output views |
|
# Detailed Citation View ---> sub detailed_citation_view |
|
# Summary View ---> sub summary_view |
|
# Fielded Format ---> sub fielded_format_view |
|
# XML/SGML ---> sub xml_sgml_view |
|
|
|
#------------------------------------------------------------- global variables |
|
my $diropendb = ""; |
|
my $domain = ""; |
|
|
|
# ----------------------------------------------------------------------- BEGIN |
|
|
|
=pod |
|
|
|
=item BEGIN block |
|
|
|
Load %hostdomains and %hostips with data from lonnet.pm. Only library |
|
servers are considered. |
|
|
|
=cut |
|
|
|
BEGIN { |
|
foreach (keys (%Apache::lonnet::libserv)) { |
|
$hostdomains{$_}=$Apache::lonnet::hostdom{$_}; |
|
$hostips{$_}=$Apache::lonnet::hostip{$_}; |
|
} |
|
} |
|
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
Line 318 sub basic_search_form{
|
Line 273 sub basic_search_form{
|
$hidden |
$hidden |
<h3>Basic Search</h3> |
<h3>Basic Search</h3> |
<p> |
<p> |
Enter terms or phrases separated by AND, OR, or NOT then press SEARCH below. |
Enter terms or quoted phrases separated by AND, OR, or NOT |
|
then press SEARCH below. |
</p> |
</p> |
<p> |
<p> |
<table> |
<table> |
Line 367 Returns a scalar which holds html for th
|
Line 323 Returns a scalar which holds html for th
|
|
|
sub advanced_search_form{ |
sub advanced_search_form{ |
my ($closebutton,$hidden) = @_; |
my ($closebutton,$hidden) = @_; |
|
my $advanced_buttons = <<"END"; |
|
<p> |
|
<input type="submit" name="advancedsubmit" value='SEARCH' /> |
|
<input type="reset" name="reset" value='RESET' /> |
|
$closebutton |
|
<!-- advance view select --> |
|
<select name='advancedviewselect'> |
|
<option value='Detailed Citation View' selected="true"> |
|
Detailed Citation View</option> |
|
<option value='Summary View'>Summary View</option> |
|
<option value='Fielded Format'>Fielded Format</option> |
|
<option value='XML/SGML'>XML/SGML</option> |
|
</select> |
|
<!-- end of advanced view select --> |
|
<input type="button" value="HELP" onClick="openhelp()" /> |
|
</p> |
|
END |
my $scrout=<<"ENDHEADER"; |
my $scrout=<<"ENDHEADER"; |
<html> |
<html> |
<head> |
<head> |
Line 381 sub advanced_search_form{
|
Line 354 sub advanced_search_form{
|
</head> |
</head> |
<body bgcolor="#FFFFFF"> |
<body bgcolor="#FFFFFF"> |
<img align='right' src='/adm/lonIcons/lonlogos.gif' /> |
<img align='right' src='/adm/lonIcons/lonlogos.gif' /> |
<h1>Search Catalog</h1> |
<h1>Advanced Catalog Search</h1> |
<form method="post" action="/adm/searchcat"> |
|
$hidden |
|
<hr /> |
<hr /> |
<h3>Advanced Search</h3> |
Enter terms or quoted phrases separated by search operators |
|
such as AND, OR, or NOT.<br /> |
|
$advanced_buttons |
|
$hidden |
|
<table> |
ENDHEADER |
ENDHEADER |
$scrout.=&searchphrasefield('Limit by title','title', |
$scrout.=&searchphrasefield('title','title', |
$ENV{'form.title'}); |
$ENV{'form.title'}); |
$scrout.=&searchphrasefield('Limit by author','author', |
$scrout.=&searchphrasefield('author','author', |
$ENV{'form.author'}); |
$ENV{'form.author'}); |
$scrout.=&searchphrasefield('Limit by subject','subject', |
$scrout.=&searchphrasefield('subject','subject', |
$ENV{'form.subject'}); |
$ENV{'form.subject'}); |
$scrout.=&searchphrasefield('Limit by keywords','keywords', |
$scrout.=&searchphrasefield('keywords','keywords', |
$ENV{'form.keywords'}); |
$ENV{'form.keywords'}); |
$scrout.=&searchphrasefield('Limit by URL','url', |
$scrout.=&searchphrasefield('URL','url', |
$ENV{'form.url'}); |
$ENV{'form.url'}); |
# $scrout.=&searchphrasefield('Limit by version','version', |
# $scrout.=&searchphrasefield('Limit by version','version', |
# $ENV{'form.version'}); |
# $ENV{'form.version'}); |
$scrout.=&searchphrasefield('Limit by notes','notes', |
$scrout.=&searchphrasefield('notes','notes', |
$ENV{'form.notes'}); |
$ENV{'form.notes'}); |
$scrout.=&searchphrasefield('Limit by abstract','abstract', |
$scrout.=&searchphrasefield('abstract','abstract', |
$ENV{'form.abstract'}); |
$ENV{'form.abstract'}); |
$ENV{'form.mime'}='any' unless length($ENV{'form.mime'}); |
# Hack - an empty table row. |
$scrout.=&selectbox('Limit by MIME type','mime', |
$scrout.="<tr><td> </td><td> </td></tr>\n"; |
$ENV{'form.mime'}, |
$scrout.=&searchphrasefield('file<br />extension','mime', |
'any','Any type', |
$ENV{'form.mime'}); |
\&{Apache::loncommon::filedescriptionex}, |
$scrout.="<tr><td> </td><td> </td></tr>\n"; |
(&Apache::loncommon::fileextensions)); |
$scrout.=&searchphrasefield('publisher<br />owner','owner', |
|
$ENV{'form.owner'}); |
|
$scrout.="</table>\n"; |
|
# $ENV{'form.mime'}='any' unless length($ENV{'form.mime'}); |
|
# $scrout.=&selectbox('Limit by MIME type','mime', |
|
# $ENV{'form.mime'}, |
|
# 'any','Any type', |
|
# \&{Apache::loncommon::filedescriptionex}, |
|
# (&Apache::loncommon::fileextensions)); |
$ENV{'form.language'}='any' unless length($ENV{'form.language'}); |
$ENV{'form.language'}='any' unless length($ENV{'form.language'}); |
$scrout.=&selectbox('Limit by language','language', |
$scrout.=&selectbox('Limit by language','language', |
$ENV{'form.language'},'any','Any Language', |
$ENV{'form.language'},'any','Any Language', |
Line 455 LASTREVISIONDATEEND
|
Line 438 LASTREVISIONDATEEND
|
$ENV{'form.lastrevisiondateend_year'}, |
$ENV{'form.lastrevisiondateend_year'}, |
); |
); |
$scrout.='</p>'; |
$scrout.='</p>'; |
$scrout.=&searchphrasefield('Limit by publisher/owner','owner', |
|
$ENV{'form.owner'}); |
|
$ENV{'form.copyright'}='any' unless length($ENV{'form.copyright'}); |
$ENV{'form.copyright'}='any' unless length($ENV{'form.copyright'}); |
$scrout.=&selectbox('Limit by copyright/distribution','copyright', |
$scrout.=&selectbox('Limit by copyright/distribution','copyright', |
$ENV{'form.copyright'}, |
$ENV{'form.copyright'}, |
Line 485 in a fielded listing for each record res
|
Line 466 in a fielded listing for each record res
|
CUSTOMSHOW |
CUSTOMSHOW |
$scrout.=&simpletextfield('customshow',$ENV{'form.customshow'}); |
$scrout.=&simpletextfield('customshow',$ENV{'form.customshow'}); |
$scrout.=<<ENDDOCUMENT; |
$scrout.=<<ENDDOCUMENT; |
<p> |
$advanced_buttons |
<input type="submit" name="advancedsubmit" value='SEARCH' /> |
|
<input type="reset" name="reset" value='RESET' /> |
|
$closebutton |
|
<!-- advance view select --> |
|
<select name='advancedviewselect'> |
|
<option value='Detailed Citation View' selected="true"> |
|
Detailed Citation View</option> |
|
<option value='Summary View'>Summary View</option> |
|
<option value='Fielded Format'>Fielded Format</option> |
|
<option value='XML/SGML'>XML/SGML</option> |
|
</select> |
|
<!-- end of advanced view select --> |
|
<input type="button" value="HELP" onClick="openhelp()" /> |
|
</p> |
|
</form> |
</form> |
</body> |
</body> |
</html> |
</html> |
Line 579 the day, month, and year.
|
Line 546 the day, month, and year.
|
|
|
=item &selectbox() |
=item &selectbox() |
|
|
Returns html selection form. |
Returns a scalar containing an html <select> form. |
|
|
|
Inputs: |
|
|
|
=over 4 |
|
|
|
=item $title |
|
|
|
Printed above the select box, in uppercase. |
|
|
|
=item $name |
|
|
|
The name element of the <select> tag. |
|
|
|
=item $default |
|
|
|
The default value of the form. Can be $anyvalue or in @idlist. |
|
|
|
=item $anyvalue |
|
|
|
The <option value="..."> used to indicate a default of |
|
none of the values. |
|
|
|
=item $anytag |
|
|
|
The text associate with $anyvalue above. |
|
|
|
=item $functionref |
|
|
|
Each element in @idlist will be passed as a parameter |
|
to the function referenced here. The return value of the function should |
|
be a scalar description of the items. If this value is undefined the |
|
description of each item in @idlist will be the item name. |
|
|
|
=item @idlist |
|
|
|
The items to be selected from. One of these or $anyvalue will be the |
|
value returned by the form element, $ENV{form.$name}. |
|
|
|
=back |
|
|
=back |
=back |
|
|
Line 598 sub simpletextfield {
|
Line 604 sub simpletextfield {
|
sub simplecheckbox { |
sub simplecheckbox { |
my ($name,$value)=@_; |
my ($name,$value)=@_; |
my $checked=''; |
my $checked=''; |
$checked="CHECKED" if $value eq 'on'; |
$checked="checked" if $value eq 'on'; |
return '<input type="checkbox" name="'.$name.'" '. $checked . ' />'; |
return '<input type="checkbox" name="'.$name.'" '. $checked . ' />'; |
} |
} |
|
|
sub searchphrasefield { |
sub searchphrasefield { |
my ($title,$name,$value)=@_; |
my ($title,$name,$value)=@_; |
my $instruction=<<END; |
|
Enter terms or phrases separated by search operators such as AND, OR, or NOT. |
|
END |
|
my $uctitle=uc($title); |
my $uctitle=uc($title); |
return "\n". |
return '<tr><td><font color="#800000" face="helvetica">'. |
'<p><font color="#800000" face="helvetica"><b>'.$uctitle.':</b>'. |
'<b>'.$uctitle.': </b></font></td><td>'. |
"</FONT> $instruction<br />".&simpletextfield($name,$value,80); |
&simpletextfield($name,$value,50)."</td></tr>\n"; |
} |
} |
|
|
sub dateboxes { |
sub dateboxes { |
Line 658 END
|
Line 661 END
|
} |
} |
|
|
sub selectbox { |
sub selectbox { |
my ($title,$name,$value,$anyvalue,$anytag,$functionref,@idlist)=@_; |
my ($title,$name,$default,$anyvalue,$anytag,$functionref,@idlist)=@_; |
|
if (! defined($functionref)) { $functionref = sub { $_[0]}; } |
my $uctitle=uc($title); |
my $uctitle=uc($title); |
my $selout="\n".'<p><font color="#800000" face="helvetica">'. |
my $selout="\n".'<p><font color="#800000" face="helvetica">'. |
'<b>'.$uctitle.':</b></font><br /><select name="'.$name.'">'; |
'<b>'.$uctitle.':</b></font><br /><select name="'.$name.'">'; |
foreach ($anyvalue,@idlist) { |
foreach ($anyvalue,@idlist) { |
$selout.='<option value="'.$_.'"'; |
$selout.='<option value="'.$_.'"'; |
if ($_ eq $value and !/^any$/) { |
if ($_ eq $default and !/^any$/) { |
$selout.=' selected >'.&{$functionref}($_).'</option>'; |
$selout.=' selected >'.&{$functionref}($_).'</option>'; |
} |
} |
elsif ($_ eq $value and /^$anyvalue$/) { |
elsif ($_ eq $default and /^$anyvalue$/) { |
$selout.=' selected >'.$anytag.'</option>'; |
$selout.=' selected >'.$anytag.'</option>'; |
} |
} |
else {$selout.='>'.&{$functionref}($_).'</option>';} |
else {$selout.='>'.&{$functionref}($_).'</option>';} |
} |
} |
return $selout.'</select>'; |
return $selout.'</select></p>'; |
} |
} |
|
|
###################################################################### |
###################################################################### |
Line 727 sub advancedsearch {
|
Line 731 sub advancedsearch {
|
my @queries; |
my @queries; |
# Evaluate logical expression AND/OR/NOT phrase fields. |
# Evaluate logical expression AND/OR/NOT phrase fields. |
foreach my $field ('title','author','subject','notes','abstract','url', |
foreach my $field ('title','author','subject','notes','abstract','url', |
'keywords','version','owner') { |
'keywords','version','owner','mime') { |
if ($ENV{'form.'.$field}) { |
if ($ENV{'form.'.$field}) { |
push @queries,&build_SQL_query($field,$ENV{'form.'.$field}); |
push @queries,&build_SQL_query($field,$ENV{'form.'.$field}); |
} |
} |
Line 736 sub advancedsearch {
|
Line 740 sub advancedsearch {
|
if ($ENV{'form.language'} and $ENV{'form.language'} ne 'any') { |
if ($ENV{'form.language'} and $ENV{'form.language'} ne 'any') { |
push @queries,"(language like \"$ENV{'form.language'}\")"; |
push @queries,"(language like \"$ENV{'form.language'}\")"; |
} |
} |
if ($ENV{'form.mime'} and $ENV{'form.mime'} ne 'any') { |
# if ($ENV{'form.mime'} and $ENV{'form.mime'} ne 'any') { |
push @queries,"(mime like \"$ENV{'form.mime'}\")"; |
# push @queries,"(mime like \"$ENV{'form.mime'}\")"; |
} |
# } |
if ($ENV{'form.copyright'} and $ENV{'form.copyright'} ne 'any') { |
if ($ENV{'form.copyright'} and $ENV{'form.copyright'} ne 'any') { |
push @queries,"(copyright like \"$ENV{'form.copyright'}\")"; |
push @queries,"(copyright like \"$ENV{'form.copyright'}\")"; |
} |
} |
Line 1066 sub output_results {
|
Line 1070 sub output_results {
|
<img align=right src=/adm/lonIcons/lonlogos.gif> |
<img align=right src=/adm/lonIcons/lonlogos.gif> |
<h1>Search Catalog</h1> |
<h1>Search Catalog</h1> |
CATALOGBEGIN |
CATALOGBEGIN |
$r->print(<<CATALOGCONTROLS); |
my $action = "/adm/searchcat"; |
<form name='results' method="post" action="/adm/searchcat"> |
if ($mode eq 'Basic') { |
|
$action .= "?reqinterface=basic"; |
|
} elsif ($mode eq 'Advanced') { |
|
$action .= "?reqinterface=advanced"; |
|
} |
|
$r->print(<<CATALOGCONTROLS); |
|
<form name='results' method="post" action="$action"> |
$hidden |
$hidden |
<input type='hidden' name='acts' value='' /> |
<input type='hidden' name='acts' value='' /> |
<input type='button' value='Revise search request' |
<input type='button' value='Revise search request' |
Line 1143 CATALOGCONTROLS
|
Line 1153 CATALOGCONTROLS
|
return OK; |
return OK; |
} |
} |
@results=<$fh> if $fh; |
@results=<$fh> if $fh; |
$hitcount{$rkey}=@results+0; |
my $hits =@results; |
&popwin_js($r,'popwin.hc["'.$rkey.'"]='. |
&popwin_js($r,'popwin.hc["'.$rkey.'"]='. |
$hitcount{$rkey}.';'); |
$hits.';'); |
$hitcountsum+=$hitcount{$rkey}; |
$hitcountsum+=$hits; |
&popwin_js($r,'popwin.document.forms.popremain.'. |
&popwin_js($r,'popwin.document.forms.popremain.'. |
'numhits.value='.$hitcountsum.';'); |
'numhits.value='.$hitcountsum.';'); |
} else { |
} else { |
Line 1547 sub make_popwin {
|
Line 1557 sub make_popwin {
|
$hcinit.="hc[\"$sk\"]=\"not yet connected...\";"; |
$hcinit.="hc[\"$sk\"]=\"not yet connected...\";"; |
} |
} |
$grid.=" hitcount=".$hc; |
$grid.=" hitcount=".$hc; |
$grid.=" domain=".$hostdomains{$sk}; |
$grid.=" domain=".$Apache::lonnet::hostdom{$sk}; |
$grid.=" IP=".$hostips{$sk}; |
$grid.=" IP=".$Apache::lonnet::hostip{$sk}; |
# '+"'"+'">'+ |
# '+"'"+'">'+ |
$grid.="'+\"'\"+')\">'+"; |
$grid.="'+\"'\"+')\">'+"; |
$grid.="\n"; |
$grid.="\n"; |
$grid.="'<img border=\"0\" name=\"img_".$hostdomains{$sk}.'_'.$sk."\"". |
$grid.="'<img border=\"0\" name=\"img_".$Apache::lonnet::hostdom{$sk}. |
" src=\"/adm/lonIcons/srvnull.gif\" alt=\"".$sk."\" /></a>'+\n"; |
'_'.$sk."\" src=\"/adm/lonIcons/srvnull.gif\" alt=\"".$sk. |
|
"\" /></a>'+\n"; |
$grid.="'<br />'+\n" unless $sn%10; |
$grid.="'<br />'+\n" unless $sn%10; |
$sn++; |
$sn++; |
} |
} |
Line 1943 input $r, loncapa server id, and an icon
|
Line 1954 input $r, loncapa server id, and an icon
|
###################################################################### |
###################################################################### |
sub popwin_imgupdate { |
sub popwin_imgupdate { |
my ($r,$server,$icon) = @_; |
my ($r,$server,$icon) = @_; |
&popwin_js($r,'popwin.document.img_'.$hostdomains{$server}.'_'.$server.'.'. |
&popwin_js($r,'popwin.document.img_'.$Apache::lonnet::hostdom{$server}. |
'src="/adm/lonIcons/'.$icon.'";'); |
'_'.$server.'.'.'src="/adm/lonIcons/'.$icon.'";'); |
} |
} |
|
|
1; |
1; |