version 1.228, 2004/06/03 19:23:08
|
version 1.231, 2004/07/19 16:38:07
|
Line 76 use Apache::lonlocal;
|
Line 76 use Apache::lonlocal;
|
use LONCAPA::lonmetadata(); |
use LONCAPA::lonmetadata(); |
use HTML::Entities(); |
use HTML::Entities(); |
use Parse::RecDescent; |
use Parse::RecDescent; |
|
use Apache::lonnavmaps; |
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
Line 463 sub course_search {
|
Line 464 sub course_search {
|
} |
} |
} |
} |
my $fulltext=$ENV{'form.crsfulltext'}; |
my $fulltext=$ENV{'form.crsfulltext'}; |
|
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>'. |
$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 />'); |
$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; |
undef %alreadyseen; |
Line 484 sub course_search {
|
Line 486 sub course_search {
|
untie(%hash); |
untie(%hash); |
} |
} |
unless ($totalfound) { |
unless ($totalfound) { |
$r->print('<p>'.&mt('No resources found').'.</p>'); |
$r->print('<p>'.&mt('No matches found in resources').'.</p>'); |
} |
} |
|
|
|
# Check discussions if requested |
|
if ($discuss) { |
|
my $totaldiscussions = 0; |
|
$r->print('<br /><br /><b>'.&mt('Discussion postings').':</b><br />'); |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
my @allres=$navmap->retrieveResources(); |
|
my %discussiontime = &Apache::lonnet::dump('discussiontimes', |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}); |
|
foreach my $resource (@allres) { |
|
my $result = ''; |
|
my $applies = 0; |
|
my $symb = $resource->symb(); |
|
my $ressymb = $symb; |
|
if ($symb =~ m#(___adm/\w+/\w+)/(\d+)/bulletinboard$#) { |
|
$ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; |
|
unless ($ressymb =~ m#bulletin___\d+___adm/wrapper#) { |
|
$ressymb=~s#(bulletin___\d+___)#$1adm/wrapper/#; |
|
} |
|
} |
|
if (defined($discussiontime{$ressymb})) { |
|
my %contrib = &Apache::lonnet::restore($ressymb,$ENV{'request.course.id'}, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}); |
|
if ($contrib{'version'}) { |
|
for (my $id=1;$id<=$contrib{'version'};$id++) { |
|
unless (($contrib{'hidden'}=~/\.$id\./) || ($contrib{'deleted'}=~/\.$id\./)) { |
|
if ($contrib{$id.':subject'}) { |
|
$result .= $contrib{$id.':subject'}; |
|
} |
|
if ($contrib{$id.':message'}) { |
|
$result .= $contrib{$id.':message'}; |
|
} |
|
if ($contrib{$id,':attachmenturl'}) { |
|
if ($contrib{$id,':attachmenturl'} =~ m-/([^/]+)$-) { |
|
$result .= $1; |
|
} |
|
} |
|
$applies = &checkwords($result,$applies,@allwords); |
|
} |
|
} |
|
} |
|
} |
|
# Does this discussion apply? |
|
if ($applies) { |
|
my ($map,$ind,$url)=&Apache::lonnet::decode_symb($ressymb); |
|
my $disctype = &mt('resource'); |
|
if ($url =~ m#/bulletinboard$#) { |
|
if ($url =~m#^adm/wrapper/adm/.*/bulletinboard$#) { |
|
$url =~s#^adm/wrapper##; |
|
} |
|
$disctype = &mt('bulletin board'); |
|
} else { |
|
$url = '/res/'.$url; |
|
} |
|
if ($url =~ /\?/) { |
|
$url .= '&symb='; |
|
} else { |
|
$url .= '?symb='; |
|
} |
|
$url .= &Apache::lonnet::escape($resource->symb()); |
|
my $title = $resource->compTitle(); |
|
$r->print('<br /><a href="'.$url.'" target="cat">'. |
|
($title?$title:$url).'</a> - '.$disctype.'<br />'); |
|
$totaldiscussions++; |
|
} else { |
|
$r->print(' .'); |
|
} |
|
} |
|
unless ($totaldiscussions) { |
|
$r->print('<p>'.&mt('No matches found in postings').'.</p>'); |
|
} |
|
} |
|
|
# =================================================== Done going through course |
# =================================================== Done going through course |
$r->print('</body></html>'); |
$r->print('</body></html>'); |
} |
} |
Line 504 sub checkonthis {
|
Line 581 sub checkonthis {
|
$result.=&Apache::lonnet::ssi_body($url); |
$result.=&Apache::lonnet::ssi_body($url); |
} |
} |
$result=~s/\s+/ /gs; |
$result=~s/\s+/ /gs; |
my $applies=0; |
my $applies = 0; |
foreach (@allwords) { |
$applies = &checkwords($result,$applies,@allwords); |
if ($_=~/\w/) { |
|
if ($result=~/$_/si) { |
|
$applies++; |
|
} |
|
} |
|
} |
|
# Does this resource apply? |
# Does this resource apply? |
if ($applies) { |
if ($applies) { |
$r->print('<br />'); |
$r->print('<br />'); |
Line 535 sub checkonthis {
|
Line 606 sub checkonthis {
|
} |
} |
} |
} |
|
|
|
sub checkwords { |
|
my ($result,$applies,@allwords) = @_; |
|
foreach (@allwords) { |
|
if ($_=~/\w/) { |
|
if ($result=~/$_/si) { |
|
$applies++; |
|
} |
|
} |
|
} |
|
return $applies; |
|
} |
|
|
sub untiehash { |
sub untiehash { |
if (tied(%hash)) { |
if (tied(%hash)) { |
untie(%hash); |
untie(%hash); |
Line 570 sub print_basic_search_form {
|
Line 653 sub print_basic_search_form {
|
my ($r,$closebutton,$hidden_fields) = @_; |
my ($r,$closebutton,$hidden_fields) = @_; |
my $result = ($ENV{'form.catalogmode'} ne 'groupsearch'); |
my $result = ($ENV{'form.catalogmode'} ne 'groupsearch'); |
my $bodytag=&Apache::loncommon::bodytag('Search'). |
my $bodytag=&Apache::loncommon::bodytag('Search'). |
&Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Searching', |
&Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Search_Basic', |
undef,undef, |
undef,undef, |
$ENV{'form.catalogmode'} ne 'groupsearch'); |
$ENV{'form.catalogmode'} ne 'groupsearch'); |
my $scrout = &search_html_header().$bodytag; |
my $scrout = &search_html_header().$bodytag; |
Line 638 sub print_basic_search_form {
|
Line 721 sub print_basic_search_form {
|
'header' => 'Course Search', |
'header' => 'Course Search', |
'note' => 'Enter terms or phrases, then press "Search" below', |
'note' => 'Enter terms or phrases, then press "Search" below', |
'use' => 'use related words', |
'use' => 'use related words', |
'full' =>'fulltext search (time consuming)' |
'full' =>'fulltext search (time consuming)', |
|
'disc' => 'search discussion postings (resources and bulletin boards)', |
); |
); |
$scrout.=(<<ENDCOURSESEARCH); |
$scrout.=(<<ENDCOURSESEARCH); |
<form name="loncapa_search" method="post" action="/adm/searchcat"> |
<form name="loncapa_search" method="post" action="/adm/searchcat"> |
Line 663 ENDCOURSESEARCH
|
Line 747 ENDCOURSESEARCH
|
my $relcheckbox = |
my $relcheckbox = |
&Apache::lonhtmlcommon::checkbox('crsrelated', |
&Apache::lonhtmlcommon::checkbox('crsrelated', |
$ENV{'form.crsrelated'}); |
$ENV{'form.crsrelated'}); |
|
my $discheckbox = |
|
&Apache::lonhtmlcommon::checkbox('crsdiscuss', |
|
$ENV{'form.crsrelated'}); |
$scrout.=(<<ENDENDCOURSE); |
$scrout.=(<<ENDENDCOURSE); |
</td></tr> |
</td></tr> |
<tr><td>$relcheckbox $lt{'use'}</td><td></td></tr> |
<tr><td>$relcheckbox $lt{'use'}</td><td></td></tr> |
<tr><td>$crscheckbox $lt{'full'}</td><td></td></tr> |
<tr><td>$crscheckbox $lt{'full'}</td><td></td></tr> |
|
<tr><td>$discheckbox $lt{'disc'}</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 697 Prints the advanced search form.
|
Line 785 Prints the advanced search form.
|
sub print_advanced_search_form{ |
sub print_advanced_search_form{ |
my ($r,$closebutton,$hidden_fields) = @_; |
my ($r,$closebutton,$hidden_fields) = @_; |
my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search'). |
my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search'). |
&Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Searching', |
&Apache::lonhtmlcommon::breadcrumbs(undef,'Searching', |
undef,undef, |
'Search_Advanced', |
|
undef,undef, |
$ENV{'form.catalogmode'} ne 'groupsearch'); |
$ENV{'form.catalogmode'} ne 'groupsearch'); |
my %lt=&Apache::lonlocal::texthash('srch' => 'Search', |
my %lt=&Apache::lonlocal::texthash('srch' => 'Search', |
'reset' => 'Reset', |
'reset' => 'Reset', |
Line 780 ENDHEADER
|
Line 869 ENDHEADER
|
$scrout.='<tr><td align="right" valign="top">'. |
$scrout.='<tr><td align="right" valign="top">'. |
&titlefield(&mt('Copyright/Distribution')).'</td><td colspan="2">'. |
&titlefield(&mt('Copyright/Distribution')).'</td><td colspan="2">'. |
&Apache::lonmeta::selectbox('copyright', |
&Apache::lonmeta::selectbox('copyright', |
'',, |
$ENV{'form.copyright'}, |
\&Apache::loncommon::copyrightdescription, |
\&Apache::loncommon::copyrightdescription, |
( undef, |
( undef, |
&Apache::loncommon::copyrightids) |
&Apache::loncommon::copyrightids) |
Line 788 ENDHEADER
|
Line 877 ENDHEADER
|
$scrout.='<tr><td align="right" valign="top">'. |
$scrout.='<tr><td align="right" valign="top">'. |
&titlefield(&mt('Language')).'</td><td colspan="2">'. |
&titlefield(&mt('Language')).'</td><td colspan="2">'. |
&Apache::lonmeta::selectbox('language', |
&Apache::lonmeta::selectbox('language', |
'notset',, |
$ENV{'form.language'}, |
\&Apache::loncommon::languagedescription, |
\&Apache::loncommon::languagedescription, |
('any',&Apache::loncommon::languageids) |
('any',&Apache::loncommon::languageids) |
).'</td></tr>'; |
).'</td></tr>'; |
Line 1200 sub parse_advanced_search {
|
Line 1289 sub parse_advanced_search {
|
my @StatsFields = &statfields(); |
my @StatsFields = &statfields(); |
my @EvalFields = &evalfields(); |
my @EvalFields = &evalfields(); |
my $fillflag=0; |
my $fillflag=0; |
my $pretty_search_string = "<br />\n"; |
my $pretty_search_string = ""; |
# Clean up fields for safety |
# Clean up fields for safety |
for my $field (@BasicFields, |
for my $field (@BasicFields, |
'creationdatestart_month','creationdatestart_day', |
'creationdatestart_month','creationdatestart_day', |
Line 1326 sub parse_advanced_search {
|
Line 1415 sub parse_advanced_search {
|
push @queries,"(copyright like \"$ENV{'form.copyright'}\")"; |
push @queries,"(copyright like \"$ENV{'form.copyright'}\")"; |
$pretty_search_string.=$font."copyright</font> = ". |
$pretty_search_string.=$font."copyright</font> = ". |
&Apache::loncommon::copyrightdescription($ENV{'form.copyright'}). |
&Apache::loncommon::copyrightdescription($ENV{'form.copyright'}). |
"<br \>\n"; |
"<br />\n"; |
} |
} |
# |
# |
# Statistics |
# Statistics |
Line 2244 $bodytag
|
Line 2333 $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="" /> |
END |
END |
# Check to see if $pretty_string has more than one carriage return. |
# Remove leading and trailing <br /> |
# Assume \n s are following <br /> s and truncate the value. |
$pretty_string =~ s:^\s*<br />::i; |
# (there is probably a better way)... |
$pretty_string =~ s:(<br />)*\s*$::im; |
my @Lines = split /<br \/>/,$pretty_string; |
my @Lines = split("<br />",$pretty_string); |
|
# I keep getting blank items at the end of the list, hence the following: |
|
while ($Lines[-1] =~ /^\s*$/ && @Lines) { |
|
pop(@Lines); |
|
} |
if (@Lines > 2) { |
if (@Lines > 2) { |
$pretty_string = join '<br \>',(@Lines[0..2],'....<br />'); |
$pretty_string = join '<br />',(@Lines[0..2],'....<br />'); |
} |
} |
$r->print(&mt("Search: [_1]",$pretty_string)); |
$r->print(&mt("Search: [_1]",$pretty_string)); |
$r->rflush(); |
$r->rflush(); |
Line 3077 sub detailed_citation_view {
|
Line 3170 sub detailed_citation_view {
|
} elsif (exists($field->{'format'}) && $field->{'format'} ne ''){ |
} elsif (exists($field->{'format'}) && $field->{'format'} ne ''){ |
$result.= &mt($field->{'translate'}, |
$result.= &mt($field->{'translate'}, |
sprintf($field->{'format'}, |
sprintf($field->{'format'}, |
$values{$field->{'name'}})).'<br />'."\n"; |
$values{$field->{'name'}}))."<br />\n"; |
} else { |
} else { |
if ($field->{'special'} eq 'url link') { |
if ($field->{'special'} eq 'url link') { |
$result.= |
$result.= |