--- rat/lonpage.pm 2004/08/29 18:45:52 1.58 +++ rat/lonpage.pm 2004/12/12 21:06:36 1.65 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Page Handler # -# $Id: lonpage.pm,v 1.58 2004/08/29 18:45:52 raeburn Exp $ +# $Id: lonpage.pm,v 1.65 2004/12/12 21:06:36 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -232,13 +232,21 @@ sub handler { $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1)); foreach (@colcont) { my $src=$hash{'src_'.$_}; - $src=~/\.(\w+)$/; + my ($extension)=($src=~/\.(\w+)$/); + if ($hash{'encrypted_'.$_}) { + $src=&Apache::lonenc::encrypted($src); + } $metalink{$_}=$src.'.meta'; - $cellemb{$_}=Apache::loncommon::fileembstyle($1); + $cellemb{$_}= + &Apache::loncommon::fileembstyle($extension); if ($cellemb{$_} eq 'ssi') { # --------------------------------------------------------- This is an SSI cell + my ($mapid,$resid)=split(/\./,$_); + my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src); + my $prefix=$_.'_'; - my %posthash=('request.prefix' => $prefix); + my %posthash=('request.prefix' => $prefix, + 'symb' => $symb); if ($ENV{'form.grade_target'} eq 'tex') { $posthash{'grade_target'}=$ENV{'form.grade_target'}; $posthash{'textwidth'}=$ENV{'form.textwidth'}; @@ -257,8 +265,7 @@ sub handler { } } my $output=Apache::lonnet::ssi($src,%posthash); - $output=~ - s/\/\/ BEGIN LON\-CAPA Internal.+\/\/ END LON\-CAPA Internal\s//gs; + $output=~s|//(\s*)?\s||gs; if ($target eq 'tex') { $output =~ s/^([^&]+)\\begin{document}//; $output =~ s/\\end{document}//; @@ -351,7 +358,17 @@ sub handler { unless ($contents) { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - $r->print(''.&mt('Empty page').'.'); + $r->print(''."\n". + ''."\n". + &Apache::lonmenu::registerurl(1,undef)."\n". + ''."\n". + ''. + &Apache::lonmenu::menubuttons(undef,$target,1) + ); + $r->print(&mt('This page is either empty or it only contains resources that are currently hidden').'. '); + $r->print('

'.&mt('Please use the LON-CAPA navigation arrows to move to another item in the course').'.'); } else { # ------------------------------------------------------------------ Build page @@ -387,7 +404,8 @@ sub handler { # ------------------------------------------------------------------ Start form if ($nforms) { $r->print('
'); + &Apache::lonenc::check_encrypt($requrl) + .'">'); } } elsif ($target eq 'tex') { $r->print('\documentclass{article} @@ -403,7 +421,7 @@ sub handler { $r->print('\begin{longtable}INSERTTHEHEADOFLONGTABLE\endfirsthead\endhead '); if ($number_of_columns le $lcm) {$number_of_columns=$lcm;}; } else { - $r->print(''); + $r->print('
'); } for ($i=0;$i<=$#rows;$i++) { if ($rows[$i]) { @@ -414,19 +432,29 @@ sub handler { my $avespan=$lcm/($#colcont+1); for ($j=0;$j<=$#colcont;$j++) { my $rid=$colcont[$j]; - my $metainfo=''. - ''. - ''. - ''. - ''. - ''; + my $metainfo = ''; + my $esrc=&Apache::lonnet::declutter($hash{'src_'.$rid}); + my ($mapid,$resid)=split(/\./,$rid); + my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$rid}); + if ($hash{'encrypted_'.$rid}) { + $symb=&Apache::lonenc::encrypted($symb); + $esrc=&Apache::lonenc::encrypted($esrc); + } + unless ($hash{'src_'.$rid} =~ m-^/uploaded/-) { + $metainfo =''. + ''. + ''. + ''; + } + $metainfo .= ''. + ''. + ''; if ( ($hash{'src_'.$rid}=~/\.(problem|exam|quiz|assess|survey|form)$/) && - (&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'}))) { + (&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && + ($hash{'src_'.$rid} !~ m-^/uploaded/-)) { my ($mapid,$resid)=split(/\./,$rid); my $symb= &Apache::lonnet::declutter($hash{'map_id_'.$mapid}). @@ -494,6 +522,10 @@ sub handler { } elsif ($cellemb{$rid} eq 'emb') { $r->print('>'.$metainfo.''); + } elsif (&Apache::lonnet::declutter($hash{'src_'.$rid}) !~/\.(sequence|page)$/) { + $r->print($metainfo.''.$hash{'title_'.$rid}.'
'. + &mt('It is recommended that you use an up-to-date virus scanner before handling this file.').'

'. + &Apache::londocs::entryline(0,&mt("Click to download or use your browser's Save Link function"),'/'.&Apache::lonnet::declutter($hash{'src_'.$rid})).'


'); } unless ($target eq 'tex') { $r->print('');