Diff for /rat/lonpage.pm between versions 1.56 and 1.65

version 1.56, 2004/03/22 20:37:06 version 1.65, 2004/12/12 21:06:36
Line 45  use Apache::Constants qw(:common :http); Line 45  use Apache::Constants qw(:common :http);
 use Apache::lonnet();  use Apache::lonnet();
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonxml();  use Apache::lonxml();
   use Apache::lonlocal;
 use Apache::lonmenu;  use Apache::lonmenu;
 use HTML::TokeParser;  use HTML::TokeParser;
 use GDBM_File;  use GDBM_File;
Line 72  sub euclid { Line 73  sub euclid {
 sub tracetable {  sub tracetable {
     my ($sofar,$rid,$beenhere)=@_;      my ($sofar,$rid,$beenhere)=@_;
     my $further=$sofar;      my $further=$sofar;
       my $randomout=0;
       unless ($ENV{'request.role.adv'}) {
           $randomout = $hash{'randomout_'.$rid};
       }
     unless ($beenhere=~/\&$rid\&/) {      unless ($beenhere=~/\&$rid\&/) {
        $beenhere.=$rid.'&';            $beenhere.=$rid.'&';
           unless ($randomout) {
        if (defined($hash{'is_map_'.$rid})) {              if (defined($hash{'is_map_'.$rid})) {
            if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&                  if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
                (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) {                      (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) {
               my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}};                      my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}};
       $sofar=              $sofar=
                 &tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},                         &tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},
                 '&'.$frid.'&');                         '&'.$frid.'&');
               $sofar++;                      $sofar++;
               if ($hash{'src_'.$frid}) {                      if ($hash{'src_'.$frid}) {
                my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$frid});                          my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$frid});
                if (($brepriv eq '2') || ($brepriv eq 'F')) {                          if (($brepriv eq '2') || ($brepriv eq 'F')) {
                  if (defined($rows[$sofar])) {                              if (defined($rows[$sofar])) {
                    $rows[$sofar].='&'.$frid;                                  $rows[$sofar].='&'.$frid;
                  } else {                              } else {
                    $rows[$sofar]=$frid;                                  $rows[$sofar]=$frid;
                  }                              }
        }                  }
       }              }
    }          }
        } else {              } else {
           $sofar++;                  $sofar++;
           if ($hash{'src_'.$rid}) {                  if ($hash{'src_'.$rid}) {
            my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$rid});                      my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$rid});
            if (($brepriv eq '2') || ($brepriv eq 'F')) {                      if (($brepriv eq '2') || ($brepriv eq 'F')) {
              if (defined($rows[$sofar])) {                          if (defined($rows[$sofar])) {
                $rows[$sofar].='&'.$rid;                              $rows[$sofar].='&'.$rid;
              } else {                          } else {
                $rows[$sofar]=$rid;                              $rows[$sofar]=$rid;
              }                          }
    }              }
           }                  }
        }              }
           }
        if (defined($hash{'to_'.$rid})) {  
   my $mincond=1;          if (defined($hash{'to_'.$rid})) {
           my $next='';      my $mincond=1;
           foreach (split(/\,/,$hash{'to_'.$rid})) {              my $next='';
               my $thiscond=              foreach (split(/\,/,$hash{'to_'.$rid})) {
                   my $thiscond=
       &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}});        &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}});
               if ($thiscond>=$mincond) {                  if ($thiscond>=$mincond) {
   if ($next) {      if ($next) {
       $next.=','.$_.':'.$thiscond;          $next.=','.$_.':'.$thiscond;
                   } else {                      } else {
                       $next=$_.':'.$thiscond;                          $next=$_.':'.$thiscond;
   }      }
                   if ($thiscond>$mincond) { $mincond=$thiscond; }                      if ($thiscond>$mincond) { $mincond=$thiscond; }
       }          }
           }              }
           foreach (split(/\,/,$next)) {              foreach (split(/\,/,$next)) {
               my ($linkid,$condval)=split(/\:/,$_);                  my ($linkid,$condval)=split(/\:/,$_);
               if ($condval>=$mincond) {                  if ($condval>=$mincond) {
                 my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere);                      my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere);
                 if ($now>$further) { $further=$now; }                      if ($now>$further) { $further=$now; }
       }          }
           }              }
           }
        }  
     }      }
     return $further;      return $further;
 }  }
