version 1.106, 2001/11/28 19:26:20
|
version 1.114, 2002/01/06 01:29:53
|
Line 1
|
Line 1
|
# The LearningOnline Network with CAPA |
# The LearningOnline Network with CAPA |
# |
|
# Search Catalog |
# Search Catalog |
# |
# |
|
# $Id$ |
|
# |
|
# Copyright Michigan State University Board of Trustees |
|
# |
|
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
|
# |
|
# LON-CAPA is free software; you can redistribute it and/or modify |
|
# it under the terms of the GNU General Public License as published by |
|
# the Free Software Foundation; either version 2 of the License, or |
|
# (at your option) any later version. |
|
# |
|
# LON-CAPA is distributed in the hope that it will be useful, |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
# GNU General Public License for more details. |
|
# |
|
# You should have received a copy of the GNU General Public License |
|
# along with LON-CAPA; if not, write to the Free Software |
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
# |
|
# /home/httpd/html/adm/gpl.txt |
|
# |
|
# http://www.lon-capa.org/ |
|
# |
# YEAR=2001 |
# YEAR=2001 |
# 3/8, 3/12, 3/13, 3/14, 3/15, 3/19 Scott Harrison |
# 3/8, 3/12, 3/13, 3/14, 3/15, 3/19 Scott Harrison |
# 3/20, 3/21, 3/22, 3/26, 3/27, 4/2, 8/15, 8/24, 8/25 Scott Harrison |
# 3/20, 3/21, 3/22, 3/26, 3/27, 4/2, 8/15, 8/24, 8/25 Scott Harrison |
# 10/12,10/14,10/15,10/16,11/28 Scott Harrison |
# 10/12,10/14,10/15,10/16,11/28,11/29,12/10,12/12,12/16 Scott Harrison |
# |
# |
# $Id$ |
|
### |
### |
|
|
############################################################################### |
############################################################################### |
Line 32 use Apache::File();
|
Line 54 use Apache::File();
|
use CGI qw(:standard); |
use CGI qw(:standard); |
use Text::Query; |
use Text::Query; |
use GDBM_File; |
use GDBM_File; |
|
use Apache::loncommon(); |
|
|
# ---------------------------------------- variables used throughout the module |
# ---------------------------------------- variables used throughout the module |
|
|
# -- information holders |
# -- information holders |
my %language; # holds contents of language.tab |
|
my %cprtag; # holds contents of copyright.tab |
|
my %mimetag; # holds contents of filetypes.tab |
|
my %hostdomains; # matches host name to host domain |
my %hostdomains; # matches host name to host domain |
my %hostips; # matches host name to host ip |
my %hostips; # matches host name to host ip |
my %hitcount; # stores number of hits per host |
my %hitcount; # stores number of hits per host |
Line 75 my $advancedviewselect=<<END;
|
Line 95 my $advancedviewselect=<<END;
|
END |
END |
|
|
# ----------------------------------------------------------------------- BEGIN |
# ----------------------------------------------------------------------- BEGIN |
sub BEGIN { |
BEGIN { |
# --------------------------------- Compute various listings of metadata values |
|
$language{'any'}='Any language'; |
|
{ |
|
my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}. |
|
'/language.tab'); |
|
map { |
|
$_=~/(\w+)\s+([\w\s\-]+)/; chomp; |
|
$language{$1}=$2; |
|
} <$fh>; |
|
} |
|
$cprtag{'any'}='Any copyright/distribution'; |
|
{ |
|
my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonIncludes'}. |
|
'/copyright.tab'); |
|
map { |
|
$_=~/(\w+)\s+([\w\s\-]+)/; chomp; |
|
$cprtag{$1}=$2; |
|
} <$fh>; |
|
} |
|
$mimetag{'any'}='Any type'; |
|
{ |
|
my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}. |
|
'/filetypes.tab'); |
|
map { |
|
$_=~/(\w+)\s+(\w+)\s+([\w\s\-]+)/; chomp; |
|
$mimetag{$1}=".$1 $3"; |
|
} <$fh>; |
|
} |
|
{ |
{ |
my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}. |
my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}. |
'/hosts.tab'); |
'/hosts.tab'); |
map { |
while (<$fh>) { |
$_=~/(\w+?)\:(\w+?)\:(\w+?)\:(.*)/; chomp; |
$_=~/(\w+?)\:(\w+?)\:(\w+?)\:(.*)/; chomp; |
if ($3 eq 'library') { |
if ($3 eq 'library') { |
$hostdomains{$1}=$2; |
$hostdomains{$1}=$2; |
$hostips{$1}=$4; |
$hostips{$1}=$4; |
} |
} |
} <$fh>; |
} |
} |
} |
} |
} |
|
|
Line 209 END
|
Line 201 END
|
$scrout.=&searchphrasefield('Limit by abstract','abstract', |
$scrout.=&searchphrasefield('Limit by abstract','abstract', |
$ENV{'form.abstract'}); |
$ENV{'form.abstract'}); |
|
|
$ENV{'form.mime'}='notxxx' unless length($ENV{'form.mime'}); |
$ENV{'form.mime'}='any' unless length($ENV{'form.mime'}); |
$scrout.=&selectbox('Limit by MIME type','mime', |
$scrout.=&selectbox('Limit by MIME type','mime', |
$ENV{'form.mime'},%mimetag); |
$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'},%language); |
$ENV{'form.language'},'any','Any Language', |
|
\&{Apache::loncommon::languagedescription}, |
|
(&Apache::loncommon::languageids), |
|
); |
|
|
# ------------------------------------------------ Compute date selection boxes |
# ------------------------------------------------ Compute date selection boxes |
$scrout.=<<CREATIONDATESTART; |
$scrout.=<<CREATIONDATESTART; |
Line 268 LASTREVISIONDATEEND
|
Line 265 LASTREVISIONDATEEND
|
|
|
$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'},%cprtag); |
$ENV{'form.copyright'}, |
|
'any','Any copyright/distribution', |
|
\&{Apache::loncommon::copyrightdescription}, |
|
(&Apache::loncommon::copyrightids), |
|
); |
|
|
# ------------------------------------------- Compute customized metadata field |
# ------------------------------------------- Compute customized metadata field |
$scrout.=<<CUSTOMMETADATA; |
$scrout.=<<CUSTOMMETADATA; |
Line 354 ENDDOCUMENT
|
Line 355 ENDDOCUMENT
|
|
|
# ----------- grab unprocessed CGI variables that may have been appended to URL |
# ----------- grab unprocessed CGI variables that may have been appended to URL |
sub get_unprocessed_cgi { |
sub get_unprocessed_cgi { |
map { |
foreach (split(/&/,$ENV{'QUERY_STRING'})) { |
my ($name, $value) = split(/=/,$_); |
my ($name, $value) = split(/=/,$_); |
$value =~ tr/+/ /; |
$value =~ tr/+/ /; |
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; |
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; |
if ($name eq 'catalogmode' or $name eq 'launch' or $name eq 'acts') { |
if ($name eq 'catalogmode' or $name eq 'launch' or $name eq 'acts') { |
$ENV{'form.'.$name}=$value; |
$ENV{'form.'.$name}=$value; |
} |
} |
} (split(/&/,$ENV{'QUERY_STRING'})); |
} |
} |
} |
|
|
# ------------------------------------------------------------- make persistent |
# ------------------------------------------------------------- make persistent |
sub make_persistent { |
sub make_persistent { |
my $persistent=''; |
my $persistent=''; |
|
|
map { |
foreach (keys %ENV) { |
if (/^form\./ && !/submit/) { |
if (/^form\./ && !/submit/) { |
my $name=$_; |
my $name=$_; |
my $key=$name; |
my $key=$name; |
Line 378 sub make_persistent {
|
Line 379 sub make_persistent {
|
<input type='hidden' name='$name' value='$ENV{$key}' /> |
<input type='hidden' name='$name' value='$ENV{$key}' /> |
END |
END |
} |
} |
} (keys %ENV); |
} |
return $persistent; |
return $persistent; |
} |
} |
|
|
Line 554 END
|
Line 555 END
|
} |
} |
|
|
sub selectbox { |
sub selectbox { |
my ($title,$name,$value,%options)=@_; |
my ($title,$name,$value,$anyvalue,$anytag,$functionref,@idlist)=@_; |
my $uctitle=uc($title); |
my $uctitle=uc($title); |
my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:". |
my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:". |
"</b></font><br />".'<select name="'.$name.'">'; |
"</b></font><br />".'<select name="'.$name.'">'; |
map { |
foreach ($anyvalue,@idlist) { |
$selout.='<option value=\''.$_.'\''; |
$selout.='<option value=\''.$_.'\''; |
if ($_ eq $value) { $selout.=' selected'; } |
if ($_ eq $value and !/^any$/) { |
$selout.='>'.$options{$_}.'</option>'; |
$selout.=' selected>'.&{$functionref}($_).'</option>'; |
} sort keys %options; |
} |
|
elsif ($_ eq $value and /^$anyvalue$/) { |
|
$selout.=' selected>'.$anytag.'</option>'; |
|
} |
|
else {$selout.='>'.&{$functionref}($_).'</option>';} |
|
} |
return $selout.'</select>'; |
return $selout.'</select>'; |
} |
} |
|
|
|
sub testf { |
|
return @_[0]; |
|
} |
|
|
# ----------------------------------------------- Performing an advanced search |
# ----------------------------------------------- Performing an advanced search |
sub advancedsearch { |
sub advancedsearch { |
my ($r,$envhash)=@_; |
my ($r,$envhash)=@_; |
Line 1033 ENDPOP
|
Line 1043 ENDPOP
|
BLOOP: while(1) { |
BLOOP: while(1) { |
my $sn=0; |
my $sn=0; |
last BLOOP unless $bloop; |
last BLOOP unless $bloop; |
|
last BLOOP unless $timeremain; |
RLOOP: foreach my $rkey (sort keys %rhash) { |
RLOOP: foreach my $rkey (sort keys %rhash) { |
$sn++; |
$sn++; |
next RLOOP if $orkey{$rkey}; |
next RLOOP if $orkey{$rkey}; |
Line 1074 ENDPOP
|
Line 1085 ENDPOP
|
$r->rflush(); |
$r->rflush(); |
$tflag=0; |
$tflag=0; |
} |
} |
if ($temp>1) { |
|
sleep 1; |
|
$timeremain--; |
|
$elapsetime++; |
|
last WLOOP; |
|
} |
|
if (-e "$replyfile.end") { |
if (-e "$replyfile.end") { |
$bloop--; |
$bloop--; |
$orkey{$rkey}=1; |
$orkey{$rkey}=1; |
Line 1123 ENDPOP
|
Line 1128 ENDPOP
|
} |
} |
last WLOOP; |
last WLOOP; |
} |
} |
|
if ($temp>1) { |
|
sleep 1; |
|
$timeremain--; |
|
$elapsetime++; |
|
last WLOOP; |
|
} |
last WLOOP unless $timeremain; |
last WLOOP unless $timeremain; |
sleep 1; |
sleep 1; |
$timeremain--; |
$timeremain--; |
Line 1308 sub detailed_citation_view {
|
Line 1319 sub detailed_citation_view {
|
<b>Subject:</b> $subject<br /> |
<b>Subject:</b> $subject<br /> |
<b>Keyword(s):</b> $keywords<br /> |
<b>Keyword(s):</b> $keywords<br /> |
<b>Notes:</b> $notes<br /> |
<b>Notes:</b> $notes<br /> |
<b>MIME Type:</b> $mimetag{$mime}<br /> |
<b>MIME Type:</b> |
<b>Language:</b> $language{$lang}<br /> |
END |
<b>Copyright/Distribution:</b> $cprtag{$copyright}<br /> |
$result.=&Apache::loncommon::filedescription($mime); |
|
$result.=<<END; |
|
<br /> |
|
<b>Language:</b> |
|
END |
|
$result.=&Apache::loncommon::languagedescription($lang); |
|
$result.=<<END; |
|
<br /> |
|
<b>Copyright/Distribution:</b> |
|
END |
|
$result.=&Apache::loncommon::copyrightdescription($copyright); |
|
$result.=<<END; |
|
<br /> |
</p> |
</p> |
$extrashow |
$extrashow |
<p> |
<p> |
Line 1326 sub summary_view {
|
Line 1349 sub summary_view {
|
$notes,$shortabstract,$mime,$lang, |
$notes,$shortabstract,$mime,$lang, |
$creationdate,$lastrevisiondate,$owner,$copyright, |
$creationdate,$lastrevisiondate,$owner,$copyright, |
$hostname,$httphost,$extrashow)=@_; |
$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://$httphost$url" TARGET='search_preview'>$author</a><br /> |
$title<br /> |
$title<br /> |
$owner -- $lastrevisiondate<br /> |
$owner -- $lastrevisiondate<br /> |
$cprtag{$copyright}<br /> |
$cprtag<br /> |
$extrashow |
$extrashow |
</p> |
</p> |
END |
END |
Line 1343 sub fielded_format_view {
|
Line 1367 sub fielded_format_view {
|
$notes,$shortabstract,$mime,$lang, |
$notes,$shortabstract,$mime,$lang, |
$creationdate,$lastrevisiondate,$owner,$copyright, |
$creationdate,$lastrevisiondate,$owner,$copyright, |
$hostname,$httphost,$extrashow)=@_; |
$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://$httphost$url" TARGET='search_preview'>$url</A> |
<br /> |
<br /> |
Line 1351 sub fielded_format_view {
|
Line 1378 sub fielded_format_view {
|
<b>Subject:</b> $subject<br /> |
<b>Subject:</b> $subject<br /> |
<b>Keyword(s):</b> $keywords<br /> |
<b>Keyword(s):</b> $keywords<br /> |
<b>Notes:</b> $notes<br /> |
<b>Notes:</b> $notes<br /> |
<b>MIME Type:</b> $mimetag{$mime}<br /> |
<b>MIME Type:</b> $mimetag<br /> |
<b>Language:</b> $language{$lang}<br /> |
<b>Language:</b> $language<br /> |
<b>Creation Date:</b> $creationdate<br /> |
<b>Creation Date:</b> $creationdate<br /> |
<b>Last Revision Date:</b> $lastrevisiondate<br /> |
<b>Last Revision Date:</b> $lastrevisiondate<br /> |
<b>Publisher/Owner:</b> $owner<br /> |
<b>Publisher/Owner:</b> $owner<br /> |
<b>Copyright/Distribution:</b> $cprtag{$copyright}<br /> |
<b>Copyright/Distribution:</b> $cprtag<br /> |
<b>Repository Location:</b> $hostname<br /> |
<b>Repository Location:</b> $hostname<br /> |
<b>Abstract:</b> $shortabstract<br /> |
<b>Abstract:</b> $shortabstract<br /> |
$extrashow |
$extrashow |
Line 1371 sub xml_sgml_view {
|
Line 1398 sub xml_sgml_view {
|
$notes,$shortabstract,$mime,$lang, |
$notes,$shortabstract,$mime,$lang, |
$creationdate,$lastrevisiondate,$owner,$copyright, |
$creationdate,$lastrevisiondate,$owner,$copyright, |
$hostname,$httphost,$extrashow)=@_; |
$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> |
Line 1382 sub xml_sgml_view {
|
Line 1412 sub xml_sgml_view {
|
<notes>$notes</notes> |
<notes>$notes</notes> |
<mimeInfo> |
<mimeInfo> |
<mime>$mime</mime> |
<mime>$mime</mime> |
<mimetag>$mimetag{$mime}</mimetag> |
<mimetag>$mimetag</mimetag> |
</mimeInfo> |
</mimeInfo> |
<languageInfo> |
<languageInfo> |
<language>$lang</language> |
<language>$lang</language> |
<languagetag>$language{$lang}</languagetag> |
<languagetag>$language</languagetag> |
</languageInfo> |
</languageInfo> |
<creationdate>$creationdate</creationdate> |
<creationdate>$creationdate</creationdate> |
<lastrevisiondate>$lastrevisiondate</lastrevisiondate> |
<lastrevisiondate>$lastrevisiondate</lastrevisiondate> |
<owner>$owner</owner> |
<owner>$owner</owner> |
<copyrightInfo> |
<copyrightInfo> |
<copyright>$copyright</copyright> |
<copyright>$copyright</copyright> |
<copyrighttag>$cprtag{$copyright}</copyrighttag> |
<copyrighttag>$cprtag</copyrighttag> |
</copyrightInfo> |
</copyrightInfo> |
<repositoryLocation>$hostname</repositoryLocation> |
<repositoryLocation>$hostname</repositoryLocation> |
<shortabstract>$shortabstract</shortabstract> |
<shortabstract>$shortabstract</shortabstract> |
Line 1483 RESULTS
|
Line 1513 RESULTS
|
# --------- settings whenever the user causes the search window to be launched |
# --------- settings whenever the user causes the search window to be launched |
sub start_fresh_session { |
sub start_fresh_session { |
delete $hash{'mode_catalog'}; |
delete $hash{'mode_catalog'}; |
map { |
foreach (keys %hash) { |
if ($_ =~ /^pre_/) { |
if ($_ =~ /^pre_/) { |
delete $hash{$_}; |
delete $hash{$_}; |
} |
} |
if ($_ =~ /^store/) { |
if ($_ =~ /^store/) { |
delete $hash{$_}; |
delete $hash{$_}; |
} |
} |
} keys %hash; |
} |
} |
} |
|
|
1; |
1; |
Line 1528 This routine is only run once after comp
|
Line 1558 This routine is only run once after comp
|
|
|
=item * |
=item * |
|
|
Initializes %language hash table. |
|
|
|
=item * |
|
|
|
Initializes %cprtag hash table (for copyright.tab). |
|
|
|
=item * |
|
|
|
Initializes %mimetag hash table (for filetypes.tab). |
|
|
|
=item * |
|
|
|
Initializes %hostdomains and hostips hash table (for hosts.tab). |
Initializes %hostdomains and hostips hash table (for hosts.tab). |
|
|
=back |
=back |