--- loncom/interface/lonsearchcat.pm 2001/11/28 19:26:20 1.106 +++ loncom/interface/lonsearchcat.pm 2001/12/17 00:56:48 1.113 @@ -1,13 +1,35 @@ # The LearningOnline Network with CAPA -# # Search Catalog # +# $Id: lonsearchcat.pm,v 1.113 2001/12/17 00:56:48 harris41 Exp $ +# +# 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 # 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 -# 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: lonsearchcat.pm,v 1.106 2001/11/28 19:26:20 harris41 Exp $ ### ############################################################################### @@ -32,13 +54,11 @@ use Apache::File(); use CGI qw(:standard); use Text::Query; use GDBM_File; +use Apache::loncommon(); # ---------------------------------------- variables used throughout the module # -- 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 %hostips; # matches host name to host ip my %hitcount; # stores number of hits per host @@ -76,44 +96,16 @@ END # ----------------------------------------------------------------------- BEGIN sub 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'}. '/hosts.tab'); - map { + while (<$fh>) { $_=~/(\w+?)\:(\w+?)\:(\w+?)\:(.*)/; chomp; if ($3 eq 'library') { $hostdomains{$1}=$2; $hostips{$1}=$4; } - } <$fh>; + } } } @@ -209,15 +201,20 @@ END $scrout.=&searchphrasefield('Limit by abstract','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', - $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'}); $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 $scrout.=< END } - } (keys %ENV); + } return $persistent; } @@ -554,18 +555,27 @@ END } sub selectbox { - my ($title,$name,$value,%options)=@_; + my ($title,$name,$value,$anyvalue,$anytag,$functionref,@idlist)=@_; my $uctitle=uc($title); my $selout="\n

$uctitle:". "
".''; } +sub testf { + return @_[0]; +} + # ----------------------------------------------- Performing an advanced search sub advancedsearch { my ($r,$envhash)=@_; @@ -1033,6 +1043,7 @@ ENDPOP BLOOP: while(1) { my $sn=0; last BLOOP unless $bloop; + last BLOOP unless $timeremain; RLOOP: foreach my $rkey (sort keys %rhash) { $sn++; next RLOOP if $orkey{$rkey}; @@ -1074,12 +1085,6 @@ ENDPOP $r->rflush(); $tflag=0; } - if ($temp>1) { - sleep 1; - $timeremain--; - $elapsetime++; - last WLOOP; - } if (-e "$replyfile.end") { $bloop--; $orkey{$rkey}=1; @@ -1123,6 +1128,12 @@ ENDPOP } last WLOOP; } + if ($temp>1) { + sleep 1; + $timeremain--; + $elapsetime++; + last WLOOP; + } last WLOOP unless $timeremain; sleep 1; $timeremain--; @@ -1308,9 +1319,21 @@ sub detailed_citation_view { Subject: $subject
Keyword(s): $keywords
Notes: $notes
-MIME Type: $mimetag{$mime}
-Language: $language{$lang}
-Copyright/Distribution: $cprtag{$copyright}
+MIME Type: +END + $result.=&Apache::loncommon::filedescription($mime); + $result.=< +Language: +END + $result.=&Apache::loncommon::languagedescription($lang); + $result.=< +Copyright/Distribution: +END + $result.=&Apache::loncommon::copyrightdescription($copyright); + $result.=<

$extrashow

@@ -1326,11 +1349,12 @@ sub summary_view { $notes,$shortabstract,$mime,$lang, $creationdate,$lastrevisiondate,$owner,$copyright, $hostname,$httphost,$extrashow)=@_; + my $cprtag=&Apache::loncommon::copyrightdescription($copyright); my $result=<$author
$title
$owner -- $lastrevisiondate
-$cprtag{$copyright}
+$cprtag
$extrashow

END @@ -1343,6 +1367,9 @@ sub fielded_format_view { $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=<URL: $url
@@ -1351,12 +1378,12 @@ sub fielded_format_view { Subject: $subject
Keyword(s): $keywords
Notes: $notes
-MIME Type: $mimetag{$mime}
-Language: $language{$lang}
+MIME Type: $mimetag
+Language: $language
Creation Date: $creationdate
Last Revision Date: $lastrevisiondate
Publisher/Owner: $owner
-Copyright/Distribution: $cprtag{$copyright}
+Copyright/Distribution: $cprtag
Repository Location: $hostname
Abstract: $shortabstract
$extrashow @@ -1371,6 +1398,9 @@ sub xml_sgml_view { $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=< <LonCapaResource> @@ -1382,18 +1412,18 @@ sub xml_sgml_view { <notes>$notes</notes> <mimeInfo> <mime>$mime</mime> -<mimetag>$mimetag{$mime}</mimetag> +<mimetag>$mimetag</mimetag> </mimeInfo> <languageInfo> <language>$lang</language> -<languagetag>$language{$lang}</languagetag> +<languagetag>$language</languagetag> </languageInfo> <creationdate>$creationdate</creationdate> <lastrevisiondate>$lastrevisiondate</lastrevisiondate> <owner>$owner</owner> <copyrightInfo> <copyright>$copyright</copyright> -<copyrighttag>$cprtag{$copyright}</copyrighttag> +<copyrighttag>$cprtag</copyrighttag> </copyrightInfo> <repositoryLocation>$hostname</repositoryLocation> <shortabstract>$shortabstract</shortabstract> @@ -1483,14 +1513,14 @@ RESULTS # --------- settings whenever the user causes the search window to be launched sub start_fresh_session { delete $hash{'mode_catalog'}; - map { + foreach (keys %hash) { if ($_ =~ /^pre_/) { delete $hash{$_}; } if ($_ =~ /^store/) { delete $hash{$_}; } - } keys %hash; + } } 1; @@ -1528,18 +1558,6 @@ This routine is only run once after comp =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). =back