Line 227  sub handler { Line 232  sub handler {
                       $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));                        $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));
                       foreach (@colcont) {                        foreach (@colcont) {
                           my $src=$hash{'src_'.$_};                            my $src=$hash{'src_'.$_};
                           $src=~/\.(\w+)$/;    my ($extension)=($src=~/\.(\w+)$/);
     if ($hash{'encrypted_'.$_}) {
         $src=&Apache::lonenc::encrypted($src);
     }
                           $metalink{$_}=$src.'.meta';                            $metalink{$_}=$src.'.meta';
                           $cellemb{$_}=Apache::loncommon::fileembstyle($1);                            $cellemb{$_}=
         &Apache::loncommon::fileembstyle($extension);
                           if ($cellemb{$_} eq 'ssi') {                            if ($cellemb{$_} eq 'ssi') {
 # --------------------------------------------------------- This is an SSI cell  # --------------------------------------------------------- This is an SSI cell
         my ($mapid,$resid)=split(/\./,$_);
         my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src);
         
       my $prefix=$_.'_';        my $prefix=$_.'_';
                               my %posthash=('request.prefix' => $prefix);                                my %posthash=('request.prefix' => $prefix,
       'symb' => $symb);
       if ($ENV{'form.grade_target'} eq 'tex') {        if ($ENV{'form.grade_target'} eq 'tex') {
   $posthash{'grade_target'}=$ENV{'form.grade_target'};    $posthash{'grade_target'}=$ENV{'form.grade_target'};
   $posthash{'textwidth'}=$ENV{'form.textwidth'};    $posthash{'textwidth'}=$ENV{'form.textwidth'};
Line 252  sub handler { Line 265  sub handler {
                                }                                 }
       }        }
                               my $output=Apache::lonnet::ssi($src,%posthash);                                my $output=Apache::lonnet::ssi($src,%posthash);
       $output=~        $output=~s|//(\s*<!--)? BEGIN LON-CAPA Internal.+// END LON-CAPA Internal\s*(-->)?\s||gs;
     s/\/\/ BEGIN LON\-CAPA Internal.+\/\/ END LON\-CAPA Internal\s//gs;  
                               if ($target eq 'tex') {                                if ($target eq 'tex') {
   $output =~ s/^([^&]+)\\begin{document}//;    $output =~ s/^([^&]+)\\begin{document}//;
   $output =~ s/\\end{document}//;    $output =~ s/\\end{document}//;
Line 346  sub handler { Line 358  sub handler {
                   unless ($contents) {                    unless ($contents) {
                       &Apache::loncommon::content_type($r,'text/html');                        &Apache::loncommon::content_type($r,'text/html');
                       $r->send_http_header;                        $r->send_http_header;
                       $r->print('<html><body>'.&mt('Empty page').'.</body></html>');                        $r->print('<html>'."\n".
                                   '<head>'."\n".
                                   &Apache::lonmenu::registerurl(1,undef)."\n".
                                   '</head>'."\n".
                                   '<body bgcolor="#FFFFFF" onLoad="'
                                   .&Apache::lonmenu::loadevents.
                                   '" onUnload="'.&Apache::lonmenu::unloadevents.'">'.
                                    &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('<br /><br />'.&mt('Please use the LON-CAPA navigation arrows to move to another item in the course').'.</body></html>');
                   } else {                    } else {
 # ------------------------------------------------------------------ Build page  # ------------------------------------------------------------------ Build page
   
Line 382  sub handler { Line 404  sub handler {
 # ------------------------------------------------------------------ Start form  # ------------------------------------------------------------------ Start form
   if ($nforms) {    if ($nforms) {
       $r->print('<form method="post" action="'.        $r->print('<form method="post" action="'.
  $requrl.'">');   &Apache::lonenc::check_encrypt($requrl)
    .'">');
   }    }
       } elsif ($target eq 'tex') {        } elsif ($target eq 'tex') {
   $r->print('\documentclass{article}    $r->print('\documentclass{article}
Line 398  sub handler { Line 421  sub handler {
   $r->print('\begin{longtable}INSERTTHEHEADOFLONGTABLE\endfirsthead\endhead ');    $r->print('\begin{longtable}INSERTTHEHEADOFLONGTABLE\endfirsthead\endhead ');
   if ($number_of_columns le $lcm) {$number_of_columns=$lcm;};    if ($number_of_columns le $lcm) {$number_of_columns=$lcm;};
       } else {        } else {
   $r->print('<table cols="'.$lcm.'" border="0">');    $r->print('<table width="100%" cols="'.$lcm.'" border="0">');
       }        }
                       for ($i=0;$i<=$#rows;$i++) {                        for ($i=0;$i<=$#rows;$i++) {
  if ($rows[$i]) {   if ($rows[$i]) {
Line 409  sub handler { Line 432  sub handler {
                           my $avespan=$lcm/($#colcont+1);                            my $avespan=$lcm/($#colcont+1);
                           for ($j=0;$j<=$#colcont;$j++) {                            for ($j=0;$j<=$#colcont;$j++) {
                               my $rid=$colcont[$j];                                my $rid=$colcont[$j];
                               my $metainfo='<a name="'.                                my $metainfo = '';
   &Apache::lonnet::escape(&Apache::lonnet::declutter($hash{'src_'.$rid})).'" />'.        my $esrc=&Apache::lonnet::declutter($hash{'src_'.$rid});
   '<a href="'.        my ($mapid,$resid)=split(/\./,$rid);
                                     $metalink{$rid}.'" target="LONcatInfo">'.        my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$rid});
                           '<img src="/adm/lonMisc/cat_button.gif" border=0>'.        if ($hash{'encrypted_'.$rid}) {
   '</img></a><a href="/adm/evaluate?postdata='.    $symb=&Apache::lonenc::encrypted($symb);
       &Apache::lonnet::escape(&Apache::lonnet::declutter($hash{'src_'.$rid}))    $esrc=&Apache::lonenc::encrypted($esrc);
       .'" target="LONcatInfo">'.        }
                           '<img src="/adm/lonMisc/eval_button.gif" border=0>'.                                unless ($hash{'src_'.$rid} =~ m-^/uploaded/-) { 
                           '</img></a>';                                    $metainfo ='<a name="'.&Apache::lonnet::escape($symb).'" />'.
                                     '<a href="'.$metalink{$rid}.'" target="LONcatInfo">'.
                                     '<img src="/adm/lonMisc/cat_button.gif" border=0>'.
                                     '</img></a>';
                                 }
                                 $metainfo .= '<a href="/adm/evaluate?postdata='.
     &Apache::lonnet::escape($esrc).
                                     '" target="LONcatInfo">'.
                                     '<img src="/adm/lonMisc/eval_button.gif" border=0>'.
                                     '</img></a>';
                               if (                                if (
  ($hash{'src_'.$rid}=~/\.(problem|exam|quiz|assess|survey|form)$/) &&   ($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 ($mapid,$resid)=split(/\./,$rid);
                                  my $symb=                                   my $symb=
                 &Apache::lonnet::declutter($hash{'map_id_'.$mapid}).                  &Apache::lonnet::declutter($hash{'map_id_'.$mapid}).
Line 489  sub handler { Line 522  sub handler {
       } elsif ($cellemb{$rid} eq 'emb') {        } elsif ($cellemb{$rid} eq 'emb') {
                                   $r->print('>'.$metainfo.'<embed src="'.                                    $r->print('>'.$metainfo.'<embed src="'.
                                     $hash{'src_'.$rid}.'"></embed>');                                      $hash{'src_'.$rid}.'"></embed>');
                                 } elsif (&Apache::lonnet::declutter($hash{'src_'.$rid}) !~/\.(sequence|page)$/) {
                                     $r->print($metainfo.'<b>'.$hash{'title_'.$rid}.'</b><br />'.
                                     &mt('It is recommended that you use an up-to-date virus scanner before handling this file.').'</p><p><table>'.
                                     &Apache::londocs::entryline(0,&mt("Click to download or use your browser's Save Link function"),'/'.&Apache::lonnet::declutter($hash{'src_'.$rid})).'</table></p><br />');
                               }                                }
       unless ($target eq 'tex') {        unless ($target eq 'tex') {
   $r->print('</td>');    $r->print('</td>');

Removed from v.1.56  
changed lines
  Added in v.1.65


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>