version 1.233, 2004/09/23 21:16:45
|
version 1.238, 2005/02/17 08:29:43
|
Line 195 sub handler {
|
Line 195 sub handler {
|
&Apache::lonnet::logthis('lonsearchcat:'. |
&Apache::lonnet::logthis('lonsearchcat:'. |
'Unable to recover data from '. |
'Unable to recover data from '. |
$persistent_db_file); |
$persistent_db_file); |
$r->print(<<END); |
my $html=&Apache::lonxml::xmlbegin(); |
<html> |
$r->print(<<END); |
<head><title>LON-CAPA Search Error</title></head> |
$html |
|
<head> |
|
<title>LON-CAPA Search Error</title></head> |
$bodytag |
$bodytag |
We were unable to retrieve data describing your search. This is a serious |
We were unable to retrieve data describing your search. This is a serious |
error and has been logged. Please alert your LON-CAPA administrator. |
error and has been logged. Please alert your LON-CAPA administrator. |
Line 224 END
|
Line 226 END
|
} else { |
} else { |
# This is a stupid error to give to the user. |
# This is a stupid error to give to the user. |
# It really tells them nothing. |
# It really tells them nothing. |
$r->print('<html><head></head>'.$bodytag. |
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print($html.'<head></head>'.$bodytag. |
'Unable to tie hash to db file</body></html>'); |
'Unable to tie hash to db file</body></html>'); |
return OK; |
return OK; |
} |
} |
Line 368 END
|
Line 371 END
|
&Apache::lonnet::logthis('lonsearchcat.pm: Unable to create '. |
&Apache::lonnet::logthis('lonsearchcat.pm: Unable to create '. |
'needed table. lonmysql error:'. |
'needed table. lonmysql error:'. |
$errorstring); |
$errorstring); |
|
my $html=&Apache::lonxml::xmlbegin(); |
$r->print(<<END); |
$r->print(<<END); |
<html><head><title>Search Error</title></head> |
$html |
|
<head> |
|
<title>Search Error</title></head> |
$bodytag |
$bodytag |
Unable to create table in which to store search results. |
Unable to create table in which to store search results. |
The search has been aborted. |
The search has been aborted. |
Line 380 END
|
Line 386 END
|
} |
} |
delete($ENV{'form.launch'}); |
delete($ENV{'form.launch'}); |
if (! &make_form_data_persistent($r,$persistent_db_file)) { |
if (! &make_form_data_persistent($r,$persistent_db_file)) { |
$r->print(<<END); |
my $html=&Apache::lonxml::xmlbegin(); |
<html><head><title>Search Error</title></head> |
$r->print(<<END); |
|
$html |
|
<head> |
|
<title>Search Error</title></head> |
$bodytag |
$bodytag |
Unable to properly store search information. The search has been aborted. |
Unable to properly store search information. The search has been aborted. |
</body> |
</body> |
Line 449 my %alreadyseen;
|
Line 458 my %alreadyseen;
|
my %hash; |
my %hash; |
my $totalfound; |
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 { |
sub course_search { |
my $r=shift; |
my $r=shift; |
my $bodytag=&Apache::loncommon::bodytag('Course Search'); |
my $bodytag=&Apache::loncommon::bodytag('Course Search'); |
my $pretty_search_string = '<b>'.$ENV{'form.courseexp'}.'</b>'; |
my $pretty_search_string = '<b>'.$ENV{'form.courseexp'}.'</b>'; |
my $search_string = $ENV{'form.courseexp'}; |
my $search_string = $ENV{'form.courseexp'}; |
my @New_Words; |
my @New_Words; |
|
undef(%alreadyseen); |
if ($ENV{'form.crsrelated'}) { |
if ($ENV{'form.crsrelated'}) { |
($search_string,@New_Words) = &related_version($ENV{'form.courseexp'}); |
($search_string,@New_Words) = &related_version($ENV{'form.courseexp'}); |
if (@New_Words) { |
if (@New_Words) { |
Line 467 sub course_search {
|
Line 486 sub course_search {
|
my $discuss=$ENV{'form.crsdiscuss'}; |
my $discuss=$ENV{'form.crsdiscuss'}; |
my @allwords=($search_string,@New_Words); |
my @allwords=($search_string,@New_Words); |
$totalfound=0; |
$totalfound=0; |
$r->print('<html><head><title>LON-CAPA Course Search</title></head>'. |
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print($html.'<head><title>LON-CAPA Course Search</title></head>'. |
$bodytag.'<hr /><center><font size="+2" face="arial">'.$pretty_search_string.'</font></center><hr /><b>'.&mt('Course content').':</b><br />'); |
$bodytag.'<hr /><center><font size="+2" face="arial">'.$pretty_search_string.'</font></center><hr /><b>'.&mt('Course content').':</b><br />'); |
$r->rflush(); |
$r->rflush(); |
# ======================================================= Go through the course |
# ======================================================= Go through the course |
undef %alreadyseen; |
|
%alreadyseen=(); |
|
my $c=$r->connection; |
my $c=$r->connection; |
if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db", |
if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db", |
&GDBM_READER(),0640)) { |
&GDBM_READER(),0640)) { |
foreach (keys %hash) { |
foreach (sort(keys(%hash))) { |
if ($c->aborted()) { last; } |
if ($c->aborted()) { last; } |
if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) { |
if (($_=~/^src\_(.+)$/)) { |
&checkonthis($r,$hash{$_},0,$hash{'title_'.$1},$fulltext, |
if ($hash{'randomout_'.$1} & !$ENV{'request.role.adv'}) { |
@allwords); |
next; |
|
} |
|
my $symb=&make_symb($1); |
|
&checkonthis($r,$1,$hash{$_},0,&Apache::lonnet::gettitle($symb), |
|
$fulltext,$symb,@allwords); |
} |
} |
} |
} |
untie(%hash); |
untie(%hash); |
Line 570 sub course_search {
|
Line 592 sub course_search {
|
# =============================== This pulls up a resource and its dependencies |
# =============================== This pulls up a resource and its dependencies |
|
|
sub checkonthis { |
sub checkonthis { |
my ($r,$url,$level,$title,$fulltext,@allwords)=@_; |
my ($r,$id,$url,$level,$title,$fulltext,$symb,@allwords)=@_; |
$alreadyseen{$url}=1; |
$alreadyseen{$id}=1; |
|
if (&Apache::loncommon::connection_aborted($r)) { return; } |
$r->rflush(); |
$r->rflush(); |
my $result=&Apache::lonnet::metadata($url,'title').' '. |
|
&Apache::lonnet::metadata($url,'subject').' '. |
my $result=$title.' '; |
&Apache::lonnet::metadata($url,'abstract').' '. |
if ($ENV{'request.role.adv'} || !$hash{'encrypted_'.$id}) { |
&Apache::lonnet::metadata($url,'keywords'); |
$result.=&Apache::lonnet::metadata($url,'title').' '. |
if (($url) && ($fulltext)) { |
&Apache::lonnet::metadata($url,'subject').' '. |
$result.=&Apache::lonnet::ssi_body($url); |
&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; |
$result=~s/\s+/ /gs; |
my $applies = 0; |
my $applies = 0; |
Line 589 sub checkonthis {
|
Line 618 sub checkonthis {
|
for (my $i=0;$i<=$level*5;$i++) { |
for (my $i=0;$i<=$level*5;$i++) { |
$r->print(' '); |
$r->print(' '); |
} |
} |
$r->print('<a href="'.$url.'" target="cat">'. |
my $href=$url; |
($title?$title:$url).'</a><br />'); |
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('<a href="'.$href.'" target="cat">'.($title?$title:$url). |
|
'</a><br />'); |
$totalfound++; |
$totalfound++; |
} elsif ($fulltext) { |
} elsif ($fulltext) { |
$r->print(' .'); |
$r->print(' .'); |
Line 600 sub checkonthis {
|
Line 636 sub checkonthis {
|
my $dependencies= |
my $dependencies= |
&Apache::lonnet::metadata($url,'dependencies'); |
&Apache::lonnet::metadata($url,'dependencies'); |
foreach (split(/\,/,$dependencies)) { |
foreach (split(/\,/,$dependencies)) { |
if (($_=~/^\/res\//) && (!$alreadyseen{$_})) { |
if (($_=~/^\/res\//) && (!$alreadyseen{$id})) { |
&checkonthis($r,$_,$level+1,'',$fulltext,@allwords); |
&checkonthis($r,$id,$_,$level+1,'',$fulltext,undef,@allwords); |
} |
} |
} |
} |
} |
} |
Line 627 sub untiehash {
|
Line 663 sub untiehash {
|
} # End of course search scoping |
} # End of course search scoping |
|
|
sub search_html_header { |
sub search_html_header { |
|
my $html=&Apache::lonxml::xmlbegin(); |
my $Str = <<ENDHEADER; |
my $Str = <<ENDHEADER; |
<html> |
$html |
<head> |
<head> |
<title>The LearningOnline Network with CAPA</title> |
<title>The LearningOnline Network with CAPA</title> |
</head> |
</head> |
Line 752 ENDCOURSESEARCH
|
Line 789 ENDCOURSESEARCH
|
$ENV{'form.crsrelated'}); |
$ENV{'form.crsrelated'}); |
$scrout.=(<<ENDENDCOURSE); |
$scrout.=(<<ENDENDCOURSE); |
</td></tr> |
</td></tr> |
<tr><td>$relcheckbox $lt{'use'}</td><td></td></tr> |
<tr><td><label>$relcheckbox $lt{'use'}</label></td><td></td></tr> |
<tr><td>$crscheckbox $lt{'full'}</td><td></td></tr> |
<tr><td><label>$crscheckbox $lt{'full'}</label></td><td></td></tr> |
<tr><td>$discheckbox $lt{'disc'}</td><td></td></tr> |
<tr><td><label>$discheckbox $lt{'disc'}</label></td><td></td></tr> |
</table><p> |
</table><p> |
<input type="submit" name="coursesubmit" value='$lt{'srch'}' /> |
<input type="submit" name="coursesubmit" value='$lt{'srch'}' /> |
</p> |
</p> |
Line 2085 sub print_sort_form {
|
Line 2122 sub print_sort_form {
|
return; |
return; |
} |
} |
my $result; |
my $result; |
|
my $html=&Apache::lonxml::xmlbegin(); |
$result.=<<END; |
$result.=<<END; |
<html> |
$html |
<head> |
<head> |
<script> |
<script> |
function change_sort() { |
function change_sort() { |
Line 2326 sub run_search {
|
Line 2364 sub run_search {
|
# |
# |
# Print run_search header |
# Print run_search header |
# |
# |
|
my $html=&Apache::lonxml::xmlbegin(); |
$r->print(<<END); |
$r->print(<<END); |
<html> |
$html |
<head><title>Search Status</title></head> |
<head> |
|
<title>Search Status</title></head> |
$bodytag |
$bodytag |
<form name="statusform" action="" method="post"> |
<form name="statusform" action="" method="post"> |
<input type="hidden" name="Queue" value="" /> |
<input type="hidden" name="Queue" value="" /> |
Line 3061 END
|
Line 3101 END
|
###################################################################### |
###################################################################### |
sub search_status_header { |
sub search_status_header { |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); |
|
my $html=&Apache::lonxml::xmlbegin(); |
return <<ENDSTATUS; |
return <<ENDSTATUS; |
<html><head><title>Search Status</title></head> |
$html |
|
<head> |
|
<title>Search Status</title></head> |
$bodytag |
$bodytag |
<h3>Search Status</h3> |
<h3>Search Status</h3> |
Sending search request to LON-CAPA servers.<br /> |
Sending search request to LON-CAPA servers.<br /> |
Line 3085 sub print_frames_interface {
|
Line 3128 sub print_frames_interface {
|
"&persistent_db_id=".$ENV{'form.persistent_db_id'}; |
"&persistent_db_id=".$ENV{'form.persistent_db_id'}; |
my $run_search_link = $basic_link."&phase=run_search"; |
my $run_search_link = $basic_link."&phase=run_search"; |
my $results_link = &results_link(); |
my $results_link = &results_link(); |
|
my $html=&Apache::lonxml::xmlbegin(); |
my $result = <<"ENDFRAMES"; |
my $result = <<"ENDFRAMES"; |
<html> |
$html |
<head> |
<head> |
<script> |
<script> |
var targetwin = opener; |
var targetwin = opener; |
Line 3482 sub output_unparsed_phrase_error {
|
Line 3526 sub output_unparsed_phrase_error {
|
my $heading = &mt('Unparsed Field'); |
my $heading = &mt('Unparsed Field'); |
my $revise = &mt('Revise search request'); |
my $revise = &mt('Revise search request'); |
# make query information persistent to allow for subsequent revision |
# make query information persistent to allow for subsequent revision |
|
my $html=&Apache::lonxml::xmlbegin(); |
$r->print(<<ENDPAGE); |
$r->print(<<ENDPAGE); |
<html> |
$html |
<head> |
<head> |
<title>The LearningOnline Network with CAPA</title> |
<title>The LearningOnline Network with CAPA</title> |
</head> |
</head> |
Line 3530 sub output_blank_field_error {
|
Line 3575 sub output_blank_field_error {
|
my $errormsg = &mt('You did not fill in enough information for the search to be started. You need to fill in relevant fields on the search page in order for a query to be processed.'); |
my $errormsg = &mt('You did not fill in enough information for the search to be started. You need to fill in relevant fields on the search page in order for a query to be processed.'); |
my $revise = &mt('Revise Search Request'); |
my $revise = &mt('Revise Search Request'); |
my $heading = &mt('Unactionable Search Queary'); |
my $heading = &mt('Unactionable Search Queary'); |
|
my $html=&Apache::lonxml::xmlbegin(); |
$r->print(<<ENDPAGE); |
$r->print(<<ENDPAGE); |
<html> |
$html |
<head> |
<head> |
<title>The LearningOnline Network with CAPA</title> |
<title>The LearningOnline Network with CAPA</title> |
</head> |
</head> |
Line 3576 sub output_date_error {
|
Line 3622 sub output_date_error {
|
my ($r,$message,$closebutton,$hidden_fields)=@_; |
my ($r,$message,$closebutton,$hidden_fields)=@_; |
# make query information persistent to allow for subsequent revision |
# make query information persistent to allow for subsequent revision |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); |
|
my $html=&Apache::lonxml::xmlbegin(); |
$r->print(<<RESULTS); |
$r->print(<<RESULTS); |
<html> |
$html |
<head> |
<head> |
<title>The LearningOnline Network with CAPA</title> |
<title>The LearningOnline Network with CAPA</title> |
</head> |
</head> |