--- loncom/interface/lonsearchcat.pm 2004/06/03 20:32:33 1.229
+++ loncom/interface/lonsearchcat.pm 2005/02/02 21:27:28 1.230.2.2
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.229 2004/06/03 20:32:33 matthew Exp $
+# $Id: lonsearchcat.pm,v 1.230.2.2 2005/02/02 21:27:28 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -448,12 +448,22 @@ my %alreadyseen;
my %hash;
my $totalfound;
+sub make_symb {
+ my ($id)=@_;
+ my ($mapid,$resid)=split(/\./,$id);
+ my $map=$hash{'map_id_'.$mapid};
+ my $res=$hash{'src_'.$id};
+ my $symb=&Apache::lonnet::encode_symb($map,$resid,$res);
+ return $symb;
+}
+
sub course_search {
my $r=shift;
my $bodytag=&Apache::loncommon::bodytag('Course Search');
my $pretty_search_string = ''.$ENV{'form.courseexp'}.'';
my $search_string = $ENV{'form.courseexp'};
my @New_Words;
+ undef(%alreadyseen);
if ($ENV{'form.crsrelated'}) {
($search_string,@New_Words) = &related_version($ENV{'form.courseexp'});
if (@New_Words) {
@@ -469,16 +479,18 @@ sub course_search {
$bodytag.'
'.$pretty_search_string.'
');
$r->rflush();
# ======================================================= Go through the course
- undef %alreadyseen;
- %alreadyseen=();
my $c=$r->connection;
if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
&GDBM_READER(),0640)) {
- foreach (keys %hash) {
+ foreach (sort(keys(%hash))) {
if ($c->aborted()) { last; }
- if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
- &checkonthis($r,$hash{$_},0,$hash{'title_'.$1},$fulltext,
- @allwords);
+ if (($_=~/^src\_(.+)$/)) {
+ if ($hash{'randomout_'.$1} & !$ENV{'request.role.adv'}) {
+ next;
+ }
+ my $symb=&make_symb($1);
+ &checkonthis($r,$1,$hash{$_},0,&Apache::lonnet::gettitle($symb),
+ $fulltext,$symb,@allwords);
}
}
untie(%hash);
@@ -493,15 +505,22 @@ sub course_search {
# =============================== This pulls up a resource and its dependencies
sub checkonthis {
- my ($r,$url,$level,$title,$fulltext,@allwords)=@_;
- $alreadyseen{$url}=1;
+ my ($r,$id,$url,$level,$title,$fulltext,$symb,@allwords)=@_;
+ $alreadyseen{$id}=1;
+ if (&Apache::loncommon::connection_aborted($r)) { return; }
$r->rflush();
- my $result=&Apache::lonnet::metadata($url,'title').' '.
- &Apache::lonnet::metadata($url,'subject').' '.
- &Apache::lonnet::metadata($url,'abstract').' '.
- &Apache::lonnet::metadata($url,'keywords');
- if (($url) && ($fulltext)) {
- $result.=&Apache::lonnet::ssi_body($url);
+
+ my $result=$title.' ';
+ if ($ENV{'request.role.adv'} || !$hash{'encrypted_'.$id}) {
+ $result.=&Apache::lonnet::metadata($url,'title').' '.
+ &Apache::lonnet::metadata($url,'subject').' '.
+ &Apache::lonnet::metadata($url,'abstract').' '.
+ &Apache::lonnet::metadata($url,'keywords');
+ }
+ my ($extension)=($url=~/\.(\w+)$/);
+ if (&Apache::loncommon::fileembstyle($extension) eq 'ssi' &&
+ ($url) && ($fulltext)) {
+ $result.=&Apache::lonnet::ssi_body($url.'?symb='.&Apache::lonnet::escape($symb));
}
$result=~s/\s+/ /gs;
my $applies=0;
@@ -518,8 +537,15 @@ sub checkonthis {
for (my $i=0;$i<=$level*5;$i++) {
$r->print(' ');
}
- $r->print(''.
- ($title?$title:$url).'
');
+ my $href=$url;
+ if ($hash{'encrypted_'.$id} && !$ENV{'request.role.adv'}) {
+ $href=&Apache::lonenc::encrypted($href)
+ .'?symb='.&Apache::lonenc::encrypted($symb);
+ } else {
+ $href.='?symb='.&Apache::lonnet::escape($symb);
+ }
+ $r->print(''.($title?$title:$url).
+ '
');
$totalfound++;
} elsif ($fulltext) {
$r->print(' .');
@@ -528,9 +554,9 @@ sub checkonthis {
# Check also the dependencies of this one
my $dependencies=
&Apache::lonnet::metadata($url,'dependencies');
- foreach (split(/\,/,$dependencies)) {
- if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
- &checkonthis($r,$_,$level+1,'',$fulltext,@allwords);
+ foreach (split(/\,/,$dependencies) && (!$alreadyseen{$id})) {
+ if (($_=~/^\/res\//)) {
+ &checkonthis($r,$id,$_,$level+1,'',$fulltext,undef,@allwords);
}
}
}
@@ -781,7 +807,7 @@ ENDHEADER
$scrout.=''.
&titlefield(&mt('Copyright/Distribution')).' | '.
&Apache::lonmeta::selectbox('copyright',
- '',,
+ $ENV{'form.copyright'},
\&Apache::loncommon::copyrightdescription,
( undef,
&Apache::loncommon::copyrightids)
@@ -789,7 +815,7 @@ ENDHEADER
$scrout.=' |
'.
&titlefield(&mt('Language')).' | '.
&Apache::lonmeta::selectbox('language',
- 'notset',,
+ $ENV{'form.language'},
\&Apache::loncommon::languagedescription,
('any',&Apache::loncommon::languageids)
).' |
';
@@ -1201,7 +1227,7 @@ sub parse_advanced_search {
my @StatsFields = &statfields();
my @EvalFields = &evalfields();
my $fillflag=0;
- my $pretty_search_string = "
\n";
+ my $pretty_search_string = "";
# Clean up fields for safety
for my $field (@BasicFields,
'creationdatestart_month','creationdatestart_day',
@@ -1327,7 +1353,7 @@ sub parse_advanced_search {
push @queries,"(copyright like \"$ENV{'form.copyright'}\")";
$pretty_search_string.=$font."copyright = ".
&Apache::loncommon::copyrightdescription($ENV{'form.copyright'}).
- "
\n";
+ "
\n";
}
#
# Statistics
@@ -2245,12 +2271,16 @@ $bodytag